| Package | com.afcomponents.umap.styles |
| Class | public class DropShadowStyle |
| Inheritance | DropShadowStyle Style |
applyTo() method to
create a drop shadow of a target DisplayObject
in the specified DisplayObjectContainer.
It is more convinient to have target & shadow DisplayObjects on the same parent.
Please also note that shadow is corretly rendered if target object is placed in negative y space of it's parent object.
Imagine that y = 0 line is the ground-level and target object "floats" above this line,
and the shadow will be rendered on the "ground".
import com.afcomponents.umap.styles.DropShadowStyle; import flash.display.Sprite; // create sample Sprite that will hold both content & shadow var sample:Sprite = new Sprite(); addChild(sample); sample.x = 50; sample.y = 150; // create Sprites for content & shadow var content:Sprite = new Sprite(); var shadow:Sprite = new Sprite(); sample.addChild(shadow); sample.addChild(content); // draw 100x100 square on content content.graphics.lineStyle(3, 0x0); content.graphics.beginFill(0xFFCC00, 0.5); content.graphics.drawRect(0,0,100,100); // mportantmove content to -height, so that drop shadow will look correctly content.y = -content.height; // create drop shadow style var style:DropShadowStyle = new DropShadowStyle(); style.applyTo(content, shadow);
Here is what you should see after executing the code:
|
|
| Property | Defined by | ||
|---|---|---|---|
| alpha : Number = 0.6
Defines shadow opacity.
| DropShadowStyle | ||
| angle : Number = 15
Defines shadow skewing angle in degrees.
| DropShadowStyle | ||
| blurX : Number = 3
Defines horizontal blur distance.
| DropShadowStyle | ||
| blurY : Number = 3
Defines vertical blur distance.
| DropShadowStyle | ||
| color : uint = 0x0
Defines shadow RGB color.
| DropShadowStyle | ||
| distance : Number = 0.5
Defines shadow vertical scale factor.
| DropShadowStyle | ||
| quality : Number = 1
Defines blur filer quality.
| DropShadowStyle | ||
| strength : Number = 1
Defines number of times blur filter will be applied.
| DropShadowStyle | ||
| Method | Defined by | ||
|---|---|---|---|
|
DropShadowStyle(param:Object = null)
DropShadowStyle constructor.
| DropShadowStyle | ||
|
apply():Boolean
Reapplies the drop shadow for the objects specified in the last
applyTo() call. | DropShadowStyle | ||
|
applyTo(target_mc:DisplayObject, shadow_mc:DisplayObjectContainer):Boolean
Creates a drop shadow of a target
DisplayObject in the specified DisplayObjectContainer. | DropShadowStyle | ||
|
clear(shadow_mc:DisplayObjectContainer = null):void
Clears the drop shadow from the specified
DisplayObjectContainer
Id you don't specify an object to clear, this object will be taken from the last applyTo() call. | DropShadowStyle | ||
![]() |
Creates a copy of the
Style object. | Style | |
![]() |
Creates a clone of this
Style,
copies the properties from specified object and returns the new style. | Style | |
![]() |
copy(object:Object):void
Copies all the properties from the specified object into the
Style object. | Style | |
![]() |
copyStyle(dest:Object, src:Object):void
[static]
Copies all properties of one object into another.
| Style | |
![]() |
getStyleFromXML(xml:XML):Style
[static]
Returns new
Style object, from the source XML object. | Style | |
![]() |
getXMLFromStyle(style:Style, name:String = ""):XML
[static]
Returns an
XML object that represents all the style's properties. | Style | |
![]() |
toString():String
Returns a
String that represents all the style's properties. | Style | |
![]() |
toXML(afcTags:Boolean = false):XML
Abstract function.
| Style | |
| alpha | property |
public var alpha:Number = 0.6Defines shadow opacity.
The default value is 0.6.
| angle | property |
public var angle:Number = 15Defines shadow skewing angle in degrees.
The default value is 15.
| blurX | property |
public var blurX:Number = 3Defines horizontal blur distance.
The default value is 3.
| blurY | property |
public var blurY:Number = 3Defines vertical blur distance.
The default value is 3.
| color | property |
public var color:uint = 0x0Defines shadow RGB color.
The default value is 0x0 (black).
| distance | property |
public var distance:Number = 0.5Defines shadow vertical scale factor.
The default value is 0.5.
| quality | property |
public var quality:Number = 1
Defines blur filer quality.
You can use flash.filters.BitmapFilterQuality constants to define this property.
The default value is 1.
See also
| strength | property |
public var strength:Number = 1Defines number of times blur filter will be applied.
The default value is 1.
| DropShadowStyle | () | constructor |
public function DropShadowStyle(param:Object = null)DropShadowStyle constructor.
Creates new DropShadowStyle object with the default parameters.
Properties defined in param object will override the default values.
Please use applyTo() method to crate a drop shadow for the specified DisplayObject object.
Use apply() method to reapply the shadow style for the objects specified in the last applyTo() call.
To remove the shadow for the specified DisplayObjectContainer, please call clear() method.
param:Object (default = null) — Object that holds all the properites of a style you wish to override upon its creation.
|
See also
| apply | () | method |
public function apply():Boolean
Reapplies the drop shadow for the objects specified in the last applyTo() call.
Boolean — Value of true if the shadow generation was successfull; false if it was not.
|
| applyTo | () | method |
public function applyTo(target_mc:DisplayObject, shadow_mc:DisplayObjectContainer):Boolean
Creates a drop shadow of a target DisplayObject in the specified DisplayObjectContainer.
Usually these objects are placed on the same parent. Target DisplayObject should be placed in the negative
vertical space. Horizontal line, y = 0, is considered the ground level for target object.
A reference to the passed objects will be saved internally, so you call reapply the shadow with an apply() call.
target_mc:DisplayObject — An object from which a drop shadow should be generated.
|
|
shadow_mc:DisplayObjectContainer — A container where the drop shadow should be created.
|
Boolean — Value of true if the shadow generation was successfull; false if it was not.
|
| clear | () | method |
public function clear(shadow_mc:DisplayObjectContainer = null):void
Clears the drop shadow from the specified DisplayObjectContainer
Id you don't specify an object to clear, this object will be taken from the last applyTo() call.
shadow_mc:DisplayObjectContainer (default = null) — A container where drop shadow have been created.
|