DuMmWiaM.com, Personal Showreel, lab & resources for web development.

AS3 Click on Fast Moving or Animated Objects

Here is a quick tip for Flash/Flex or Flash Builder or anything that uses ActionScript 3. If you are having a (fast) moving animated DisplayObjects that you want the user to be able to click, I suggest NOT using the MouseEvent.CLICK but MouseEvent.MOUSE_DOWN. MouseEvent.MOUSE_DOWN works a lot better and it fires faster than the MouseEvent.CLICK event.

Today I was coding a game, that some monsters were running and the user had to click on them to "kill" them. Without even thinking I used the MouseEvent.CLICK event, but when I tried to kill those bastards, I had to click again and again to hit them. My first reaction is to panic, but then I change CLICK to MOUSE_DOWN and voila!

So the lesson for today...

If you have a fastmoving sprite or movieclip in AS3 and you want the user to be able to click on it, use the MouseEvent.MOUSE_DOWN Event, instead of MouseEvent.CLICK!

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.