Packagestarling.textures
Classpublic class ConcreteTexture
InheritanceConcreteTexture Inheritance Texture Inheritance Object

A ConcreteTexture wraps a Stage3D texture object, storing the properties of the texture and providing utility methods for data upload, etc.

This class cannot be instantiated directly; create instances using Texture.fromTextureBase instead. However, that's only necessary when you need to wrap a TextureBase object in a Starling texture; the preferred way of creating textures is to use one of the other Texture.from... factory methods in the Texture class.

See also

Texture


Public Properties
 PropertyDefined By
 InheritedasyncBitmapUploadEnabled : Boolean
[static] Indicates if it should be attempted to upload bitmaps asynchronously when the async parameter is supplied to supported methods.
Texture
  base : TextureBase
[override] [read-only] The Stage3D texture object the texture is based on.
ConcreteTexture
  format : String
[override] [read-only] The Context3DTextureFormat of the underlying texture data.
ConcreteTexture
 Inheritedframe : Rectangle
[read-only] The texture frame if it has one (see class description), otherwise null.
Texture
 InheritedframeHeight : Number
[read-only] The width of the texture in points, taking into account the frame rectangle (if there is one).
Texture
 InheritedframeWidth : Number
[read-only] The height of the texture in points, taking into account the frame rectangle (if there is one).
Texture
  height : Number
[override] [read-only] The height of the texture in points.
ConcreteTexture
  isPotTexture : Boolean
[read-only] Indicates if the base texture is a standard power-of-two dimensioned texture of type flash.display3D.textures.Texture.
ConcreteTexture
 InheritedmaxSize : int
[static] [read-only] Returns the maximum size constraint (for both width and height) for uncompressed textures in the current Context3D profile.
Texture
  mipMapping : Boolean
[override] [read-only] Indicates if the texture contains mip maps.
ConcreteTexture
  nativeHeight : Number
[override] [read-only] The height of the texture in pixels (without scale adjustment).
ConcreteTexture
  nativeWidth : Number
[override] [read-only] The width of the texture in pixels (without scale adjustment).
ConcreteTexture
  onRestore : Function
The function that you provide here will be called after a context loss.
ConcreteTexture
  optimizedForRenderTexture : Boolean
[read-only] Indicates if the base texture was optimized for being used in a render texture.
ConcreteTexture
  premultipliedAlpha : Boolean
[override] [read-only] Indicates if the alpha values are premultiplied into the RGB values.
ConcreteTexture
  root : ConcreteTexture
[override] [read-only] The concrete texture the texture is based on.
ConcreteTexture
  scale : Number
[override] [read-only] The scale factor, which influences width and height properties.
ConcreteTexture
 InheritedtransformationMatrix : Matrix
[read-only] The matrix that is used to transform the texture coordinates into the coordinate space of the parent texture, if there is one.
Texture
 InheritedtransformationMatrixToRoot : Matrix
[read-only] The matrix that is used to transform the texture coordinates into the coordinate space of the root texture, if this instance is not the root.
Texture
  width : Number
[override] [read-only] The width of the texture in points.
ConcreteTexture
Public Methods
 MethodDefined By
  
attachCamera(camera:Camera, onComplete:Function = null):void
Specifies a video stream from a camera to be rendered within the texture.
ConcreteTexture
  
attachNetStream(netStream:NetStream, onComplete:Function = null):void
Specifies a video stream to be rendered within the texture.
ConcreteTexture
  
clear(color:uint = 0x0, alpha:Number = 0.0):void
Clears the texture with a certain color and alpha value.
ConcreteTexture
  
dispose():void
[override] Disposes the TextureBase object.
ConcreteTexture
 Inherited
empty(width:Number, height:Number, premultipliedAlpha:Boolean = true, mipMapping:Boolean = false, optimizeForRenderToTexture:Boolean = false, scale:Number = -1, format:String = bgra, forcePotTexture: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, premultipliedAlpha:Boolean = false):Texture
[static] Creates a texture from ATF data (Adobe Texture Compression).
Texture
 Inherited
fromBitmap(bitmap:Bitmap, generateMipMaps:Boolean = false, optimizeForRenderToTexture:Boolean = false, scale:Number = 1, format:String = bgra, forcePotTexture:Boolean = false, async:Function = null):Texture
[static] Creates a texture object from a bitmap.
Texture
 Inherited
