----- Original Message ----- From: "Mic" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, October 22, 2008 10:28 PM Subject: [flexcoders] Re: createChildren(): adding 20 identical buttons to panel?
> Thanks for all the help .... I was trying to > > b1 = new Button; > this.addChild(b1); > this.addChild(b1); > this.addChild(b1); etc which is why it appeared that b1 was "all used > up" :-)When adding to the displaylist why does b1 = new Button; have > to be done each time? Why can't b1, which is an instance of the button > class, be duplicated into the list? b1 is just a variable that refers > to the instance, right? Right, but b1 refers to one button. If you add it ten times over you're trying to add the same button to the container not ten different buttons. Using new Button() gives you a new button, so writing b1 = new Button(); this.addChild(b1); creates a new Button, points b1 at it and adds it to the display list. Do it again and then b1 points to a different Button.. The mxml tag notation not only refers to the Button class but also instantiates a seprate instance, so you would get ten different buttons. Paul > Not a unique id. Not sure why this is > different from > > <mx:Panel> > <mx:Button/> > <mx:Button/> > <mx:Button/> > </mx:Panel> > > TIA, Mic.

