Hi,
The TypedArray class extends Array class. Ok
But when we make a new instance of TypedArray class, we
cant' pass variable directly in constructor.
Look this small exemple :
var ba:Array = new Array(10,20,30);
trace(ba) //return 10,20,30
var ta:TypedArray = new TypedArray(Number, 10,20,30);
trace(ta); //return noting, array is empty.
I think giving possibility to construct a TypedArray
like another basic Array can be very very useful ;)
So I test a small implementation for the new TypedArray
constructor :
----------------------------------------
public function TypedArray(type:Function) {
this.type = type;
var args:Array = arguments.slice(1);
var l:Number = args.length;
for(var i:Number = 0; i < l; i++) validate(args[i]);
splice.apply(this, [0, 0].concat(args));
}
----------------------------------------
I made some tests or everything seems to work well ;)
Morever we validate all objects passed in arguments
chain, so the "strong typing" array is preserved.
Please check the RFE 1114626, concerning the
"getType()" method in TypedClass...
Thanks a lot.
eRom
Logged In: YES
user_id=922171
I added support for this feature. The usage is: new
TypedArray(Number, 10, 20, 30). Type safety is also preserved!
Logged In: YES
user_id=1196309
Thanks a lot ;)
Bye.
eRom