Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

BlurFilter at MovieClip with Actionscript 3.0

This is a discussion on BlurFilter at MovieClip with Actionscript 3.0 within the Tutorials forums, part of the English Forums category; The BlurFilter is simply something I love. I"ve created an example on how to apply the BlurFilter to our ...


Go Back   Forum Flash CS3 Flash CS4 > English Forums > Tutorials

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  4 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 08-10-07, 15:24
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,352
Blog Entries: 1
Rep Power: 6
Flep is on a distinguished road
BlurFilter at MovieClip with Actionscript 3.0

The BlurFilter is simply something I love.
I"ve created an example on how to apply the BlurFilter to our MovieClip with Actionscript 3.0 and I"ve played a little with it.







Let"s see how I"ve done it"
Code:
package
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.filters.BlurFilter;
	
	public class Bluring extends MovieClip
	{
		private var clips_array:Array;
		private var fields_array:Array;
		private var arrX:Number;
		private var arrY:Number;
		
		public function Bluring()
		{
			stage.frameRate=31;
			
			init();
			initListener();
		}
		
		private function init():void
		{
			clips_array=new Array(clip_0_mc,clip_1_mc,clip_2_mc,clip_3_mc,clip_4_mc);
			fields_array=new Array(tag_0_mc.info_txt,tag_1_mc.info_txt,tag_2_mc.info_txt,
								   tag_3_mc.info_txt,tag_4_mc.info_txt);
		}
		
		private function initListener():void
		{
			addEventListener(Event.ENTER_FRAME,controllaMouse);
		}
		
		private function controllaMouse(e:Event):void
		{
			var point:Point=new Point(mouseX,mouseY);
			
			for(var i:int=0;i < clips_array.length;i++)
			{
				var scalingX:Number=12-clips_array[i].scaleX*6;
				var scalingY:Number=12-clips_array[i].scaleY*6;
				fields_array[i].text='BLUR = '+(scalingX.toFixed(2)).toString();
				getFilter(scalingX,scalingY,clips_array[i]);
				
				if(clips_array[i].hitTestPoint(point.x,point.y,false))
					sottoFocus(clips_array[i]);
				else
					libero(clips_array[i]);
			}
		}
		
		private function sottoFocus(m:MovieClip):void
		{
			var arrS:Number=200;
			var ds:Number=arrS-m.scaleX*100;
			var xs:Number=ds*.2;
			m.scaleX+=xs/100;
			m.scaleY+=xs/100;
		}
		
		private function libero(m:MovieClip):void
		{
			var arrS:Number=100;
			var ds:Number=arrS-m.scaleX*100;
			var xs:Number=ds*.2;
			m.scaleX+=xs/100;
			m.scaleY+=xs/100;
		}
		
		private function getFilter(xx:Number,yy:Number,m:MovieClip):void 
		{
			var array_filter:Array=new Array();
			var quality:int=2;
			var filter:BlurFilter=new BlurFilter(xx,yy,quality);
			array_filter.push(filter);
			m.filters=array_filter;
		}
	}
}
The juice of this script ( which I"ve probably fattened too much and the beginners might find difficulty in translating it ) is made of how to apply the BlurFilter to a MovieClip, like so:
You need to pass the internal filter of an Array to the filters property of the MovieClip.

I create an array:
var array_filter:Array=new Array();
I create a filter ( in this case the BlurFilter ):
var filter:BlurFilter=new BlurFilter(10,10,1);
I insert the filter inside the Array:
array_filter.push(filter);
I pass the Array to the MovieClip:
nameClip.filters=array_filter;

Stay tuned !
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !

Last edited by Flep; 28-08-08 at 05:37.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 04-04-08, 02:01
donteatyourfriends's Avatar
Junior Member
 
Join Date: Mar 2008
Location: Los Angeles
Posts: 6
Rep Power: 0
donteatyourfriends is on a distinguished road
Re: BlurFilter at MovieClip with Actionscript 3.0

This is bad ass.

Anyway you can put the source files up for download?

Quote:
Originally Posted by Flep View Post
The BlurFilter is simply something I love.
I?ve created an example on how to apply the BlurFilter to our MovieClip with Actionscript 3.0 and I?ve played a little with it.







Let?s see how I?ve done it?
Code:
package
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.filters.BlurFilter;
	
	public class Bluring extends MovieClip
	{
		private var clips_array:Array;
		private var fields_array:Array;
		private var arrX:Number;
		private var arrY:Number;
		
		public function Bluring()
		{
			stage.frameRate=31;
			
			init();
			initListener();
		}
		
		private function init():void
		{
			clips_array=new Array(clip_0_mc,clip_1_mc,clip_2_mc,clip_3_mc,clip_4_mc);
			fields_array=new Array(tag_0_mc.info_txt,tag_1_mc.info_txt,tag_2_mc.info_txt,
								   tag_3_mc.info_txt,tag_4_mc.info_txt);
		}
		
		private function initListener():void
		{
			addEventListener(Event.ENTER_FRAME,controllaMouse);
		}
		
		private function controllaMouse(e:Event):void
		{
			var point:Point=new Point(mouseX,mouseY);
			
			for(var i:int=0;i < clips_array.length;i++)
			{
				var scalingX:Number=12-clips_array[i].scaleX*6;
				var scalingY:Number=12-clips_array[i].scaleY*6;
				fields_array[i].text='BLUR = '+(scalingX.toFixed(2)).toString();
				getFilter(scalingX,scalingY,clips_array[i]);
				
				if(clips_array[i].hitTestPoint(point.x,point.y,false))
					sottoFocus(clips_array[i]);
				else
					libero(clips_array[i]);
			}
		}
		
		private function sottoFocus(m:MovieClip):void
		{
			var arrS:Number=200;
			var ds:Number=arrS-m.scaleX*100;
			var xs:Number=ds*.2;
			m.scaleX+=xs/100;
			m.scaleY+=xs/100;
		}
		
		private function libero(m:MovieClip):void
		{
			var arrS:Number=100;
			var ds:Number=arrS-m.scaleX*100;
			var xs:Number=ds*.2;
			m.scaleX+=xs/100;
			m.scaleY+=xs/100;
		}
		
		private function getFilter(xx:Number,yy:Number,m:MovieClip):void 
		{
			var array_filter:Array=new Array();
			var quality:int=2;
			var filter:BlurFilter=new BlurFilter(xx,yy,quality);
			array_filter.push(filter);
			m.filters=array_filter;
		}
	}
}
The juice of this script ( which I?ve probably fattened too much and the beginners might find difficulty in translating it ) is made of how to apply the BlurFilter to a MovieClip, like so:
You need to pass the internal filter of an Array to the filters property of the MovieClip.

I create an array:
var array_filter:Array=new Array();
I create a filter ( in this case the BlurFilter ):
var filter:BlurFilter=new BlurFilter(10,10,1);
I insert the filter inside the Array:
array_filter.push(filter);
I pass the Array to the MovieClip:
nameClip.filters=array_filter;

Stay tuned !
__________________
"Don't Eat Your Friends!"

Dust Bunny Creative
Rob Tortora
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Apply the BlurFilter to a MovieClip with Actionscript 3.0 - script 2 Flep Tutorials 1 25-06-08 07:31
BlurFilter alle MovieClip con Actionscript 3.0 Flep Articoli e tutorials 63 26-04-08 17:17
BlurFilter e Interpolazione Movimento knip Actionscript 3.0 base 2 21-04-08 19:54
BlurFilter alle MovieClip con Actionscript 3.0 - script 2 Flep Articoli e tutorials 23 29-11-07 12:09
Aggiungere dinamicamente un MovieClip figlio ad un altro MovieClip nextpaco Actionscript 3.0 avanzato 17 17-10-07 06:05


All times are GMT. The time now is 06:26.


Powered by vBulletin versione 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406