Imajine Blog Imajine Articles
Contact Me

Flash tutorial to create glow effect using actionscript

In this tutorial,  with the help of actionscript, we shall draw a star, fill color to it and provide outer glow to the same. We shall also include actionscript event to change glow color.

Select frame 1 and paste the below code in the actions window.

import flash.filters.GlowFilter;

var mc:MovieClip = createglowstar("glowstarColor");
mc.onRelease = function()
{
var filter:GlowFilter = this.filters[0];
filter.color = 0x3399FF;
this.filters = new Array(filter);
}
function createglowstar(name:String):MovieClip
{
var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
var w:Number = 100;
var h:Number = 100;
art.beginFill(0xf7f7f7);
art.lineTo(100, 0);
art.lineTo(150, -100);
art.lineTo(200, 0);
art.lineTo(300, 0);
art.lineTo(200, 50);
art.lineTo(250, 150);
art.lineTo(150, 75);
art.lineTo(50, 150);
art.lineTo(100, 50);
art.lineTo(0, 0);
art._x = 50;
art._y = 150; 

var filter:GlowFilter = new GlowFilter(0xccaa00, .8, 16, 16, 5, 5, false, false);
var filterArray:Array = new Array();
filterArray.push(filter);
art.filters = filterArray;
return art;

}

Press Ctrl+Enter to view Glow effect.
--------------------------------------------------------------------------------------------------------------------------------

Explanation to the code above

First and formost we will need to import flash.filters package which contains classes for the bitmap filter effects

import flash.filters.GlowFilter;


Next, lets define a variable for movieclip and draw a star and add glow effect to the same. If you are not familiar with actionscript drawing, please go through my drawing tutorial before you proceed.

var mc:MovieClip = createglowstar("glowstarColor");
function createglowstar(name:String):MovieClip
{
var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());
var w:Number = 100;
var h:Number = 100;
art.beginFill(0xf7f7f7);
art.lineTo(100, 0);
art.lineTo(150, -100);
art.lineTo(200, 0);
art.lineTo(300, 0);
art.lineTo(200, 50);
art.lineTo(250, 150);
art.lineTo(150, 75);
art.lineTo(50, 150);
art.lineTo(100, 50);
art.lineTo(0, 0);
art._x = 50;
art._y = 150; 

var filter:GlowFilter = new GlowFilter(0xccaa00, .8, 16, 16, 5, 5, false, false);
var filterArray:Array = new Array();
filterArray.push(filter);
art.filters = filterArray;
return art;

}


Now right below movieclip variable let add event to change glow filter color

mc.onRelease = function()
{
var filter:GlowFilter = this.filters[0];
filter.color = 0x3399FF;
this.filters = new Array(filter);
}


I hope you enjoyed this tutorial. Please do write to me if you have any query.

Tags: Glow effect in flash, actionscript filters, Glow in as2, Flash glow effect at runtime,

Download Free Photo Gallery

Download Free Photo Gallery

You can download Imajine's Scrapbook Photo Gallery absolutely free of cost and to customize , you need no knowledge of Adobe Flash.  Click here to view Scrapbook Photo Gallery / download

Tutorials
Flash Tutorials
Horizontal 3D Carousel
MP3 Player
Scrapbook Photo Gallery
Text Enhancement
Color object
Glow effect using actionscript
Drawing with actionscript
Blur Effect
Load external .mp3 file
Preload external .mp3 file
Sound Controller
Set volume of externally .mp3 file
View MP3 song details
Actionscript blur effect
Actionscript fade in / out effect
Fireworks Tutorials
Custom Stroke
Typography / Ink blot effect
Photograph focus effect
Rainbow Pattern
Inset Text Effect
Fuzzy Light Blending Mode
Little bulb effect
Old paper effect
'Post it' effect
Hand drawn designs
Black/White and Sepia tone
Water color painting effect
Vintage effect on vector graphics
Solid color, black/white
Photoshop Tutorials
Photo editing
Purple Haze

Portfolio

Logos
Website design
CMS Customization
Flash
Web development
Print


Download free textures and patterns and use it for your personal use.

Click here to download Textures and Patterns.

Download free birthday cards

Free Birthday Cards
Click here to view Imajine's free downloadable birthday cards for personal and corporate use. Imajine's birthday cards are in jpeg format so it is faster to download and send in your wishes to your friends and family.
Bookmark and Share Tell a Friend jayanthi.varma@imajine.in  |  © 2008 Imajine