Skip to main content
Known Participant
January 12, 2010
Question

How can I leave a button pressed?

  • January 12, 2010
  • 1 reply
  • 636 views

Hello, world...

I need to be pushed a button after I selected it. In other words, I want the button remains down...

Please, help me...

Emiliano.

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
January 12, 2010

You can either create it as a movieclip and have complete control as to which frame it lands/stays on under whatever circumstances or you can change the state of the button in its CLICK event handler function using...  btn.upState = btn.downState; ... where btn is whatever instance name you assign to the button.

Known Participant
January 13, 2010

Hi, Ned Murphy...

First...Happy New Year...

I tried your advice but it doesn't work...

I wrote:

import fl.controls.Button;

private var Btn1:Button;

Btn1 = new Button ();
Btn1.move(160,135);
Btn1.setSize(30,30);
Btn1.label = "S";
Btn1.addEventListener (MouseEvent.CLICK,select);
addChild (Btn1);

private function select (e:MouseEvent)
        {
            Btn1.upState = Btn1.downState;
        }

I have these errors:

1119: Accesso a una proprietà non definita downState mediante un riferimento con tipo statico fl.controls:Button.

1119: Accesso a una proprietà non definita upState mediante un riferimento con tipo statico fl.controls:Button.

I'd like to have 3 Buttons. When I press one of them it is held down and the other two remain up.Only one Button can be pressed for time...

I can't use RadioButtons because I have problems with FMS using them (when I load this .swf into another .swf, I can see only the RadioButton.label but not the RadioButton itself, like you can see from the image attached)...

Please, help me...

Emiliano.

Ned Murphy
Legend
January 13, 2010

The state change control is a feature that applies to SimpleButton objects (buttons you create yourself), not Button components--this is something new that came with AS3, earlier versions had no provision for controlling button states.  You'll either have to create your own buttons if you want to use the "State" property controls or use a movieclip and control which frame is presented when.