Skip to main content
Inspiring
June 12, 2021
Question

How do I make my "Go to frame and play " button work with advanced layers on?

  • June 12, 2021
  • 1 reply
  • 1122 views

Hello there, I hope anyone can help me with this as I can't seem to find a solution anywhere at all on the internet for such a simple problem. I have a button on its own layer called rock_button_layer, and the code snippet on the button "go to a frame and play". Here is the code.

Rock_button1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_8);

function fl_ClickToGoToAndPlayFromFrame_8(event:MouseEvent):void
{
gotoAndPlay(1560);
}

I need to keep advanced layers on as its important for my animation. All I want is for my button to work and I just can't seem to rack my brain over how to change the code with advanced layers on.

I hope someone can explain this to me please, thank you.

This topic has been closed for replies.

1 reply

JoãoCésar17023019
Community Expert
Community Expert
June 12, 2021

Hi.

 

What version of Animate are you using?

 

In the most recent versions, you should be able to reference any instance directly, with or without using the advanced layers mode.

 

In older versions, you're gonna need to referece the layer that contains the instance first. For example:

import flash.display.MovieClip;
import flash.display.SimpleButton;

var layer:MovieClip = getChildByName("Layer_1") as MovieClip;
var button:SimpleButton = layer.getChildByName("Rock_button1") as SimpleButton;

button.addEventListener(MouseEvent.CLICK, clickHandler);

function clickHandler(event:MouseEvent):void
{
	gotoAndPlay(1560);
}

 

Please let us know if this helps.

 

Regards,

JC

Inspiring
June 12, 2021

Thank you so much for you reply!

I am using Adobe Animate version 20.0.3

I just used your code but replaced layer_1 with rock_button_layer as thats what the layer is called with the button. However, It doesnt seem to play when I click then button. Do you know why this is the case? I even changed to go to frame 1561 but the button still doesnt play.

If looking at my adobe animate file would help, here it is  but it is 294mb: https://drive.google.com/file/d/1irAke5ZBrdaJBbk0NpBB2FugqQMLCicO/view?usp=sharing


JoãoCésar17023019
Community Expert
Community Expert
June 12, 2021

I have updated the file to be shared to anyone with the link. The code I am looking at is at fram 1559. Thank you so much for your help man.


Thanks.

 

Do you have a simplified version of this file?

 

It seems my humble notebook cannot open your FLA. Haha

 

The opening process has not gone beyond 10% so far.

 

I just need the code and the button in frame you mentioned.

 

Regards,

JC