PDA

View Full Version : How do I have apply a pulsating glow via actionscript?


MarionC
05-06-2008, 10:11 PM
Hello all,

I'm trying to add a pulsing glow (for maybe 5 secs) to a movieclip object and please bear with me, I'm still new to flash.

I tried to make 3 loops, 2 inner ones which the first one increases the strength and the 2nd one decreases and the outer loop repeats the glow the number of times I want it to glow. Needless to say, this doesn't work! lol. I tried it via adding listeners and such with a timer and got hung up with passing the movieclip over in the event. I just don't know how to declare it.

Anyone have pointers how I should go about making a pulsating glow on a movieclip object via actionscript code?

Any help is appreciated,
-m

ASWC
05-07-2008, 12:03 AM
Copy and paste this code in a new fla to test the functionality and then play with it:
import flash.filters.GlowFilter;
this.createEmptyMovieClip("square_mc", this.getNextHighestDepth());
square_mc.beginFill(0xFF0000);
square_mc.moveTo(0, 0);
square_mc.lineTo(100, 0);
square_mc.lineTo(100, 100);
square_mc.lineTo(0, 100);
square_mc.lineTo(0, 0);
square_mc.endFill();
square_mc._x = Stage.width/2-square_mc._width/2;
square_mc._y = Stage.height/2-square_mc._height/2;

var color:Number = 0x0000FF;
var alpha:Number = 1;
var blurX:Number = 5;
var blurY:Number = 5;
var strength:Number = 5;
var quality:Number = 3;
var inner:Boolean = false;
var knockout:Boolean = false;
var speed:Number = 1;
square_mc.onEnterFrame = function(){

blurX+=speed;
blurY+=speed;
if(blurY>25){speed*=-1}
if(blurY<5){speed*=-1}
var filter:GlowFilter = new GlowFilter(color,
alpha,
blurX,
blurY,
strength,
quality,
inner,
knockout);
var filterArray:Array = new Array();
filterArray.push(filter);
this.filters = filterArray;
}