event.currentTarget.name
event.currentTarget.id

Maybe?

On Mon, Sep 29, 2008 at 3:50 PM, Lucas Golden <[EMAIL PROTECTED]> wrote:

> Hey folks,
>
> I've got an issue where I'm creating a series of buttons inside of a loop.
> I'm then creating an Event Listener inside that loop to go along with the
> button to create an onClick event.   Is there anyway I can pass a value or
> even get the name of the button that was clicked inside of the Event
> Listener?  I've tried  "this.name"  but it just gives the application
> name.
>
> Here's my loop and my event listener:
>
>      for(var m:int = 0; m < optionArray.length; m++)
>        {
>             var optionHBox:HBox = new HBox();
>                var optionImage:Image = new Image();
>                var optionButton:Button = new Button();   //button creations
>                var optionLabel:Text = new Text();
>                optionLabel.width = 100;
>                optionLabel.percentHeight = 100;
>
>                optionImage.source = optionArray[m].optionURL;
>                optionImage.setStyle("horizontalCenter","0");
>                optionImage.addEventListener("click",clickColor);
>
>
>                optionLabel.htmlText = optionArray[m].label;
>                optionButton.toggle = true;
>
>                optionButton.name = "optionButton" + i + m;        //button
> name
>                optionButton.id = "optionButton" + i + m;            //
> button ID
>                optionButton.addEventListener("click",optionClick);
>
>
>                optionButton.setStyle("horizontalCenter","0");
>
>                optionHBox.addChild(optionButton);
>                optionHBox.addChild(optionImage);
>                optionHBox.addChild(optionLabel);
>                optionHBox.y = newLabel2.y + 30;
>
>             optionHBox.width = 235;
>             optionHBox.setStyle("horizontalCenter","0");
>             optionHBox.setStyle("horizontalAlign","center");
>             optionVBox.addChild(optionHBox);
>        }
>
>
> and here's the event Listener Function:
>
>   private function optionClick(event:Event):void
>    {
>         Alert.show(this.name);  //this is just here to try and see if I
> can get a value though.
>     }
>
>
>
> Thanks for the help!
> Luke
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe in
> the subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by FusionLink <http://www.fusionlink.com/>
> -------------------------------------------------------------



-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the 
subject line

For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------

Reply via email to