A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] buttons to stay in down state after clicked

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    9

    resolved [RESOLVED] buttons to stay in down state after clicked

    I am trying to get buttons to stay in the down state after it is clicked and remain there. I want the user to know what buttons they have clicked. I am using flash 8. Here is code:

    my1_btn.onPress = function () {
    gotoAndStop("down");
    };
    my2_btn.onPress = function () {
    gotoAndStop("down");
    };
    my3_btn.onPress = function () {
    gotoAndStop("down");
    };
    my4_btn.onPress = function () {
    gotoAndStop("down");
    };
    my5_btn.onPress = function () {
    gotoAndStop("down");
    };

    the down state works when pressed but doesn't stay.

  2. #2
    Getting There! bitsk308's Avatar
    Join Date
    Jul 2000
    Location
    Phoenix, AZ
    Posts
    427
    gotoAndStop is not a method of the button class. try making your buttons into movie clips, control the rollOver/Out and press/release functionality with AS just like you're doing above, and either label frames in the mcs or just use frames one two and three (maybe four). You'll then have to break the onRollOut function (which resets the mc too the original state) as part of your onRelease function.

    _b

  3. #3
    Junior Member
    Join Date
    May 2008
    Posts
    9
    I tried with movie clips but using the same code and instance names but I still cannot get them to stop on the down state
    Last edited by msanbo; 05-08-2008 at 02:20 PM.

  4. #4
    Senior Member Ovaire d'Oz's Avatar
    Join Date
    May 2006
    Location
    France
    Posts
    148
    I am not sure about this one, but have a try with this:
    PHP Code:
    mybtn.onPress = function(){
        
    this.gotoAndStop("down");


  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    // on stage - 3 movieclips - instance names clip0,clip1,clip2
    // each clip has 3 frames
    // frame#1 - stop(); - frame label _up
    // frame#2 - frame label _over
    // frame#3 - frame label _down

    // code on main timeline

    clipArray = [clip0,clip1,clip2]; // array holds the clip instance names 

    function downState(mc){
    for(var 
    n=0;n!=clipArray.length;n++){
    clipArray[n].gotoAndStop("_up"); // send all to up-state
    clipArray[n].enabled true// make all enabled
    }
    mc.gotoAndStop("_down"); // send pressed clip to down-state
    mc.enabled false// make pressed clip disabled
    };

    // each clip sends its instance name to the function
    clip0.onRelease = function(){ downState(this); };
    clip1.onRelease = function(){ downState(this); };
    clip2.onRelease = function(){ downState(this); }; 
    hth

  6. #6
    Junior Member
    Join Date
    May 2008
    Posts
    9
    a_modified_dog that works great but when I click the button to send it to another frame with the button still on frame it returns to up state and is inactive i want it to stay in down state throughout timeline

  7. #7
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    seems to work in this file

    how does your file differ ?
    Attached Files Attached Files

  8. #8
    Junior Member
    Join Date
    May 2008
    Posts
    9
    i want once they are clicked whether any other button is clicked to stay in down state so in your example if you go from frame 1-2-3-4 at frame 4 all buttons would be red because they all have been clicked I have it set up now like your

  9. #9
    Junior Member
    Join Date
    May 2008
    Posts
    9
    I figured it out you are the man thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center