Copy link to clipboard
Copied
Hi guys, i'm new at code writing
i made a drop down menu now i want to make buttons stay down state until i click another button
here is my code :
concept1btn.visible = false;
concept2btn.visible = false;
concept3btn.visible = false;
concept4btn.visible = false;
concept5btn.visible = false;
concept6btn.visible = false;
this.addEventListener(MouseEvent.MOUSE_OVER,drop);
this.addEventListener(MouseEvent.MOUSE_OUT,up);
this.addEventListener(MouseEvent.MOUSE_DOWN,down);
function drop(e:MouseEvent) {
concept1btn.visible = true;
concept2btn.visible = true;
concept3btn.visible = true;
concept4btn.visible = true;
concept5btn.visible = true;
concept6btn.visible = true;
}
function up(e:MouseEvent) {
concept1btn.visible = false;
concept2btn.visible = false;
concept3btn.visible = false;
concept4btn.visible = false;
concept5btn.visible = false;
concept6btn.visible = false;
}
function down(e:MouseEvent) {
concept1btn.upState = concept1btn.downState;
concept1btn.overState = concept1btn.downState;
what else should i add ???
}
If you are using the button symbol then you don't really have control over the state of the button. That's controlled by the button symbol itself, the up, over and down states are built in. In order to get "latching" buttons, you'll have to use a movieClip instead of a button and then use Actionscript to change the way that the button looks to the user. There are a couple of different ways to accomplish this. Here's a link to some different ways to do this that I wrote some years' ago: Flash latching buttons
...Copy link to clipboard
Copied
Use Boolean var and upState & downState properties:
var _down: Boolean = true;
var buttonUp: DisplayObject = my_btn.upState; //store the upState to use it again
function checkStatus(): void {
if (_down == true) {
my_btn.upState = my_btn.downState;
_down = false;
}
else {
my_btn.upState = buttonUp;
_down = true;
}
}
my_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event: MouseEvent): void {
checkStatus();
}
Copy link to clipboard
Copied
If you are using the button symbol then you don't really have control over the state of the button. That's controlled by the button symbol itself, the up, over and down states are built in. In order to get "latching" buttons, you'll have to use a movieClip instead of a button and then use Actionscript to change the way that the button looks to the user. There are a couple of different ways to accomplish this. Here's a link to some different ways to do this that I wrote some years' ago: Flash latching buttons
I hope this helps.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now