| Subcribe via RSS

As 3.0 Line Effect

January 13th, 2009 Posted in ActionScript 3.0

Hi everyone and welcome again to my blog. Well, this is a very simply effect applied to a line. This is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
	 * Author: Horatiu Condrea ( http://www.flashdesign-store.com )
	 * Description: AS 3.0 Line Effect
**/
 
    // -------------------------------------
    // Variables
    // -------------------------------------
 
// I created these 2 variables(bmd and bm)
// Because the filter must know where to act
// If you whant a full effect, the stage size must be equal in the script
 
var bmd:BitmapData = new BitmapData(550, 400 , true, 0X000000);
var bm:Bitmap = new Bitmap(bmd);
addChild(bm);
 
var sp:Sprite = new Sprite();
addChild(sp);
 
var bf:BlurFilter = new BlurFilter(3,3,3);   // Set the BlurFilter Effect
 
var cmf:ColorMatrixFilter = new ColorMatrixFilter   // Set the ColorMatrixFilter Effect
([1, 2, 1, 5, 1,
  0, 1, 2, 2, 3,
  2, 0, 2, 2, 0,
  0, 0, 0, 0.83, 0]);
 
    // -------------------------------------
    //  Methods
    // -------------------------------------
 
stage.addEventListener (MouseEvent.MOUSE_MOVE, curveLine);
// Now, add an ENTER_FRAME event listener that
// will allow to add the filter
addEventListener(Event.ENTER_FRAME, loop); 
 
function curveLine(event:MouseEvent):void
{
 
// Set the line settings
   sp.graphics.clear();
   sp.graphics.lineStyle(1.5, 0xffffff);
   sp.graphics.moveTo(mouseX, mouseY);
   sp.graphics.curveTo(stage.stageWidth / 2, stage.stageHeight / 2,
                    stage.stageWidth / 2, 0);
}
 
function loop(e:Event):void
{
        // Apply the filter effects to line
	bmd.draw(sp);
	bmd.applyFilter(bmd, bmd.rect,new Point(),bf);
	bmd.applyFilter(bmd, bmd.rect,new Point(),cmf);
	bmd.scroll(2,1);
}

Here is the final result:

10 Responses to “As 3.0 Line Effect”

  1. Alexxcz Says:

    Cool :D Frumos efect!


  2. Horatiu Condrea Says:

    Thanks, in the following comments please use english.


  3. George Profenza Says:

    based on Lee’s tutorial (http://www.gotoandlearn.com/play?id=63) ?


  4. Horatiu Condrea Says:

    Somewhat. When I starated to learn AS 3.0, Lee was a good friend for me. And on the first post I whant to publish something basic and funny. And a develop this effect.Indeed, is a very simple effect, but is funny and I like it.

    Horatiu


  5. Jessicarah Says:

    I really liked this post. Can I copy it to my site? Thank you in advance.


  6. Horatiu Condrea Says:

    Of course! I’m glad you like this effect.

    Horatiu


  7. Flash tutorial | 10 Cool flash tutorials | Lemlinh.com Says:

    [...] Read tutorial [...]


  8. Flash tutorial | 10 Cool flash tutorials | Lemlinh.com Says:

    [...] Read tutorial [...]


  9. Russian souvenirs Says:

    can i translate in Russian and post on my blog? )


  10. Horatiu Condrea Says:

    Yes! But provide the original link!


Leave a Reply

Get Adobe Flash playerPlugin by wpburn.com wordpress themes