stop() a nested movieclip with Actionscript 3.0

Car animation with controls

I spent most of last night animating this car for homework for my Digital Sound and the Still Image class. For a class that only happens once a fortnight in blocks, somehow it's more stressful despite there being fewer classes simply because there's still so much work in between.

In any case, if you were interested in the finished .swf file, you can take a look and play around at this link here (I recommend downloading). I won't embed it because it autoplays and I'm sure your computers will not thank me for it.

I don't know whether I did it right, but at least I followed the homework spec. There was a point where I did get stuck though, which was where I wanted to make the controls stop the animation of the wheels, as the wheel animation was in a nested movie clip. (Make sure the object on the main timeline is a movie clip, and clicking through will allow you to drill into its own timeline.)

I think my main problem was the fact that my method was more of a nested movie clip in a nested movie clip, but once I'd managed to fix that so it was only one level of nesting, as long as you'd made sure the object within the nested movie clip was converted to a graphic, and then the instance of the movie clip in your main timeline was named, then you can write the following Actionscript to stop the wheels:


function stopIt(event:MouseEvent):void {

function startIt(event:MouseEvent):void {

stop_btn.addEventListener(MouseEvent.CLICK, stopIt);
play_btn.addEventListener(MouseEvent.CLICK, startIt);

Of course the above code assumes that you've created two buttons and named them, but we are speaking in the context of my work.

Nice to be rid of the errors telling me variables hadn't been assigned. Still a long way to go before I get a good hang of ActionScript though.