0
votes

Firstly, I have seen many threads about this question but all was about create Toggle button in MovieClip not in Button symbol. I've created Button symbol in Flash Pro. I defined Up And Over And Down specific states for each of those.

The question is :

How can i create a toggle button with Button symbol.

P.S :

I'm not talking about create that via MovieClip, i can do it through MovieClip but i need to do that via Button symbol. Like below : (MovieClip)

var flag:Boolean = false;
myBtn.stop();
myBtn.addEventListener(MouseEvent.CLICK, clicked);

function clicked(evt:MouseEvent):void {
    if (flag) {
        myBtn.gotoAndStop(1);
    } else { 
        myBtn.gotoAndStop(2);
    }
    flag = !flag;
}

Any ideas would be appreciated.

1
You can't. A button just has the 3 different states + hit zone. So other than creating an extra movieclip in your button and showing / hiding that is not possible.putvande
So, is there any way to stay on OnMouseDown state in Button ?Hamed Kamrava
I added an answer below, but I'm curious why you NEED it to be a Button instead of MovieClip. Just wondering.Cadin

1 Answers

0
votes

You can try swapping around the downState and upState DisplayObjects when the user clicks the button.

Something like this:

function clicked(evt:MouseEvent):void {
    var oldUpState:DisplayObject = myBtn.upState;
    myBtn.upState = myBtn.downState;
    myBtn.downState = oldUpState;
}