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: creationComplete vs onRegister  (Read 14857 times)
ceaseoleo
Newbie
*
Posts: 9


View Profile Email
« on: November 18, 2008, 05:51:28 »

Hi

I have a component call it homeView, and on the canvas tag I have creationComplete="sendEvent(constants.HOME_LOAD)"

In the mediator in the onRegister function I have a listener defined as
homeView.addEventListener(constants.HOME_LOAD, loadComboBox);

i can see in my trace messages that --
inside of send event homeLoad
startup command
register
--
The creation event gets fired even before the startup command and onRegister of the mediator. 

Is this expected behavior, and if so how do you do on load events ? I was able to accomplish what i needed by added a <mx:RemoteObject > tag at the bottom of the page and loading combo box that way, but I read the preferred way was to keep services in the proxy, and thats what i've been trying to do thanks.   

Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: November 19, 2008, 10:41:26 »

The Flex component's  creationComplete event fires before the Application's creationComplete. This is because the the app's creation logically isn't finished until all of its required children are created.

Generally it goes something like this:

* Mxml creation
  * View components
  * Facade
* PureMVC startup 
  * Register proxies
  * Register mediators
* Request data
  * Proxy method (such as 'load') invoked by mediator or command
  * Proxy calls service directly or uses a delegate to do so.
* Receive data
  * Proxy recieves result/fault return
  * if result then Proxy stores data internally, parsing if need be, possibly using a helper.
  * Proxy sends result or fault notification.
  * Interested mediators respond by setting data on view component.

Hope this helps.
-=Cliff> 
Logged
ceaseoleo
Newbie
*
Posts: 9


View Profile Email
« Reply #2 on: November 20, 2008, 04:18:54 »

Hey Cliff

thanks thats very helpful.  I appreciate it.  Anyways the solution I am using is the startup manager , found here http://blog.log2e.com/2008/05/19/getting-started-with-the-puremvc-startup-manager-introduction/ for intro. thanks
Logged
philipSe
Sr. Member
****
Posts: 139


View Profile Email
« Reply #3 on: November 21, 2008, 03:16:07 »

You might like to be sure that you are using the latest version of Startup Manager
http://trac.puremvc.org/Utility_AS3_StartupManager

Forgive me if this point is redundant.  Good luck!
----Philip
Logged
Bill_BSB
Jr. Member
**
Posts: 13


View Profile Email
« Reply #4 on: March 30, 2009, 02:28:27 »

Wow ... there´s a warning about this post beeing old but ... I guess I´m pretty sure to reply.

Ok, to the question. In my code I do something like this.
:
...
facade.registerMediator( new UsersListMediator( new UsersList() ) );
...

So, everything changes on the UsersListMediator. Should I use the Container initialize() method or FlexEvent.CREATION_COMPLETE????

I can be more specific if that wasn´t clear enought.

Thansk!
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #5 on: March 30, 2009, 03:56:00 »

Sorry, I don't understand your question.

-=Cliff>
Logged
Bill_BSB
Jr. Member
**
Posts: 13


View Profile Email
« Reply #6 on: March 31, 2009, 12:06:11 »

Sorry. I was in a hurry last time. I´ll try to be more specific.

This my Application.mxml:
:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*">
<mx:TitleWindow x="106" y="174" width="426" height="275" layout="absolute" title="User Detail" showCloseButton="true">
<mx:TabNavigator x="0" y="0" width="100%" height="100%">
<mx:HBox label="My Self" width="100%" height="100%">
<mx:Image width="152" height="202">

</mx:Image>

<mx:VBox width="100%">
<mx:HBox width="100%">
<mx:Label text="Status: " fontWeight="bold"/>
<mx:Text text="At Work" width="100%"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label text="Name: " fontWeight="bold"/>
<mx:Text text="William Rafael Ribeiro" width="100%"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label text="Personal Message: " fontWeight="bold"/>
<mx:Text text="Hi there!" width="100%"/>
</mx:HBox>
</mx:VBox>
</mx:HBox>
<ns1:UsersList label="Friends" width="100%" height="100%">
</ns1:UsersList>
</mx:TabNavigator>
</mx:TitleWindow>

</mx:Application>

And this is the UserList:
:
<?xml version="1.0" encoding="utf-8"?>
<mx:Accordion xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">
<mx:Canvas label="Work" width="100%" height="100%">
<mx:DataGrid x="0" y="0" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="Status" dataField="status"/>
<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Personal Message" dataField="pmessage"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Canvas label="College" width="100%" height="100%">
<mx:DataGrid x="0" y="0" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="Status" dataField="status"/>
<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Personal Message" dataField="pmessage"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
<mx:Canvas label="Family" width="100%" height="100%">
<mx:DataGrid x="0" y="0" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="Status" dataField="status"/>
<mx:DataGridColumn headerText="Name" dataField="name"/>
<mx:DataGridColumn headerText="Personal Message" dataField="pmessage"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
</mx:Accordion>

I want one mediator for each component, ApplicationMediator and UsersListMediator, (wich I don´t have the code right now) but the doubt is, where do I register the UsersListMediator? on the TabNAvigator´s index change event? on UsersList´s creationComplete event? On ApplicationMediator´s onRegister?
My guess is that there´s more than one solution but wich one is better or the correct one?

Thanks!
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #7 on: April 01, 2009, 03:36:30 »

This is your classic deferred instantiation problem. Check out the Slacker demo on the AS3 Standard Version menu for how to deal with this. There is also an article about Slacker describing the problem in detail in the News section of the site.

-=Cliff> 
Logged
Pages: [1]
Print