Hi does anyone know how to create the following - a mc with inertia which chases the mouse pointer, the closer it gets to the pointer the more it fades out??
i can do the mouse follow with inertia and i can do the alpha bit but i just don’t know how to combine them.
ok, well since this is all happening for _root.bar4, you might as well just put the onEnterFrame on it. Not quite sure what the _root hittest is for… because you only want this to happen if the mouse is over the movie? … Ill ignore that for now since its not that important to the fading.
Basically, all you need to do is just figure out how far away your bar4 is from the mouse and set its alpha to that. if the ba is 4 px away, setting its alpha to 4 would make it almost invisible. Further away, at 100 px is fully visible. visble when far, not so much when close. And thats all based on the difference of the _x value and the _xmouse - somethign also used in the movement. So with that we can get something like:
Math.abs prevents a value from being negative. If a value is negative, it makes it positive. This is for when the mouse is on the left side of the clip. Then, the x_difference is a negative number and you wouldnt want the _alpha going negative but back up, so MAth.abs makes the negative go positive. The _alpha, though, is just based on the x_difference