2 Replies Latest reply on Aug 18, 2009 8:20 PM by msakrejda

    Modify a Repeater currentItem?


      Hello Everyone


      Im trying to create a nice Login component, where a user can double click his name and the password textinput should appear


                      <mx:Repeater id="userRepeater" dataProvider="{users}" >

                          <mx:Label x="101" y="10" text="{userRepeater.currentItem.name}" fontSize="18"/>
                          <mx:TextInput id="passwordBox" visible="false" x="101" y="46" width="182" showEffect="Fade"/>



      how could i make the TextInput Component appear when clicked?


      I have tried:




      On the Label but no joy, also from a function in AS3 tells me that Repeater is not being executed.


      Sorry for such a simple question but i can't wrap my head around this one,





        • 1. Re: Modify a Repeater currentItem?
          msakrejda Level 4

          Try the password box outside the repeater, and when the user clicks, position it next to that name (set its x and y). You only need one password input (you'll only have one user logging in at a time from any particular instance of your app), so you don't need to repeat it and this will be easier to manage.

          1 person found this helpful
          • 2. Re: Modify a Repeater currentItem?
            alejandrorrr Level 1

            Thanks for answering... that is a good idea, I guess i could try that and also do something like sending and event and using currentTarget to get which Name the user clicked on.


            But i was scaling down on the example to ask the question *my bad, as i see* because actually this password box i wanted to appear was part inside a canvas thas being repeated.


            Here is how i solved it:


                            <mx:Repeater id="userRepeater" dataProvider="{users}" >
                              <mx:Canvas id="canvasArray" click="showPasswordBox(event.currentTarget.instanceIndices);" width="367" height="100" >

                                <mx:Label x="101" y="10" text="{userRepeater.currentItem.name}" fontSize="18"/>
                                <mx:TextInput id="passwordBoxArray" visible="false" x="101" y="46" width="182" showEffect="Fade"/>           


            Then a function that does:


                        private function showPasswordBox(i:int):void {


            Cool, with instanceIndices you get the index of the repeater, so you can access the tiem you wanted inside the repeater, no matter how many components you have inside (or what you click).


            Thanks for taking the time to answer again, good work uncomplicating things!