Solved

Button Clicked to remain on "Down State"

Posted on 2004-03-25
5
352 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 175 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 175 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SWF won't scale? 4 518
HTML 5 or Flash 7 475
Crash with shockwave flash 8 228
Script to Delete registry entry based on Product name 6 145
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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…
The goal of the tutorial is to teach the user how to how to record live broadcast.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

705 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now