• Home
  • About
  • Contact
  • QuickTip: Stopping an Event

    Posted on May 3rd, 2010 Rasmus Wriedt Larsen 1 comment
    This entry is part 5 of 4 in the series Quick Tips

    Quick Tips
    • QuickTip: Execute Code After Animaiton
    • QuickTip: Scrolling Only in SWF, not on Page.
    • QuickTip: Managing Saved Data (SharedObject)
    • QuickTip: Understanding Right Click Menus (ContextMenu)
    • QuickTip: Stopping an Event

    Learn how to stop an event, and also why.

    I play a lot of games that makes a mistake in the UI, and it’s so freaking simple to correct. What mistake am I talking about? Well I just made a little sample of it, picture this is a shooting game (and I guess you need to use a lot of your imagination there), and we have a button for changing the sound. Try clicking on the “empty” space of the swf, and on the sound button.

    (Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

    What do you see? Oh yes, when we try and turn off the sound, we also shoot! That’s not good, I didn’t want to waste my precious ammo, I just wanted to turn the sound off.

     

    And here is how to fix it:

    In the event handler for the sound button, just add this line of code:

    e.stopPropagation ( ) ;

    Here is the result:
    (Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

    Hurray, problem solved!

     

    Want to learn a little about what you just did, or more generally how events work? Take a look at this great article from Adobe.

     

    Happy coding ;)

    Share this Article
    • Digg
    • Sphinn
    • del.icio.us
    • Facebook
    • Google Bookmarks
    • MySpace
    • StumbleUpon
    • TwitThis
    ActionScript 3, Flash, Tutorial, User Interface
     

    1 responses to “QuickTip: Stopping an Event” RSS icon

    • MC September 1st, 2010 at 13:36

      VERY VERY VERY VERY VERY VERY USEFUL!!!! THANKS!


    Leave a reply

    Click here to cancel reply.

Subscribe

Grab my feed
or
Subscribe by Email

Categories

  • ActionScript 3 (11)
  • Animation (1)
  • Flash (10)
  • This Blog (1)
  • Tutorial (10)
  • Uncategorized (2)
  • User Interface (3)
  • Util (1)

Flash Blogs

  • ASgamer
  • Emanuele Feronato
  • Flash Game License
  • FreelanceFlashGames
  • GameDevigner
  • Gaming Your Way
  • Michael James Williams
  • Untoldentertainment
  • Vortix Games Studio
Powered by WordPress
Designed by My Mobiles