user1298923
user1298923

Reputation: 194

AS2 - Jump to a frame of a movieclip in another frame

Lets say that I have 2 frames:

Frame 1 with mc01 in it (Instance name: f1) Frame 2 with mc02 in it (Instance name: f2)

At a certain point, in mc02 (inside Frame 2), I want to jump to let's say Frame 50 of mc01, that is contained in Frame 1. How?

My code atm (that produces 0 results):

_root.f1.mc01.gotoAndPlay(50);

Remember this is an Actionscript 2 question. Any help would be appreciated.

Thanks!

Upvotes: 0

Views: 1188

Answers (1)

blvz
blvz

Reputation: 1493

You just need to specify the instance name, like this:

_root.f1.gotoAndPlay(50);

Also, you can just use _parent, if both are siblings:

_parent.f1.gotoAndPlay(50);

Please note that the mc01 (named f1) must exist on frame 2 for this to work.

Update:

Your problem is that, when you need to change the frame of mc01, it doesn't exist. So you need to store a configuration for it to access on it's initialization. For example:

_root frame 1:

// if config isn't set yet, let's define it.
var config;
if (!config) {
  config = {f1: {startFrame: 1}};
}

mc01 frame 1:

// go to config.f1.startFrame. If no config is set, go to 1.
gotoAndPlay(_parent.config.f1.startFrame || 1);

mc02 anywhere:

// change the config of mc01. Now, when it's created again
// it'll read the new value and jump straight to it.
_parent.config.f1.startFrame = 50;

Upvotes: 1

Related Questions