Create an eye-catching glittering neon

September 16th, 2009 in Flash

In the following lesson, let’s see how to create the effect of a glittering neon.

View DemoDownload Source

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.

4. Here’s the entire code, test your movie to see it in action.

var timerOn : Timer ;
var timerDuration : Timer ;
var glow:GlowFilter ;

function init():void{
	glow = new GlowFilter(0xFFFF5B,1,5,5,2,BitmapFilterQuality.HIGH);
	neon_mc.filters = [glow];
	neon_mc.alpha = .1;
	timerOn = new Timer(1000);
	timerDuration = new Timer(3000);
	timerOn.addEventListener(TimerEvent.TIMER, startGlitter);
	timerDuration.addEventListener(TimerEvent.TIMER,stopGlitter);
	timerOn.start();
}

function startGlitter(e:TimerEvent):void{
	timerOn.stop();
	timerDuration.start();
	this.addEventListener(Event.ENTER_FRAME, glitter);
}

function glitter(e:Event):void{
	neon_mc.alpha = .5 +(Math.random() * .5);
}

function stopGlitter(e:TimerEvent):void{
	timerDuration.stop();
	this.removeEventListener(Event.ENTER_FRAME,glitter);
	neon_mc.alpha = .1;
	timerOn.delay = 1000 + Math.random()*3000;
	timerOn.start();
}

init();
  • Digg
  • del.icio.us
  • Reddit
  • StumbleUpon
  • Twitter


What you think ...

(3 Comments)

+ Add a Comment
  1. Sam
    Sep 21st, 2009

    Cool effect

  2. k77
    Sep 22nd, 2009

    It’s very cool.

  3. HOW TO BUILD A FLASH POP-UP MENU « Random Stuff Blog
    Oct 13th, 2009

    [...] is the link so you can get [...]

Leave a Comment

Name (required)

E-mail (required, will not be published)

Website