Be a Supporter!

(as3) Dynamically Removing Filters

  • 668 Views
  • 4 Replies
New Topic Respond to this Topic
Lynkusu
Lynkusu
  • Member since: Aug. 27, 2009
  • Offline.
Forum Stats
Member
Level 06
Programmer
(as3) Dynamically Removing Filters 2011-08-02 20:55:01 Reply

Basically, the effect I'm going for is, you click on a button that calls an mc to the stage and blurs everything below it. When you click another button (that was also called), that mc (and button) is removed, as well as the blur filter.
I have this for the filter:

var BLUR:Array = [new BlurFilter(16, 16, 1)];

var i:int = this.numChildren - 5;
while(i > 0){
i--;
    
this.getChildAt(i).filters = BLUR;
}

I thought copying it and changing the last line to

this.getChildAt(i).filters = [];

would work, but, well, I wouldn't be here if it did...

Does anyone know how to do this? Thanks in advance.


Intellectually Questionable? You decide.

Atlas
Atlas
  • Member since: Nov. 14, 2010
  • Offline.
Forum Stats
Member
Level 21
Musician
Response to (as3) Dynamically Removing Filters 2011-08-02 21:13:50 Reply

http://icodesnip.com/search/as3%20image%
20filters/

That has somethings about blurring the stage in it.

Also try tutcity below.

http://www.tutcity.com/flash/using-actio nscript-to-apply-the-blur-filter-to-butt on-symbols.10730.html


Steam | Letterboxd | AllPoetry | Formerly Known As J-Rex

BBS Signature
Lynkusu
Lynkusu
  • Member since: Aug. 27, 2009
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to (as3) Dynamically Removing Filters 2011-08-02 21:23:17 Reply

Well, the blur is already successful. I can get the background stuff to blur. I just can't get it to unblur...


Intellectually Questionable? You decide.

Atlas
Atlas
  • Member since: Nov. 14, 2010
  • Offline.
Forum Stats
Member
Level 21
Musician
Response to (as3) Dynamically Removing Filters 2011-08-02 22:08:27 Reply

http://flashexplained.com/actionscript/a pplying-the-blur-filter-to-buttons-via-a ctionscript/

That should help. One of the chapters is how to remove the blur from your stage.


Steam | Letterboxd | AllPoetry | Formerly Known As J-Rex

BBS Signature
Lynkusu
Lynkusu
  • Member since: Aug. 27, 2009
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to (as3) Dynamically Removing Filters 2011-08-02 22:57:25 Reply

Well, that's just telling me to use filters = null; which is what I already have and what isn't working.

This is all relevant code I have; maybe someone can detect a problem. (Also, just ignore my stupid function names. I pretty much just name them after the next word I hear in the song I'm listening to :\)

hint.addEventListener(MouseEvent.CLICK,manipulation);
function manipulation(event:MouseEvent){
	this.addChild(newHint);
	newHint.x = 121;
	newHint.y = 78;
	
	this.addChild(newX);
	newX.x = 350.9;
	newX.y = 100.0;

	var i:int = this.numChildren - 5;
	while(i > 0){
        i--;
    
        this.getChildAt(i).filters = BLUR;
	} 
	
	newX.addEventListener(MouseEvent.CLICK,traumst);
	function traumst(event:MouseEvent){
		removeChild(newHint);
		removeChild(newX);
		var i:int = this.numChildren - 5;
		while(i > 0){
		i--;
		
		this.getChildAt(i).filters = [];
		} 
	} 
}

Everything works perfectly except

var i:int = this.numChildren - 5;
while(i > 0){
i--;
		
this.getChildAt(i).filters = [];

and I have no compiler errors, the blur just simply doesn't go away when "newX" is pressed.


Intellectually Questionable? You decide.