Tween Blur A Movie Clip Using AS3 - actionscript-3

I am trying to tween a movie clip called "SmartBg" to blur from zero to 8% on trigger of a mouse click event on another movieclip.
How do I go about achieving that?

I would suggest using the GTween library for it: http://www.gskinner.com/libraries/gtween/
Actually, they even have an example about twenning blur of a clip: http://www.gskinner.com/libraries/gtween/demos/GTweenSimpleSequencing.swf

Related

Optimizing AS3 DropShadowFilter

I'm using GreenSock's TweenMax to fade in a TLFTextField with a DropShadowFilter applied. The framerate drops to about 8fps when I try to do this. Without the shadow, the transition is a consistent 24fps. I know Flash is redrawing the shadow each frame - is there any way I can avoid this?
cacheAsBitmap seems to have no noticeable effect. I could draw the textfield to a bitmap, but I'd like that to be a last resort. Is there any override for redrawing the shadow? Or perhaps an alternative method?
Any help would be appreciated.
Thanks in advance.
Embed the TextField to fade in into a parent Sprite, cache that sprite as bitmap, and fade the parent in by tweening its alpha. This should make Flash draw the drop shadow only once per entire processing.
var fadeholder:Sprite=new Sprite();
fadeholder.addChild(tf); // your textfield
tf.alpha=1;
// it should have filter applied already
fadeholder.cacheAsBitmap=true;
addChild(fadeholder);
After you do this, initiate tween on fadeholder.alpha, and once it's over, add the textfield to a proper parent ("this", maybe) and remove the obsolete fadeholder from display list.

Event Click On MovieClips Mask (Non Transparent Area)

I'm working with Flash CS6 to create MovieClips that I want to use in my AS3 project using Linked Classes, I'm trying to detect when the mouse is clicking the MovieClip, but the event is fired also when I click the transparent area of the PNG image used to create the MovieClip, and I want to fire the event only when I click the non transparent area of the Movieclip (the mask), is there any work around I can do in Flash CS5 or with AS3 code !
You should add an instance name to the mask (which means it must be a symbol), and then add listener directly on the mask, not on the whole movie clip.
Another solution is to set mouseEnabled and mouseChildren to false on that bitmap, and leave only the area you wish to be clickable.

How to resize a movie clip as a whole, without hindering animation?

I have a movie clip with some animation in it. If I resize it inside the movie clip, the animation goes weird. How can I resize the whole movie clip without hindering the animation or changing the animation?
This movie clip gets brought on the stage by action script
This code scales a movieclip myMovieClip by 200%
myMovieClip.scaleX = 2;
myMovieClip.scaleY = 2;
Assuming the movieclip has been added to the stage w/ ActionScript (e.g., addChild(myMovieClip); and has an instance name, you should be able to plug that code in there to get it going.

AS3: restoring timeline animation after code alteration

I have a movie clip that I animate in my timeline.
At a certain point of my code I need to move that mc by actionscript and at another point I need it to do the timeline animation.
Now, I know that if I alter my movieclip through AS the timeline animations will be ignored further on, but I was wondering: is there a way to force the movieclip to follow the timeline tweenings back again?
No. Once you change a property, it is detached from the timeline.
One solution is having another movieclip inside that movieclip. That way, the timeline animates the main movieclip, but you can access the inner movieclip with a reference to it and do whatever additional transformations you want to it. How you do this will depend on what exactly you're doing, and you have to remember the transformations will "stack", but it works.

erasing a movieclip

I have a fully working flash application, made in as3. Now i dynamicly added a movieclip and i would like to be able to erase that movieclip with a eraser of some sort, my goal is to be able pick up a sponge with the mouse and then start dragging over the movieclip and erasing the parts where i dragged over it.
Anyone who can help?
Looks like this might be what you're looking for:
http://www.piterwilson.com/personal/2008/05/07/bitmapdata-erasing-in-as3-with-custom-brush-shape/
Is the background behind the MovieClip always the same?
If so you can put an image of the background over the MovieClip you want to erase, and mask that image so it becomes invisible, then add a click listener that draws a circle in the mask when clicked. This way it'll look like the MovieClip is being erased.
With getPixel you can loop over the mask and detect the percentage of the MovieClip that has been erased, so you can remove the clip from stage when it's fully erased.