Skip to main content
lcg_2012
Inspiring
November 27, 2016
Answered

gotoAndPlay MovieClip

  • November 27, 2016
  • 2 replies
  • 5058 views

I have a button on the top layer of my Adobe Animate CC 2017 Canvas file the instance name is "btn_Button01". I have this ClickTag code which is working on the Actions layer:

this.btn_Button01.addEventListener("click", fl_ClickToGoToWebPage);

function fl_ClickToGoToWebPage() {

  window.open(window.clickTag);

}

Further down the timeline, a movieclip with an instance name "btn_Button02" fades in UNDER the button. I want to move the playhead of the movieclip when the button is rolled over. So, rollover btn_Button01 and btn_Button02 will gotoAndPlay "over". I have tried this code but it is not working. I am not sure the proper syntax to control the playhead of a movieclip when a button is rolled over. Any help would be appreciated.

stage.enableMouseOver;

this.btn_Button01.addEventListener("mouseover", fl_MouseOverHandler.bind(this));

this.btn_Button01.addEventListener("mouseout", fl_MouseOutHandler.bind(this));

function fl_MouseOverHandler()

{

  this.btn_Button02.gotoAndPlay("over");

}

function fl_MouseOutHandler()

{

  this.btn_Button02.gotoAndPlay("off");

}

This topic has been closed for replies.
Correct answer just.emma

I do have instance names on the keyframes. Have you looked at my .fla?


Yes, I looked at your Fla; that's how I know that you don't have an instance name on both keyframes.

You have an instance name on frame 164, but not frame 151.  You need to have a matching instance name on both keyframes.

2 replies

just.emma
Inspiring
November 28, 2016

The code that you original posted in this thread was fine.  It should still be:

this.btn_Button01.addEventListener("mouseover", fl_MouseOverHandler.bind(this));

this.btn_Button01.addEventListener("mouseout", fl_MouseOutHandler.bind(this));

Not what's currently in your file:

this.btn_Button01.addEventListener("mouseover", fl_MouseOverHandler.bind(this.btn_Button02));

this.btn_Button01.addEventListener("mouseout", fl_MouseOutHandler.bind(this.btn_Button02));

You also need to have an instance name on both keyframes of your button in the main timeline.

lcg_2012
lcg_2012Author
Inspiring
November 28, 2016

When I use the code in green, it doesn't work. Not in my actual banner or the test one I shared. When I click CMD-Return to view the animation.

just.emma
Inspiring
November 28, 2016

You also need to have an instance name on both keyframes of the button symbol on the main timeline.  That was your other problem.

just.emma
Inspiring
November 27, 2016

For this to work, you need to add frame labels for the"over" and "off" animation frames.  Here is some basic information about frame labels: Use frames and keyframes in Adobe Animate CC

You also need parenthesis in stage.enableMouseOver();but if you have any button symbols you don't actually need to include enableMouseOver at all, because it will be automatically generated in the HTML.

lcg_2012
lcg_2012Author
Inspiring
November 28, 2016

I am using frame labels. I added the parenthesis but the problem persists. This would work fine with ActionScript. Having trouble getting used to this new scripting syntax. The banner ad needs to be HTML5.

So just to be clear, I am rolling over a button. When rolled over, I want to gotoAndPlay a label of another movieclip on the main timeline that is beneath the button layer.

just.emma
Inspiring
November 28, 2016

Yes.  The syntax is fine and should work as you described. 

If you're still experiencing issues, please share a copy of your Fla file using Box, Dropbox, Google Drive, or something similar to make troubleshooting easier.