イベントの書き方

マウスイベント

[sourcecode language=”java”]

my_mc.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void {
trace("ありがとう。");
}

[/sourcecode]

フレームイベント

[sourcecode language=”java”]

box1_mc.addEventListener(Event.ENTER_FRAME, onRotaMe);
box2_mc.addEventListener(Event.ENTER_FRAME, onRotaMe);
//フレーム再生イベントで連続的に呼び出される
function onRotaMe(event:Event):void {
var targetMC:MovieClip = event.target as MovieClip;
//インスタンスの回転
targetMC.rotation += 10;
}

[/sourcecode]