Posted By

olwarpaint on 11/26/10


Tagged

array as3 Vector fixed-length


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tspitzr


no fixed length Arrays in as3


 / Published in: ActionScript 3
 

  1. var COUNT:int = 10;
  2.  
  3. var a:Array = new Array( COUNT ); //Vector.<Number> = Vector.<Number>( new Array( COUNT ));
  4. //a.fixed = true;
  5.  
  6. var writeTo:Object;
  7.  
  8. var i:int;
  9.  
  10. while ( i < COUNT )
  11. {
  12. writeTo = a[ i ]; //testing that we indeed have access to the index
  13. a[ i ] = Math.random();
  14. writeTo = a[ i++ ];
  15. }
  16.  
  17. while ( i >= 0 )
  18. {
  19. a.pop(); //if a is a Vector, this will throw a run-time error
  20. i--;
  21. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: haxpor on January 14, 2011

Thx olwarpaint,

If anyone need to use a fixed length array, consider using Vector class. We have an option to use either fixed or not in Vector.

You need to login to post a comment.