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

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

New Here ,
Oct 13, 2017 Oct 13, 2017

Copy link to clipboard

Copied

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

Views

319

Translate

Translate

Report

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 14, 2017 Oct 14, 2017

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,btn

...

Votes

Translate

Translate
LEGEND ,
Oct 14, 2017 Oct 14, 2017

Copy link to clipboard

Copied

LATEST

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'.

Votes

Translate

Translate

Report

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