Flash Glow Effect with greensock plugin in AS3


Glow Effect with GreenSock

Glow effect with GreenSock plugin in action script 3, download the latest files from the greensock site and copy the com folder from the zip package. I think the plugin is in com, otherwise make it in com folder.

glowFilter : Object – To apply a GlowFilter, pass an object with one or more of the following properties: alpha, blurX, blurY, color, strength, quality, inner, knockout, remove, addFilter, index
Download Source Code

Syntax:

// TweenMax.to(target:Object, duration:Number, vars:Object)
TweenMax.to(mc, 1, {glowFilter:{color:0xFFFFFF, alpha:5, blurX:50, blurY:50}});

Step1:

Create a movie clip named “circle” (I used this name for the demo) or else.

Step2:

Set the document class as ‘com.Glow’

Setp3:

Create an action script file in the com folder and name it as Glow.as (which is same as in Document class)

Setp4:

Add Event Listener to the movieclip “circle” for the MOUSE_OVER and MOUSE_OUT events.

circle.addEventListener(MouseEvent.MOUSE_OVER, mc_mouseOver);
circle.addEventListener(MouseEvent.MOUSE_OUT, mc_mouseOut);

Function for the particular events.

function mc_mouseOver(evt:MouseEvent):void {
	TweenMax.to(circle, 1, {glowFilter:{color:0xFFFFFF, alpha:5, blurX:50, blurY:50}});
}
function mc_mouseOut(evt:MouseEvent):void {
	TweenMax.to(circle, 1, {glowFilter:{color:0xCCCCCC, alpha:0, blurX:10, blurY:10, remove:true}});
}

Setp5:

Run your fla by pressing Ctrl+Enter

Glow.as File

package com{
	import com.greensock.*;
	import com.greensock.easing.*;
	import flash.events.*;
	import flash.display.MovieClip;
	public class Glow extends MovieClip {
		function Glow():void {
			circle.addEventListener(MouseEvent.MOUSE_OVER, mc_mouseOver);
			circle.addEventListener(MouseEvent.MOUSE_OUT, mc_mouseOut);
		}
		function mc_mouseOver(evt:MouseEvent):void {
			TweenMax.to(circle, 1, {glowFilter:{color:0xFFFFFF, alpha:5, blurX:50, blurY:50}});
		}
		function mc_mouseOut(evt:MouseEvent):void {
			TweenMax.to(circle, 1, {glowFilter:{color:0xCCCCCC, alpha:0, blurX:10, blurY:10, remove:true}});
		}
	}
}

Download Source Code


Share Your Thoughts

9 Responses to Flash Glow Effect with greensock plugin in AS3

  1. If I want to add another filter to the same mouse_over/mouse_out event how do I go about doing that?

    For example, I want the object to glow but also change color.

    Please help.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">