Highlighted

Buttons not working correctly in Animate CC 2019

Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

I've encountered issues with the functionality of buttons in Adobe Animate CC 2019 (Build 326) and am curious if anyone else is having the same problem or knows how to resolve the issue. What I've found is that if I create and add AS3 script for a button, it works fine if it is on the first frame. If you move the button and accompanying frame script off of the first frame, to say frame 2 or 10 or 20, it fails. Sometimes it throws an "access of undefined property buttonInstanceName" error (even though the button is correctly named and present on the same frame as the script) and sometimes it makes the rollOver states wacky and ceases to function. Strangely, when I open old projects in 2019, they function fine. But, if I copy the layers from an old project to a new document created in 2019, it fails. I can't figure out what is going wrong and any advice/assistance would be appreciated.  I made this video documenting the issue if you'd like to see what I am talking about: buttonProblems - YouTube

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

disable 'use advanced layers' in the document settings (modify>document).

TOPICS
Discussions

Views

5.7K

Likes

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

Buttons not working correctly in Animate CC 2019

Community Beginner ,
Nov 16, 2018

Copy link to clipboard

Copied

I've encountered issues with the functionality of buttons in Adobe Animate CC 2019 (Build 326) and am curious if anyone else is having the same problem or knows how to resolve the issue. What I've found is that if I create and add AS3 script for a button, it works fine if it is on the first frame. If you move the button and accompanying frame script off of the first frame, to say frame 2 or 10 or 20, it fails. Sometimes it throws an "access of undefined property buttonInstanceName" error (even though the button is correctly named and present on the same frame as the script) and sometimes it makes the rollOver states wacky and ceases to function. Strangely, when I open old projects in 2019, they function fine. But, if I copy the layers from an old project to a new document created in 2019, it fails. I can't figure out what is going wrong and any advice/assistance would be appreciated.  I made this video documenting the issue if you'd like to see what I am talking about: buttonProblems - YouTube

Adobe Community Professional
Correct answer by kglad | Adobe Community Professional

disable 'use advanced layers' in the document settings (modify>document).

TOPICS
Discussions

Views

5.7K

Likes

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
Nov 16, 2018 2
Adobe Community Professional ,
Nov 17, 2018

Copy link to clipboard

Copied

disable 'use advanced layers' in the document settings (modify>document).

Likes

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
Reply
Loading...
Nov 17, 2018 1
Community Beginner ,
Nov 17, 2018

Copy link to clipboard

Copied

Thank you!  I didn't realize advanced layers turned all layers into symbols. While turning it off works, I'd still like to know how to get the functionality I want while maintaining advanced layers, but it does seem like advanced layers confounds or complicates some simple scripting for basic interactivity.

It seems that if you don't instantiate a button on frame 1, its button states (over, down) don't function correctly. Move any button off of the first frame, to frame 10 let's say, and you will not be able to see the "over" state on rollOver (although it seems to flash for a brief instant), regardless of any ActionScript you may have. Beyond this, let's say I wanted to get this simple AS3 code to work on a button or movieclip:

play_btn.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e) {

    trace("play");

}

Using advanced layers, I can access the layer symbol with:

var myLayer = MovieClip(getChildByName("Layer_1"));

Then, I can access the button within it, using:

var myButton = myLayer.getChildByName("play_btn");  // or simply myLayer.play_btn

But, while this doesn't throw any errors, it does not work:

myButton.addEventListener(MouseEvent.CLICK, onClick);

function onClick(e) {

    trace("play");

}

Any advice on how to get this code (and/or any button or movieclip that does not reside on frame 1) to work?

Likes

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
Reply
Loading...
Nov 17, 2018 0
Adobe Community Professional ,
Nov 17, 2018

Copy link to clipboard

Copied

put the code in frame 1 along with your button and use the button's visible property to toggle when it's seen and clickable.

or put a stop() in the frame where you have your button code that uses the layer as the button's parent.

or extend the button's layer, at least, one frame beyond the frame that contains a stop().  ie, the last frame of the button's layer causes a problem, if that's when you click your button.

Likes

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
Reply
Loading...
Nov 17, 2018 0
Community Beginner ,
Nov 17, 2018

Copy link to clipboard

Copied

Thanks. Yes, I had thought of the work-around of simply hiding and showing the button and that works. I did have a stop() action in the frame with the button/code, but that doesn't matter. However, extending the button's layer by one frame does then make the code and button work (I don't quite understand why, however). Same goes for working with movieclips. Thanks for your help.

Likes

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
Reply
Loading...
Nov 17, 2018 0
Adobe Community Professional ,
Nov 17, 2018

Copy link to clipboard

Copied

you're welcome.

Likes

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
Reply
Loading...
Nov 17, 2018 0
New Here ,
Jun 06, 2019

Copy link to clipboard

Copied

if i turn off advanced layers alpha doesn't work anymore? so is there another solution?

Likes

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
Reply
Loading...
Jun 06, 2019 0
Adobe Community Professional ,
Jun 06, 2019

Copy link to clipboard

Copied

stijnr1701  wrote

if i turn off advanced layers alpha doesn't work anymore?

No.

Likes

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
Reply
Loading...
Jun 06, 2019 0
New Here ,
Jun 06, 2019

Copy link to clipboard

Copied

Well yes it does. I turned it off and the object in a layer with a classic tween to make them slowly invisible with the alpha function did not become transparant at all. It was not actually a question it was a determination

Likes

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
Reply
Loading...
Jun 06, 2019 0
Adobe Community Professional ,
Jun 06, 2019

Copy link to clipboard

Copied

Works fine for me. Maybe try removing and re-adding the tween.

Likes

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
Reply
Loading...
Jun 06, 2019 0
New Here ,
Sep 29, 2019

Copy link to clipboard

Copied

I'm seeing the same thing; buttons all work correctly when I test in the browser, but then the buttons DON'T work (no rollover state, clicks don't work, etc) when I open the HTML file in a browser (any browser). I tried turning off "Advanced Layers", but still no dice. Thoughts?

Likes

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
Reply
Loading...
Sep 29, 2019 0
kglad LATEST
Adobe Community Professional ,
Sep 30, 2019

Copy link to clipboard

Copied

check the browser console for errors. and create a new thread because it's not even clear what you're doing that's similar to the op and what's different.

Likes

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
Reply
Loading...
Sep 30, 2019 0