Adobe Help Documentation

Dynamically Add Script to Frames of a MovieClip with AS3

Tags: ,

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);

Warning!

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?

Related Posts

ActionScript 3 Logo

Moving From AS2 to AS3: A Handy List of Resources

AS3 Reverse String

How To: Reverse Any Given String Using AS3

Welcome to ActionScript 3.0

ActionScript 1:1 – Getting Intimate With ActionScript 3.0

ActionScript 3 Migration Cookbook

ActionScript 3 Migration Cookbook

2 Comments

  1. arek

    02.10.2009

    Reply

    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?

    • Angel

      02.11.2009

      Reply

      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.

Leave a Reply









Latest Theme From WooThemes

Whitelight

By WooThemes

Whitelight was designed by Chris Rowe, with the aims to set a new standard on our business theme line-up. It features a clean and responsive design, customized modular homepage, portfolio functionality that we all love and integrated WooCommerce goodness (child theme) for your e-commerce needs.

Theme Categories: Business, Responsive

Latest Tweets