There are two ways to access a
property of an object. One way is with dot syntax:
var
booktitle:String = eas2book.title;
and the other way is with a
string index (treating the object as what's called an associative array):
var
booktitle:String = eas2book["title"];
The former is more compact; the
latter is useful when properties are to be accessed with a variable
representation or in a loop, eg:
var
field:String = "title";
var
booktitle:String = eas2book[field];
trace(booktitle); // Essential Actionscript 2.0
I'll repeat that because it's
important to remember:
Accessing properties of an object
There are two ways to access a property in an object. One is with dot syntax:
eas2book.title;
and the other is with a string index:
eas2book["title"];
There are two ways to access a property in an object. One is with dot syntax:
eas2book.title;
and the other is with a string index:
eas2book["title"];
No comments:
Post a Comment