Button Clicked to remain on "Down State"

I would like a button to remain as its Down State when clicked by the user. I would like the frame to remain the same otherwise (with the button in its down state and all other objects as they were). This is for the case taht I have a menu of options, all buttons, and I want the user to be able to select any or all options, with the Down State signifying that they have selected that option.

Also, I would like to have the user be able to "deselect" the button, or click on the static bown state of the button and return it to its normal functioning (Off, Over, Down). Please inform of the correct action script or basic command to do this.
LVL 2
bisonfur37Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
dub2kConnect With a Mentor Commented:
A movieclip with a invisible button in it should do it.  You cant make a button change frame to my knowledge.. only movieclips. Besides, you dont need to.

I'm going to assume next to no knowledge of flash, so any1 can do this...

(This is for Flash MX/PC btw.. not done much with 2k4 yet)

Draw a square, select the square + lines (double click), and make it a button (f8). Call it "invisbtn".  Double click on it (Edit in Place), the first frame of the layer should be highlighted(black), drag it to the hit state of the layer.  This is basically an invisible button.

Go back to your main timeline, select the button and create a movie clip(f8).  

Edit the mc, create a new layer under the button, put the normal state of the button on the first frame, the mouse over state on the second frame, then the selected state in third.  Add two blank frames to the invisible buttons layer so it will be active on all states.  Position the invisible btn cyan box over your button graphics, select it, and add the following code on it:

on (rollOver) {
      if (_currentframe == 1) {
            this.gotoAndStop(2);
      }
}
on (rollOut) {
      if (_currentframe == 2) {
            this.gotoAndStop(1);
      }
}
on (release) {
      if (_currentframe != 3) {
            this.gotoAndStop(3);
            //other actions that you want button to do here
      } else {
            this.gotoAndStop(2);
      }
}

Just replace the comment with whatever action you wanted the button to do (remembering that the button is in a movieclip .. so the "path" to objects is different eg. to tell the main timeline to gotoAndPlay for example, it would be _root.gotoAndPlay(x); ...)

Finally, select the first frame of the invisible button layer, and add a stop action to that frame.

Tadaa.. one button :)

An example of that in action can be found at:  http://viewmy.info/ee/Q_20932511/    

I'm not going to provide fla yet tho.. it took me 20 times longer to write this than it did to make the button :)
0
 
SandyCookeConnect With a Mentor Commented:
I don't think you can make a button stop on its 'down' state, so you'll have to improvise:

1) Instead of creating a button, create a movieclip.
2) On the first frame put a stop action and the image/text/whatever for your 'up' state.
3) On the second frame put a stop action and the image/text/whatever for your 'over' state.
4) On the third frame put a stop action and the image/text/whatever for your 'down' state.

5) Put the following code on the movieclip:

onClipEvent(load){

this.onRollover = function() {
if (isSelected == false) {
this.gotoandStop("2");
};
};

this.onRollout = function() {
if (isSelected == false) {
this.gotoandStop("1");
};
};

this.onRelease = function() {
if (isSelected == false) {
this.gotoandStop("1");
} else {
this.gotoandStop("3");
};
isSelected = !isSelected;
};

Sandy
0
 
bisonfur37Author Commented:
This seems like a good idea, but I cannot get the movie to react to anything. Namely, when I follow your instructions, the movie clip is static, and does not change (react to mouse over or click down). Please inform how to make the movie clip act as required.
0
 
SandyCookeCommented:
onClipEvent (load) {
      //
      isSelected = false;
      //
      this.onRollOver = function() {
            if (isSelected == false) {
                  gotoandStop(2);
            }
      };
      //
      this.onRollOut = function() {
            if (isSelected == false) {
                  gotoandStop(1);
            }
      };
      //
      this.onPress = function() {
            if (isSelected == false) {
                  gotoandStop(3);
            } else {
                  gotoandStop(1);
            }
            //
            isSelected = !isSelected;
      };
}
0
 
rascalpantsCommented:
you might also do a search for a component that does that same thing...  I am sure someone out there has used the same technique and developed something to share...

try the Extensions area of the MM web site...

rp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.