Applying filters with AS

Posted by andersj 
Applying filters with AS
November 25, 2008 12:38PM
Hi there

I am more of a ActionScript guy, and am having trouble adding a filter to a pattern..the filter simply don´t show up. I add my filter like so:


import com.jumpeye.Events.FLASHEFFEvents;
import com.jumpeye.flashEff.symbol.flip.FESFlip;

var myPatternShow:FESFlip = new FESFlip();
myPatternShow.smooth = true;
myPatternShow.smoothSegments = 5;
myPatternShow.preset = 2;
myPatternShow.tweenType = "Strong";
myPatternShow.easeType = "easeOut";
myPatternShow.tweenDuration = 2;

var myPatternHide:FESFlip = new FESFlip();
myPatternHide.smooth = true;
myPatternHide.smoothSegments = 5;
myPatternHide.preset = 2;
myPatternHide.tweenType = "Regular";
myPatternHide.easeType = "easeNone";
myPatternHide.tweenDuration = 2;

var myEffect:FlashEff = new FlashEff();
myEffect.showTransition = myPatternShow;
myEffect.hideTransition = myPatternHide;
myEffect.showAutoPlay = false;
myEffect.hideAutoPlay = false;
//myEffect.useHandCursor = true;
myEffect.showDelay = 0;
myEffect.hideDelay = 0;

var myFace1:face1 = new face1();
myFace1.name = "myFace1";
myFace1.x = 50;
myFace1.y = 50;
addChild(myFace1);
addChild(myEffect);
myEffect._targetInstanceName = "myFace1";
myEffect.show();

How would i add for example a blur and reflect filter to this pattern ? I Have tried in many ways, but no go.

Help would be appreciated.
Anders
Re: Applying filters with AS
November 25, 2008 04:54PM
Might be wrong but have you tried changing this line..

myEffect._targetInstanceName = "myFace1";

to

myEffect._targetInstanceName = myFace1.name;
Re: Applying filters with AS
November 26, 2008 07:55AM
@Anders

I've tested your code and it works. It simply applies a show and hide effect on a target clip and starts the show effect. You mentioned something about filters not being applied, but in your code there are no filters. There is only the show and the hide effect applied on the FlashEff instance.
Re: Applying filters with AS
November 26, 2008 09:08AM
Oh, no no negush :)

My above code works perfectly, i just wished for You to show me HOW i would add a filter to my show effect above (for example a reflection and blur). I´m having troble applying filters trough AS, so i just wish for You to complete my code above and show me an example of adding a reflect & blur filter.

best regards
Anders
Re: Applying filters with AS
November 27, 2008 03:55PM
andersj Wrote:
-------------------------------------------------------
> Oh, no no negush :)
>
> My above code works perfectly, i just wished for
> You to show me HOW i would add a filter to my show
> effect above (for example a reflection and blur).
> I´m having troble applying filters trough AS, so
> i just wish for You to complete my code above and
> show me an example of adding a reflect & blur
> filter.
>
> best regards
> Anders

Here is a really simple way to add any filter.
At the end of your code just add the following:

myFace1.alpha=0
var filter2 = myEffect.addFilterByName("com.jumpeye.flashEff.filter.blur.FEFBlur" );
var filter = myEffect.addFilterByName("com.jumpeye.flashEff.filter.reflection.FEFReflection" );

Hope this helps.

-Ionut.



Edited 1 time(s). Last edit at 11/27/2008 03:56PM by Ionut.
Re: Applying filters with AS
November 27, 2008 04:34PM
Here is how you can add filters by code:

- the filters should be added after the show() method has been called and also the target clip should be hidden before the show effect, so you need to set the alpha property of the myFace1 clip to 0 when you add it to the stage;

- then add the filters after the show() method call

var blurFilter:FEFBlur = new FEFBlur();
myEffect.addFilter(blurFilter);

var reflectionFilter:FEFReflection = new FEFReflection();
myEffect.addFilter(reflectionFilter);

You can also make settings to the filter instances.
Re: Applying filters with AS
December 09, 2008 04:51PM
Thank You negush & lonut, that works. Is there any way to tween the blur filter as You can do in TweeenerLite, so the blur kind of follows the effect pattern tweening ?
Re: Applying filters with AS
December 10, 2008 07:47AM
Unfortunately you cannot tween the filters without reapplying them. So basically you would continually create a new instance of the FlashEff filter, change the properties of the filter and apply this new instance on the object.
Re: Applying filters with AS
April 10, 2009 01:43PM
Okay, I used the example above to apply two filters to a display object and it works fine. However, when I go to remove one of the filters it removes the display object. The commands I am using to add and remove the filter are in the form:

myEffect.addFilter(reflectionFilter);
myEffect.removeFilter(reflectionFilter);

What am I doing wrong?


Thanks in advance,
Tommy



Edited 2 time(s). Last edit at 04/10/2009 01:47PM by thall88.
Sorry, you do not have permission to post/reply in this forum.