Packagecom.emibap.textureAtlas
Classpublic class DynamicAtlas
InheritanceDynamicAtlas Inheritance Object

DynamicAtlas.as https://github.com/emibap/Dynamic-Texture-Atlas-Generator



Protected Properties
 PropertyDefined By
  _bData : BitmapData
[static]
DynamicAtlas
  _canvas : Sprite
[static]
DynamicAtlas
  _currentLab : String
[static]
DynamicAtlas
  _items : Array
[static]
DynamicAtlas
  _margin : Number
[static]
DynamicAtlas
  _mat : Matrix
[static]
DynamicAtlas
  _preserveColor : Boolean
[static]
DynamicAtlas
  _x : Number
[static]
DynamicAtlas
  _y : Number
[static]
DynamicAtlas
Public Methods
 MethodDefined By
  
DynamicAtlas
  
bitmapFontFromString(chars:String, fontFamily:String, fontSize:Number = 12, bold:Boolean = false, italic:Boolean = false, charMarginX:int = 0, fontCustomID:String):void
[static] This method will register a Bitmap Font based on each char that belongs to a String.
DynamicAtlas
  
bitmapFontFromTextField(tf:TextField, charMarginX:int = 0, fontCustomID:String):void
[static] This method will register a Bitmap Font based on each char that belongs to a regular flash TextField, rasterizing filters and color transforms as well.
DynamicAtlas
  
fromClassVector(assets:Vector.<Class>, scaleFactor:Number = 1, margin:uint = 0, preserveColor:Boolean = true, checkBounds:Boolean = false):TextureAtlas
[static] This method takes a vector of MovieClip class and converts it into a Texture Atlas.
DynamicAtlas
  
fromMovieClipContainer(swf:MovieClip, scaleFactor:Number = 1, margin:uint = 0, preserveColor:Boolean = true, checkBounds:Boolean = false):TextureAtlas
[static] This method will take a MovieClip sprite sheet (containing other display objects) and convert it into a Texture Atlas.
DynamicAtlas
  
getTexturesByClass(textureAtlas:TextureAtlas, assetClass:Class):Vector.<Texture>
[static] Retrieves all textures for a class.
DynamicAtlas
Protected Methods
 MethodDefined By
  
appendIntToString(num:int, numOfPlaces:int):String
[static]
DynamicAtlas
  
drawItem(clip:DisplayObject, name:String, baseName:String, clipColorTransform:ColorTransform = null, frameBounds:Rectangle = null):TextureItem
[static] drawItem - This will actually rasterize the display object passed as a parameter
DynamicAtlas
  
getRealBounds(clip:DisplayObject):Rectangle
[static]
DynamicAtlas
  
isEmbedded(fontFamily:String):Boolean
[static] isEmbedded
DynamicAtlas
  
[static]
DynamicAtlas
Protected Constants
 ConstantDefined By
  DEFAULT_CANVAS_WIDTH : Number = 640
[static]
DynamicAtlas
Property Detail
_bDataproperty
protected static var _bData:BitmapData

_canvasproperty 
protected static var _canvas:Sprite

_currentLabproperty 
protected static var _currentLab:String

_itemsproperty 
protected static var _items:Array

_marginproperty 
protected static var _margin:Number

_matproperty 
protected static var _mat:Matrix

_preserveColorproperty 
protected static var _preserveColor:Boolean

_xproperty 
protected static var _x:Number

_yproperty 
protected static var _y:Number

Constructor Detail
DynamicAtlas()Constructor
public function DynamicAtlas()



Method Detail
appendIntToString()method
protected static function appendIntToString(num:int, numOfPlaces:int):String

Parameters

num:int
 
numOfPlaces:int

Returns
String
bitmapFontFromString()method 
public static function bitmapFontFromString(chars:String, fontFamily:String, fontSize:Number = 12, bold:Boolean = false, italic:Boolean = false, charMarginX:int = 0, fontCustomID:String):void

This method will register a Bitmap Font based on each char that belongs to a String.

Parameters

chars:String — - The collection of chars which will become the Bitmap Font
 
fontFamily:String — - The name of the Font that will be converted to a Bitmap Font
 
fontSize:Number (default = 12) — - The size in pixels of the font.
 
bold:Boolean (default = false) — - A flag indicating if the font will be rasterized as bold.
 
italic:Boolean (default = false) — - A flag indicating if the font will be rasterized as italic.
 
charMarginX:int (default = 0) — - The number of pixels that each character should have as horizontal margin (negative values are allowed). Default value is 0.
 
