AS2 MovieClip fader
23/12/2009In the world of advertising sometimes your required to produce these wonderful 40k-30k flash ads using tons of images and fonts. I know we all get exited about those but settle down.
We can’t always import tweening engines, because even 4.7k is too much (Tweenlite). I’m not ragging on Greenshock, actually i use it myself and love it, but of course publishers wont budge on 40k. In the day’s of 56k i understand but tons of people are on broadband already! That’s a whole other discussion so without any further ado ::drumroll::, i present my simple fading function. tadddaa!
Quick & dirty AS2 fade function… (rollover to test)
Obviously you can expand on it by adding different properties but this is basic fading.
/* ------------------------------------------------------------------------- */ // BASIC FADE FUNCTION // @ AUTHOR - Fancisco Camberos // @ EMAIL - Francisco@1984interactive.com //Copyright (c) 2009 Fancisco Camberos, 1984interactive /* ------------------------------------------------------------------------- */ // fadeIt(direction:String,target:Movieclip,fadeSpeed:Number) function fadeIt(dir:String, tar:Object,fadeSpeed:Number):Void { onEnterFrame = function () { switch (dir) { case 'on' : tar._alpha += Math.round(fadeSpeed); break; case 'off' : tar._alpha -= Math.round(fadeSpeed); break; } if (tar._alpha >= 100 || tar._alpha <= 0) { delete onEnterFrame; } }; }