Nov
9
9
Typed Arrays
© 2010 pajamacode | Theme by DemusDesign, Theme Lab, and Search Optimization | Powered by WordPress
Nothing special here but if you want to have a look at one way of making an Array a specific type have a look at my take on it if you like.
package com.pj_co.types
{
import flash.utils.Proxy
/**
* TODO check if an interface passed to
* the constructor will cause a type error
* @author Patrick Cousins
*/
dynamic public class TypedArray extends Proxy
{
private var type : Class;
private var array : Array;
public function TypedArray ( type : Class )
{
this.type = type;
array = new Array();
}
override flash_proxy function getProperty ( name :*) :*
{
return array [ name ] as type;
}
override flash_proxy function setProperty ( name :*, value :*) : void
{
if ( value is type )
{
array [ name ] = value;
}
else
{
throw new TypeError ( "TypeError: the property named: "
+ name + ", with value: "
+ value + ", is not of type: "
+ type ) ;
}
}
}
}
filed under: Scripts | permalink
Leave a Reply
You must be logged in to post a comment.
