mc to play until a certain frame is reached, then stop
Hi, I'm hoping someone can help!
I have an mc placed on the main stage that I'm trying to control through a separate button. I want the mc to play until a certain frame number is reached and then stop. I've got the following actionscript on the button instance:
Code:
on(rollOver){
if (mc._currentframe == 10){
mc.stop()
}
else{
mc.play()
}
}
This is not working at all - the mc is not stopping at frame 10, just looping continuously - am I missing something?
Thanks for any help!
Maybe try something like this...
The on rollOver code is only checking the status of the mc currentframe once, when the cursor moves over it. To keep checking it, until it reaches 10 use something like this...
Code:
on (rollOver) {
this.onEnterFrame = function() {
mc.play();
if (mc._currentframe == 10) {
mc.stop();
delete this.onEnterFrame;
}
};
}
Play through to Cetain frame then stop in AS3 ???
I am trying to basically do the same thing. I have a circle on my main timeline that rotates as the the timeline plays. I would like to have the timeline stop on a certain frame when a certain button is pressed. So basically, i would like to to a button to play through until it reaches a certain frame. It seems like the most basic thing, however, I cant do it.
Help me FlashKit-Kenobi, you're my only hope..ok cheezy I know.
Here is my code so far:
green_btn.addEventListener(MouseEvent.CLICK, playGreen);
function playGreen(event:MouseEvent):void
{
play()
if (frame == 36) {
stop();
}
}
The easy way or the hard way.
Quote:
Originally Posted by
adrian7474
I am trying to basically do the same thing. I have a circle on my main timeline that rotates as the the timeline plays. I would like to have the timeline stop on a certain frame when a certain button is pressed. So basically, i would like to to a button to play through until it reaches a certain frame. It seems like the most basic thing, however, I cant do it.
Help me FlashKit-Kenobi, you're my only hope..ok cheezy I know.
Here is my code so far:
green_btn.addEventListener(MouseEvent.CLICK, playGreen);
function playGreen(event:MouseEvent):void
{
play()
if (frame == 36) {
stop();
}
}
You could just place a stop command on frame 36 of the timeline. This way you won't have to worry about it. If not, then you need an event listener to constantly check for current frame number. The event listener would be:
PHP Code:
stage.addEventListener(Event.ENTER_FRAME, checkFrame);
function checkFrame(event:Event):void
{
if (MovieClip(parent).currentFrame == 36 )
{
stage.removeEventListener(Event.ENTER_FRAME, checkFrame);
MovieClip(parent).stop();
}
}