Dynamically Add Script to Frames of a MovieClip with AS3

It is always fun when you come across an undocumented feature, especially when it sounds to be extremely useful. One “known” undocumented feature within ActionScript 3.0 is the ability to add ActionScript to frames of a MovieClip via runtime.

There could be many uses for this feature. One popular use could be adding a stop() action to MovieClips. Since many Flash Developers love keeping the timeline as clean as all can be, this feature, when treated wisely, is like gold.

Implementing this feature

Implementing this feature is pretty self-explanatory. As long as you have a MovieClip created at runtime, dynamically or timeline, simply add the the following code within an external .as file of its own. This method allows for an unlimited amount of framenumber, function parameter groupings.

movieclip.addFrameScript(framenumber, function, framenumber, function...etc);


Some might find this “undocumented feature” useful, some might not. Whatever the case may be, keep in mind that this feature may or may not be supported in future versions of the Flash Player. Since the feature is considered “undocumented” be careful on using it in commercial projects – for the sake of future compatibility.

Have fun experimenting!

I am curious would any of you find this feature useful in future use?

3 thoughts on “Dynamically Add Script to Frames of a MovieClip with AS3

  1. I’ve noticed that when you add actions in frames, and check that swf in decompiler (SWF Sothink and ASV6) there is normally used code like “addFrameScript(1, frame2, 2, frame3, 3, frame4);” so probably there is no future problem with future compatibility, isn’t it?

    • I wish I knew. But it is possible that this might pass along through future Flash Players. By being “undocumented”, essentially Adobe is not at fault if it is not being used later, but the last “undocumented” feature was the built-in tween engine and it is now hear to stay. So I wouldn’t worry to much about it. I would just use it wisely.

Comments are closed.