I guess about now I start logging a bug... Anyone know how to do this?
On 11/13/06, David Harris <[EMAIL PROTECTED]> 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> > > > ================================================================== >