Josh Buhler - addEventListerner() - Now What?

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    Josh Buhler - addEventListerner() - Now What? - Presentation Transcript

    1. addEventListener() - Now what? Josh Buhler
    2. WHO AM I? I like long walks on the beach... CURRENTLY Senior Developer at Rain. Building Flash, Flex, iPhone apps, and bringing the hurt in CoD4. PREVIOUSLY Flash Ninja at Footnote.com, Flash developer at mediaRAIN. (Yes, same place I’m at now, just a different name. Long story.) Basically, I’ve been writing ActionScript in some form since 2003. CONFERENCES Adobe MAX, 360|Flex San Jose, Flash Forward
    3. TODAY If you decide to walk out now, it’s OK. Really. WHAT IT IS Events 201. We’ll discuss the basics just a little bit, but then get into more intermediate topics and practical examples. WHAT IT’S NOT The molecular structure of Events, how to hack the byte- code of the .SWF to mod your events, or super-bizarre edge cases.
    4. THE AGENDA Trust me. There’s actually a plan. •What an Event is •How they work •How to use them •Dispatching events •Removing event listeners
    5. THE AGENDA Really. I promise. •Creating custom events •Event Priority •The Event Flow •Event targets •Default Behaviors •Killing events
    6. WHAT IS AN EVENT?
    7. WHAT IS AN EVENT? Noteworthy... yeah. I was gonna say that. ”A noteworthy runtime occurrence that has the potential to trigger a response in the program.”
    8. TYPES OF EVENTS BUILT-IN events are defined and dispatched by the Flash Player CUSTOM events are defined and dispatched by the developer’s code.
    9. BUILT-IN EVENTS The Freebies MouseEvent.CLICK KeyboardEvent.KEY_DOWN Stage Loading Uploading
    10. CUSTOM EVENTS If you build it, they will come... or something like that. XML Parsing Complete Game Over Application State Changes Custom Components
    11. EVENT BASICS You’re old enough, it’s time we had the talk. SOMETHING HAPPENS This is one of those noteworthy runtime occurrences. CREATION An instance of Event, or a subclass of it is created. DISPATCH The created Event instance is dispatched to anything that cares. HANDLING Something receives the event dispatch. Usually.
    12. EVENT COMPONENTS EVENT DISPATCHERS EVENT OBJECTS EVENT HANDLERS
    13. EVENT OBJECTS TYPE Either an instance of Event, or a subclass of it. NAME The name of the Event. (Kinda obvious, right?) PHASE Where in the event flow this Event is at. TARGET What triggered this Event, and what’s handling it.
    14. USING EVENTS NAME of the Event TYPE of Event REGISTER to listen for the Event HANDLE the Event when it happens WAIT for the Event to occur.
    15. EVENT NAMES
    16. EVENT TYPES
    17. REGISTER FOR THE EVENT
    18. REGISTER FOR THE EVENT addEventListener (type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false);
    19. REGISTER FOR THE EVENT addEventListener (type:String, listener:Function);
    20. DISPATCHING EVENTS CREATE an instance of the Event to be dispatched DISPATCH the Event
    21. REMOVING EVENT LISTENERS UNNECESSARY Sometimes you no longer care about that Event. MEMORY Use less of it. CPU Reduce the load.
    22. ANONYMOUS HANDLERS Quick, easy...
    23. ANONYMOUS HANDLERS ...and very, very bad.
    24. WEAK REFERENCES This picture is one.
    25. EventDispatcher
    26. addEventListener() EventDispatcher Listener
    27. addEventListener() EventDispatcher Listener
    28. EventDispatcher
    29. WEAK REFERENCES
    30. WEAK REFERENCES PREVENTS listeners from becoming stranded
    31. WEAK REFERENCES PREVENTS listeners from becoming stranded NO GUARANTEES when they’ll be cleaned up FORCE GARBAGE COLLECTION Unsupported, and SHOULD NOT be used in production code http://bit.ly/IU0Z5
    32. ALWAYS REMOVE EVENT LISTENERS Unless you still need them, of course
    33. CUSTOM EVENTS It’s alive! NAME-ONLY Still basic events, only their name has changed. EXTEND When your Events need to carry additional properties, or provide other extra functionality.
    34. EXTENDING EVENT OVERRIDE clone() and toString() EXTEND When your Events need to carry additional properties, or provide other extra functionality. MORE INFO http://bit.ly/Fwb64
    35. EVENT METADATA [Event(name=\"tempChange\", type=\"examples.TemperatureEvent\")]
    36. EVENT PRIORITY EVENTS registered for the same event, with the same object fire in the order they were registered. UNLESS you change their priority when registering. HIGHER priority listeners will be triggered first.
    37. THE EVENT FLOW
    38. Stage Capture Bubble Phase Phase Sprite Target Phase TextField
    39. EVENT FLOW Think of the possibilities...
    40. EVENT FLOW Centralize, yo.
    41. EVENT TARGETS Stay on target...
    42. DEFAULT BEHAVIOR
    43. KILLING EVENTS
    44. KILLING EVENTS stopPropagation() prevents the Event from continuing through the remainder of the event flow. stopImmediatePropagation() stops the Event in it’s tracks. Do not pass Go. Do not collect $200.
    45. THE END Worst. Session. Ever.
    46. CONTACT Have your people call my people. mediaRain.com ghostRadio.net joshbuhler ghostRadio SAMPLE CODE http://www.ghostradio.net/events360

    + 360|Conferences360|Conferences, 7 months ago

    custom

    406 views, 2 favs, 0 embeds more stats

    Working with Events in Flex and ActionScript 3.0 is more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 406
      • 406 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 10
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories