ActionScript 3.0 Language and Components Reference | All Packages | All Classes | Language Elements | Index | Appendixes | Conventions | Frames No Frames |
ShaderInput

Package | flash.display
Class | public final dynamic class ShaderInput
Inheritance | ShaderInput Object

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

A ShaderInput instance represents a single input image for a shader kernel. A kernel can be defined to accept zero, one, or more source images that are used in the kernel execution. A ShaderInput instance provides a mechanism for specifying the input image that is used when the shader executes. To specify a value for the input, create a BitmapData, ByteArray, or Vector.<Number> instance containing the image data and assign it to the `input` property.

The ShaderInput instance representing a Shader instance's input image is accessed as a property of the Shader instance's `data` property. The ShaderInput property has the same name as the input's name in the shader code. For example, if a shader defines an input named `src`, the ShaderInput instance representing the `src` input is available as the `src` property, as this example shows:

    myShader.data.src.image = new BitmapData(50, 50, true, 0xFF990000);

For some uses of a Shader instance, you do not need to specify an input image, because it is automatically specified by the operation. You only need to specify an input when a Shader is used for the following:

- Shader fill
- ShaderFilter, only for the second or additional inputs if the shader is defined to use more than one input. (The object to which the filter is applied is automatically used as the first input.)
- Shader blend mode, only for the third or additional inputs if the shader is defined to use more than two inputs. (The objects being blended are automatically used as the first and second inputs.)
- ShaderJob background execution

If the shader is being executed using a ShaderJob instance to process a ByteArray containing a linear array of data, set the ShaderInput instance's `height` to 1 and `width` to the number of 32-bit floating point values in the ByteArray. In that case, the input in the shader must be defined with the `image1` data type.

Generally, developer code does not create a ShaderInput instance directly. A ShaderInput instance is created for each of a shader's inputs when the Shader instance is created.

See also

flash.display.ShaderData
flash.display.Shader.data
flash.display.ShaderJob

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | channels : int [read-only] The number of channels that a shader input expects. | ShaderInput
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | height : int The height of the shader input. | ShaderInput
|  | index : int [read-only] The zero-based index of the input in the shader, indicating the order of the input definitions in the shader. | ShaderInput
|  | input : Object The input data that is used when the shader executes. | ShaderInput
|  | prototype : Object [static] A reference to the prototype object of a class or function object. | Object
|  | width : int The width of the shader input. | ShaderInput

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | ShaderInput() Creates a ShaderInput instance. | ShaderInput
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

channels | property

`channels:int` [read-only]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The number of channels that a shader input expects. This property must be accounted for when the input data is a ByteArray or Vector.<Number> instance.

Implementation
`public function get channels():int`

height | property |

`height:int` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The height of the shader input. This property is only used when the input data is a ByteArray or Vector.<Number> instance. When the input is a BitmapData instance the height is automatically determined.

Implementation
`public function get height():int`
`public function set height(value:int):void`

index | property |

`index:int` [read-only]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The zero-based index of the input in the shader, indicating the order of the input definitions in the shader.

Implementation
`public function get index():int`

input | property |

`input:Object` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The input data that is used when the shader executes. This property can be a BitmapData instance, a ByteArray instance, or a Vector.<Number> instance.

If a ByteArray value is assigned to the `input` property, the following conditions must be met:

- The `height` and `width` properties must be set.
- The byte array's contents must only consist of 32-bit floating-point values. These values can be written using the `ByteArray.writeFloat()` method.
- The total length in bytes of the ByteArray must be exactly `width` times `height` times `channels` times 4.
- The byte array's `endian` property must be `Endian.LITTLE_ENDIAN`.

If a Vector.<Number> instance is assigned to the `input` property, the length of the Vector must be equal to `width` times `height` times `channels`.

Implementation
`public function get input():Object`
`public function set input(value:Object):void`

width | property |

`width:int` [read-write]

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

The width of the shader input. This property is only used when the input data is a ByteArray or Vector.<Number> instance. When the input is a BitmapData instance the width is automatically determined.

Implementation
`public function get width():int`
`public function set width(value:int):void`
Constructor Detail

ShaderInput | () | Constructor

`public function ShaderInput()`

Language Version : | ActionScript 3.0

Player Version : | Flash Player 10

Creates a ShaderInput instance. Developer code does not call the ShaderInput constructor directly. A ShaderInput instance is created for each of a shader's inputs when the Shader instance is created.

Submit Feedback on LiveDocs
© 2004-2008 Adobe Systems Incorporated. All rights reserved.
Tue May 20 2008, 04:02 AM -07:00