Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-08-2004, 06:57 AM   #1
eroteme
Registered User
 
Join Date: Jun 2004
Posts: 68
Default How to make a button stay down after its clicked

After seeing many sites I wonder how do you make the button stay in the down state or whatever after its clicked. I always do my buttons as MC with some actionscripting behind them but really have no clue about how to go about this. For an example incase anyone doesn't know what I mean :
http://www.halfwayempty.com/u/tran/index.html
If you click one of the buttons, you obviously know which button you are on. How would I go about this, thanks!!
eroteme is offline   Reply With Quote
Old 10-08-2004, 02:08 PM   #2
Shanthony
Registered User
 
Join Date: May 2004
Posts: 10
Default

I would just use it as a movie clip and make the downstate a different frame and put an action on it that says when the other frames are clicked to leave the frame where it is down.
Shanthony is offline   Reply With Quote
Old 10-08-2004, 03:49 PM   #3
eroteme
Registered User
 
Join Date: Jun 2004
Posts: 68
Default

makes sense still havent gotten the hang of AS any examples of this or tutorials you know of ? Its a really nice things to implement, just really confusing for me on how to execute it, thanks.

*EDIT* MODS I didnt mean to post in AS 2.0 didn't realize it, I wanted this for AS1 so can this be moved to Flash MX Actionscript forum ? Thanks.

Last edited by eroteme; 10-08-2004 at 04:20 PM.
eroteme is offline   Reply With Quote
Old 10-08-2004, 06:58 PM   #4
woodjer
Registered User
 
Join Date: Sep 2004
Posts: 9
Default

dude. the easiest way is to change the type of symbol your button will be treated as. In the frame that you want your button to stay selected, click on the button once, go into the properties panel and change your symbol from button to graphic for that frame only. Make sure that you have set key frames in front and behind the current frame so you don't lose anything attached to the button [like AS]. So, next to that pull down, you can set which frame will show as the graphic - you will select frame 2 for over, frame 3 for down, and frame 4 for hit. You could give your button like 20 frames if you wanted.
Anyway, that is totally quick and easy and nasty.

some sites I have done this on:
http://www.compsnow.com
http://www.suu.edu/prostu/international.html [the box on the bottom right]

Last edited by woodjer; 10-08-2004 at 07:01 PM. Reason: forgot some links
woodjer is offline   Reply With Quote
Old 10-08-2004, 07:58 PM   #5
rossbruniges
Registered User
 
rossbruniges's Avatar
 
Join Date: Apr 2004
Posts: 28
Default

heya dude, this is something that i code loads of times at work!

the way i do it is to create easch button as a movieClip with one frame (labeled "normal) for your normal state and another (labelled "select" as your hit state)

i then using a nice for loop i assign handlers to all the buttons like so

Code:
for (var i:Number = 0; i < NumberOfButtons; i++) {
     // this will assign button release events for all the buttons assuming they are called button1, button2 and so on...
     this["button"+i+"_mc"].onRelease = function() {
         enableAll(); // i will explain this later
         this.gotoAndStop("select"); // this will send the clicked button to its selected state
         .this.enabled = false; // this prevents any rollout
         // put whatever you want the button to do here
     }
}
you can also assign rollovers and stuff in this loop to, but you don;t need to see that here!!

the enableAll function basicly resets everything, so any button that may have been disabled and sent to the "select" frame will act normally again....i set up the enableAll() function like this....

Code:
function enableAll():Void {
     for (var i:Numer = 0; i < NumberOfButtons; i++) {
          this["button"+i+"_mc"].enabled = true;
          this["button"+i+"_mc"].gotoAndStop("normal");
     }
}
well this works a treat for me everytime!

good luck with your coding, if you need anymore hints then please ask!

Last edited by rossbruniges; 10-08-2004 at 08:01 PM.
rossbruniges is offline   Reply With Quote
Old 10-08-2004, 10:36 PM   #6
eroteme
Registered User
 
Join Date: Jun 2004
Posts: 68
Default

Thanks guys for replies I appreciate it, im gonna try both examples out and see what happens. I'll let all you know if there is any problems, thanks again!
eroteme is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:33 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.