Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Oct 30, 2015 Oct 30, 2015

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

}

TOPICS
ActionScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 30, 2015 Oct 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

...
Translate
Enthusiast ,
Oct 30, 2015 Oct 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();

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 30, 2015 Oct 30, 2015
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines