0

I see that in an ide like FlashDevelop, when I add an event listener to certain objects, it'll auto-populate with the event strings that this object will dispatch (I'm assuming, anyway). I'd love to do this with my custom objects (esp. when it comes to sharing this code with co-workers), to clear up possible confusion as to what to listen for.

Does anyone know how to discern which events will be dispatched?

Thanks,

Keith
  • 4,144
  • 7
  • 25
  • 43

1 Answers1

1

I don't think there is a way to link suggestions to a method call as strictly as exists with the inbuilt stuff like addEventListener(), but that shouldn't stop you from producing perfectly readable code for you and your colleagues (especially if you are using FlashDevelop).

For starters, using your own event class with static properties representing the event strings you can use will provide a useful code hint by default:

enter image description here

From here, you can add code comments that work with FlashDevelop to produce a very precise tooltip:

enter image description here

Marty
  • 39,033
  • 19
  • 93
  • 162
  • 1
    What about the `[Event]` metadata that you can add to signify that a class dispatches a particular event? I always thought that's how the IDE figured it out... but was always assumin' – Sunil D. Aug 27 '13 at 03:10
  • @SunilD. I'm not familiar with the metadata you're referring to - I'd be very interested in any material you can find that makes a reference to it. – Marty Aug 27 '13 at 03:11
  • Opps, my bad, I was referring to the [Flex metadata](http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf680e1-7ffe.html) tags! Not sure why I thought they would apply to pure AS3... – Sunil D. Aug 27 '13 at 03:13
  • @SunilD. Ahh that's a shame, I would have liked to implement something like that in my game engine. – Marty Aug 27 '13 at 03:16
  • 2
    @SunilD. They do. Whether or not the data is interpreted depends on the IDE, though. Check Philipp's answer to this question:http://stackoverflow.com/questions/675402/as3-eventname-type-what-is-the-significance – weltraumpirat Aug 27 '13 at 06:51
  • thanks for the info, all! that link, weltraumpirat, answered my question! thanks again – Keith Aug 28 '13 at 09:59