Blur + Tweener in AS3

blur

Hi again ;-)

Many people ask me how to do tweening of blurX and blurY (and other filters and properties) using Tweener – but in AS3 not AS2 (as in previous posts).

The solution is quite simple:

1. You need Tweener for AS3 (you can download it from googlecode) - import the class,

2. import the filter you want (from flash.filters.*),

3. place an example mc on the stage and name it ‘my_mc’,

4. finally here is the example code:

// Import Filters
import flash.filters.*;
// Import Tweener
import caurina.transitions.Tweener;

import caurina.transitions.properties.FilterShortcuts;
//initialize the shortcuts
FilterShortcuts.init();

// Add Events
my_mc.addEventListener(MouseEvent.ROLL_OVER, my_mc_ROLLOVER);
my_mc.addEventListener(MouseEvent.ROLL_OUT, my_mc_ROLLOUT);

 

// And that is how it works…
function my_mc_ROLLOVER(e:MouseEvent):void
{
 Tweener.addTween(my_mc, {_Blur_blurX:15,_Blur_blurY:15, time:2});
};

function my_mc_ROLLOUT(e:MouseEvent):void
{
 Tweener.addTween(my_mc, {_Blur_blurX:0,_Blur_blurY:0, time:2});
};

HAVE FUN,

FLAIM

 

/// EDIT

There was a change in newer versions of Tweener which I should mention. I’ve marked the changes BOLD in the code.

// DAVE SAID

_Blur_blurX …. (Upper case B) works,
_blur_blurX ….. (lower case b) Not
Case sensitive….

 // ANOTHER CHANGES IN TWEENER WHICH YOU HAVE TO KNOW ABOUT IF U USE A NEWER VERSION OF IT

I’ve marked the changes RED in the code.

import caurina.transitions.properties.FilterShortcuts;
//initialize the shortcuts
FilterShortcuts.init();

29 Responses to “Blur + Tweener in AS3”

  1. Reda Makhchan Says:

    better to update this article because it will not work without:

    import caurina.transitions.properties.FilterShortcuts;
    //initialize the shortcuts
    FilterShortcuts.init();

    thks James ;) for the info.
    and thks for this article

  2. CaveManGenius Says:

    This isnt working for me, ## [Tweener] Error: The property ‘_Blur_blurX’ doesn’t seem to be a normal object property of [object MovieClip] or a registered special property.
    What am i doing wrong?

  3. CaveManGenius Says:

    I am using Tweener version 1.31.74 and CS3 with ActionScript 3.0. My FilterShortCut.as has _Blur_blurX & _Blur_blurY.

  4. Marcus Zorbis Says:

    Works great for me, thanks!

  5. flaim Says:

    Hi CaveManGenius,

    Depends on the version of Tweener you are using.

    import caurina.transitions.*;
    import caurina.transitions.properties.FilterShortcuts;
    FilterShortcuts.init();

    Tweener.addTween(your_MC, {_Blur_blurX: 15 ,_Blur_blurY: 15, time:1});

    The above code works fine with new version of Tweener.

    Cheers,

    FLAIM


Leave a Reply