topical media & game development
script-game-event-game-ball.ax
script-game-event-game-ball.ax
(swf
)
[ flash
]
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class script-game-event-game-ball extends MovieClip{
static public var CLICKED:String = "clicked";
static public var MISSED:String = "missed";
public var down:Boolean;
public var speed:int =3;
public function script-game-event-game-ball(tx:Number, ty:Number) {
x = tx;
y = ty;
addEventListener(MouseEvent.CLICK, mouseClicked);
down=true;
}
public function mouseClicked(e:MouseEvent):void {
dispatchEvent(new script_game_event_game_score(speed,CLICKED));
}
public function run():void {
if (down){
y += speed;
if (y > 400) {
speed++;
scaleX-=.1;
scaleY-=.1;
down=false;
alpha-=.1;
if (scaleX <= 0) {
dispatchEvent(new Event(MISSED));
}
}
} else {
y -= speed;
if (y < 0) {
speed++;
scaleX-=.1;
scaleY-=.1;
down=true;
alpha-=.1;
if (scaleX <= 0) {
dispatchEvent(new Event(MISSED));
}
}
}
}
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.