Packagecom.chargedweb.swfsize
Classpublic class SWFSize
InheritanceSWFSize Inheritance flash.events.EventDispatcher

SWFSize class gives you the ability to:

View the examples

See also

SWFSizeEvent


Public Properties
 PropertyDefined By
  bottomY : Number
[read-only] Returns the current bottomY coordinate i.e.
SWFSize
  leftX : Number
[read-only] Returns the current leftX coordinate i.e.
SWFSize
  rightX : Number
[read-only] Returns the current rightX coordinate i.e.
SWFSize
  scrollX : Number
{set/get} Scrolls the window to the X-axis to a specified value of pixels
SWFSize
  scrollY : Number
{set/get} Scrolls the window to the Y-axis to a specified value of pixels
SWFSize
  SWF_ID : String
[static] The swf attributes.id defined in the html code; you have to define this before calling other methods;
SWFSize
  topY : Number
[read-only] Returns the current topY coordinate i.e.
SWFSize
  windowHeight : Number
[read-only] Returns the current available browser window height
SWFSize
  windowWidth : Number
[read-only] Returns the current available browser window width
SWFSize
Public Methods
 MethodDefined By
  
SWFSize(key:SWFSizeKey = null)
SWFSize
  
autoSize(always:Boolean = false):void
Fits the swf's width and height values to browser available width and height
SWFSize
  
autoSizeHeight(always:Boolean = false):void
Fits the swf's height value to browser's available height
SWFSize
  
autoSizeWidth(always:Boolean = false):void
Fits the swf's width value to browser's available width
SWFSize
  
[static] Singleton construction
SWFSize
  
getSWFHeight():Object
Returns the current height value of the swf container
SWFSize
  
getSWFWidth():Object
Returns the current width value of the swf container
SWFSize
  
setSWFHeight(value:Number, absolute:Boolean = true):void
Sets the height property of the swf container
SWFSize
  
setSWFWidth(value:Number, absolute:Boolean = true):void
Sets the width property of the swf container
SWFSize
Property Detail
bottomYproperty
bottomY:Number  [read-only]

Returns the current bottomY coordinate i.e. equals to topY + windowHeight


Implementation
    public function get bottomY():Number
leftXproperty 
leftX:Number  [read-only]

Returns the current leftX coordinate i.e. the relative x '0' coordinate of the browser


Implementation
    public function get leftX():Number
rightXproperty 
rightX:Number  [read-only]

Returns the current rightX coordinate i.e. equals to leftX + windowWidth


Implementation
    public function get rightX():Number
scrollXproperty 
scrollX:Number

{set/get} Scrolls the window to the X-axis to a specified value of pixels


Implementation
    public function get scrollX():Number
    public function set scrollX(value:Number):void
scrollYproperty 
scrollY:Number

{set/get} Scrolls the window to the Y-axis to a specified value of pixels


Implementation
    public function get scrollY():Number
    public function set scrollY(value:Number):void
SWF_IDproperty 
public static var SWF_ID:String

The swf attributes.id defined in the html code; you have to define this before calling other methods;

topYproperty 
topY:Number  [read-only]

Returns the current topY coordinate i.e. the relative y '0' coordinate of the browser


Implementation
    public function get topY():Number
windowHeightproperty 
windowHeight:Number  [read-only]

Returns the current available browser window height


Implementation
    public function get windowHeight():Number
windowWidthproperty 
windowWidth:Number  [read-only]

Returns the current available browser window width


Implementation
    public function get windowWidth():Number
Constructor Detail
SWFSize()Constructor
public function SWFSize(key:SWFSizeKey = null)

Parameters
key:SWFSizeKey (default = null)

Throws
IllegalOperationError — The class cannot be instantiated.
Method Detail
autoSize()method
public function autoSize(always:Boolean = false):void

Fits the swf's width and height values to browser available width and height

Parameters

always:Boolean (default = false) — if set to true makes the swf's width and height properties elastic

autoSizeHeight()method 
public function autoSizeHeight(always:Boolean = false):void

Fits the swf's height value to browser's available height

Parameters

always:Boolean (default = false) — if set to true makes the swf's height property elastic

autoSizeWidth()method 
public function autoSizeWidth(always:Boolean = false):void

Fits the swf's width value to browser's available width

Parameters

always:Boolean (default = false) — if set to true makes the swf's width property elastic

getInstance()method 
public static function getInstance():SWFSize

Singleton construction

Returns
SWFSize — SWFSize
getSWFHeight()method 
public function getSWFHeight():Object

Returns the current height value of the swf container

Returns
Object — Object { value:Number, absolute:Boolean };
getSWFWidth()method 
public function getSWFWidth():Object

Returns the current width value of the swf container

Returns
Object — Object { value:Number, absolute:Boolean };
setSWFHeight()method 
public function setSWFHeight(value:Number, absolute:Boolean = true):void

Sets the height property of the swf container

Parameters

value:Number — new height value
 
absolute:Boolean (default = true) — whether the value is absolute or relative (%)

setSWFWidth()method 
public function setSWFWidth(value:Number, absolute:Boolean = true):void

Sets the width property of the swf container

Parameters

value:Number — new width value
 
absolute:Boolean (default = true) — whether the value is absolute or relative (%)

Examples
The following code initializes the SWFSize and when the SWFSizeEvent.INIT is dispatched retrieves browser's window coordinates and metrics:
     // import the SWFSize api
     import com.chargedweb.swfsize.SWFSize;
     import com.chargedweb.swfsize.SWFSizeEvent;
     
     // initialize SWFSize
     SWFSize.SWF_ID = stage.loaderInfo.parameters.swfsizeId;
     var swfSizer:SWFSize = SWFSize.getInstance();
     swfSizer.addEventListener(SWFSizeEvent.INIT, onSWFSizeInit);
     
     function onSWFSizeInit(event:SWFSizeEvent):void
     {
         // your code logic goes here
         // eg: retrieve window coordinates and metrics on init
         trace(event.topY, event.bottomY, event.leftX, event.rightX);
         trace(swfSizer.windowWidth, swfSizer.windowHeight);
     }