Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Dynamic loading of components  (Read 6417 times)
eco_bach
Courseware Beta
Sr. Member
***
Posts: 81


View Profile Email
« on: March 13, 2010, 06:01:15 »

Hi
I have a completed project entirely contained in 1 swf.
I'd like to break it down partially, removing a few of the view components and loading them at runtime.

These view components aren't referenced directly by any mediator, but rather are parented and instantiated by other view components.

What is the best (practices) strategy to do this?

Besides making my application more modular and easier to work on with other developers, one of my goals is also to reduce the size of my 'main' swf, so this means removing any references to the view component class I need to load.

Should I then create a view  interface for these loadable components, which the parent components reference and instantiate??

Any suggestions welcome...
Logged
inchworm
Jr. Member
**
Posts: 13


View Profile Email
« Reply #1 on: March 13, 2010, 06:54:32 »

hey eco,

I mentioned the idea in this thread: http://forums.puremvc.org/index.php?topic=1658.0 but I haven't tried it yet. Basically if you want to maintain strong typing I believe that you can make your components implement an interface and then just import that interface in your main.swf and type the loaded swf/component to that. I think things get tricky when dealing with events that your component might dispatch. Hopefully they're just in a separate class file which you can also import, otherwise you might want to check out this blog post about a hypothetical way to put events in interfaces. Though the summary of the article basically ends up by saying 'you can put events in interfaces, but it's probably better to just use AS3 Signals' http://www.davidarno.org/2010/02/24/actionscript-signals-events-and-interfaces/
Logged
Pages: [1]
Print