• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Play a movie clip and then stop at a certain frame?

New Here ,
Sep 03, 2017 Sep 03, 2017

Copy link to clipboard

Copied

I'm sorry if this has been asked, but I have trouble dealing and finding for a solution for my two-week problem.

I have this scene that i want to play when the blue button is clicked. Scene is about 50 frames, but I only want to play frames 1 to 10, then loop back again to the first frame. If I click a yellow button, frames 11-20 will be played,then loop back again to the first frame, etc. Is this actually possible?

I already tried the go to scene and play but still when I click the blue button, all frames will be played.

Thank you very much for the answer. I'm a newbie at this so i don't have that many ideas yet.

TOPICS
ActionScript

Views

4.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 04, 2017 Sep 04, 2017

When you said "loop back to the first frame" I thought you meant that you wanted it to loop the frame range continually. If you want it to play the frame range once, then go back to the first frame of the range, change the enterframe function to this:

function checkframe(e:Event){

  if(currentFrame>=endframe){

  gotoAndStop(startframe);

  }

}

Votes

Translate

Translate
LEGEND ,
Sep 03, 2017 Sep 03, 2017

Copy link to clipboard

Copied

You can have an enterframe listener that continually looks to see whether it's time to go to another frame range. Here is example code that you could put into frame 1, that will at first loop frame 2. In my example I had three buttons, named r1, r2, r3, that call functions range1, range2, range3 when clicked, and those functions set the start frame and end frame variables, and also goes to the start frame and plays from there.

import flash.events.Event;

import flash.events.MouseEvent;

var startframe:int = 2;

var endframe:int = 2;

r1.addEventListener(MouseEvent.CLICK,range1);

r2.addEventListener(MouseEvent.CLICK,range2);

r3.addEventListener(MouseEvent.CLICK,range3);

addEventListener(Event.ENTER_FRAME,checkframe);

function checkframe(e:Event){

  if(currentFrame>=endframe){

  gotoAndPlay(startframe);

  }

}

function range1(e:MouseEvent){

  startframe = 4;

  endframe = 7;

  gotoAndPlay(startframe);

}

function range2(e:MouseEvent){

  startframe = 10;

  endframe = 20;

  gotoAndPlay(startframe);

}

function range3(e:MouseEvent){

  startframe = 30;

  endframe = 40;

  gotoAndPlay(startframe);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 04, 2017 Sep 04, 2017

Copy link to clipboard

Copied

i run your code but i think that is my problem, when you click r2, for example, function range2 will get stuck in the loop (the startframe and endframe you made), and it will not go back to the first frame. Can i add a break(); or similar to it after gotoAndPlay(startframe); to make it go back to the firstframe? I tried break(); and stop(); but it ruined the code lol.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 04, 2017 Sep 04, 2017

Copy link to clipboard

Copied

When you said "loop back to the first frame" I thought you meant that you wanted it to loop the frame range continually. If you want it to play the frame range once, then go back to the first frame of the range, change the enterframe function to this:

function checkframe(e:Event){

  if(currentFrame>=endframe){

  gotoAndStop(startframe);

  }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 04, 2017 Sep 04, 2017

Copy link to clipboard

Copied

OHMYGOD U A WIZARD THANKYOU SO MUCH but i added another variable named firstframe so gotoAndStop(firstframe) will go back to the very first frame where my buttons are positioned(that's why i want it to repeat so badly lol) THANK YOU GREATLY APPRECIATED by the way, i used classic tween in my scene because when i use motion tween, there's this error, " temp init, line 1 vector not found." and many more. Or did i use the function wrong?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 04, 2017 Sep 04, 2017

Copy link to clipboard

Copied

LATEST

I marked my answer as correct, hope that's ok.

I haven't seen an error like you mentioned. Motion tween shouldn't introduce any errors, and in some cases it's safer to use than classic tweens, when tweeting named symbols for example.

If you need to use motion tweens but you're getting that error, start a new topic about that, and if possible post your FLA online somewhere.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines