Packagestarling.textures
Classpublic class SubTexture
InheritanceSubTexture Inheritance Texture Inheritance Object
Subclasses RenderTexture

A SubTexture represents a section of another texture. This is achieved solely by manipulation of texture coordinates, making the class very efficient.

Note that it is OK to create subtextures of subtextures.



Public Properties
 PropertyDefined By
  base : TextureBase
[override] [read-only] The Stage3D texture object the texture is based on.
SubTexture
  clipping : Rectangle
[read-only] The clipping rectangle, which is the region provided on initialization scaled into [0.0, 1.0].
SubTexture
  format : String
[override] [read-only] The Context3DTextureFormat of the underlying texture data.
SubTexture
  frame : Rectangle
[override] [read-only] The texture frame if it has one (see class description), otherwise null.
SubTexture
  height : Number
[override] [read-only] The height of the texture in points.
SubTexture
  mipMapping : Boolean
[override] [read-only] Indicates if the texture contains mip maps.
SubTexture
  nativeHeight : Number
[override] [read-only] The height of the texture in pixels (without scale adjustment).
SubTexture
  nativeWidth : Number
[override] [read-only] The width of the texture in pixels (without scale adjustment).
SubTexture
  ownsParent : Boolean
[read-only] Indicates if the parent texture is disposed when this object is disposed.
SubTexture
  parent : Texture
[read-only] The texture which the subtexture is based on.
SubTexture
  premultipliedAlpha : Boolean
[override] [read-only] Indicates if the alpha values are premultiplied into the RGB values.
SubTexture
  repeat : Boolean
[override] [read-only] Indicates if the texture should repeat like a wallpaper or stretch the outermost pixels.
SubTexture
  root : ConcreteTexture
[override] [read-only] The concrete texture the texture is based on.
SubTexture
  rotated : Boolean
[read-only] If true, the SubTexture will show the parent region rotated by 90 degrees (CCW).
SubTexture
  scale : Number
[override] [read-only] The scale factor, which influences width and height properties.
SubTexture
  transformationMatrix : Matrix
[read-only] The matrix that is used to transform the texture coordinates into the coordinate space of the parent texture (used internally by the "adjust..."-methods).
SubTexture
  width : Number
[override] [read-only] The width of the texture in points.
SubTexture
Public Methods
 MethodDefined By
  
SubTexture(parentTexture:Texture, region:Rectangle, ownsParent:Boolean = false, frame:Rectangle = null, rotated:Boolean = false)
Creates a new subtexture containing the specified region of a parent texture.
SubTexture
  
adjustTexCoords(texCoords:Vector.<Number>, startIndex:int = 0, stride:int = 0, count:int = -1):void
[override] Converts texture coordinates into the format required for rendering.
SubTexture
  
adjustVertexData(vertexData:VertexData, vertexID:int, count:int):void
[override] Converts texture coordinates and vertex positions of raw vertex data into the format required for rendering.
SubTexture
  
dispose():void
[override] Disposes the parent texture if this texture owns it.
SubTexture
 Inherited
empty(width:Number, height:Number, premultipliedAlpha:Boolean = true, mipMapping:Boolean = true, optimizeForRenderToTexture:Boolean = false, scale:Number = -1, format:String = bgra, repeat:Boolean = false):Texture
[static] Creates an empty texture of a certain size.
Texture
 Inherited
fromAtfData(data:ByteArray, scale:Number = 1, useMipMaps:Boolean = true, async:Function = null, repeat:Boolean = false):Texture
[static] Creates a texture from the compressed ATF format.
Texture
 Inherited
fromBitmap(bitmap:Bitmap, generateMipMaps:Boolean = true, optimizeForRenderToTexture:Boolean = false, scale:Number = 1, format:String = bgra, repeat:Boolean = false):Texture
[static] Creates a texture object from a bitmap.
Texture
 Inherited
fromBitmapData(data:BitmapData, generateMipMaps:Boolean = true, optimizeForRenderToTexture:Boolean = false, scale:Number = 1, format:String = bgra, repeat:Boolean = false):Texture
[static] Creates a texture object from bitmap data.
Texture
 Inherited
fromColor(width:Number, height:Number, color:uint = 0xffffffff, optimizeForRenderToTexture:Boolean = false, scale:Number = -1, format:String = bgra):Texture
[static] Creates a texture with a certain size and color.
Texture
 Inherited
fromData(data:Object, options:TextureOptions = null):Texture
[static] Creates a texture object from any of the supported data types, using the specified options.
Texture
 Inherited
fromEmbeddedAsset(assetClass:Class, mipMapping:Boolean = true, optimizeForRenderToTexture:Boolean = false, scale:Number = 1, format:String = bgra, repeat:Boolean = false):Texture
[static] Creates a texture object from an embedded asset class.
Texture
 Inherited
fromTexture(texture:Texture, region:Rectangle = null, frame:Rectangle = null, rotated:Boolean = false):Texture
[static] Creates a texture that contains a region (in pixels) of another texture.
Texture
Property Detail
baseproperty
base:TextureBase  [read-only] [override]

