MINI SUPPORTERS:

 

 

 

 


AS1 OOP: Custom Object Classes
         by senocular  

The Constructor Property
Every time an instance is made, it receives not only what properties you define for it, but also, it automatically gets defined for it another hidden property called constructor. As its name implies, it represents the constructor function used to create that instance. Every instance of a class, no matter if its an instance of Fish, an array or even a movieclip, has a constructor property which references the constructor function used to make that instance (or at least the constructor function associated with the instance as movieclips aren't technically created exclusively with the MovieClip constructor). See the following example.

Folder = function(contents){
this.contents = contents;
};

 
myDocuments = new Folder("untitled.fla");
trace(myDocuments.constructor == Folder); // traces true
myPictures = new myDocuments.constructor("clipboard.bmp");
trace(myPictures.constructor == Folder); // traces true

Since myDocuments is a Folder instance, its constructor property references the Folder constructor function. With that, as you can see, it can even be used to create another instance of its same type. The myPictures object was done in such a manner.

 

Prev Page
 
SUPPORTERS:

cloud storage
cloud storage
kirupa.com's fast and reliable hosting provided by Media Temple. Creative web apps. Make your own free flash banners and photo slideshows.
HTML5 CSS3 Mobile Gallery for iPhone, iPad Flash effects. Art without coding.
Flipping Book - page flip flash component. Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery
X-Platform Application Development for Flash Free Flash Components Download - XML Templates, Players and Galleries.

two computer monitors

US Direct

Learn how to advertise on kirupa.com  
 
SHARE:



MINI SUPPORTERS: