Should I Bubble?

27 Nov

Working on a fun AS3 project now, where I’ll make some UI components. The components has several events that they want to notify the world about, but I’d love some help on a design decision: should the events dispatched from a component bubble per default?

27 November 2007 at 9:17 pm

2 Responses to Should I Bubble?

  1. avatar photo
    JesterXL 28 November 2007 at 11:24 am #

    For low-level events, yes.  All Mouse events, save rollover, rollout, bubble by default.  So, you can “hear” about a click event 50 billion nested MovieClip’s deep.

    The problem is that has no strong-typing.  Meaning, you can add an event listener with no guarentee that said component will ever dispatch it.

    Using [Event(name=“someEvent”, type=“flash.events.Event”)] above your class definition is nice, but only if you use FlexBuilder.  It gives you code hints and acts as strict-typing for MXML; in Flash, it’s worthless.


    Model.instance.deeplyNestedMovieClipSays = “sup sup!”;

  2. avatar photo
    Jensa 28 November 2007 at 3:37 pm #

    Great advice Jesse! Thanks!

  3.