全部博文(315)
分类:
2008-04-02 13:58:18
接收事件通知有三种方式:
1.在MXML中注册一个事件处理器
width=”300″ height=”200″
horizontalAlign=”center” verticalAlign=”middle”
>
import flash.events.MouseEvent;
private function clickHandler ( event:MouseEvent ):void
{
myLabel.text = “Hello, World!”;
}
]]>
paddingTop=”10″ paddingBottom=”10″ paddingLeft=”10″
paddingRight=”10″ >
2.在 MXML中创建一个内联(inline)的事件处理器
horizontalAlign=”center” verticalAlign=”middle”
width=”300″ height=”200″>
paddingTop=”10″ paddingBottom=”10″ paddingLeft=”10″
paddingRight=”10″>
3.通过 ActionScript 注册一个事件监听器
horizontalAlign=”center” verticalAlign=”middle”
width=”300″ height=”200″
creationComplete=”creationCompleteHandler(event);”>
import flash.events.MouseEvent;
import mx.events.FlexEvent;
private function
creationCompleteHandler(event:FlexEvent):void
{
// Listen for the click event on the Button control
myButton.addEventListener (MouseEvent.CLICK,
clickHandler);
}
private function clickHandler ( event:Event ):void
{
myLabel.text = “Hello, World!”;
}
]]>
paddingTop=”10″ paddingBottom=”10″ paddingLeft=”10″
paddingRight=”10″>