Same Imports Again, if you use Flex Builder (Flex Builder I use too), it is not mandatory to write this step, because Flex Builder automatically imports when it sees something unknown. But
if you use Flash CS3 or CS4 is required to write this step.
[SWF(width = "600", height = "400", frameRate = "30", backgroundColor = "#000000", pageTitle = "Line Effect")]If you are confused about this line of code:
[SWF(width = "600", height = "400", frameRate = "30", backgroundColor = "#000000", pageTitle = "Line Effect")]Well, here we set the width, height, framerate, backgroundColor and the title of the SWF file.
Declaring Variables To be easier for your future reference, I’ve declared variables for each color line. But before colors we need to declare a Sprite because we want to draw a line, and apply an effect to it. After that we will declare an Array that will help to animate the line. At the end we will declare the buttons with text as also line colors. The line colors consists in a BlurFilter, two GlowFilter and a DropShadowFilter. The code looks like that:
public class LineEffect extends Sprite { private var sp:Sprite = new Sprite(); private var points:Array = new Array(); private var prevmouseX:Number = 0; private var prevmouseY:Number = 0;
private var fireBtn:MovieClip = new MovieClip(); private var fireTF:TextField = new TextField();
private var skyBtn:MovieClip = new MovieClip(); private var skyTF:TextField = new TextField();
private var grassBtn:MovieClip = new MovieClip(); private var grassTF:TextField = new TextField();
private var sunBtn:MovieClip = new MovieClip(); private var sunTF:TextField = new TextField();
private var bf:BlurFilter = new BlurFilter(3,3,1); private var growFilter:GlowFilter = new GlowFilter(0xff3300, 2, 20, 10, 2, 3, true, false); private var growFilter_b:GlowFilter = new GlowFilter(0xfff000, 2, 16, 10, 3, 9, false, false); private var dropShadow:DropShadowFilter = new DropShadowFilter(0, 360, 0xC11B17, 1, 70, 70, 5, 3, false, false, false);
private var growFilter_2:GlowFilter = new GlowFilter(0x00ffff, 2, 20, 10, 2, 3, true, false); private var growFilter_b_2:GlowFilter = new GlowFilter(0x00ffff, 2, 16, 10, 3, 9, false, false); private var dropShadow_2:DropShadowFilter = new DropShadowFilter(0, 360, 0x000fff, 1, 70, 70, 5, 3, false, false, false);
private var growFilter_3:GlowFilter = new GlowFilter(0x4AA02C, 2, 20, 10, 2, 3, true, false); private var growFilter_b_3:GlowFilter = new GlowFilter(0x4AA02C, 2, 16, 10, 3, 9, false, false); private var dropShadow_3:DropShadowFilter = new DropShadowFilter(0, 360, 0x4AA02C, 1, 70, 70, 5, 3, false, false, false);
private var growFilter_4:GlowFilter = new GlowFilter(0xFDD017, 2, 20, 10, 2, 3, true, false); private var growFilter_b_4:GlowFilter = new GlowFilter(0xFDD017, 2, 16, 10, 3, 9, false, false); private var dropShadow_4:DropShadowFilter = new DropShadowFilter(0, 360, 0xFDD017, 1, 70, 70, 5, 3, false, false, false);
What events we have here? First we add the sp(Sprite) to the stage, then we add an Enter_Frame event to our Sprite, draw each button and create a Click event for each one in order to change from color and effect.
Draw the buttons and make the click events Now we write a function for each button that applies the colors and effects we have created in the beginning. On each function we insert the text buttons into the stage by drawing it with actionscript 3.0 using the drawRect class and we choose the rectangle fill color. Then we create a second function inside this one which calls the MouseEvent we have mentioned above and will start the effect.
private function makeSun(e:MouseEvent):void { sp.filters = [bf,growFilter_4,growFilter_b_4,dropShadow_4]; } } }This was the Line Effect tutorial. I hope it will be usefull for many of you. Now you can try to create your own line effects and drop a comment mentioning the url of your experiments. We are always looking for the results of our tutorials.