Skip to main content
Inspiring
June 12, 2021
質問

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

  • June 12, 2021
  • 返信数 1.
  • 1122 ビュー

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.

このトピックへの返信は締め切られました。

返信数 1

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

Sure! Please allow me to access the file.