explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

No Fixed Length as3 Array

2 Comments

[note to self]

Recently been doing some performance-intensive development for the as3isolib.v2.core engine and was experimenting with what I thought were fixed-length arrays. Apparently they don’t exist in as3. I discovered this as I had inadvertently called pop() on a fixed-length array. You’d expect this would throw a run-time error but since it doesn’t and thus I had a hard time determining the origin of other run-time errors.

To prove this you can simply run the following test: pastebin link (sorry the code formatting for multi line code isn’t working at the moment).

In order to ensure an collection is indeed a fixed-length and throws run-time errors if you attempt to modify the length, you need to use a Vector and set the fixed property to true;

var v:Vector.<T> = Vector.<T>( new Array( FIXED ));
v.fixed = true;

On another note: I did conclude that during my performance-intensive code, that using fixed-length collections made nominal improvements.  This is further reduced when NOT using simple object types of String, Number, int, or uint in a Vector.  In my case I was storing complex data structures in a FILO queue.

Advertisements

2 thoughts on “No Fixed Length as3 Array

  1. Как ни хорони концов, а бог найдет.

  2. Распинаться за что, за кого (божиться, ручаться).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s