4 Replies Latest reply on Aug 14, 2009 12:03 AM by Virat Patel

    creation complete

    Seglespaan Level 1

      am I right in thining for a view stack, the creation complete will fire every time that view is enabled? or is it just the first time?

        • 1. Re: creation complete
          Seglespaan Level 1

          ok so I've worked out that creation complete will only fire the first time a view in a stack is loaded / viewed.

           

          However whayt I need is this,

           

          I have a viewstack with two views, view 1 and view 2, each time a view is loaded I want to call a function which will in turn populate the view stack, any ideas how I can call this time each time a view is loaded?

           

          Cheers

           

          Tim

          • 2. Re: creation complete
            FlexAppsStore.com Level 1

            Hello,

             

                 Give this a try. On the Canvas or Panel or whatever it is in your viewstack use the show event to fire the action.

             

            Example:

             

            <mx:ViewStack id="vs1">

             

                 <mx:Canvas id="can1" label="Customers" show="Alert.show('Fires when showed')"/>

             

            </mx:ViewStack>

            • 3. Re: creation complete
              Virat Patel Level 2

              Hello

               

              As you require to load data every time when view of viewstack is being changed.

               

              There is two way to do samething.


              1. You can use viewstack change event

               

              in this you willl get  oldindex and newindex of viewsatck so as per that you can load or unload the data as per requirement

               

              2. You can use 'show' event of childern inside the viewstack

               

              in this 'show' event is fiered when any child inside view stack is in visible mode, so you can do for that viw also.

               

              With Regards

              Virat Patel

              • 4. Re: creation complete
                Virat Patel Level 2

                Hello

                 

                This can be possible is two ways

                 

                Like you can use 'change' event of the viewstack or 'show' event of the childs inside viewstack.

                 

                Sample Example...

                 

                //////////////////////////////////////////////////////////

                 

                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
                    
                     <mx:Script>
                         <![CDATA[
                             import mx.events.IndexChangedEvent;
                             import mx.events.FlexEvent;
                            
                             private function onCanShow(event:FlexEvent):void
                             {
                                 // load new data
                                 // do something
                             }
                            
                             private function onChildChange(event:IndexChangedEvent):void
                             {
                                 // load new data
                                 // do something
                             }
                            
                         ]]>
                     </mx:Script>
                    
                     <mx:TabBar dataProvider="{vs}" />
                    
                     <mx:ViewStack id="vs" height="400" width="400" change="onChildChange(event)">
                         <mx:Canvas label="Can1" height="100%" width="100%"
                             backgroundColor="0xCCCCCC" show="onCanShow(event)" />
                         <mx:Canvas label="Can2" height="100%" width="100%"
                             backgroundColor="0x00FFCC" show="onCanShow(event)" />
                     </mx:ViewStack>
                    
                </mx:Application>

                 

                //////////////////////////////////////////////////////////////////////

                 

                With Regards

                Virat Patel