MINI SUPPORTERS:

 

 

 

 


AS1 OOP: Custom Classes with MovieClips
         by senocular  

Object.registerClass
Object.registerClass (which, if you’ll notice, is a static method of the Object class) works by changing an internal association of a movieclip symbol in the library from what would normally be the MovieClip class to the class of your choice. Then, whenever an instance of that movieclip symbol is copied onto the screen (either through the timeline or with Actionscript), that instance will directly inherit not from the MovieClip class, but from the class you specified – the registered class – from a Object.registerClass call. The association is setup using a movieclip symbol’s linkage ID (export for actionscript identifier). So, for Object.registerClass to work, it will need to be used with a movieclip in your movie’s library that has a linkage ID assigned for it. The linkage ID can be assigned when you create the moiveclip symbol or through the properties options from the movieclip in the library.

[ assigning a linkage ID from the library ]

Then its just a matter of calling Object.registerClass in the following format to setup the association between a movieclip symbol and class.

Object.registerClass("linkageID", myClass);

With that command, any ‘linkageID’ movieclip symbol placed on the screen thereafter will directly inherit from, and technically be an instance of, myClass. If you ever need to break this connection, you may also do so by registering the linkageID to null.

Object.registerClass("linkageID", null);

Then new ‘linkageID’ instances will no longer be myClass instances and will inherit from MovieClip as they would normally.

 

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: