Question

I have an application built in Flex Builder 3. It has a fair amount of mxml and as3 code which uses some other custom compenents. I have looked at the documentation on building components which shows how to make a simple mxml or action script component that extends something like a combobox, but I'm lost as to how to take a whole existing and independently functioning Application and turn it into a reusable component.

Basically, I'd just like to create multiple instances of this app inside of another flex project.

Anyone able to provide a little guidance?

Was it helpful?

Solution

The easy thing to do is to swap the Application mxml tag with a VBox tag...thus making it act like a component.

e.g. If this were your application:


//Foo.mxml
<mx:Appliction xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Label text = "foo" />
</mx:Appliction>

change it to:


//Foo.mxml
<mx:VBox>
    <mx:Label text = "foo" />
</mx:VBox>

and then you can do something like this:


//App.mxml
<mx:Appliction 
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:local="your.package.scheme.*"
>
    <local:Foo />

</mx:Appliction>

You may have to make some public properties if you need to pass in any data to the component...

OTHER TIPS

If you simply want some "parent" Flex application to embed several instances of this autonomous child application, then you should see Adobe's "Embedding Asset Types" documentation, which describes how to embed one SWF file in another.

From the documentation:

You typically embed a Flex application when you do not require the embedding application to interact with the embedded application. If the embedding application requires interactivity with the embedded application, you might consider implementing it as a custom component, rather than as a separate application.

If you do require interaction between the embedded application and the parent application, you can look into the SWFLoader control.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top