0 Replies Latest reply on May 10, 2012 10:37 AM by cputnam14

    Binding a text box to a child index


      I have an Hbox that contains 10 custom components (all the same component). Only 5 are displayed at a time, and I am building something similar to a thumbnail scroller that is in an endless loop.


      I have a Timer that triggers every 5 seconds to "scroll" the images.


      Here is my function to do that.


      public function DoLoop(event:TimerEvent):void


                      var imgnum:DisplayObject

                      imgnum = myHbox.getChildAt(0);               




      So this grabs the custom component in position 0 and adds it to the end. That works just fine.


      Now my problem arises when I am inside of my custom component. I want to bind it's current index (inside the Hbox) to a label. So I started off like this.


      <mx:Label id="mylbl" x="50" y="26" text="{parentDocument.myHbox.getChildIndex(this)}"/>

      That displays the current index of my custom component inside of the hbox, but when the Timer function fires, it does not update the label.


      So basically the label in index 0 of the hbox should always say 0...but it doesn't it changes to 1...2...3 ect everytime the timer function fires.


      I added a button to my component and I call a function which does a trace(parentDocument.myHbox.getChildIndex(this)); and it always returns 0 when I click the button in the 0 position.


      How can I bind my label to always show the correct position?