Should put this into a class for use later. Uses ‘btn0’ and ‘pop0’ as the instance names.
// popup code. should keep it somewhere. import com.greensock.TweenLite; import com.greensock.easing.*; var pop:Array = new Array(); var btn:Array = new Array(); var numItems:Number; var tweenSpeed:Number = 0.5; function init():void { for(var i:uint = 0;i< 200;i++) { if(this["btn" + i]) { btn.push(this["btn" + i]); btn[i].uniqueID = i; btn[i].alpha = 0; btn[i].addEventListener(MouseEvent.ROLL_OVER, rollOverHandler); btn[i].addEventListener(MouseEvent.ROLL_OUT, rollOutHandler); pop.push(this["pop" + i]); pop[i].uniqueID = i; pop[i].scaleX = pop[i].scaleY = pop[i].alpha = 0; } } } init(); function rollOverHandler(event:MouseEvent):void { MovieClip(event.target).alpha = .2; TweenLite.to(pop[event.target.uniqueID], tweenSpeed, {scaleX:1, scaleY:1, alpha:1, ease:Back.easeOut}); } function rollOutHandler(event:MouseEvent):void { MovieClip(event.target).alpha = 0; TweenLite.to(pop[event.target.uniqueID], tweenSpeed/2, {scaleX:0, scaleY:0, alpha:0}); }
Tech Reference: AS3
Leave a Reply