no fixed length Arrays in as3


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  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

You need to login to post a comment.