0
votes

I have three buttons on my third frame and these should control a movieclip on the main timeline's fifth frame. How could I control that movieclip without leaving the third frame but affecting the fifth frame? To be concrete, it's a car game's car select option. If the porsche_select button is clicked, then the movieclip on the maintimeline's fifth frame goes to the porsche's frame and stops. If the ferrari_select button is clicked then it goes the the movieclip's frame which on the ferrari is placed, same with the Lamborghini.

porsche_select.addEventListener(MouseEvent.CLICK, clicked7);
function clicked7(e:MouseEvent):void
{
    MovieClip(5).auto.gotoAndStop(1);
}

I have this, but it throws back this error: TypeError: Error #1034: Type Coercion failed: cannot convert 5 to flash.display.MovieClip.

auto is the instance name of the movieclip on frame 5.

1

1 Answers

0
votes

I don't believe you can do that the way you have it written...at least you can't turn the number 5 in to a movieclip, which is what the error is saying.

At the moment on the timeline, until you first go to frame 5, that movieclip won't 'exist' yet so it can't really be accessed.

One way you can do what you've described is when you press a button, you can set a 'car type' variable that you can then when you reach frame 5, you can use it to do what you need to.

Or maybe another way is to make that car movie clip exist on frame 3 along, but have the first frame of it be 'empty' so initially it won't really show.