Re: [Flashcoders] Adding Listeners in a loop

2008-09-17 Thread Omar Fouad
Thanks Juan... That was so useful. Cheers On Wed, Sep 17, 2008 at 6:40 PM, Juan Pablo Califano < [EMAIL PROTECTED]> wrote: > Hi, the problem is that by the time the event fires and your inline > function > is called, R1 points to the last object created in the loop. > > However, an event object

Re: [Flashcoders] Adding Listeners in a loop

2008-09-17 Thread Adrian Ionut Beschea
AIL PROTECTED]> wrote: From: Omar Fouad <[EMAIL PROTECTED]> Subject: [Flashcoders] Adding Listeners in a loop To: "Flash Coders List" Date: Wednesday, September 17, 2008, 5:47 PM Hi, I got this loop that creates some MovieClips one under another. for (var i:uint = 0; i < data.

Re: [Flashcoders] Adding Listeners in a loop

2008-09-17 Thread Juan Pablo Califano
Hi, the problem is that by the time the event fires and your inline function is called, R1 points to the last object created in the loop. However, an event object is passed to the handler function. The target property of that object cointains a reference to the object that fired it, so you can do

Re: [Flashcoders] Adding Listeners in a loop

2008-09-17 Thread Adrian Ionut Beschea
; i++) { fn(i); } --- On Wed, 9/17/08, Omar Fouad <[EMAIL PROTECTED]> wrote: From: Omar Fouad <[EMAIL PROTECTED]> Subject: [Flashcoders] Adding Listeners in a loop To: "Flash Coders List" Date: Wednesday, September 17, 2008, 5:47 PM Hi, I got this loop that creates some Mov

[Flashcoders] Adding Listeners in a loop

2008-09-17 Thread Omar Fouad
Hi, I got this loop that creates some MovieClips one under another. for (var i:uint = 0; i < data.length; i++) { var R1:ResultLink = new ResultLink(data[i].CompanyName, data[i].CompanyId); // R1.addEventListener(MouseEvent.CLICK, function():void {trace(R1.Label)}); BlackBox.addChild(R1)