Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

BlurFilter and BitmapData with Flash CS3

This is a discussion on BlurFilter and BitmapData with Flash CS3 within the Tutorials forums, part of the Flash English category; The best way to apply a filter to an image with ActionScript 3.0 is to use the applyFilter method ...


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-10-07, 16:41
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,535
Rep Power: 6
Flep is on a distinguished road
BlurFilter and BitmapData with Flash CS3

The best way to apply a filter to an image with ActionScript 3.0 is to use the applyFilter method of the BitmapData class.
In the example, I'll be using the Document Class and another class that extends the BitmapData to load and image from the gallery..then play a little with the BlurFilter on the loaded image.
I create an FLA and save it as ' blur.fla ' . I import a random image from the gallery (file>import>import to library and browse until I find the image I wish to select). I select the loaded image, click right, option linkage and in the Class field I insert the word Image (like the name of the class I'm about to create).
I create the Document Class, an AS file that I save as ' BlurMe.as '. Here is what I write:
Code:
package
{
	import flash.display.MovieClip;
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import flash.filters.BlurFilter;
	import flash.geom.Rectangle;
	import flash.events.Event;
	
	public class BlurMe extends MovieClip
	{
		private var bit:Bitmap;
		private var immagine:Immagine;
		private var w:Number;
		private var h:Number;
		
		public function BlurMe()
		{
			initListener();
		}
		
		private function initListener():void
		{
			addEventListener(Event.ENTER_FRAME,applicaFiltro);
		}
		private function applicaFiltro(e:Event):void
		{
			var immagine:Immagine=new Immagine();
			bit=new Bitmap(immagine);
			addChild(bit);
			w=mouseX-bit.x;
			h=mouseY-bit.y;
			var filtro:BlurFilter=new BlurFilter(8,8,1);
			var rettangolo:Rectangle=new Rectangle(0,0,w,h);
			bit.bitmapData.applyFilter(bit.bitmapData,rettangolo,rettangolo.topLeft,filtro);
		}
	}
}
Now I create another class, another AS file that I save as 'Immagine.as' , like so;
Code:
package
{
	import flash.display.BitmapData;
	
	public class Immagine extends BitmapData
	{
		public function Immagine()
		{
			super(0,0);
		}
	}
}
This class loads an image from the FLA gallery. It's the same class used in the article: How to load an image from a gallery with Flash CS3
Here is the result: (hover the mouse pointer over the image to see the effect)







Source files:
Attached Files
File Type: zip BlurFilter_bitmapdata.zip (125.8 KB, 19 views)

__________________

 


I recommend: Essential Actionscript 3.0

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

Last edited by Flep; 05-06-08 at 15:31..
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
blurMoving - effetto BlurFilter Flep Articoli e tutorials 3 04-09-08 08:19
BlurFilter alle MovieClip con Actionscript 3.0 Flep Articoli e tutorials 63 26-04-08 18:17
BlurFilter e Interpolazione Movimento knip Actionscript 3.0 base 2 21-04-08 20:54
BlurFilter at MovieClip with Actionscript 3.0 Flep Tutorials 1 04-04-08 03:01
BlurFilter e BitmapData con Flash CS3 Flep Articoli e tutorials 0 19-09-07 14:53


All times are GMT. The time now is 18:44.

Powered by vBulletin version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap