Search code examples
actionscript-3flashmovieclipgotodisplayobject

AS3 GoToAndPlay Error


so I tried all examples given here, mainly all the 3 options from another post:

 //option 1
MovieClip(this.root).gotoAndPlay(134);

//option 2
MovieClip(parent).gotoAndPlay(134);

//option 3
var mc:MovieClip = this.parent as MovieClip;
mc.gotoAndPlay(134);

And here is my issue: On my main timeline I have a mc tweening from frame 1 to frame 25. The movieclip instance has the instance name "carMc". ON frame 25 I have the following code:

var carMc:MovieClip = this.parent as MovieClip;
carMc.gotoAndPlay(5);

carMc has 6 frames. A stop action on frame 1 and a gotoAndPlay(5); action on frame 6

My issue is that carMc won't go as directed to play frame 5.When I run a trace on frame 25 of the main timeline I get a

[object carMc_3] 

returned...And have no idea why this is. For some reason it doesn't seem as if Flash is treating my movieclip instance on the timeline as a movieclip.

Any ideas??? Thanks guys!


Solution

  • Your problem is a bit complicated to understand but i'll try.

    On my main timeline I have a mc tweening from frame 1 to frame 25. The movieclip instance has the instance name "carMc". ON frame 25 I have the following code:

    var carMc:MovieClip = this.parent as MovieClip; carMc.gotoAndPlay(5);

    If this code is in main timeline than this.parent would be Stage which is indeed an object. If you want to reference car movieclip than you need to reference it as

    this.CarMc