I got the same problem... and solve with this function

function $(object:String,container:DisplayObjectContainer = null) {
        if (container == null) container = this;
    
    for (var i:uint=0; i < container.numChildren; i++) 
    {
        var child:DisplayObject = container.getChildAt(i);
        
        if (child.name== object) {
                return child; 
        }

        if (container.getChildAt(i) is DisplayObjectContainer) 
        {
           var obj = $(object,DisplayObjectContainer(child));
           if (obj is DisplayObject) {
                 return obj;
           }
        }
    }
}




try $('element name')




--- In [email protected], DreamCode <[EMAIL PROTECTED]> wrote:
>
> I think you should be able to constuct the id something like this:
> 
> var currentItem:Object = this['hbox' + number]
> 
> I assume you know the number of boxes you create.....
> 
> --Allan
> 
> On Nov 21, 2007 11:49 PM, gaurav1146 <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> > Hi,
> > I have a component where a user can add text boxes and Combo boxes
> > depending on his requirement. For each addition I assign the ids to
> > the elements in ascending order. Now I want to read the values from
> > each of these textboxes and combo boxes in a for loop. How can I do
> > that. I have a structure something like:
> >
> > <mx:VBox>
> > <mx:HBox id="hbox1">
> > <mx:Textbox id="textbox1"/>
> > <mx:ComboBox dataProvider="{dp}" id="comboBox1">
> > <mx:HBox>
> >
> > <mx:HBox id="hbox2">
> > <mx:Textbox id="textbox2"/>
> > <mx:ComboBox dataProvider="{dp}" id="comboBox2">
> > <mx:HBox>
> > <!--Next HBox would be added here with id="hbox3" and so on -->
> > <mx:Button click="addHbox()">
> > </mx:VBox>
> >
> > Had the number of HBoxes been fixed I could access them by
> > {hboxId.textboxid.text} but I can't do the same for dynamically
> > generated ids. I tried using getChildByName but that was not working
> > for me. Is there any function where I can get a component by supplying
> > its id(like Javascript's getElementById)?
> >
> > TIA,
> > Gaurav
> >
> >
>


Reply via email to