Highlighted

can we get the current frame label?

Explorer ,
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?

 

 

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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_label

 

I hope this helps.

 

Regards,

JC

TOPICS
ActionScript

Views

276

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

can we get the current frame label?

Explorer ,
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?

 

 

Adobe Community Professional
Correct answer by JoãoCésar | Adobe Community Professional

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_label

 

I hope this helps.

 

Regards,

JC

TOPICS
ActionScript

Views

277

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
Jun 10, 2020 1
Adobe Community Professional ,
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
Reply
Loading...
Jun 10, 2020 0
Explorer ,
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
Reply
Loading...
Jun 10, 2020 0
Adobe Community Professional ,
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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

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
Reply
Loading...
Jun 11, 2020 1
Explorer ,
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
Reply
Loading...
Jun 12, 2020 0
tazkerah LATEST
Explorer ,
Jun 13, 2020

Copy link to clipboard

Copied

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
Reply
Loading...
Jun 13, 2020 0