Adobe® Flex® 4 Language Reference
Show Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
flash.display 
ShaderParameter 
Packageflash.display
Classpublic final dynamic class ShaderParameter
InheritanceShaderParameter Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

A ShaderParameter instance represents a single input parameter of a shader kernel. A kernel can be defined to accept zero, one, or more parameters that are used in the kernel execution. A ShaderParameter provides information about the parameter, such as the type of data it expects. It also provides a mechanism for setting the parameter value that is used when the shader executes. To specify a value or values for the shader parameter, create an Array containing the value or values and assign it to the value property.

A ShaderParameter instance representing a parameter for a Shader instance is accessed as a property of the Shader instance's data property. The ShaderParameter property has the same name as the parameter's name in the shader code. For example, if a shader defines a parameter named radius, the ShaderParameter instance representing the radius parameter is available as the radius property, as shown here:

var radiusParam:ShaderParameter = myShader.data.radius;

In addition to the defined properties of the ShaderParameter class, each ShaderParameter instance has additional properties corresponding to any metadata defined for the parameter. These properties are added to the ShaderParameter object when it is created. The properties' names match the metadata names specified in the shader's source code. The data type of each property varies according to the data type of the corresponding metadata. A text metadata value such as "description" is a String instance. A metadata property with a non-string value (such as minValue or defaultValue) is represented as an Array instance. The number of elements and element data types correspond to the metadata values.

For example, suppose a shader includes the following two parameter declarations:

     parameter float2 size
     <
         description: "The size of the image to which the kernel is applied";
         minValue: float2(0.0, 0.0);
         maxValue: float2(100.0, 100.0);
         defaultValue: float2(50.0, 50.0);
     >;
     
     parameter float radius
     <
         description: "The radius of the effect";
         minValue: 0.0;
         maxValue: 50.0;
         defaultValue: 25.0;
     >;
     

The ShaderParameter instance corresponding to the size parameter has the following metadata properties in addition to its built-in properties:

Property nameData typeValue
name String "size"
description String "The size of the image to which the kernel is applied"
minValue Array [0, 0]
maxValue Array [100, 100]
defaultValue Array [50, 50]

The ShaderParameter corresponding to the radius parameter has the following additional properties:

Property nameData typeValue
name String "radius"
description String "The radius of the effect"
minValue Array [0]
maxValue Array [50]
defaultValue Array [25]

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

See also



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  index : int
[read-only] The zero-based index of the parameter.
ShaderParameter
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  type : String
[read-only] The data type of the parameter as defined in the shader.
ShaderParameter
  value : Array
The value or values that are passed in as the parameter value to the shader.
ShaderParameter
Public Methods
 MethodDefined By
  
Creates a ShaderParameter instance.
ShaderParameter
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Property Detail

index

property
index:int  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The zero-based index of the parameter.



Implementation
    public function get index():int

type

property 
type:String  [read-only]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The data type of the parameter as defined in the shader. The set of possible values for the type property is defined by the constants in the ShaderParameterType class.



Implementation
    public function get type():String

See also

value

property 
value:Array

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

The value or values that are passed in as the parameter value to the shader. The value property is an indexed Array. The number and type of the elements of the Array correspond to the data type of the parameter, which can be determined using the type property.

The following table indicates the parameter type and corresponding number and data type of the value Array's elements:

Parameter type# ElementsElement data type
float (ShaderParameterType.FLOAT)1Number
float2 (ShaderParameterType.FLOAT2)2Number
float3 (ShaderParameterType.FLOAT3)3Number
float4 (ShaderParameterType.FLOAT4)4Number
int (ShaderParameterType.INT)1int or uint
int2 (ShaderParameterType.INT2)2int or uint
int3 (ShaderParameterType.INT3)3int or uint
int4 (ShaderParameterType.INT4)4int or uint
bool (ShaderParameterType.BOOL)1Boolean
bool2 (ShaderParameterType.BOOL2)2Boolean
bool3 (ShaderParameterType.BOOL3)3Boolean
bool4 (ShaderParameterType.BOOL4)4Boolean
float2x2 (ShaderParameterType.MATRIX2X2)4Number
float3x3 (ShaderParameterType.MATRIX3X3)9Number
float4x4 (ShaderParameterType.MATRIX4X4)16Number

For the matrix parameter types, the array elements fill the rows of the matrix, then the columns. For example, suppose the following line of ActionScript is used to fill a float2x2 parameter named myMatrix:

myShader.data.myMatrix.value = [.1, .2, .3, .4];

Within the shader, the matrix elements have the following values:

  • myMatrix[0][0]: .1
  • myMatrix[0][1]: .2
  • myMatrix[1][0]: .3
  • myMatrix[1][1]: .4



Implementation
    public function get value():Array
    public function set value(value:Array):void
Constructor Detail

ShaderParameter

()Constructor
public function ShaderParameter()

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 10, AIR 1.5

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