Brian Chia
       
 
categories
actionscript
actionscript 1.0
actionscript 2.0
misc
 
processing
 
links
brian chia
kelvin zhao
ronald leong
 
 
Mouse Trailer
 
A very simple mouse trailer effect. Incorporate the use of vector class to highlight our we can put the Vector Class into use.

One thing to note is that the minimum speed cannot be set to 0, once it set to 0 and when you try to set the speed back to > 0, the object will no longer move. This is why i put +1 behind the code:

var s:Number=(drag_mc._x-line_mc._x)/5+1;

Speed can be adjust through the slidebar.



import Vector;

//set the inital speed, add 1 behind so that it minimum speed is 1
var s:Number=(drag_mc._x-line_mc._x)/5+1;
var t:Vector=new Vector(_xmouse,_ymouse);
var v:Vector=new Vector(0,0);

function trailer(mc:MovieClip):Void{

//reset the v vector (treat this as the velocity)
v.reset((_xmouse-t.vx)/s,(_ymouse-t.vy)/s);
t.plus(v);

mc._x=t.vx;
mc._y=t.vy;

}

circle_mc.onEnterFrame=function():Void{

trailer(this);

}



suggestion

 
 
 
         
  © copyright 2007 THINKLUNATIC.    
Brian Chia Jonathan Ng