Packagecom.afcomponents.umap.types
Classpublic class Offset

Offset class provides an interface to save offset point either in pixels or % of width & height.

To use the Offset class you should first create it's instance where you should specify x and y offset distance either in pixels or in percent. Then you should use toPoint() method, where you should pass a Size object with the width & height values of the object you wish to offset. This method returns Point object with calculated x & y offset distance.

Here is a quick usage example:

 import com.afcomponents.umap.types.Offset;
 import com.afcomponents.umap.types.Size;
  
 var offset:Offset = new Offset(10,"50%");
 trace(offset); // traces (x=10, y=50%)
 trace(offset.toPoint(new Size(100,200))); // traces (x=10, y=100)

See also

Size
toPoint()
flash.geom.Point


Public Properties
 PropertyDefined by
  x : String
Gets or sets the horizontal offset either in pixels as a Number or in percent as a String
Offset
  y : String
Gets or sets the vertical offset either in pixels as a Number or in percent as a String
Offset
Public Methods
 MethodDefined by
  
Offset(xOffset:*, yOffset:*)
Offset constructor.
Offset
  
Creates a copy of this Offset object.
Offset
  
[static] Returns new object, which will be constructed from the source XML data.
Offset
  
getXMLFromType(offset:Offset, name:String):XML
[static] Returns XML data that describes the Object.
Offset
  
toPoint(size:Size):Point
Returns a Point object as the result of applying current Offset to the specified Size object.
Offset
  
toString():String
Returns a String that represents this object's properties.
Offset
Public Constants
 ConstantDefined by
  DEFAULT_NODE_NAME : String = "offset"
[static] Defines default root node name for XML conversion.
Offset
Property detail
xproperty
x:String  [read-write]

Gets or sets the horizontal offset either in pixels as a Number or in percent as a String

Implementation
    public function get x():String
    public function set x(value:String):void
yproperty 
y:String  [read-write]

Gets or sets the vertical offset either in pixels as a Number or in percent as a String

Implementation
    public function get y():String
    public function set y(value:String):void
Constructor detail
Offset()constructor
public function Offset(xOffset:*, yOffset:*)

Offset constructor.

Constructs an Offset object from specified x and y offset distances. You can pass either distance as a Number of pixels or a percentage offset as a String with trailing % sign.

Parameters
xOffset:* — Horizontal offset.
 
yOffset:* — Vertical offset.
Method detail
clone()method
public function clone():Offset

Creates a copy of this Offset object.

Returns
Offset — A copy of this object.
getTypeFromXML()method 
public static function getTypeFromXML(xml:XML):Offset

Returns new object, which will be constructed from the source XML data.

Parameters
xml:XML — Source XML data.

Returns
Offset — Object that was constructed from the source XML data.
getXMLFromType()method 
public static function getXMLFromType(offset:Offset, name:String):XML

Returns XML data that describes the Object. You can also specify root node name in the second parameter.

Parameters
offset:Offset — Object that should be converted to XML.
 
name:String — Root node name.

Returns
XML — XML data that describes the properties of the source object.
toPoint()method 
public function toPoint(size:Size):Point

Returns a Point object as the result of applying current Offset to the specified Size object.

The method will fail if size object has a value of null. Be sure to validate the result, before using the returned object.

Parameters
size:Size — Object that holds target width & height

Returns
Point — Offset point or null if an error occurs.

See also

Size
flash.geom.Point
toString()method 
public function toString():String

Returns a String that represents this object's properties.

The output will look like "(x=horizontal offset, y=vertical offset)"

Returns
String — A textual representation of this Offset object.
Constant detail
DEFAULT_NODE_NAMEconstant
public static const DEFAULT_NODE_NAME:String = "offset"

Defines default root node name for XML conversion.