|
-
[AS3] Add/Remove filters at will
Im not sure about the easiest way to dynamically add and remove filters on a Sprite. From the docs it indicates that you have to explicitly say what the filters are - you cant simply push a new filter to the filters property.
If I have applied one filter to something, how do I apply another filter on top of it without explicitly knowing what the previous filter was?
-
hippie hater
Every DisplayObject has a filters array, however you cant acess this array directly, i mean,
//sq.filters.push(bf);//that will not work
so you pass a reference to this array, change this new one and put it back
PHP Code:
var gf:GlowFilter = new GlowFilter(0xAAFFFF,0.5, 32, 32, 32, 1,false, false);
var bf:BlurFilter = new BlurFilter(128, 2, 1);
sq.filters = [gf];
//sq.filters.push(bf);//that will not work
var ar:Array = new Array();
ar = sq.filters;
ar.push(bf);
sq.filters = ar;
sq.filters = [gf]; <-- will only work cos the array was empty before
Last edited by Cimmerian; 07-26-2007 at 12:45 PM.
-
...so easy...
Thank you sir!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|