fromBitmapData(data:BitmapData, generateMipMaps:Boolean = false, optimizeForRenderToTexture:Boolean = false, scale:Number = 1, format:String = bgra, forcePotTexture:Boolean = false, async:Function = null):Texture
[static] Creates a texture object from bitmap data.
Texture
 Inherited
fromCamera(camera:Camera, scale:Number = 1, onComplete:Function = null):Texture
[static] Creates a video texture from a camera.
Texture
 Inherited
fromColor(width:Number, height:Number, color:uint = 0xffffff, alpha:Number = 1.0, optimizeForRenderToTexture:Boolean = false, scale:Number = -1, format:String = bgra, forcePotTexture:Boolean = false):Texture
[static] Creates a texture with a certain size and color.
Texture
 Inherited
fromData(data:Object, options:TextureOptions = null):Texture
[static] Creates a texture from any of the supported data types, using the specified options.
Texture
 Inherited
fromEmbeddedAsset(assetClass:Class, mipMapping:Boolean = false, optimizeForRenderToTexture:Boolean = false, scale:Number = 1, format:String = bgra, forcePotTexture:Boolean = false):Texture
[static] Creates a texture object from an embedded asset class.
Texture
 Inherited
fromNetStream(stream:NetStream, scale:Number = 1, onComplete:Function = null):Texture
[static] Creates a video texture from a NetStream.
Texture
 Inherited
fromTexture(texture:Texture, region:Rectangle = null, frame:Rectangle = null, rotated:Boolean = false, scaleModifier:Number = 1.0):Texture
[static] Creates a texture that contains a region (in pixels) of another texture.
Texture
 Inherited
fromTextureBase(base:TextureBase, width:int, height:int, options:TextureOptions = null):ConcreteTexture
[static] Creates a texture from a TextureBase object.
Texture
 Inherited
getMaxSize(textureFormat:String = bgra):int
[static] Returns the maximum size constraint (for both width and height) for normal and RectangleTextures with the given format in the current Context3D profile.
Texture
 Inherited
getTexCoords(vertexData:VertexData, vertexID:int, attrName:String = texCoords, out:Point = null):Point
Reads a pair of texture coordinates from the given VertexData instance and transforms them into the current texture's coordinate system.
Texture
 Inherited
globalToLocal(u:Number, v:Number, out:Point = null):Point
Transforms the given texture coordinates from the root texture's coordinate system to the local coordinate system.
Texture
 Inherited
localToGlobal(u:Number, v:Number, out:Point = null):Point
Transforms the given texture coordinates from the local coordinate system into the root texture's coordinate system.
Texture
 Inherited
setTexCoords(vertexData:VertexData, vertexID:int, attrName:String, u:Number, v:Number):void
Writes the given texture coordinates to a VertexData instance after transforming them into the root texture's coordinate system.
Texture
 Inherited
setupTextureCoordinates(vertexData:VertexData, vertexID:int = 0, attrName:String = texCoords):void
Sets up a VertexData instance with the correct texture coordinates for 4 vertices so that the texture is mapped to the complete quad.
Texture
 Inherited
setupVertexPositions(vertexData:VertexData, vertexID:int = 0, attrName:String = position, bounds:Rectangle = null):void
Sets up a VertexData instance with the correct positions for 4 vertices so that the texture can be mapped onto it unscaled.
Texture
  
uploadAtfData(data:ByteArray, offset:int = 0, async:* = null):void
Uploads ATF data from a ByteArray to the texture.
ConcreteTexture
  
uploadBitmap(bitmap:Bitmap, async:* = null):void
Uploads a bitmap to the texture.
ConcreteTexture
  
uploadBitmapData(data:BitmapData, async:* = null):void
Uploads bitmap data to the texture.
ConcreteTexture
Protected Methods
 MethodDefined By
  
createBase():TextureBase
Recreates the underlying Stage3D texture object with the same dimensions and attributes as the one that was passed to the constructor.
ConcreteTexture
  
Notifies the instance that the base texture may now be used for rendering.
ConcreteTexture
Property Detail
baseproperty
base:TextureBase  [read-only] [override]

The Stage3D texture object the texture is based on.


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

