Skip to main content
Leux
Participating Frequently
February 7, 2020
Answered

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

  • February 7, 2020
  • 1 reply
  • 338 views

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!

 

This topic has been closed for replies.
Correct answer JoãoCésar17023019

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

1 reply

JoãoCésar17023019
Community Expert
JoãoCésar17023019Community ExpertCorrect answer
Community Expert
February 7, 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