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

How to make a button that only advances to next image strip when previous strip ends?

New Here ,
Jan 16, 2018 Jan 16, 2018

Hey, I just started using AS for the first time and I have a small flash that I'm working on and everything has been going good. But I'm having a problem with a button.

I have imported two image strips, 100 frames each, and as soon the flash loads, it plays the first strip in a loop until I press the button to move to the next strip. However, here is the issue, while it indeed goes to the next strip, it doesn't wait for the other to finish. How can I make it wait for the previous strip to finish before moving on to the next one when the button is pressed?

TOPICS
ActionScript
407
Translate
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

Community Expert , Jan 16, 2018 Jan 16, 2018

yourbutton.addEventListener(MouseEvent.CLICK,f);

function f(e:MouseEvent):void{

this.addEventListener(Event.ENTER_FRAME,ff);

yourbutton.removeEventListener(MouseEvent.CLICK,f);

removeChild(yourbutton);

}

function ff(e:Event):void{

if(firststrip.currentFrame==firststrip.totalFrames){

this.removeEventListener(Event.ENTER_FRAME,ff);

// go to nextstrip

}

}

Translate
Community Expert ,
Jan 16, 2018 Jan 16, 2018

yourbutton.addEventListener(MouseEvent.CLICK,f);

function f(e:MouseEvent):void{

this.addEventListener(Event.ENTER_FRAME,ff);

yourbutton.removeEventListener(MouseEvent.CLICK,f);

removeChild(yourbutton);

}

function ff(e:Event):void{

if(firststrip.currentFrame==firststrip.totalFrames){

this.removeEventListener(Event.ENTER_FRAME,ff);

// go to nextstrip

}

}

Translate
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 ,
Jan 16, 2018 Jan 16, 2018

Am I suppose to replace the firststrip part in this line: if(firststrip.currentFrame==firststrip.totalFrames){ with something?

Translate
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
Community Expert ,
Jan 16, 2018 Jan 16, 2018

you need to replace all the instance names with the ones you used and you need to replace "// go to nextstrip"

Translate
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 ,
Jan 16, 2018 Jan 16, 2018

Oh right, ofcourse! Thank you for the help, it worked!

Translate
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
Community Expert ,
Jan 16, 2018 Jan 16, 2018
LATEST

you're welcome.

Translate
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