Undocumented Method – addFrameScript();

A little looking around the web, and this stood out.

From http://www.flashguru.co.uk/undocumented-actionscript-3/#comments

It allows you to specify a function that is called when the playhead of the Movieclip timeline enters the specified frame number. Their are four parameters to the method, i only completley understand the purpose of the first two, the other two are worth investigating more.

While I am trying to get away from scripting on frames, there are definately situations where it is essential (and this simply provides a cleaner way to do frame-scripting, but not on a frame). One of my older projects (currently stalled) involved a MovieClip that had animations for turning in different directions, and I had to use copious amounts of frame-scripting for me to know when each “animation” had completed. This should come in handy.

Anyway, Senocular came up with the appropriate usage of this method:

addFrameScript(...rest);

Arguments must be in pairs, frame-number followed by function. Note that frame-number 0 refers to the very first frame. Also, your MovieClip must have that number of frames before it will execute.

addFrameScript(2, frameMethod1, 5, frameMethod2);
function frameMethod1():void
{
  trace("Frame 3 reached");
}
function frameMethod2():void
{
  trace("Frame  6 reached");
}

Share this post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Facebook
  • Google Bookmarks

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>