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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.