How to play MovieClip animation which is not on the main timeline

1.1k Views Asked by At

enter image description hereOn my main timeline, I have a 'background' layer, a 'play' layer an an 'actions' layer. In the 'play' layer, there is a MovieClip whose instance name is playButton. All layers on the main timeline only have one frame.

In the actions layer on the main timeline, this is what is there

import flash.events.MouseEvent;
import flashx.textLayout.formats.Float;

function playButtonClicked(evt:MouseEvent) {
    backgroundMC.analysisScreenMC.play();
}

playButton.addEventListener(MouseEvent.CLICK, playButtonClicked);

In the background layer, there is a MovieClip called backgroundMC. Inside backgroundMC (if you double click backgroundMC) there is another MovieClip whole instance name is analysisScreenMC and it has two layers, an 'actions' layer and an 'answers' layer. Both these layers have 13 frames. The 'answers' layer is a motion tween, and basically makes analysisScreenMC fade out to 50% opacity. The actions layer in analysisScreenMC is just this

stop();

(without stop(); the animation plays over and over again)

Now, when I run the animation, nothing happens even if I click the play button. Any idea why?

Note: I also tried doing this

function playButtonClicked(evt:MouseEvent) {
    trace('clicked');
    backgroundMC.analysisScreenMC.play();
}

and it does in fact trace 'clicked' every time I click the play button.

Below is an image of the timeline of analysisScreenMC.

2

There are 2 best solutions below

10
On

Try this.

function playButtonClicked(evt:MouseEvent) {
    backgroundMC.analysisScreenMC.gotoAndPlay(2);
}

Also have stop() in first frame of the action layer of analysisScreenMC and remove the remaining frames of the action layer.

4
On

In playButtonClicked, try:

trace("backgroundMC="+ backgroundMC+", backgroundMC.analysisScreenMC="+ backgroundMC.analysisScreenMC);

This will show you if these movieClips exist.