Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Chane Button Color On press Actionscript

Posted on 2004-08-25
5
Medium Priority
?
316 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
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…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

722 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