David's you could uses currentStateChanging to do the dispatchEvent.
in the Object you want to do it.


REgards.

On 11/17/06, David Harris <[EMAIL PROTECTED]> wrote:

  Hi Matt,

the problem isn't the ViewStack, but the states.

If you have 2 states, and then you go from one to another, all the
children are created.
The situation I found this was where one State was a login and the other
State the application.
When logging was a success, the appliction switched to the
"MainApplication" state, which then created ALL it's children.
The fact that all the children are created had the same effect as having
creationPolicy="all" set, which can not be good if application is quite
complex.

Hope that makes sense.

Regards,

David

On 11/17/06, Matt Chotin <[EMAIL PROTECTED]> wrote:
>
>    Yes, this is expected behavior.  Is the problem that you have panels
> in a ViewStack and you don't want the events for all of those at once?
>  Maybe you should use the "show" event instead?  That will fire each time
> the Panel in the stack is shown, so if you plan on going back and forth you
> may want to keep a flag as to whether you've already executed that call.
>
>
>  ------------------------------
>
> *From:* [EMAIL PROTECTED] ups.com [mailto:[EMAIL PROTECTED] ups.com]
> *On Behalf Of *David Harris
> *Sent:* Thursday, November 16, 2006 10:39 AM
> *To:* flexcoders@yahoogroups.com
> *Subject:* [flexcoders] Re: States create all their children
>
>
>
> I guess about now I start logging a bug...
>
> Anyone know how to do this?
>
> On 11/13/06, David Harris <[EMAIL PROTECTED]<djohnsmarie%40gmail.com>>
> wrote:
> > I have a situation where my "states" in my application are very
> complex.
> >
> > Each state has a lot in them, and each view in the state has events of
> > data retrieval tied to the "creationComplete" event.
> >
> > The problem is this:
> >
> > If you switch from one state to another, all the children of the new
> > state are created, so all the "creationComplete" events are fired, and
> > my server gets alot of hits very quickly, and the app takes a long
> > time to load.
> >
> > Below is are 2 simple examples (I have posted before, so sorry for the
> > double up...) that show what I mean:
> >
> > Baring an typo's, when you run example 1, and you click on the button
> > to switch states, all the sub panels fire their creationComplete
> > events, while in the second example, the creationComplete is fired as
> > the ApplicationControlBar is clicked.
> >
> > Is the "expected" (and justified) behaviour of a Flex app, or am I
> > (yet again) missing the obvious?
> >
> > Example 1 (with view states):
> >
> > ===================================================================
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application
> > xmlns:mx="http://www.adobe.com/2006/mxml";
> > layout="absolute"
> > currentState="initalizing"
> > >
> >
> > <mx:Script>
> > <![CDATA[
> >
> > public function handleCreationComplete(event:Event):void
> > {
> >
> > trace("This got created : " + event.target);
> >
> > }
> >
> > ]]>
> > </mx:Script>
> >
> >
> > <mx:states>
> > <mx:State name="initalizing">
> > <mx:AddChild position="lastChild">
> > <mx:Button click="this.currentState = 'MainApplication'" />
> > </mx:AddChild>
> > </mx:State>
> >
> > <mx:State name="MainApplication">
> >
> > <mx:AddChild position="lastChild">
> >
> > <mx:Panel width="400" height="400">
> >
> > <mx:ApplicationControlBar width="100%" cornerRadius="6"
> > shadowDistance="3" paddingLeft="40" >
> >
> > <mx:LinkBar dataProvider="myViewstack" disabledColor="#8F8F8F"
> > color="#000000" separatorWidth="2"/>
> >
> > </mx:ApplicationControlBar>
> >
> > <mx:ViewStack id="myViewstack" width="100%"
> > height="100%">
> >
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="one"
> > width="100%"
> > height="100%"
> > />
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="two"
> > width="100%"
> > height="100%"
> > />
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="three"
> > width="100%"
> > height="100%"
> > />
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="four"
> > width="100%"
> > height="100%"
> > />
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="five"
> > width="100%"
> > height="100%"
> > />
> >
> > </mx:ViewStack>
> >
> > </mx:Panel>
> >
> > </mx:AddChild>
> > </mx:State>
> > </mx:states>
> > </mx:Application>
> >
> >
> > ===================================================================
> >
> > Example 2:
> >
> > ==================================================================
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application
> > xmlns:mx="http://www.adobe.com/2006/mxml";
> > layout="absolute"
> >
> > >
> >
> > <mx:Script>
> > <![CDATA[
> >
> > public function handleCreationComplete(event:Event):void
> > {
> >
> > trace("This got created : " + event.target);
> >
> > }
> >
> > ]]>
> > </mx:Script>
> >
> >
> > <mx:Panel width="400" height="400">
> >
> > <mx:ApplicationControlBar width="100%" cornerRadius="6"
> > shadowDistance="3" paddingLeft="40" >
> >
> > <mx:LinkBar dataProvider="myViewstack" disabledColor="#8F8F8F"
> > color="#000000" separatorWidth="2"/>
> >
> > </mx:ApplicationControlBar>
> >
> > <mx:ViewStack id="myViewstack" width="100%"
> > height="100%">
> >
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="one"
> > width="100%"
> > height="100%"
> > />
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="two"
> > width="100%"
> > height="100%"
> > />
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="three"
> > width="100%"
> > height="100%"
> > />
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="four"
> > width="100%"
> > height="100%"
> > />
> > <mx:Panel creationComplete="handleCreationComplete(event)"
> > label="five"
> > width="100%"
> > height="100%"
> > />
> >
> > </mx:ViewStack>
> >
> > </mx:Panel>
> >
> >
> > </mx:Application>
> >
> >
> > ==================================================================
> >
>
>



--
----------------------------
Igor Costa
www.igorcosta.com

Reply via email to