From:
http://www.riacodes.com/flash/create-an-eye-catching-glittering-neon
Preview link:
http://files.riacodes.com/flash_neon
Download source:
http://files.riacodes.com/flash_neon/src.zip
http://www.riacodes.com/flash/create-an-eye-catching-glittering-neon
Preview link:
http://files.riacodes.com/flash_neon
Download source:
http://files.riacodes.com/flash_neon/src.zip
1. Create a new flash file (Actionscript 3.0) and save it as neon.fla.
2. Rename “layer 1″ to “neon” and on this layer, draw the shape that will be your neon. Convert it to a movie clip and give an instance name of “neon_mc”.
3. Create a new “actions” layer. With its first frame selected, open the actions panel.
To create the appearance of a neon we apply to “neon_mc” a glow filter.
To make the “on/off glitter”, we use the Timer class. We declare two timers, one that will tell us when the neon will start glittering and the second that we’ll use to set the duration of the glitter.
When the light is off, we set the alpha property to a low value and when we want the neon to glitter, we change its alpha property to a random high value.
To create the appearance of a neon we apply to “neon_mc” a glow filter.
To make the “on/off glitter”, we use the Timer class. We declare two timers, one that will tell us when the neon will start glittering and the second that we’ll use to set the duration of the glitter.
When the light is off, we set the alpha property to a low value and when we want the neon to glitter, we change its alpha property to a random high value.
4. Here’s the entire code, test your movie to see it in action. from
01.var timerOn : Timer ;02.var timerDuration : Timer ;03.var glow:GlowFilter ;04. 05.function init():void{06.glow = new GlowFilter(0xFFFF5B,1,5,5,2,BitmapFilterQuality.HIGH);07.neon_mc.filters = [glow];08.neon_mc.alpha = .1;09.timerOn = new Timer(1000);10.timerDuration = new Timer(3000);11.timerOn.addEventListener(TimerEvent.TIMER, startGlitter);12.timerDuration.addEventListener(TimerEvent.TIMER,stopGlitter);13.timerOn.start();14.}15. 16.function startGlitter(e:TimerEvent):void{17.timerOn.stop();18.timerDuration.start();19.this.addEventListener(Event.ENTER_FRAME, glitter);20.}21. 22.function glitter(e:Event):void{23.neon_mc.alpha = .5 +(Math.random() * .5);24.}25. 26.function stopGlitter(e:TimerEvent):void{27.timerDuration.stop();28.this.removeEventListener(Event.ENTER_FRAME,glitter);29.neon_mc.alpha = .1;30.timerOn.delay = 1000 + Math.random()*3000;31.timerOn.start();32.}33. 34.init();
No comments:
Post a Comment