# Actionscript 2.0 - two nagging n00b questions

**URL:** <https://forum.kirupa.com/t/actionscript-2-0-two-nagging-n00b-questions/195422>\
**Category:** flash\
**Created:** [July 31, 2006, 5:47pm UTC](https://forum.kirupa.com/t/actionscript-2-0-two-nagging-n00b-questions/195422 "2006-07-31T17:47:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lardlad](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lardlad](https://forum.kirupa.com/u/lardlad)\
**Post date:** [July 31, 2006, 5:47pm UTC](https://forum.kirupa.com/t/actionscript-2-0-two-nagging-n00b-questions/195422/1 "2006-07-31T17:47:01Z")

</div>

I’m not sure if my questions are nagging or if I’m a nagging n00b, but here goes:

I’m running flash 8 pro on a mac.

1. When I use a for … in loop to step through an array or properties of an object, it ends up being last in - first out. Here’s what I mean:  
[FONT=Fixedsys]var testArray:Array = [“one”, “two”, “three”];  
[/FONT][FONT=Fixedsys] // prints out three, then two, then one  
[/FONT][FONT=Fixedsys] for (var i:String in testArray) {  
trace(testArray\*);  
}  
[/FONT][FONT=Fixedsys] // prints out one, then two, then three[/FONT]  
[FONT=Fixedsys]for (var j:Number = 0; j\<testArray.length; j++) {  
trace(testArray[j]);  
}  
[/FONT]  
What’s that all about, and is there an elegant way to make the for … in loop work first  
in - first out?

2. I’m trying to understand literals versus new objects. To wit:  
[FONT=Fixedsys]var literalString:String = “fred”;  
var objectString:String = new String(“barney”);[/FONT]

The handy manual sez “Use string literals unless you specifically need to use a String object for better performance”.

Can someone give me an example of a place to use String objects for better performance and explain a little bit about how they improve performance?

Thanks…
