How to include a MXML file in a new MXML file?

I would like to include the MXML file in my MXML file the same way you can include an external file in AS3 using include . Using the include directive leads the code from an external file to the source file at compile time, placing it in the same area.

For instance,

Application.mxml:

<Application>

    <source="external.mxml"/>

</Application>

External.mxml:

<Styles/>

<Declarations>
    <Object id="test"/>
</Declarations>

I need to save this code / mxml / xml in an external file in the area with the original. Do not ask me why I want to do this.

Another example. Here is my current code (simplified) in just 1 mxml file:

...

File1.mxml
<Button click="clickHandler()"/>

<Script>
public function clickHandler():void {

}
</Script>

...

Here is what I want:

...

File1.mxml
<Group>

    <source="File2.mxml"/>

    <Button click="clickHandler()"/>

<Group>


File2.mxml
<Script>
public function clickHandler():void {
    trace(this); // File1.mxml
}
</Script>

...

I want to split my code into a separate file ...

~~ Update ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~

, "code behind", , . MXML, MyGroup.mxml MyGroup.as , clickHandler.

, , , . , , , MXML, , - .

, , . , / , , , , . . , Code Behind, ( styles.as ). , .

,

MyGroupBehind.mxml:

<Group>

   <Script>
   public function clickHandler():void {
       trace(this); // File1.mxml
   }
   </Script>

</Group>

MyGroupAhead.mxml:

<MyGroupBehind>

    <Button click="clickHandler()"/>

</MyGroupBehind>
+5
4

MXML , , .

, . " ". , . , .

+2

, Ctrl + Space. , , . . . "/" > " ( ), ! , MXML.

+1

, mxml XML. , MXML, , :

<Application>
<external:External/>
</Application>

'external' - External.mxml.

0

Say my MXML file is called Example in the views folder . Just call the parent MXML file that you want it to be in

eg.

<views:Example/>
-1
source

All Articles