Skip to main content
adama37276094
Participant
October 30, 2015
Answered

how can i make button stay down state when i click it ? Help please

  • October 30, 2015
  • 2 replies
  • 1272 views

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 ???

}

This topic has been closed for replies.
Correct answer robdillon

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.

2 replies

robdillon
robdillonCorrect answer
Participating Frequently
October 30, 2015

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.

Inspiring
October 30, 2015

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();

}