Object Declaration

Different Way of Declaring and storing Objects

First Method

var obj:Object=new Object()
obj={fname:”Steve”, lname:”chan”}
trace(obj.fname) //Returns Steve

Second Method

var obj:Object={fname:”Steve”, lname:”chan”}
trace(obj.fname) //Returns Steve

Third Method

var obj:Object=new Object()
obj.fname=”Steve”
obj.lname=”chan”
trace(obj.fname) //Returns Steve

Fourth Method

var obj:Object=new Object()
obj[“fname”]=”Steve”
obj[“lname”]=”chan”
trace(obj[“fname”]) //Returns Steve
trace(obj.fname) //Returns Steve