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

In actionscript, how do I click to go to next frame, but not past a certain frame?

Community Beginner ,
Feb 06, 2020 Feb 06, 2020

Hey everyone,

 

I was wondering how I would be able to "Click to Go to Frame and Stop" (In code snippets), but add something to it, that makes it not go past a certain frame.

 

For example:

I am creating a slideshow

I already have a next button

I want to do a secret button

Frames 1-11 are a part of my slideshow

Frame 12 is my "secret" part of my slideshow, something I dont want accessible by the next button

 

How would I code this to work?

 

Does anyone know how I'd be able to do this?

Thank you!

 

TOPICS
ActionScript
349
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 , Feb 07, 2020 Feb 07, 2020

Hi.

 

Use the Math.min method. Like this:

import flash.events.MouseEvent;

var frameLimit:uint = 11;

function goForward(e:MouseEvent)
{
	gotoAndStop(Math.min(currentFrame + 1, frameLimit));
};

stop();
yourButton.addEventListener(MouseEvent.CLICK, goForward);

 

Regards,

JC

Translate
Community Expert ,
Feb 07, 2020 Feb 07, 2020
LATEST

Hi.

 

Use the Math.min method. Like this:

import flash.events.MouseEvent;

var frameLimit:uint = 11;

function goForward(e:MouseEvent)
{
	gotoAndStop(Math.min(currentFrame + 1, frameLimit));
};

stop();
yourButton.addEventListener(MouseEvent.CLICK, goForward);

 

Regards,

JC

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