A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Mouse Trail Help!

Threaded View

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    3

    Mouse Trail Help!

    Hey guys,

    so I'm working on a game with a good buddy of mine and i came across
    a little trouble. My friend wants it so the mouse has a trail once you
    move the mouse along the screen. I found a tutorial online and it worked
    out great. But the problem is that the movieclips that i already had
    won't work well with the cursor. I've attempted to find something about
    mouseEnabled but I do not know how to apply it correctly. Any ideas?

    [Edit: It would really help if someone replied!!!!!]

    Here's the code. Thanks


    Code:
    var centerX:Number = stage.stageWidth / 2;
    var centerY:Number = stage.stageHeight / 2;
    
    ball.addEventListener(Event.ENTER_FRAME, moveBall);
    
    var timer:Timer = new Timer(100,400000);
    timer.addEventListener(TimerEvent.TIMER, createTrailBall);
    timer.start();
    
    function moveBall(e:Event):void {
    
    	var xpos:Number = mouseX;
    	var ypos:Number = mouseY;
    
    	//Move the ball to da new coordinates
    	ball.x = xpos;
    	ball.y = ypos;
    
    	angle += speed;
    
    }
    function createTrailBall(e:Event):void {
    
    	var trailBall:Ball=new Ball();
    
    	trailBall.x = ball.x;
    	trailBall.y = ball.y;
    
    	trailBall.addEventListener(Event.ENTER_FRAME,animateTrailBall);
    
    	addChildAt(trailBall,10);
    }
    function animateTrailBall(e:Event):void {
    	
    	e.target.alpha -= 0.04;
    	e.target.scaleY -= 0.04;
    	e.target.scaleX -= 0.04;
    
    	if (e.target.alpha < 0) {
    		e.target.removeEventListener(Event.ENTER_FRAME,animateTrailBall);
    		removeChild((MovieClip)(e.target));
    	}
    }
    Last edited by AndyChickenGame; 02-20-2009 at 11:01 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center