Using Buttons to change other objects' images

New Here ,
Feb 26, 2021 Feb 26, 2021

Copy link to clipboard

Copied

Hello, I'm attempting to put together a small animate project for my finals in college, and I've run into a massive roadblock with one specific function.

I want to be able to have a button's graphic change based on a button press.

The current system is as stands: In frame 0 there is the title, the instructions, and four buttons, three of which bring up additional content. All three of these will present the user with choices, where when you choose any of them, or the main menu button, it returns you to frame 0. However, I want the choices you have (AKA the buttons attached to those choices) to change the image of the button you originally pressed.

IE: >Click WorldChoiceButton; >Opens Menu; >Click PeacefulButton; >Changes image under WorldChoiceButton's frame to Peaceful.jpg

but I can't figure out what to do here to make this work. At first, I wanted to try changing the whole symbol used for the Buttons entirely, but then I decided to leave the button as a frame, with transparency in the middle, and place a Graphic symbol in the transparent space, and try using actions within the symbol to change the frame based on a global variable. Issue is, I don't know how to call on global variables in the script in Animate, and I everything I've attempted has caused some fatal error in the html code and it won't display in-browser as long as the code remains in place.

Views

109

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Mar 08, 2021 Mar 08, 2021
you're coding it wrong. but i'm not sure what the correct coding should be because i don't know the timeline containing the code and i don't know what you're trying to reference with code. but if you're trying to direct moveiclip mc (that's on the timeline with the code) and you're trying to direct it to a frame (label or number) stored in FrameName and FrameName is defined on mc's timeline, use: this.mc.gotoAndStop(this.mc.FrameName);

Likes

Translate

Translate
Adobe Community Professional ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

html5/canvas or as3?

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
community guidelines
New Here ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

Html5

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
community guidelines
Adobe Community Professional ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

use movieclip buttons and put the images you want to use on the various movieclip buttons' timeline (with a this.stop() in the first frame).  you can then use code to determine which frame to display on each moveiclip button timeline.

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
community guidelines
New Here ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

That's what I'm attempting to do, but I don't know how to link actions inside of a movieclip to outside variables. I have it set up to the point where I have the stop action on each frame of the movieclip, and the separate images within each frame, but I can't figure out how to make the button press affect the movieclip's frames.

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
community guidelines
Adobe Community Professional ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

one way would be to label each frame in each movieclip button timeline and use the variable's value directly.

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
community guidelines
New Here ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

What do you mean by that? I'm not quite sure how that would fix the issue. Because a variable inside of the movieclip is one thing, but then I'd still need to find a way to affect that variable using the button outside of said movieclip. 

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
community guidelines
Adobe Community Professional ,
Feb 27, 2021 Feb 27, 2021

Copy link to clipboard

Copied

you can reference a variable (eg, framename) inside a movieclip (eg, mc) by using

 

mc.framename

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
community guidelines
New Here ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

Sorry for the delay, another final took priority for the moment. I'm now back to working on the issue, and any attempts to call the variables in actions isn't working.

I've tried multiple versions of this code, ranging from attempting

mc.[MovieClipName].gotoAndStop([FrameName]);
to
_this.gotoAndStop(mc.[FrameName]);
And nothing has yielded results in changing the active frame in the movieclip. Am I simply coding it wrong or would I need to put it in a separate check than the _this.gotoAndStop(0); action under the check for _this.[Button].on('click', function(){})?

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
community guidelines
Adobe Community Professional ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

you're coding it wrong.

 

but i'm not sure what the correct coding should be because i don't know the timeline containing the code and i don't know what you're trying to reference with code.

 

but if you're trying to direct moveiclip mc (that's on the timeline with the code) and you're trying to direct it to a frame (label or number) stored in FrameName and FrameName is defined on mc's timeline, use:

 

this.mc.gotoAndStop(this.mc.FrameName);

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
community guidelines
New Here ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

Okay, so you are right, but the issue I was having was that I wasn't labeling the movieclip so I couldn't call on the clip's framelabels. I now have it working, and can finally finish my project. I'm elated! Thank you for your patience with me, and for your help in guiding me towards this answer.

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
community guidelines
Adobe Community Professional ,
Mar 08, 2021 Mar 08, 2021

Copy link to clipboard

Copied

LATEST

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
community guidelines