Vijay Dev
Vijay Dev

Reputation: 27476

Converting a Flex custom component to a module

How to take an existing custom component in Flex and convert it into a module?

EDIT: What should be done in the mxml where this custom component is used? Should it be replaced with a to load the module? If yes, how to deal with code that uses instances of the components?

Upvotes: 0

Views: 1084

Answers (2)

midhunhk
midhunhk

Reputation: 5554

You would need to place a ModuleLoader in place of the custom component like

<mx:ModuleLoader id="moduleLoader" width="100%" height="100%"/>

And load the Module using the url.

moduleLoader.unloadModule();

moduleLoader.url = "path\to\module.swf"; moduleLoader.loadModule();

You can keep the above code in a function and load modules.

If your module will be used in the same project only, you can create a new MXML Module that can be optimized for the project from FlexBuilder

Upvotes: 0

Chris Klepeis
Chris Klepeis

Reputation: 9983

Change the root mxml tag to <mx:Module... then in the properties of the project click on the "Flex Modules" button and add it in there.

Edit: This is assuming your modules are in the same project. I prefer to create new projects per module as it makes development easier with multiple developers. So what I do is create a new project, change the root to <mx:Module..., in the properties of the module project I disable it from creating the html wrapper, then in my main project I just load up the module swf's based on what menu item was clicked

Upvotes: 1

Related Questions