A simple one. Suppose we create two buttons: one called offButton with a label value of "off" and another one onButton with a label value of "on".
Then, if we add event listeners to both:
onButton.addEventListener("click", buttonPushed);
offButton.addEventListener("click", buttonPushed);
we can tell which one we pushed with this function:
function buttonPushed(evt:Object):Void{
var label:String = evt.target.label;
if(label == "off")
{
trace("You pushed the off button");
}else if(label == "off")
{
trace("You pushed the on button");
}
}
Wednesday, April 8, 2009
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment