THE CODE
From Interactivity
About programming (Java-Processing, Action script,..Etc)
Did you discover something amazing? Something strange? Do you have troubles with some script? Questions?
This page is here for it!
the code(written by Evan)for movie clip to follow the mouse cursor and to turn behind it:
stop();
birdie.onEnterFrame=function()
{
var dx= _root._xmouse-this._x;
var dy= _root._ymouse-this._y;
//the difference between x,y of the mouse and x,y of the movie clip(birdie)
var angle= Math.atan2(dy,dx)*180/Math.PI;
// "Math.atan2"computes and returns the arc tangent of y(here dy),x(here dy) in radians,
// next step multiply it by 180 and divide by PI,which converts radiants into degrees
birdie._rotation = angle;
//rotate the movie clip"birdie" in degrees acording to the previously created variable "angle"
this._x= this._x+dx/5;
this._y= this._y+dy/5;
}
//this make movie clip move always by 5 pixels after the mouse cursor
PS:I put this code here because somebody asked me for it, hope is OK,also I hope the description I wrote are right, not quite sure :) MarieP
