View Single Post
Old 04-20-2008   #1 (permalink)
NikonErik
Registered User
 
NikonErik's Avatar
 
Join Date: Nov 2007
Location: Long Island, NY
Posts: 119

Flicker effect in FLASH

I am trying to create a flickering neon sign. I looked here (of course) and found no references to creating the effect.

I looked elsewhere on the 'Net and found:
Dynamic Flickering Effect

I have followed the tutorial carefully but don't know why I can't get it to work. I am shure it would help if I had more than just a basic understanding of Flash!

Am I supposed to plug-in some numerical values??

Here's the code from the tutorial: Dynamic Flickering Effect

Copy & Paste the following code: ( All explained in my comments )

1.
// -------------------------------
2.
// Flickering MovieClip Effect
3.
// Pixel Hive Design : Custom Web, Media and Graphic Services
4.
// -------------------------------
5.
// All time in milliseconds. (1000 = 1 second)
6.
maxTB = 4000; // Maximum time between flickering
7.
minTB = 1000; // Minimum time between flickering
8.
flickerDuration = 2000; // How long flicker will last
9.
10.
// Get a random start time.
11.
flickerTime = getNewTime();
12.
13.
// Every frame execute the following code.
14.
this.onEnterFrame = function(){
15.
// Get current time in milliseconds.
16.
curTime = getTimer();
17.
18.
// Check if current time is past the time to flicker.
19.
if(curTime >= flickerTime){
20.
// Flickering.
21.
// Check if flicker has lasted the duration specified.
22.
if(curTime <= flickerTime+flickerDuration){
23.
// Continue flickering.
24.
// Alternate between alpha values.
25.
// This creates the flicker appearance.
26.
if( cnt >= 2){
27.
// Reduce alpha.
28.
// Lower this for more dramatic effect.
29.
this._alpha = 90;
30.
cnt = 0;
31.
} else {
32.
// Increase alpha.
33.
this._alpha = 100;
34.
cnt++;
35.
}
36.
} else {
37.
// Flicker lasted for duration.
38.
// Stop flickering and get next time to flicker.
39.
this._alpha = 100;
40.
flickerTime = getNewTime();
41.
}
42.
}
43.
}
44.
// Create a random time between maxTB and minTB specified.
45.
function getNewTime(){
46.
return getTimer() + (Math.random() * (maxTB-minTB))+minTB;
47.
}

Dynamic Flickering Effect : Conclusion

Change the "Neon_Sign" MovieClip to anything and it will flicker to your settings. It's a great effect to draw attention to interface elements.
__________________


There are always two people in every picture: the photographer and the viewer. ~Ansel Adams

NikonErik is offline   Reply With Quote