Flex – Generate a ModuleLoader at Runtime

I spent most of a day running up against a problem in Adobe’s Flex 2.0. Flex 2.0.1 introduced the concept of modules. With this, you can stick a <mx:ModuleLoader> component in your .mxml file, then load it with the url to your module .swf file when you need it.

Now, I wanted to allow the user to load arbitrary modules at arbitrary times, and then load those into a ViewStack component. The problem is, no matter what I did, I couldn’t seem to get the dynamically loaded module to obey sizing (IE, height=”100%”). Here’s the solution: You have to put the ModuleLoader in a Canvas, and then add the Canvas to your ViewStack. Also, you must use percentWidth and percentHeight in your <Module> tag (not width and height).

Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Anonymous
    Posted July 28, 2007 at 4:17 pm | Permalink

    Dude, seriously, you’re supposed to be keeping me awake for this thing.. SNORE.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>