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

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / General Discussion / Deferred Instantiation... Ughh! on: August 23, 2008, 06:34:52
Hey all,

So I'll be the first to admit that I'm fairly new to Flex and AS3 in general, but so far I've been doing pretty well and I've settled on PureMVC as the architecture we'd like to use for this project.. However, I'm finding myself in Deferred Instantiation hell and it's really bothering me..

Here's the basic problem:

Main app has a view stack with a bunch of Canvas components.. I've read all the FAQs and saw the Slacker demo and I get it.. I create a few custom events which trigger the ApplicationMediator to create whatever mediators I want when each component is actually created by AIR. Fair enough..

My problem is past that point..

So consider if I have a ViewStack with two views.. Splash and Main.. I need to fire an event on creation of Main to register it's mediator, but now what of my Main component's components? Although the creationComplete event fired, and now my mediator is registered all of the sub-components still don't exist so in the constructor of my MainMediator, where I'd like to register event handlers (for instance, to handle an click event from a button in my component) viewComponent.myButton is *still* null.. which means I in my new component again have to create all of these dummy events to fire and then capture the dummy events in the mediator to then call real methods... This is absolutely annoying, because I basically have to create "fake" events for every real event that gets fired in my components because the component doesn't exist..

I've tried to do creationPolicy="all" on my canvas component (used in the viewStack) but that didn't do anything useful, and I really am hating the idea of having to pollute my application with a million THISBUTTON_CLICK:String = "someuniquestringforthisspecificbutton"; values so I can do click="dispatchEvent(new Event(THISBUTTON_CLICK))"... so I can then turn arround and finally do viewComponent.addEventListener(MainScreen.THISBUTTON_CLICK, onThisButtonClick)...

There must be a better way! Help Please!

John
Pages: [1]