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  

MovieClip Constructors
When a movieclip symbol is setup to be created as an alternative class instance with Object.registerClass, even though a movieclip instance isn’t created with a call to the constructor function of that class, the constructor function still gets run for that movieclip instance when its made. So don’t pass off your class constructor as useless for classes used to extend movieclip instances. They still get run like any other objects enabling you to define properties etc. as you please. Consider the following example:

EnhancedClip = function(){
this.abilities = "enhanced";
};
EnhancedClip.prototype = new MovieClip();
Object.registerClass("libraryItemA", EnhancedClip);

 
this.attachMovie("libraryItemA", "myEnhanced_mc", 1);
trace(myEnhanced_mc.constructor == EnhancedClip); // traces true
trace(myEnhanced_mc.abilities); // traces "enhanced"

(Note that super wasn’t used, and isn’t needed, to add default movieclip properties to the movieclip instance created. Setting up the inheritance with class.prototype = new MovieClip() is all you need to take care of that).

 

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 Templates
CSS Templates
Dreamweaver Templates

flash menus, buttons and components
Digicrafts Components The best flash components ever!
Entheos Flash Website Templates Free Flash Page Flip
flash components Buy and sell FLAs at Ultrashock!
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
Learn how to advertise on kirupa.com