Agreed on Option 3. Custom event inclusive of whatever kind of data you want
to send to the associated listening method. I think I whip up custom events
more than almost anything else.

- Eric

On Thu, Feb 5, 2009 at 1:30 PM, Nate Beck <[email protected]> wrote:

> Option 3!
>
> Always opt to use event based architecture.  It promotes loose coupling of
> your components.  Although it might be a bit more code, you will be able to
> use BouncingBall within many games, or other applications.
>
> On Thu, Feb 5, 2009 at 10:02 AM, Merrill, Jason <
> [email protected]> wrote:
>
> > >>*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
> >
>
>
>
> --
>
> Cheers,
> Nate
> ----------------------------------------
> http://blog.natebeck.net
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
http://ericd.net
Interactive design and development
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to