can we get the current frame label?

Explorer ,
Jun 10, 2020 Jun 10, 2020

Copy link to clipboard

Copied

hello! I am trying to make universal next and previous button that navigate between labeled frame

if the first frame labeled with the label "1" (the label is "1") and the seconed is "2" and etc.

if i can get the current frame label then i can use the current farme label +1, and the previous button current farme label -1

or is there another way?

 

 

TOPICS
ActionScript

Views

450

Likes

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

Adobe Community Professional , Jun 11, 2020 Jun 11, 2020
Hi. You can use the labels array property that stores the labels names and their corresponding frames. Then you can increment and decrement a counter variable to keep track of which array item to access. Like this: Preview: https://bit.ly/2XQr6Po JavaScript code: var root = this; var labels = root.labels; var index = 0; root.start = function() { root.gotoPrevLabel = function(e) { index = root.clamp(--index, 0, labels.length - 1); root.gotoAndStop(labels[index].position); }; root....

Likes

Translate

Translate
Adobe Community Professional ,
Jun 10, 2020 Jun 10, 2020

Copy link to clipboard

Copied

If these buttons are the only way to move between frames, you should just have a global variable that tracks the current frame label number.

 

Also, you should absolutely not use numbers as frame labels. That's just begging Animate to get confused whether you're asking it to go to a frame number or a frame label.

Likes

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
Explorer ,
Jun 10, 2020 Jun 10, 2020

Copy link to clipboard

Copied

"you should just have a global variable that tracks the current frame label number."

and how to do that?

Likes

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
Adobe Community Professional ,
Jun 11, 2020 Jun 11, 2020

Copy link to clipboard

Copied

Hi.

 

You can use the labels array property that stores the labels names and their corresponding frames. Then you can increment and decrement a counter variable to keep track of which array item to access. Like this:

 

Preview:

https://bit.ly/2XQr6Po

 

JavaScript code:

var root = this;
var labels = root.labels;
var index = 0;

root.start = function()
{
	root.gotoPrevLabel = function(e)
	{
		index = root.clamp(--index, 0, labels.length - 1);
		root.gotoAndStop(labels[index].position);
	};

	root.gotoNextLabel = function(e)
	{
		index = root.clamp(++index, 0, labels.length - 1);
		root.gotoAndStop(labels[index].position);
	};

	root.on("click", function(e)
	{
		if (e.target.name === "prevButton")
			root.gotoPrevLabel();
		else if (e.target.name === "nextButton")
			root.gotoNextLabel();
	});

	root.stop();
};

root.clamp = function(value, min, max)
{
	if (value < min)
		return min;
	
	if (value > max)
		return max;
	
	return value;
};

if (!root.frame0Started)
{
	root.start();
	root.frame0Started = true;
}

 

FLA / source / files:

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/navigate_from_label_to_lab...

 

I hope this helps.

 

Regards,

JC

Likes

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
Explorer ,
Jun 12, 2020 Jun 12, 2020

Copy link to clipboard

Copied

It works! obrigado

Likes

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
Explorer ,
Jun 13, 2020 Jun 13, 2020

Copy link to clipboard

Copied

LATEST

Hi, there is a small issue. I originaly had in the verey first frame a small script, stop [this.stop();] and a play button [playBtn on click; gotoAndPlay(currentFrame + 1); ] and they used to work but not now, I think when redifined [this] something happend,

so if you can please add to the code a third button [playBtn] wich on click of any instant of it just play the time line.

another issue, in which line should I add stop sound functionality to the next and previous button

 

Regards.

Likes

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