Thanks, everybody!

Sounds like creating custom events is the way to go (and yes, it's for "Send
an alert of some kind to MyGame" kind of functionality). I don't have a lot
of experience with 'em, so I was probably going through more trouble to
avoid them than would actually be required to just suck it up and do things
the right way. :)

--T



On Thu, Feb 5, 2009 at 11:31 AM, Merrill, Jason <
[email protected]> wrote:

> Yes - just turn event bubbling on - then any DisplayObject like sprite or
> movie clip will pass the event up the display list.
>
>
> Jason Merrill
> Bank of America     Instructional Technology & Media   ·   Learning
> Performance Solutions L&LD
>
> Interested in Flash Platform technologies?  Join the Bank of America Flash
> Platform Community
> Interested in innovative ideas in Learning?  Check out the Innovative
> Learning Blog and subscribe.
>
>
>
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:
> [email protected]] On Behalf Of Lehr, Ross
> (N-SGIS)
> Sent: Thursday, February 05, 2009 2:15 PM
> To: Flash Coders List
> Subject: RE: [Flashcoders] Best way to access my main class?
>
> This brings up a question I had about events.  Is there a way to send an
> event all the way to the document class, no matter where it's been
> dispatched from?  For instance, I have a document class that creates a
> "menu" class, which creates several "icon button" classes.  I want the
> document class to be able to receive the event dispatched from the "icon
> button".  Currently, the only way I know how to do it is have the "icon
> button" send it to the "menu" and then the "menu" send it to the document.
>  So, my question is, can the document class receive an event directly sent
> from the "icon button"?
>
> Thanks,
> Ross
>
> -----Original Message-----
> From: [email protected] [mailto:
> [email protected]] On Behalf Of Merrill, Jason
> Sent: Thursday, February 05, 2009 1:03 PM
> To: Flash Coders List
> Subject: RE: [Flashcoders] Best way to access my main class?
>
> >>*Option 3:* I create a custom event, dispatch that event, and create a
> >>listener in MyGame rather than call a function directly.
> >>I'm guessing this is the best way to go theoretically, and will allow me
> to
> >>reuse my BouncingBall object in other applications, but it's a lot of
> extra
> >>code, and I constantly worry about not property cleaning up event
> listeners.
>
>
> Hands down, your option 3 is what you should do.  So what if it's some
> extra code? It's the right way to accomplish this.  Your object should not
> target and call methods in other classes outside of it, that's extremely
> tight coupling, which is bad.
>
> So have your bouncing ball sprite dispatch a custom event, have the other
> class listen for that same custom event and do whatever logic you want, like
> call another method.  It's not messy if you keep your code clean.  It just
> takes practice of doing this a lot before you realize an architecture
> emerges in your coding you are familiar with.  I think its even messier to
> do option 1 or 2, if that makes you feel any better.
>
>
> Jason Merrill
> Bank of America     Instructional Technology & Media   ·   Learning
> Performance Solutions L&LD
>
> Interested in Flash Platform technologies?  Join the Bank of America Flash
> Platform Community
> Interested in innovative ideas in Learning?  Check out the Innovative
> Learning Blog and subscribe.
>
>
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to