Does anyone know if string literals are the same as String objects in AS3? >From what I understand, in AS2, a String object was a wrapper object around a >string literal. For exemple, in AS2, these were not the same:
var myFirstString:String = "my first string"; var mySecondString:String = new String("my second string"); The first line (the string literal) was just that, a literal value with no properties or methods. The second line (the instance of the String class) was just that, an instance of a class with methods and properties. And it was recommended to use mostly literals over String objects unless you needed to call methods or set/get properties. When the Flash Player would encounter a situation where you would call a method or set/get a property on a string literal, it would create a temporary String object, call the method or set/get the property and then delete the temporary String object. So, in the folowing exemple, it would create and delete 3 temporary String objects: var myString:String = "this is a string literal"; trace(myString.length); trace(myString.charAt(0)); trace(myString.indexOf("s")); I'm not 100% sure that's right but that's what I think it used to be in AS2. Now in AS3, I'm not sure but I think this might have changed. Does anyone know if the Flash Player 9 with AS3 still interprets String objects and string literals as described above (the same way as AS2) or as it changed? Are String objects and string literals treated exactly the same now (with no temporary String objects created and destroyed by the Player when calling methods or setting/getting property values directly on string literals)? What about other literals that have wrapper functions like Number, Boolean, Object and Array? David __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com