I have a button that triggers a movie clip to start playing i have put a frame label on the last frame of a movie clip. On the button action script i have code below:
on (release) {
_root.note.enabled = false;
_root.move_object.gotoAndPlay(101);
var frame = _root.move_object._currentlabel;
if (frame == "end")
{
_root.gotoAndStop(3);
}
}
What I want the if statement to do is when the button is pressed it tell it when the movieclip called move_object get to the frame label end on the main timeline I want it to go to frame 3 and stop. The if statement in the actionscript above dose not work.
Why not just put the code on the “end” frame: gotoAndStop(3) ??
The problem with your if statement is that it’s contained within the on (release). In other words, it’s only checking if you’re on the last frame as soon as the button is released but not after. you already know that it’s on frame 101. Either use the above suggestion or put the if statement in an onEnterFrame
You may want to check you syntax on (release)/ onRelease…
They are both functions that should provide the wanted effect, but i believe on works for buttons and the other for MovieClips, which means it may be casting your mc as a Button. and i dunno if buttons have frames…
secoundly order of operations, actionscript is not all run immediately each one runs at its designated time. for example if you try changing the frame it takes time before the movie updates with the current frame, b/c a movie has a specified framerate like 30fps… but these tend be a bit more on the advanced topics
if you can avoid it try to or else there might be a timely work around required. and it might require an onEnterFrame = function() like DaRicardo said.