6 Replies Latest reply on Nov 10, 2011 5:10 AM by Amy Blankenship

    Dynamic Components


      I am developing a education system with complex menus, 4 levels deep, at the bottom level I use a viewstack which I dynamicly add  Components, on the "creation complete" event, this works well, however when I reenter this componentt, as we would expect the " creation complete" event does not run as the component is "created" and I can not change the objects in the view stack


      what I need is a "on enter component" event so I can dynamicly change the the objects in the view stack, any ideas ?

        • 1. Re: Dynamic Components
          saisri2k2 Level 4

          thre is a 'show' event on every component, you can use it, also you can use 'hide' event in the reverse case.

          1 person found this helpful
          • 2. Re: Dynamic Components

            Ur Requirement is not very clear. But If i'm not wrong you wish to trigger something everytime a screen / component gains focus or is the current target. Have you tried ur luck with FocusIn handler ? This gets triggered everytime user highlights using pointing device / keyboard navigation. You could also take Persistence Manager to account along with FocusIn handler. Else you could try adding a custom event to taylor your need.

            1 person found this helpful
            • 3. Re: Dynamic Components
              sandc666 Level 1

              I am building an education tool, not a normal website, more of a hierarchical menu system, with 2 levels, all the screens are full size, no place to use stages, so I have used 2 levels of view stack, the bottom level defines the work the student will perform, the actual screens and number of pages are driven by there place in the course

              So when I enter the working level, I was going to look at my position in the course, say lesson 100 and build the “work screens” dynamically,

              I wanted to add the dynamic code in the component for this type of work, so the function run each time I enter the, component

              Could I just run a function as I move to the compounded

              DictationNavigation id="Dictation"  runbuild=” ”



              This is what I have



              <mx:ViewStack   selectedIndex="{_uofsModel.activeMainMeunScreen}" width="796" height="579">   <!-- controling the size of the pages with in the overall screen -->

                   <nas:Login id="login"    styleName="login"    />  <!-- index 0-->

                   <nas:Pips id="pips"   styleName="pipspage"       /> 

                   <nas:Workmenu id="workmenu" styleName="workmenu"   />   

                   <nas:TeacherNavigation id="teachersNavigation"      />  

                   <nas:GoToPage id="GoTpPage" />

                   <ns3:ReadingNavigation id="Reading" />      <!--5-->

                   <ns1:SpellingNavigation id="Spleeing" />    <!-- 6-->

                   <ns:MemoryNavigation id="Memeory" />       <!-- 7 -->

                    <ns2:DictationNavigation id="Dictation" />  <!-- 8 -->




              so when the user selects Dictaion, and DictationNavigation is loaded, i run










                 private function init():void



                  if (_uofsModel.studentRecord.currentDictationPage > 52) {

                   dictationViewStack.addElement(new Dictation2);

                      dictationViewStack.addElement(new Dictation3);


                        dictationViewStack.addElement(new Dictation1);




              • 4. Re: Dynamic Components
                Dushyandh Level 1

                There is a propery called 'change' for view Stack.





                protected function onChangeHandler(event:IndexChangedEvent):void{


                if(viewStackID.selectedChild (or) index == 'ur condition / id / childname'){

                     Execute necessary !!







                <mx:ViewStack   change="onChangeHandler(event)"

                selectedIndex="{_uofsModel.activeMainMeunScreen}" width="796" height="579"> 


                Is this what you are expecting ?

                • 5. Re: Dynamic Components
                  sandc666 Level 1


                                    thanks, this is almost what I need, is there an event for the child of the view stack (i tried focusin="onload()")   that will be dispatched when a child becomes active, I can then add the code in the component to handle the components own children, something like


                  mx:ViewStack   selectedIndex="{_uofsModel.activeMainMeunScreen}" width="796" height="579">   <!-- controling the size of the pages with in the overall screen --> 



                        <ns2:DictationNavigation     someEvent="onload()"       id="Dictation" />  <!-- 8 -->


                  • 6. Re: Dynamic Components
                    Amy Blankenship Level 4

                    Here are some posts that go into detail about what happens during delayed instantiation in Flex:




                    Maybe they will help point you in the right direction