Thanks Fumio! That's the answer I was looking for.
So my next question would be : When would you ever need to use the String class' constructor instead of just a string literal? AS2.0 var myString:String = "this is a string"; trace(myString instanceof String); // outputs FALSE AS3.0 var myString:String = "this is a string"; trace(myString instanceof String); // outputs TRUE ----- Original Message ---- From: Fumio Nonaka <[EMAIL PROTECTED]> To: flashcoders@chattyfig.figleaf.com Sent: Monday, April 30, 2007 6:40:34 PM Subject: Re: [Flashcoders] Are string literals and String objects the same in AS3? Programming ActionScript 3.0 > ActionScript language and syntax > Data types: http://livedocs.adobe.com/flash/9.0/main/00000044.html "In ActionScript 3.0, primitive values and their wrapper objects are, for practical purposes, indistinguishable. All values, even primitive values, are objects. Flash Player treats these primitive types as special cases that behave like objects but that don't require the normal overhead associated with creating objects." ECMAScript 4 > Types http://www.mozilla.org/js/language/es4/libraries/types.html "Unlike in ECMAScript 3, there is no distinction between objects and primitive values. All values can have methods." _____ David Bellerive wrote: > In AS2, your example would of course work but only because the Flash Player > would create a temporary String object with your string literal, then get the > object's length property and return the value, and then delete the temporary > String object it created. So yes, all method calls and get/set on property > values would work just fine on literals in AS2, but only because Flash Player > used to create temporary objects and delete them as soon as the operation > ended. > Thus, when you needed to call multiple methods on a string for exemple, it > was more efficient to explicitely create a new instance of the String object > and call those methods on the object rather that just calling those methods > on a string literal. > But it seems that this is no longer true in AS3, that String objects and > string literals are now treated the same by Flash Player 9 using AS3 (there > are no more implicit temporary String objects created by the Flash Player). -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My books<http://www.FumioNonaka.com/Books/index.html> Flash community<http://F-site.org/> _______________________________________________ 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 __________________________________________________ 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