PDA

View Full Version : referencing button label in click function


skippylou
12-04-2008, 01:52 AM
So I have a button in a Flex 3 project, that calls an AS function of mine when clicked. I want to pass the button's label as the parameter name to the function, but it doesn't seem to be working. Here is the example:

<mx:Button label="blahblah" click="myFunction(this.label);"/>

Can "this" not be used in the way that I am using it? Any other thoughts or ideas on how to accomplish this?

Thanks,

Scott

pulse00
12-04-2008, 10:38 AM
i think you can access the buttons label by casting the
event target property to Button. then you should be able to access
your buttonlabel inside the callback.

private function myCallback(e:MouseEvent):void {

var button:Button = Button(e.target);

if (button) {

button.label;

}

}

something like that.

skippylou
12-04-2008, 06:44 PM
That worked fantastic! Thanks!

Scott