Thursday, July 19, 2007

flex : cast using "as" , "is" or "instanceof"

as and TypeCast
================
var obj:* = new Event();

var testObj1:Sprite = Sprite( obj ); // throw an error
var testObj2:Sprite = ( obj as Sprite ); // return null

// below 2 lines as same.
var testObj11:Event = Event( obj ); // no error, correct!
var testObj22:Event = ( obj as Event ); // no error, correct!


is and instanceof
=================
AS3: is
AS2: instanceof

No comments: