• 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 HTML5 canvas can't update a var on mouseover

Explorer ,
Sep 08, 2023 Sep 08, 2023

Copy link to clipboard

Copied

If any one can help!, I have 2 frames, first frame has a this.stop(); and I want to go to the second frame afer x seconds (11), but only if I havent already gone to the second frame by hovering a button object.

So srated with var _frame1 = "f1"; and tried to updated that with_frame1 = "f2"; on mouseover so the if statement wouldn't run the code for the second time.

var _frame1 = "f1";

if(_frame1 == "f1") {
	var t=setTimeout(function(){
	console.log(this, _this);
	_this.gotoAndPlay("frame2_play");
}, 11500);
}

this.ball_ani_3.ball_graphic_outer_frame1.ball_graphic_text.hotspot_outer.hotspot.addEventListener("mouseover", ballMouseOver3.bind(this));

function ballMouseOver1()
{
	//play
	var t=setTimeout(function(){
		console.log(this, _this);
		_this.gotoAndPlay("frame2_play");
	}, 1000);
	//set frame position
	_frame1 = "f2"
}

 

 

TOPICS
Code , How to

Views

121

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

Community Expert , Sep 08, 2023 Sep 08, 2023

there are a few problems with your code. try:

 

this.stop();
var _this=this;
stage.enableMouseOver();
 
setTimeout(gotoF,11500);
 
function gotoF(){
if(_this.currentFrame==0){
_this.gotoAndStop(1);
}
}
 
this.ball_ani_3.ball_graphic_outer_frame1.ball_graphic_text.hotspot_outer.hotspot​.addEventListener("mouseover", ballMouseOver1.bind(this));
 
function ballMouseOver1(){
_this.gotoAndStop(1);
}
 

Votes

Translate

Translate
Community Expert ,
Sep 08, 2023 Sep 08, 2023

Copy link to clipboard

Copied

there are a few problems with your code. try:

 

this.stop();
var _this=this;
stage.enableMouseOver();
 
setTimeout(gotoF,11500);
 
function gotoF(){
if(_this.currentFrame==0){
_this.gotoAndStop(1);
}
}
 
this.ball_ani_3.ball_graphic_outer_frame1.ball_graphic_text.hotspot_outer.hotspot​.addEventListener("mouseover", ballMouseOver1.bind(this));
 
function ballMouseOver1(){
_this.gotoAndStop(1);
}
 

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
Explorer ,
Sep 08, 2023 Sep 08, 2023

Copy link to clipboard

Copied

Thanks this work perfectly.

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 Expert ,
Sep 09, 2023 Sep 09, 2023

Copy link to clipboard

Copied

LATEST

you're welcome.

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