fontCustomID:String — - A custom font family name indicated by the user. Helpful when using differnt effects for the same font. [Optional]

bitmapFontFromTextField()method 
public static function bitmapFontFromTextField(tf:TextField, charMarginX:int = 0, fontCustomID:String):void

This method will register a Bitmap Font based on each char that belongs to a regular flash TextField, rasterizing filters and color transforms as well.

Parameters

tf:TextField — - The textfield that will be used to rasterize every char of the text property
 
charMarginX:int (default = 0) — - The number of pixels that each character should have as horizontal margin (negative values are allowed). Default value is 0.
 
fontCustomID:String — - A custom font family name indicated by the user. Helpful when using differnt effects for the same font. [Optional]

drawItem()method 
protected static function drawItem(clip:DisplayObject, name:String, baseName:String, clipColorTransform:ColorTransform = null, frameBounds:Rectangle = null):TextureItem

drawItem - This will actually rasterize the display object passed as a parameter

Parameters

clip:DisplayObject
 
name:String
 
baseName:String
 
clipColorTransform:ColorTransform (default = null)
 
frameBounds:Rectangle (default = null)

Returns
TextureItem — TextureItem
fromClassVector()method 
public static function fromClassVector(assets:Vector.<Class>, scaleFactor:Number = 1, margin:uint = 0, preserveColor:Boolean = true, checkBounds:Boolean = false):TextureAtlas

This method takes a vector of MovieClip class and converts it into a Texture Atlas.

Parameters

assets:Vector.<Class> — - The MovieClip classes you wish to convert into a TextureAtlas. Must contain classes whose instances are of type MovieClip that will be rasterized and become the subtextures of your Atlas.
 
scaleFactor:Number (default = 1) — - The scaling factor to apply to every object. Default value is 1 (no scaling).
 
margin:uint (default = 0) — - The amount of pixels that should be used as the resulting image margin (for each side of the image). Default value is 0 (no margin).
 
preserveColor:Boolean (default = true) — - A Flag which indicates if the color transforms should be captured or not. Default value is true (capture color transform).
 
checkBounds:Boolean (default = false) — - A Flag used to scan the clip prior the rasterization in order to get the bounds of the entire MovieClip. By default is false because it adds overhead to the process.

Returns
TextureAtlas — TextureAtlas - The dynamically generated Texture Atlas.
fromMovieClipContainer()method 
public static function fromMovieClipContainer(swf:MovieClip, scaleFactor:Number = 1, margin:uint = 0, preserveColor:Boolean = true, checkBounds:Boolean = false):TextureAtlas

This method will take a MovieClip sprite sheet (containing other display objects) and convert it into a Texture Atlas.

Parameters

swf:MovieClip — - The MovieClip sprite sheet you wish to convert into a TextureAtlas. I must contain named instances of every display object that will be rasterized and become the subtextures of your Atlas.
 
scaleFactor:Number (default = 1) — - The scaling factor to apply to every object. Default value is 1 (no scaling).
 
margin:uint (default = 0) — - The amount of pixels that should be used as the resulting image margin (for each side of the image). Default value is 0 (no margin).
 
preserveColor:Boolean (default = true) — - A Flag which indicates if the color transforms should be captured or not. Default value is true (capture color transform).
 
checkBounds:Boolean (default = false) — - A Flag used to scan the clip prior the rasterization in order to get the bounds of the entire MovieClip. By default is false because it adds overhead to the process.

Returns
TextureAtlas — TextureAtlas - The dynamically generated Texture Atlas.
getRealBounds()method 
protected static function getRealBounds(clip:DisplayObject):Rectangle

Parameters

clip:DisplayObject

Returns
Rectangle
getTexturesByClass()method 
public static function getTexturesByClass(textureAtlas:TextureAtlas, assetClass:Class):Vector.<Texture>

Retrieves all textures for a class. Returns null if it is not found. This method can be used if TextureAtlass doesn't support classes.

Parameters

textureAtlas:TextureAtlas
 
assetClass:Class

Returns
Vector.<Texture>
isEmbedded()method 
protected static function isEmbedded(fontFamily:String):Boolean

isEmbedded

Parameters

fontFamily:String — - The name of the Font

Returns
Boolean — Boolean - True if the font is an embedded one
layoutChildren()method 
protected static function layoutChildren():void

Constant Detail
DEFAULT_CANVAS_WIDTHConstant
protected static const DEFAULT_CANVAS_WIDTH:Number = 640