Hey, FlashCoders.
I'm wondering if you can help me out with a general style question that I
keep running into. Let's say I've got a setup like this...
class MyGame extends MovieClip
- It creates a camera sprite that I can add children into
- It then creates a Bouncing Ball object with the
*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
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
My preference is usually option 3, using an event. It means you can use
your ball in other situations, where that call back to the root may or may
not be necessary. Regarding cleaning up references in event listeners, you
can use a weak reference when you call addEventListener(). Also, I often
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 n...@tldstudio.com wrote:
Option 3!
Always opt to use
I think I whip up custom events more than almost anything else.
Yup - me too - in fact, in FlashDevelop, I have a nice event template in the
form of a code snippet for a new custom events I use all the time:
package
{
import flash.events.Event;
public class extends
Additionally, you should take a look at what the code is doing.
Why does Bouncing Ball have to call something in the parent?
Is it some sort of notification? (I've finished animating/I've hit a
wall!). In which case an event is definitely the right solution.
Is it to gain information of some
, 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
?
Thanks,
Ross
-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] 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
-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
Message-
From: flashcoders-boun...@chattyfig.figleaf.com [mailto:
flashcoders-boun...@chattyfig.figleaf.com] 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
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
12 matches
Mail list logo