| Package | graphics.filters |
| Class | public class Filters |
| Inheritance | Filters Object |
| Implements | Lockable |
DisplayObject view with multiple
BitmapFilter (or multiple with the apply method).
package examples
{
import graphics.filters.Filters;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.events.KeyboardEvent;
import flash.filters.BlurFilter;
import flash.filters.DropShadowFilter;
import flash.ui.Keyboard;
public class FiltersExample extends Sprite
{
public function FiltersExample()
{
/////
stage.scaleMode = StageScaleMode.NO_SCALE ;
stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
/////
var shape:Shape = new Shape() ;
shape.graphics.beginFill( 0xFF0000 ) ;
shape.graphics.drawRect( 0 , 0 ,50 , 50 ) ;
shape.x = 50 ;
shape.y = 50 ;
addChild( shape ) ;
/////
effects = new Filters( shape ) ;
effects.addFilter( blur ) ;
effects.addFilter( shadow ) ;
}
public var blur:BlurFilter = new BlurFilter(10,5,3) ;
public var effects:Filters ;
public var shadow:DropShadowFilter = new DropShadowFilter(2,45,0,0.7,10,10,1,3) ;
public function keyDown( e:KeyboardEvent ):void
{
var code:uint = e.keyCode ;
switch( code )
{
case Keyboard.UP :
{
blur.blurX = 10 ;
shadow.distance = 2 ;
shadow.angle = 45 ;
break ;
}
case Keyboard.DOWN :
{
blur.blurX = 20 ;
shadow.distance = 6 ;
shadow.angle = 90 ;
break ;
}
}
effects.update() ;
}
}
}
| Property | Defined By | ||
|---|---|---|---|
| display : DisplayObject
Indicates the display reference. | Filters | ||
| numFilters : uint [read-only]
Indicates the number of filters. | Filters | ||
| Method | Defined By | ||
|---|---|---|---|
Filters(display:DisplayObject = null)
Creates a new Filters instance. | Filters | ||
addFilter(filter:BitmapFilter):Boolean
Inserts a new BitmapFilter. | Filters | ||
apply(display:DisplayObject):void
Initialize the filters property of the specified DisplayObject reference. | Filters | ||
hasFilter(filter:BitmapFilter):Boolean
Returns true if the specified receiver is connected. | Filters | ||
isEmpty():Boolean
Returns true if one or more receivers are connected. | Filters | ||
isLocked():Boolean
Returns true if the object is locked. | Filters | ||
lock():void
Locks the object. | Filters | ||
removeFilter(filter:BitmapFilter = null):Boolean
Removes a specific BitmapFilter reference. | Filters | ||
synchronise(display:DisplayObject = null):void
Synchronise the Filters object with the display. | Filters | ||
toArray():Array
Returns the Array representation of all receivers connected with the signal. | Filters | ||
unlock():void
Unlocks the object. | Filters | ||
update(... arguments):void
Updates the display filters. | Filters | ||
| display | property |
display:DisplayObjectIndicates the display reference.
public function get display():DisplayObject public function set display(value:DisplayObject):void| numFilters | property |
numFilters:uint [read-only] Indicates the number of filters.
public function get numFilters():uint| Filters | () | Constructor |
public function Filters(display:DisplayObject = null)Creates a new Filters instance.
Parametersdisplay:DisplayObject (default = null) — An optional DisplayObject reference.
|
| addFilter | () | method |
public function addFilter(filter:BitmapFilter):BooleanInserts a new BitmapFilter.
Parameters
filter:BitmapFilter — The BitmapFilter object to insert in the collection.
|
Boolean — true If the BitmapFilter is register.
|
| apply | () | method |
public function apply(display:DisplayObject):voidInitialize the filters property of the specified DisplayObject reference.
Parameters
display:DisplayObject |
| hasFilter | () | method |
public function hasFilter(filter:BitmapFilter):Boolean
Returns true if the specified receiver is connected.
Parameters
filter:BitmapFilter |
Boolean — true if the specified receiver is connected.
|
| isEmpty | () | method |
public function isEmpty():Boolean
Returns true if one or more receivers are connected.
Boolean — true if one or more receivers are connected.
|
| isLocked | () | method |
public function isLocked():Boolean
Returns true if the object is locked.
Boolean — true if the object is locked.
|
| lock | () | method |
public function lock():voidLocks the object.
| removeFilter | () | method |
public function removeFilter(filter:BitmapFilter = null):BooleanRemoves a specific BitmapFilter reference.
Parameters
filter:BitmapFilter (default = null) |
Boolean — true if the specified filter exist and can be unregister.
|
| synchronise | () | method |
public function synchronise(display:DisplayObject = null):voidSynchronise the Filters object with the display.
Parameters
display:DisplayObject (default = null) |
| toArray | () | method |
public function toArray():ArrayReturns the Array representation of all receivers connected with the signal.
ReturnsArray — the Array representation of all receivers connected with the signal.
|
| unlock | () | method |
public function unlock():voidUnlocks the object.
| update | () | method |
public function update(... arguments):voidUpdates the display filters.
Parameters
... arguments |