Question about hide button on click or show

125 views Asked by At

How can I force my button to hide or show or change appearance on click? I use actionscript3 by adobe animate. Mouse over and mouse down are working. But on release I see mouse up image. Note: I shouldn't have more than one scene because all of my buttons are in one scene. anyone can help? Thanks

1

There are 1 answers

2
EverGrand On
package
{
    import fl.controls.*;
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;
    import flash.ui.*;


    dynamic public class Main extends MovieClip
    {
        public var MyButton:MovieClip;
        public var HideMouseTimer:Timer;
        
        public function Main()
        {
            this.MyButton.addEventListener(MouseEvent.CLICK, this.onMyButton);
            
            this.HideMouseTimer = new Timer(5000, 1);
            this.HideMouseTimer.addEventListener(TimerEvent.TIMER, this.HideMouseTimerEvent);
            setInterval(this.HideMouse, 100);
        }

        public function HideMouseTimerEvent(event:TimerEvent) : void
        {
            Mouse.hide();
            this.MyButton.visible = false;
        }// end function

        public function HideMouse() : void
        {
            if (this.mouseXprev == mouseX && this.mouseYprev == mouseY)
            {
                this.HideMouseTimer.start();
            }
            else
            {
                Mouse.show();
                this.MyButton.visible = true;
                this.HideMouseTimer.reset();
            }
            this.mouseXprev = mouseX;
            this.mouseYprev = mouseY;
        }// end function

        public function onMyButton (event:MouseEvent) : void
        {
            trace ("Pressed MyButton");
        }
    } //end Class Main
    
} //end Package