Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Chane Button Color On press Actionscript

Posted on 2004-08-25
5
Medium Priority
?
320 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
ID: 11897530
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
ID: 11897639
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
ID: 11900281
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 100 total points
ID: 11900332
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
ID: 11900936
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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 how to record live broadcast.
Suggested Courses

773 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