Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.display.MovieClip;
- import flash.events.Event;
- import flash.display.Stage;
- public class Mermi extends MovieClip{
- private var radyan:Number;
- public function Mermi(startX:Number,startY:Number,stageR:Stage) {
- x=startX;
- y=startY;
- addEventListener(Event.ENTER_FRAME,step);
- var dx:Number=stageR.mouseX-this.x;
- var dy:Number=stageR.mouseY-this.y;
- radyan=Math.atan2(dy,dx);
- rotation=radyan*180/Math.PI;
- }
- private function step(e:Event):void{
- x+=Math.cos(radyan)*15;
- y+=Math.sin(radyan)*15;
- if (this.x>stage.stageWidth || this.x<0 || this.y<0 || this.y>stage.stageHeight){
- this.parent.removeChild(this);
- removeEventListener(Event.ENTER_FRAME,step);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment