Copy link to clipboard
Copied
Hello,
I'm wondering what's the difference between this 3 ways of getting around.
there's zero difference between casting an object as a string using:
String(something)
and
something as String.
if you can use one of the above on the same object that you're applying the toString() method to, there will be no difference among the 3.
Copy link to clipboard
Copied
there's zero difference between casting an object as a string using:
String(something)
and
something as String.
if you can use one of the above on the same object that you're applying the toString() method to, there will be no difference among the 3.
Copy link to clipboard
Copied
I see, but if instead of string there's MyClass or MovieClip...
Copy link to clipboard
Copied
if there's a difference between the two classes, MyClass and MovieClip, then there might be a difference when casting.
Copy link to clipboard
Copied
There is a great difference between String(), as String and toString() methods.
String(param) -- the more general and safe method.
param asString --
param.toString() -- call of toString() member function
Exists also ""+param and param+"" ways. They are similar to ""+String(param) and String(param)+""
Pay attention:
var ss:String = null;
trace(String(ss)==(ss as String)); // Returns false as "null" not equal to null
Find more inspiration, events, and resources on the new Adobe Community
Explore Now