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)); } } } } } }