Adding Methods to Core Flash Classes

Every once in a while I get an email that looks like this:

I tried using your Object, Function, and String method additions. When I tried to compile I get a bunch of error messages! What do I do?!

Yup, this is because the method definitions are not in the Class definition files that flash looks at when compiling. The core class definitions that Flash looks at are located here:

~/Library/Application Support/Macromedia/Flash MX 2004/en/Configuration/Classes

That “Classes” folder will contain all the method definitions for all core Flash classes (MovieClip, Object, Button, Color, etc).

To make my method additions compile correctly you’ll have to edit the corresponding Class definition files and add the method definitions in. So, for instance, if you wanted to use the object.as additions you would add these method definitions to your Object.as file in the “Classes” directory referenced above:

function initBroadcaster();
function addEventListener();
function removeEventListener();
function dispatchEvent();
function centerXY(x:Number, y:Number):Void;
function centerY(y:Number):Void;
function centerX(x:Number):Void;
function isInstanceOf();
function isMemberOf();

If you are using Flash 8, they will be spread out in two different directories “FP7″ & “FP8″ located in this directory:

~/Library/Application Support/Macromedia/Flash 8/en/Configuration/Classes

If you use mtasc you’ll have to edit the class definitions located in the “std” directory.

0 Response to “Adding Methods to Core Flash Classes”


  • No Comments

Leave a Reply