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

Animate cc canvas movie clip button.

Community Beginner ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

Hello everyone on the forum.
Maybe someone will guide me on how to solve this problem in adobe animate cc canwas.
In AS 3 the button works fine, but in javaScript I tried different ways and can't do it.

This is AS 3 code

var x:Boolean = false;

this.info_btn.addEventListener(MouseEvent.CLICK, onClick);
this.info_btn.addEventListener(Event.ENTER_FRAME, animate);

function onClick(e: MouseEvent):void {
if (x) {
x = true;
} else {
x = false;
my_mc.play();
}
}

function animate(e: Event): void {
if (!x && my_mc.currentFrame == my_mc.totalFrames - 46) {
my_mc.stop();

}
}


MovieClip starts from the current frame and stops at 47 frames from the end, and so on with each click.

 

below code but can't get it sorted

//var x = false;
//let x = false;
x = Boolean(false);


this.info_btn.addEventListener('click', onClick);

function onClick() {

if (x) {
x = true;
console.log('pause');

} else {
x = false;
root.my_mc.play();
console.log('happy');
}

}
If anyone guides me, thank you.

Views

85

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
Community Expert ,
Jun 02, 2022 Jun 02, 2022

Copy link to clipboard

Copied

Hi.

 

The code doesn't make much sense to me, but a possible solution would be:

var root = this;
var x = false;

function onClick(e)
{
	if (x)
		x = true;
	else
	{
		x = false;
		root.my_mc.play();
	}
}

function animate(e)
{
	if (!x && root.my_mc.currentFrame === root.my_mc.totalFrames - 46)
		root.my_mc.stop();
}

root.info_btn.addEventListener("click", onClick);
createjs.Ticker.addEventListener("tick", animate);

 

I hope it helps.

 

Regards,

JC

Votes

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
Community Beginner ,
Jun 08, 2022 Jun 08, 2022

Copy link to clipboard

Copied

LATEST

Hello

Thank you for your reply.

This is my first time on this forum.

Let me write something about myself briefly.

Writes through google translator, I think you will understand something of this.

My name is Jan, this year I will be 62 years old, I started on the pro versions of Flash,
I learn from flash literature, ActionScript 3.0 online courses.
But Animate CC canvas is difficult and it takes time, when I retire I will devote myself to it, I'm very interested in computer animation.

I did a project with AS 3 360 ° photos once and I would like to transfer it to canvas.
The code you wrote to me works, but other buttons take over its function, it must be a local variable, I have to work on it, or ask on the forum.

Thanks again for your answer and I think we will exchange a few more sentences in the forum.
It was nice to meet you.

I am sending greeting and I wish you good luck.

Jan

Votes

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