1 Reply Latest reply on Oct 14, 2017 1:30 AM by Colin Holgate

    How to Show New Image or Animation on Release of Left Mouse Button?

    Thatisdifficult

      My teacher made a flash project and wants me to figure out how to do this; I don't mind helping him out. How do I code this? I need to stop it from going back to the mouse over state when I release the LMB; it needs to show a new image or animation after the LMB is released. I'll pass the info over to my teacher when I get the solution. I'll really appreciate the help!

       

      I've used flash mainly for doing frame by frame animation things, but I don't really know how to use Actionscript 3 aside from really basic things like stop(); and gotoAndPlay.

       

      here's my problem.gif

        • 1. Re: How to Show New Image or Animation on Release of Left Mouse Button?
          Colin Holgate MVP & Adobe Community Professional

          If those are currently buttons it would always go back to the over state when you release the mouse button, and to the idle state when you mouse out of the area. If you want the object to stay in the pressed state after you release the mouse button, one easy solution would be to put the button into a two frame movieclip. In the movieclip frame 1 would be this:

           

          stop();

          btn.addEventListener(MouseEvent.CLICK,btnpressed);

          function btnpressed(e:MouseEvent){

             btn.removeEventListener(MouseEvent.CLICK,btnpressed);

             gotoAndStop(2);

          }

           

          In frame 2 would be the movieclip of animation that you want to be seen when the mouse is pressed. That could be simply a repeat of the pressed state image from the button.

           

          If you want the user to also be able to deselect the object, you could have this in frame 2 of that two frame movieclip:

           

          stop();

          mc.addEventListener(MouseEvent.CLICK,mcpressed);

          function mcpressed(e:MouseEvent){

             mc.removeEventListener(MouseEvent.CLICK,mcpressed);

             gotoAndStop(1);

          }

           

          For my example the button on frame 1 would have an instance name of 'btn', and in frame 2 the movieclip would have a name of 'mc'.