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

CC Animate HTML5 Canvas - Change (z-index) on hover

Explorer ,
Sep 08, 2023 Sep 08, 2023

Copy link to clipboard

Copied

Using an "addEventListener" for "mouseover" I am trying to chnage the (z-index) move to the front this.ball_ani_1 when mouseover of this.ball_ani_1.ball_graphic_outer_frame1.ball_graphic_text.hotspot

 

 

this.ball_ani_1.ball_graphic_outer_frame1.ball_graphic_text.hotspot.addEventListener("mouseover", ballMouseOver1.bind(this));

function ballMouseOver1()
{
	this.setChildIndex( ball_ani_1, this.numChildren()-1);
}

 

 

Any help much appriciated 🙂

TOPICS
Code , How to

Views

164

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

Hi.

 

There are a few problems in your code:
1 - The first argument in the setChildIndex method should be this.ball_ani_1;
2 - numChildren is a property and not a method;

3 - You should subtract 1 from numChildren and not add 1;
4 - For hover interactions to work, you need to call stage.enableMouseOver() if there are no Button symbol instance anywhere in your code;
5 - Even if you have one frame in your timeline, you need to call this.stop() so that changes in depth will take effect.

function ballMo
...

Votes

Translate

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

Copy link to clipboard

Copied

Hi.

 

There are a few problems in your code:
1 - The first argument in the setChildIndex method should be this.ball_ani_1;
2 - numChildren is a property and not a method;

3 - You should subtract 1 from numChildren and not add 1;
4 - For hover interactions to work, you need to call stage.enableMouseOver() if there are no Button symbol instance anywhere in your code;
5 - Even if you have one frame in your timeline, you need to call this.stop() so that changes in depth will take effect.

function ballMouseOver1()
{
	this.setChildIndex(this.ball_ani_1, this.numChildren - 1);
}

stage.enableMouseOver(50);
this.stop();
this.ball_ani_1.ball_graphic_outer_frame1.ball_graphic_text.hotspot.addEventListener("mouseover", ballMouseOver1.bind(this));


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

Copy link to clipboard

Copied

Thanks JC, you explained this very well 🙂

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

Copy link to clipboard

Copied

LATEST

Nice!


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