Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

 

 


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
 

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components
flash menus, buttons and components Digicrafts Components
The best flash components ever! Entheos Flash Website Templates
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
flash components Free Website | Make a Website
Learn how to advertise on kirupa.com