Wednesday 28 November 2012

Objects in action script 3.0



Instances of the Object class can be assigned their own properties within the instance. This is the class from which most of Flash's built-in classes are derived (subclassed from) and so is a very useful one to become familiar with. A new variable (instance) of the Object class is created like this:
var eas2book:Object = new Object();
or, the abbreviated way, with curly brackets:
var eas2book:Object = {};
or, to declare and assign a value at once:
var eas2book:Object = {
   title:"Essential Actionscript 2.0",
   author:"Colin Moock",
   pubyr:2004
};
In that example, a new instance of the Object class named eas2book is created, with 3 properties: title, author, and pubyr. (Each property, as noted previously, has its own data type, though those are not explicitly declared when the object is created).

No comments:

Post a Comment