Packagecom.afcomponents.umap.styles
Classpublic class DropShadowStyle
InheritanceDropShadowStyle Inheritance Style

Specifies a drop shadow style. To use this class you should first create it's instance and the use 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".


Example
Here is a quick example:
 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:

DropShadowStyle example DropShadowStyle example



Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
 Inherited
Creates a copy of the Style object.
Style
 Inherited
concat(param:Object):Style
Creates a clone of this Style, copies the properties from specified object and returns the new style.
Style
 Inherited
copy(object:Object):void
Copies all the properties from the specified object into the Style object.
Style
 Inherited
copyStyle(dest:Object, src:Object):void
[static] Copies all properties of one object into another.
Style
 Inherited
[static] Returns new Style object, from the source XML object.
Style
 Inherited
getXMLFromStyle(style:Style, name:String = ""):XML
[static] Returns an XML object that represents all the style's properties.
Style
 Inherited
toString():String
Returns a String that represents all the style's properties.
Style
 Inherited
toXML(afcTags:Boolean = false):XML
Abstract function.
Style
Property detail
alphaproperty
public var alpha:Number = 0.6

Defines shadow opacity.

The default value is 0.6.

angleproperty 
public var angle:Number = 15

Defines shadow skewing angle in degrees.

The default value is 15.

blurXproperty 
public var blurX:Number = 3

Defines horizontal blur distance.

The default value is 3.

blurYproperty 
public var blurY:Number = 3

Defines vertical blur distance.

The default value is 3.

colorproperty 
public var color:uint = 0x0

Defines shadow RGB color.

The default value is 0x0 (black).

distanceproperty 
public var distance:Number = 0.5

Defines shadow vertical scale factor.

The default value is 0.5.

qualityproperty 
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

flash.filters.BitmapFilterQuality
strengthproperty 
public var strength:Number = 1

Defines number of times blur filter will be applied.

The default value is 1.

Constructor detail
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.

Parameters
param:Object (default = null) — Object that holds all the properites of a style you wish to override upon its creation.

See also

applyTo()
apply()
flash.display.DisplayObject
Method detail
apply()method
public function apply():Boolean

Reapplies the drop shadow for the objects specified in the last applyTo() call.

Returns
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.

DropShadowStyle example

A reference to the passed objects will be saved internally, so you call reapply the shadow with an apply() call.

Parameters
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.

Returns
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.

Parameters
shadow_mc:DisplayObjectContainer (default = null) — A container where drop shadow have been created.