-
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;
}
};
}
-
That works great, thanks!
-
thx a lot u have answered on my topic by this too
-
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();
}
}
-
Flash/Flex Developer
The easy way or the hard way.
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();
}
}
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
I have a timeline and i want to switch for particular frame number and want to play the tween animation at there
And same thing at intervals but different frame no.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|