The Context3DTextureFormat of the underlying texture data.


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

The height of the texture in points.


Implementation
    public function get height():Number
isPotTextureproperty 
isPotTexture:Boolean  [read-only]

Indicates if the base texture is a standard power-of-two dimensioned texture of type flash.display3D.textures.Texture.


Implementation
    public function get isPotTexture():Boolean
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
onRestoreproperty 
onRestore:Function

The function that you provide here will be called after a context loss. On execution, a new base texture will already have been created; however, it will be empty. Call one of the "upload..." methods from within the callback to restore the actual texture data.

          var texture:Texture = Texture.fromBitmap(new EmbeddedBitmap());
          texture.root.onRestore = function():void
          {
              texture.root.uploadFromBitmap(new EmbeddedBitmap());
          };


Implementation
    public function get onRestore():Function
    public function set onRestore(value:Function):void
optimizedForRenderTextureproperty 
optimizedForRenderTexture:Boolean  [read-only]

Indicates if the base texture was optimized for being used in a render texture.


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

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


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

The concrete texture the texture is based on.


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

The scale factor, which influences width and height properties.


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

The width of the texture in points.


Implementation
    public function get width():Number
Method Detail
attachCamera()method
public function attachCamera(camera:Camera, onComplete:Function = null):void

Specifies a video stream from a camera to be rendered within the texture.

Parameters

camera:Camera
 
onComplete:Function (default = null)

attachNetStream()method 
public function attachNetStream(netStream:NetStream, onComplete:Function = null):void

Specifies a video stream to be rendered within the texture.

Parameters

netStream:NetStream
 
onComplete:Function (default = null)

clear()method 
public function clear(color:uint = 0x0, alpha:Number = 0.0):void

Clears the texture with a certain color and alpha value. The previous contents of the texture is wiped out.

Parameters

color:uint (default = 0x0)
 
alpha:Number (default = 0.0)

createBase()method 
protected function createBase():TextureBase

Recreates the underlying Stage3D texture object with the same dimensions and attributes as the one that was passed to the constructor. You have to upload new data before the texture becomes usable again. Beware: this method does not dispose the current base.

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

Disposes the TextureBase object.

recreateBase()method 
starling_internal function recreateBase():void

Recreates the underlying Stage3D texture. May be used to manually restore a texture. Beware that new data needs to be uploaded to the texture before it can be used.

setDataUploaded()method 
protected function setDataUploaded():void

Notifies the instance that the base texture may now be used for rendering.

uploadAtfData()method 
public function uploadAtfData(data:ByteArray, offset:int = 0, async:* = null):void

Uploads ATF data from a ByteArray to the texture. Note that the size of the ATF-encoded data must be exactly the same as the original texture size.

The 'async' parameter may be either a boolean value or a callback function. If it's false or null, the texture will be decoded synchronously and will be visible right away. If it's true or a function, the data will be decoded asynchronously. The texture will remain unchanged until the upload is complete, at which time the callback function will be executed. This is the expected function definition: function(texture:Texture):void;

Parameters

data:ByteArray
 
offset:int (default = 0)
 
async:* (default = null)

uploadBitmap()method 
public function uploadBitmap(bitmap:Bitmap, async:* = null):void

Uploads a bitmap to the texture. The existing contents will be replaced. If the size of the bitmap does not match the size of the texture, the bitmap will be cropped or filled up with transparent pixels.

Pass a callback function or true to attempt asynchronous texture upload. If the current platform or runtime version does not support asynchronous texture loading, the callback will still be executed.

This is the expected function definition: function(texture:Texture, error:ErrorEvent):void; The second parameter is optional and typically null.

Parameters

bitmap:Bitmap
 
async:* (default = null)

uploadBitmapData()method 
public function uploadBitmapData(data:BitmapData, async:* = null):void

Uploads bitmap data to the texture. The existing contents will be replaced. If the size of the bitmap does not match the size of the texture, the bitmap will be cropped or filled up with transparent pixels.

Pass a callback function or true to attempt asynchronous texture upload. If the current platform or runtime version does not support asynchronous texture loading, the callback will still be executed.

This is the expected function definition: function(texture:Texture, error:ErrorEvent):void; The second parameter is optional and typically null.

Parameters

data:BitmapData
 
async:* (default = null)