Solved

Chane Button Color On press Actionscript

Posted on 2004-08-25
5
269 Views
Last Modified: 2012-05-05
How do I using Actionscript change the color of a button onPress? I have made the button and it has an over,up,down, and hit state, but I need to set its colour onPress. How is this done?  

0
Comment
Question by:jandhb
5 Comments
 
LVL 10

Expert Comment

by:muso120999
Comment Utility
That's just the colour you set it to on the "down" frame (they are the same!).

or...

If you want the colour to change, and stay that colour when you release the mouse, then create a movieclip with 2 frames (frame 2 with the "onPress" colour) and put the code...

stop();

... in frame 1, and then call the movieclip something like "myButton"

and now put the following code on the new movieclip instance:

on(press){
      gotoAndStop(2);
}
0
 
LVL 1

Author Comment

by:jandhb
Comment Utility
Maybe it would help to see what I have so far...

http://www.glennon.org/2004tour/tour.htm

When you click on say, "Ground" or any Floor for that matter I want it to stay that blue color so the user knows what floor they are on. How do I do that?


0
 
LVL 16

Expert Comment

by:ellandrd
Comment Utility
does your btn change events have to be in actionscript? why not just create a button and have your different colors for each event that way??

its much easier than trying to use actionscript...

0
 
LVL 10

Accepted Solution

by:
muso120999 earned 25 total points
Comment Utility
Okay, then I guess the simplest way (least coding) is to have 2 buttons (1 highlighted, and one normal), and when you click on "Ground" jump in the timeline to where you have the "highlighted" version.

or...

If you can't extend the timeline in this way for some reason, then you can make the "up" state of your button transparent (keep the text), and put a movieclip underneath (call this movieclip "highlight_ground", for example) and use the same 2 frame method as above...

You can then add the "on(press)" as above, but use code like this on the "ground" button (remember, the movieclip is behind it):
on(press){
     _root.highlight_ground.gotoAndStop(2);// go to the highlighted state
     _root.highlight_floor1.gotoAndStop(1);// go to the normal state
     _root.highlight_floor2.gotoAndStop(1);// go to the normal state
     _root.highlight_floor3.gotoAndStop(1);// go to the normal state
     _root.highlight_info.gotoAndStop(1);// go to the normal state
}

and for each of the buttons change the appropriate gotoAndStop to a 2.

Both ways you can use the normal functionality of the button, and have the highlight too.  There are other methods, but I feel these are the simplest.
0
 
LVL 39

Expert Comment

by:blue-genie
Comment Utility
a quick and easy would be to create a six frame movieclip, with movieclips instead of buttons - , where frame 1 is where nothing is selected, frame2 - ground is selected (i.e. blue) etc. - then name your movieclips intelligently, ie. button_01, button_02 etc so you can use a loop to reset if necessary, and to have 1 generic function to navigate.

blu.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now