My original code enables me to play another frame once the user has clicked on the object-as seen in the code;

stop();
btn1.addEventListener 
	(MouseEvent.CLICK, onClick); 

function onClick
( event:MouseEvent):void 

{
gotoAndPlay("8") 
}

However, when i replace gotoAndPlay with 'gotoAndStop' it doesnt work?

Dani AI

Generated

Nice catch , and good troubleshooting from . This kind of symptom usually comes down to timeline/targeting confusion rather than a mysterious bug. Short checklist and a couple of small patterns that make behaviour predictable.

  • Prefer descriptive frame labels over raw numbers. Labels survive edits and make reading code much easier (for example label a frame "MENU" instead of relying on a numeric index).
  • Make sure you are targeting the correct timeline. Code running inside a nested MovieClip will affect that clip unless you explicitly reference the parent/root MovieClip or the named instance you want to control. Confirm the instance name in the Properties panel.
  • Use runtime tracing to see where playback actually is. Checking both currentFrame and currentFrameLabel removes guesswork.
  • Test the SWF with the runtime tester (Control -> Test Movie) — the authoring view can be misleading.

A small debug pattern that helps diagnose scope and frame issues:

trace("frame:", MovieClip(root).currentFrame, "label:", MovieClip(root).currentFrameLabel);

var target:DisplayObject = root.getChildByName("content_mc");
if (target && target is MovieClip) {
    MovieClip(target).gotoAndStop("MENU");
} else {
    trace("content_mc not found or not a MovieClip");
}

Notes: use integer literals for explicit numeric frames and string labels for named frames to avoid ambiguity. Keeping a clear label scheme, explicit scoping (targeting the right MovieClip), and a few traces will usually show exactly why a goto/gotoAndStop call seems to "not work" and prevent miscounts like the one you ran into.

Recommended Answers

All 2 Replies

My original code enables me to play another frame once the user has clicked on the object-as seen in the code;

stop();
btn1.addEventListener 
	(MouseEvent.CLICK, onClick); 

function onClick
( event:MouseEvent):void 

{
gotoAndPlay("8") 
}

However, when i replace gotoAndPlay with 'gotoAndStop' it doesnt work?

Do you have a call to play() in the actionscript in the timeline on frame 8 of your clip? (click on frame 8 and look in the actionscript window)
That is the most likely cause of this problem......

Changing the gotoAndPlay in the code you posted to a gotoAndStop should cause your clip to go to frame 8 and stop.
But an explicit call to play() in the AS on the timeline of your clip at frame 8 would cause playback to continue..

Remove any call to Play() from the AS for frame 8. Don't replace it with a stop() as that would cause any gotoAndPlay(8) calls to fail....

Give that a go and let me know how you get on.

Cheers for now,
Jas.

I must say your very helpful and i really appreciate your response to my problem m8. But very silly of me, i made a simple mistake. What happen was i was playing frame 8 which i thought was the last frame but was actually playing the frame that i was currently on. Therefore it appear not to change when i clicked the button since it was playing the same frame i was on .
so thanks anyway m8.

But i counted wrongly for a reason, this is because in the preview it doesnt play the first frame, so i believed that all the other frames became a previous frame.(just so you think im not retarded hehe).

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.