Skip to content

Adding Methods to Core Flash Classes

Categories: Flash

Table of Contents

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:
[code]~/Library/Application Support/Macromedia/Flash MX 2004/en/Configuration/Classes[/code]
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:
[code lang=”actionscript”]
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();
[/code]

If you are using Flash 8, they will be spread out in two different directories “FP7” & “FP8” located in this directory:
[code]~/Library/Application Support/Macromedia/Flash 8/en/Configuration/Classes[/code]

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

Keep in Touch

Subscribe to my email list to keep in touch. I’ll send you new blog posts and other thoughts.