StyleSheetUtil

Kind of class:class
Inherits from:none
Version:12/22/06
Author:Aaron Clinger
Classpath:org.casalib.util.StyleSheetUtil
File last modified:Monday, 01 December 2008, 13:34:40
Since:
  • Flash Player 7

Summary


Class methods
  • positionItemWithStyleObject (item:Object, style:Object) : Boolean
    • Positions a TextField, MovieClip or Button relative to the stage using an object of defined properties that mimic the CSS equivalents.

Class methods

positionItemWithStyleObject

static function positionItemWithStyleObject (
item:Object, style:Object) : Boolean

Positions a TextField, MovieClip or Button relative to the stage using an object of defined properties that mimic the CSS equivalents. This object can be created manually or passed from a StyleSheet object.


CSS propertyActionScript propertyUsage and supported values
toptopDefines object's distance from the top of the stage. Position can be defined in pixels "15px" or as a percentage of the stage height "5%".
rightrightDefines object's distance from the right of the stage. Position can be defined in pixels "15px" or as a percentage of the stage width "5%".
bottombottomDefines object's distance from the bottom of the stage. Position can be defined in pixels "15px" or as a percentage of the stage height "5%".
leftleftDefines object's distance from the left of the stage. Position can be defined in pixels "15px" or as a percentage of the stage width "5%".
margin-topmarginTopDefines the vertical spacing from top position. Position can be defined in pixels "15px" or as a percentage of the stage height "5%".
margin-rightmarginRightDefines the horizontal spacing from right position. Position can be defined in pixels "15px" or as a percentage of the stage width "5%".
margin-bottommarginBottomDefines the vertical spacing from bottom position. Position can be defined in pixels "15px" or as a percentage of the stage height "5%".
margin-leftmarginLeftDefines the horizontal spacing from left position. Position can be defined in pixels "15px" or as a percentage of the stage width "5%".
marginmarginA shorthand property for setting the four margin properties in one declaration; see documentation above. Values should be seperated by spaces and are defined in the following order: top, right, bottom and left.
widthwidthDefines the width of the object. Value can be defined in pixels "250px" or as a percentage of the stage width "25%".
heightheightDefines the height of the object. Value can be defined in pixels "250px" or as a percentage of the stage height "25%".
max-widthmaxWidthDefines the maximum width of an object. This is most helpful when the width of an object is set to a percentage and the max width is set to a pixel value. Value can be defined in pixels "250px" or as a percentage of the stage width "25%".
max-heightmaxHeightDefines the maximum height of an object. This is most helpful when the height of an object is set to a percentage and the max height is set to a pixel value. Value can be defined in pixels "250px" or as a percentage of the stage height "25%".
min-widthminWidthDefines the minimum width of an object. This is most helpful when the width of an object is set to a percentage and the min width is set to a pixel value. Value can be defined in pixels "250px" or as a percentage of the stage width "25%".
min-heightminHeightDefines the minimum height of an object. This is most helpful when the height of an object is set to a percentage and the min height is set to a pixel value. Value can be defined in pixels "250px" or as a percentage of the stage height "25%".
background-colorbackgroundColorDefines the background color of TextFields and the object color of MovieClips and Buttons. Only hexadecimal color values are supported. Named colors (such as "blue") are not supported. Colors are written in the following format: "#FF00FF".
border-colorborderColorDefines the border color of a Textfield. Only hexadecimal color values are supported. Named colors (such as "blue") are not supported. Colors are written in the following format: "#FF00FF".
opacityopacityDefines the alpha transparency of the object. Valid value range is "0.0" to"1.0"
Parameters:
item :
A MovieClip, TextField or Button.
style:
An object that describes the style with the supported properties above.
Returns:
  • Returns true if item was of type MovieClip, TextField or Button and was successfully styled; otherwise false.
Example:
  • Stage.align = "TL";
    Stage.scaleMode = "noScale";
    
    var myStylePosition:Object = new Object();
    this.myStylePosition.top      = "25px";
    this.myStylePosition.left     = "0";
    this.myStylePosition.margin   = "0 5px 0 5px";
    this.myStylePosition.width    = "100%";
    this.myStylePosition.height   = "200px";
    
    StyleSheetUtil.positionItemWithStyleObject(this.myMovieClip_mc, this.myStylePosition);
    Or you can use a stylesheet object:
    StyleSheetUtil.positionItemWithStyleObject(this.myMovieClip_mc, myStyleSheet.getStyle());