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).

Anyone knows if that is the case?

----- Original Message ----
From: T. Michael Keesey <[EMAIL PROTECTED]>
To: flashcoders@chattyfig.figleaf.com
Sent: Monday, April 30, 2007 11:45:13 AM
Subject: Re: [Flashcoders] Are string literals and String objects the same in 
AS3?

On 4/30/07, David Bellerive <[EMAIL PROTECTED]> wrote:
>
> 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.

Not true. As a counterexample, try this:

trace("Hello".length);
// Traces "5".

-- 
Mike Keesey
_______________________________________________
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

Reply via email to