ActionScript03(onClipEventハンドラ)

画像が静止状態から加速していくプログラム

  • 画像に記述する場合。
onClipEvent(load){
	speed=0;
	accel=1;
}
onClipEvent(enterFrame){
	speed +=accel;
	this._x +=speed;
}
  • actionレイヤーに記述する場合。(ActionScriptで関数を使う場合は、インスタンスではなくタイムラインにactionレイヤーを作って記述する。)
var speed:Number;
var accel:Number;

this.onLoad=function(){
	speed=0;
	accel=1;
}
cat_mc.onEnterFrame=function(){
	speed +=accel;
	cat_mc._x +=speed;
	trace(speed);
}