The Stage3D texture object the texture is based on.


Implementation
    public function get base():TextureBase
clippingproperty 
clipping:Rectangle  [read-only]

The clipping rectangle, which is the region provided on initialization scaled into [0.0, 1.0].


Implementation
    public function get clipping():Rectangle
formatproperty 
format:String  [read-only] [override]

The Context3DTextureFormat of the underlying texture data.


Implementation
    public function get format():String
frameproperty 
frame:Rectangle  [read-only] [override]

The texture frame if it has one (see class description), otherwise null. Only SubTextures can have a frame.

CAUTION: not a copy, but the actual object! Do not modify!


Implementation
    public function get frame():Rectangle
heightproperty 
height:Number  [read-only] [override]

The height of the texture in points.


Implementation
    public function get height():Number
mipMappingproperty 
mipMapping:Boolean  [read-only] [override]

Indicates if the texture contains mip maps.


Implementation
    public function get mipMapping():Boolean
nativeHeightproperty 
nativeHeight:Number  [read-only] [override]

The height of the texture in pixels (without scale adjustment).


Implementation
    public function get nativeHeight():Number
nativeWidthproperty 
nativeWidth:Number  [read-only] [override]

The width of the texture in pixels (without scale adjustment).


Implementation
    public function get nativeWidth():Number
ownsParentproperty 
ownsParent:Boolean  [read-only]

Indicates if the parent texture is disposed when this object is disposed.


Implementation
    public function get ownsParent():Boolean
parentproperty 
parent:Texture  [read-only]

The texture which the subtexture is based on.


Implementation
    public function get parent():Texture
premultipliedAlphaproperty 
premultipliedAlpha:Boolean  [read-only] [override]

Indicates if the alpha values are premultiplied into the RGB values.


Implementation
    public function get premultipliedAlpha():Boolean
repeatproperty 
repeat:Boolean  [read-only] [override]

Indicates if the texture should repeat like a wallpaper or stretch the outermost pixels. Note: this only works in textures with sidelengths that are powers of two and that are not loaded from a texture atlas (i.e. no subtextures).


Implementation
    public function get repeat():Boolean
rootproperty 
root:ConcreteTexture  [read-only] [override]

The concrete texture the texture is based on.


Implementation
    public function get root():ConcreteTexture
rotatedproperty 
rotated:Boolean  [read-only]

If true, the SubTexture will show the parent region rotated by 90 degrees (CCW).


Implementation
    public function get rotated():Boolean
scaleproperty 
scale:Number  [read-only] [override]

The scale factor, which influences width and height properties.


Implementation
    public function get scale():Number
transformationMatrixproperty 
transformationMatrix:Matrix  [read-only]

The matrix that is used to transform the texture coordinates into the coordinate space of the parent texture (used internally by the "adjust..."-methods).

CAUTION: not a copy, but the actual object! Do not modify!


Implementation
    public function get transformationMatrix():Matrix
widthproperty 
width:Number  [read-only] [override]

The width of the texture in points.


Implementation
    public function get width():Number
Constructor Detail
SubTexture()Constructor
public function SubTexture(parentTexture:Texture, region:Rectangle, ownsParent:Boolean = false, frame:Rectangle = null, rotated:Boolean = false)

Creates a new subtexture containing the specified region of a parent texture.

Parameters
parentTexture:Texture — The texture you want to create a SubTexture from.
 
region:Rectangle — The region of the parent texture that the SubTexture will show (in points).
 
ownsParent:Boolean (default = false) — if true, the parent texture will be disposed automatically when the subtexture is disposed.
 
frame:Rectangle (default = null) — If the texture was trimmed, the frame rectangle can be used to restore the trimmed area.
 
rotated:Boolean (default = false) — If true, the SubTexture will show the parent region rotated by 90 degrees (CCW).
Method Detail
adjustTexCoords()method
override public function adjustTexCoords(texCoords:Vector.<Number>, startIndex:int = 0, stride:int = 0, count:int = -1):void

Converts texture coordinates into the format required for rendering. While the texture coordinates of an image always use the range [0, 1], the actual coordinates could be different: you might be working with a SubTexture. This method adjusts the coordinates accordingly.

Parameters

texCoords:Vector.<Number> — a vector containing UV coordinates (optionally, among other data). U and V coordinates always have to come in pairs. The vector is modified in place.
 
startIndex:int (default = 0) — the index of the first U coordinate in the vector.
 
stride:int (default = 0) — the distance (in vector elements) of consecutive UV pairs.
 
count:int (default = -1) — the number of UV pairs that should be adjusted, or "-1" for all of them.

adjustVertexData()method 
override public function adjustVertexData(vertexData:VertexData, vertexID:int, count:int):void

Converts texture coordinates and vertex positions of raw vertex data into the format required for rendering. While the texture coordinates of an image always use the range [0, 1], the actual coordinates could be different: you might be working with a SubTexture or a texture frame. This method adjusts the texture and vertex coordinates accordingly.

Parameters

vertexData:VertexData
 
vertexID:int
 
count:int

dispose()method 
override public function dispose():void

Disposes the parent texture if this texture owns it.