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 property | ActionScript property | Usage and supported values |
---|---|---|
top | top | Defines 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%" . |
right | right | Defines 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%" . |
bottom | bottom | Defines 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%" . |
left | left | Defines 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-top | marginTop | Defines the vertical spacing from top position. Position can be defined in pixels "15px" or as a percentage of the stage height "5%" . |
margin-right | marginRight | Defines the horizontal spacing from right position. Position can be defined in pixels "15px" or as a percentage of the stage width "5%" . |
margin-bottom | marginBottom | Defines the vertical spacing from bottom position. Position can be defined in pixels "15px" or as a percentage of the stage height "5%" . |
margin-left | marginLeft | Defines the horizontal spacing from left position. Position can be defined in pixels "15px" or as a percentage of the stage width "5%" . |
margin | margin | A 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. |
width | width | Defines the width of the object. Value can be defined in pixels "250px" or as a percentage of the stage width "25%" . |
height | height | Defines the height of the object. Value can be defined in pixels "250px" or as a percentage of the stage height "25%" . |
max-width | maxWidth | Defines 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-height | maxHeight | Defines 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-width | minWidth | Defines 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-height | minHeight | Defines 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-color | backgroundColor | Defines 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-color | borderColor | Defines 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" . |
opacity | opacity | Defines 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 typeMovieClip
,TextField
orButton
and was successfully styled; otherwisefalse
.
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());