Copy link to clipboard
Copied
I have an old FLA from another designer ca. 2009 or so written with Actionscript 2.0. I've been successful in converting most of it to Actionscript 3.0 to be published in HTML5 except this one function attached to a sprite which changes the transparency of the movie clip based on mouse proximity. I haven't used Flash much in recent years so any help is greatly appreciated!
onClipEvent (enterFrame)
{
pointAtWhichAlphaReaches0 = 200;
hyp = Math.sqrt(_xmouse * _xmouse + _ymouse * _ymouse);
setProperty("", _alpha, 100 - hyp / pointAtWhichAlphaReaches0 * 100);
updateAfterEvent(mouseMove);
}
Copy link to clipboard
Copied
attached to that object's timeline (which is poor coding):
var pointAtWhichAlphaReaches0:int=200;
var hyp:Number;
this.addEventListener(Event.ENTER_FRAME,f);
function f(e:Event):void{
hyp = Math.sqrt(mouseX * mouseX + mouseY * mouseY);
this.alpha=100 - hyp / pointAtWhichAlphaReaches0 * 100;
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now