use button to set a variable
hi, can someone help me.
I would like to use a couple of buttons that I made to set a variable. I'd like to use the instance name of the button(s) as the value stored as the variable. how can i code this?
thanks.
hi, can someone help me.
I would like to use a couple of buttons that I made to set a variable. I'd like to use the instance name of the button(s) as the value stored as the variable. how can i code this?
thanks.
You can use the currentTarget of the event to target the button and acquire its name...
var btnName:String;
btn.addEventListener(MouseEvent.CLICK, storeName);
function storeName(evt:MouseEvent):void {
btnName = evt.currentTarget.name;
trace(btnName); // will trace "btn"
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.