I recently came across something similar; perhaps the following helps in some way:
- gotoAndStop (frame) will immediately execute the actioncript in the frame
- you can make multiple calls to gotoAndStop during one ENTER_FRAME event (or any other event).
As a test, I created a new AS3.0 project in Flash Pro CS5.5. I created a new MovieClip and extended the timeline to 23 frames.
In the first frame, I added the following code:
import flash.events.Event; // do something every frame this.addEventListener(Event.ENTER_FRAME, handleEnterFrame); // let event handler change the playHead this.stop(); // advance playhead 2 frames every frame function handleEnterFrame(anEvent: Event): void { trace('* ENTER_FRAME'); this.gotoNextFrame(); this.gotoNextFrame(); } // advance to next frame, show playheads position function gotoNextFrame(): void { // at last frame? if (this.currentFrame < this.totalFrames) { // no, advance to next frame var before: int = this.currentFrame; this.gotoAndStop(this.currentFrame + 1); trace('before: ' + before + ', current: ' + this.currentFrame); } else { // last frame, stop updating the playhead this.removeEventListener(Event.ENTER_FRAME, handleEnterFrame); } }
In frame 5, I created a keyframe and added the code:
this.gotoAndPlay(10);
In frame 14, I created a keyframe and added the code:
this.gotoAndPlay(16);
After starting, I got the following trace output:
* ENTER_FRAME before: 1, current: 2 before: 2, current: 3 * ENTER_FRAME before: 3, current: 4 before: 4, current: 10 * ENTER_FRAME before: 11, current: 12 before: 12, current: 13 * ENTER_FRAME before: 13, current: 16 before: 16, current: 17 * ENTER_FRAME before: 17, current: 18 before: 18, current: 19 * ENTER_FRAME before: 19, current: 20 before: 20, current: 21 * ENTER_FRAME before: 21, current: 22 before: 22, current: 23 * ENTER_FRAME
I have no idea how efficient or time consuming it is above. I had to use it with only one MovieClip (at a late stage of development it was found that it would be convenient if the main character could work too, but there was no budget for starting the animation, the symbol contained steps generating a script on the timeline for the right timing )
In your case, you can check how much time has passed since the last ENTER_FRAME, and then specify the correct number of frames.
You can subclass MovieClip and use it as a base class (to quickly do this, select all the clicks that require this in the library, right-click, properties, edit the base class). For those MovieClips that are already associated with ActionScript, you can simply update the .as file by moving from the new MovieClip class.