Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different methods for type casting in ActionScript 3

What is the difference between:

Car(someObject).isRacing;

and

(someObject as Car).isRacing;
like image 993
josef.van.niekerk Avatar asked Dec 30 '22 21:12

josef.van.niekerk


2 Answers

Casting using Car(someObject) will throw an error if someObject is not of type Car or does not extend Car, whereas someObject as Car will merely return null if some object is not of type Car or extends Car.

like image 82
quoo Avatar answered Jan 01 '23 11:01

quoo


Here's an earlier thread on this same topic, you'll find lots of details in there.

Link

like image 29
Tyler Egeto Avatar answered Jan 01 '23 11:01

Tyler Egeto