0

I created a screen(calculator) with bunch of buttons,i can handle button event with one handler.But i want to know that can we do a one handler for all buttons...... like in java we can perform the task of perticular button by like this

if(event.source=="button1")
{

}
else if(event.source=="button2")
{

}

so,can we do the same thing in mobile Flex programming

4

2 回答 2

2

You can get the object, which dispatched event by event.target, and then check property you need (e.g. Button(event.target).label or Button(event.target).id).

于 2012-03-10T22:36:12.683 回答
1

You can use event.currentTarget .

<s:Button id="btn_one" width="100" height="30" label="One" 
click="onClick_btn_one(event)"/>


private function onClick_btn_one(event:MouseEvent):void
{
    if(event.currentTarget.id ==  "btn_one")
    {
         trace("button one")
    }

 }
于 2012-03-11T05:13:01.783 回答