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

x
?
Solved

Button Clicked to remain on "Down State"

Posted on 2004-03-25
5
Medium Priority
?
366 Views
Last Modified: 2008-02-26
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.
0
Comment
Question by:bisonfur37
5 Comments
 
LVL 2

Assisted Solution

by:SandyCooke
SandyCooke earned 700 total points
ID: 10683494
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
 
LVL 2

Author Comment

by:bisonfur37
ID: 10689845
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
 
LVL 2

Expert Comment

by:SandyCooke
ID: 10690351
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
 
LVL 22

Expert Comment

by:rascalpants
ID: 10706097
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
 
LVL 1

Accepted Solution

by:
dub2k earned 700 total points
ID: 10709142
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

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