Just setup your eventListeners to pass the decoupled data to your ready
functions.

dispatchEvent({type:"eventClipShowStatus", target: this, current:
currentMCNumber, total: totalMCNumber});

private function eventClipShowStatus(eventObj:Object):Void{

     clipShowStatus(eventObj.current, eventObj.total);

}

Make sense?

This preserves your function logic and adds a decoupler for all your data
being passed around. You can also error check inside the event function to
be sure proper data was passed before calling clipShowStatus.

Hope this helps,

Steve


On 1/19/07, Holth, Daniel C. <[EMAIL PROTECTED]> wrote:


After your post I spent most of this morning researching and debating
converting a lot of my code to use the EventDispatcher instead of
broadcastMessage.  I like a lot of what it has to offer, but have a
question...

I have a function in one class that displays how many more movieclips the
user will be viewing and it takes in two variables: currentMCNumber and
totalMCNumber.  Using broadcastMessage, I can pass those variables in
directly.  Can I do that with the eventDispatcher as well?

For example, doing:

this.broadcastMessage("clipShowStatus", currentMCNumber, totalMCNumber);

Runs the clipShowStatus function as if I had actually done:

clipShowStatus(currentMCNumber, totalMCNumber);

But if I use the eventDispatcher I would need to do something like:

dispatchEvent({type:"clipShowStatus", target: this, current:
currentMCNumber, total: totalMCNumber});

And make changes to my clipShowStatus method to take in an event object...
Is there a way to use the EvenDispatcher with out needing to change all my
functions to take in eventObjects and instead place the needed variables
directly into the function?

Thanks!

Daniel Holth
I.S. Programmer

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of T.
Michael Keesey
Sent: Thursday, January 18, 2007 8:11 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] advantages of EventDispatcher over
AsBroadcaster


The two are pretty much the same, except for one big thing:
EventDispatcher allows you to distinguish between types of events.
AsBroadcaster just says, "Hey, there's been an update," while
EventDispatcher gives detailed information (in an Event object) about
exactly what that event was and only notifies the listeners which are
listening to that type of event.

Another advantage to using EventDispatcher is that EventDispatcher is
heavily integrated into ActionScript 3.0, to the point that at least
half the classes you'll encounter are dispatchers. Every single
display object (movie clips, buttons, components, etc.) is a
dispatcher, some with dozens of types of events ("mouseMove", "load",
"enterFrame", etc.). AsBroadcaster, on the other hand, is deprecated.

On 1/18/07, Reuben Stanton <[EMAIL PROTECTED]> wrote:
> I have used both extensively and find that AsBroadcaster allows me to
> do the same thing in fewer lines of code, yet there seems to be a
> general preference in the flash community to use EventDispatcher.
>
> Is there any particular reason to use one or the other?
>
>
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>


--
T. Michael Keesey
Director of Technology
Exopolis, Inc.
2894 Rowena Avenue Ste. B
Los Angeles, California 90039
--
The Dinosauricon: http://dino.lm.com
Parry & Carney: http://parryandcarney.com
ISPN Forum: http://www.phylonames.org/forum/
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

This e-mail and its attachments are intended only for the use of the
addressee(s) and may contain privileged, confidential or proprietary
information. If you are not the intended recipient, or the employee or agent
responsible for delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution, displaying, copying,
or use of this information is strictly prohibited. If you have received this
communication in error, please inform the sender immediately and delete and
destroy any record of this message. Thank you.

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to