is it possible tpo have a movie clip use the gotoAndPlay function without converting it to a button.

Dani AI

Generated

was right that movie clips are great for button-like behaviour, and nailed the root cause: the clip's event code was addressing the clip's own timeline instead of the main playhead. In Flash/AS2 the scope of an event or an on-release attached to a clip is local to that clip, so navigation calls without an explicit target will move the clip itself. Explicitly targeting the main timeline fixes that, but there are cleaner patterns to avoid surprises as projects grow.

Quick checklist when a clip-based control "does nothing" or moves the wrong timeline:

  • Verify the instance name is set on the stage and you are attaching handlers to that instance.
  • Stop() the clip and its parent timelines where appropriate so you control when frames advance.
  • Use trace/debugging to confirm rollover/click handlers fire and which object is the event this or currentTarget.
  • Be mindful of nesting: a clip inside another clip may need root or an upward event to reach the document timeline.
  • For maintainability, keep navigation on the document/main timeline and have clips dispatch events or call a central navigation function rather than hard-coding root-level jumps.

For projects using AS3, prefer event listeners and explicit casting. Example pattern:

myClip.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void {
    MovieClip(root).gotoAndPlay("about");
}

Use centralized handlers or custom events for complex UIs; avoid scattering direct root-level calls inside many nested clips.

Recommended Answers

All 3 Replies

its very possible in fact movieclips are used more often as buttons than the actual button symbols them selves. this is because movieclips have a variety of functions that buttons dont.

coming to your question. a movieclip can have its own time line and therefore the gotoAndPlay event can be triggered with or within a movieclip

i have set my timeline inside the movie clip up so that i have my frame labels for the up, over and out states. the problem i am having is that when the mouse moves over the movie clip it is not playing the animation.

i have set the script up on the main timeline so that the animation should play but it is not. the code i have used on the main timeline looks like this

this.prof_mc.onRollOver = function() {
	prof_mc.gotoAndPlay("over");
};
this.prof_mc.onRollOut = function() {
	prof_mc.gotoAndPlay("out");
};

i have put a on release function on the movie clip on the main stage and this is not working. when the movie clip is pressed once it is playing the over state from inside the movie clip and when it is pressed again it plays the out state of the movie clip which should not be happening.

the on release on the movie clips has been scripted like this

on (release){
	gotoAndPlay("_about");
}

i have set up the timeline with frame labels for the individual pages with "_about" being one of the pages i have set up.

if someone could tell me where i have gone wrong that would be great as i have not a clue why it is behaving in this way.

i worked this out a few days ago forgot to come back and post my answer. to get the gotoAndPlay to work how i wanted it to i had to tell the playhead which level i wanted it to gotoAndPlay on, the code which worked for me is as follows

on (release) {
	_level0.gotoAndPlay("_about");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.