Solved

Button Clicked to remain on "Down State"

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

803 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