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: Handling flex mx:state addChild in puremvc (deferred creation)  (Read 8616 times)
arisco97
Jr. Member
**
Posts: 14


View Profile Email
« on: December 15, 2008, 09:47:46 »

As I am using deferred instantiation, I do not see any way around having the mediator listen to state change events and determining when the addchild component is created. 

I have read about the puremvc statemachine, however I am wondering if anyone has a better approach of handling addchild views in puremvc.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: December 16, 2008, 07:09:03 »

The StateMachine utility is really for implementing application-wide state management.

For handling added children, I suggest starting out looking at the Slacker demo.

The chief difference between that demo and what you are after is that the deferred instantiation is in the form of viewstack children that are created late, but never removed.

You would want a similar setup where a mediator will listen to either the app or custom component that will have children added to it when its state changes. Rater than listen for creationComplete events from the children, you'll listen for childAdded event (I believe; I'm using a limited wap browser so I can't doublecheck the API). Hook the added child to a new instance of the correct mediator. Have that mediator place a 'removed' eventlistener on the child. Whenever the child is removed from the view, its mediator should null its viewComponent property and unregister itself. 

-=Cliff>
Logged
Pages: [1]
Print