  | | | Event Dispatcher between classes | Event Dispatcher between classes 2004-03-15 - By Jens L?ffler
Back Yes, I think that's within my framework. But I haven't figured out how to connect two classes using the event modell.
This is my example: How can I make it work?
Sender:
import mx.events.EventDispatcher; class focuscast.core.Databaseproxy { public function Databaseproxy() { EventDispatcher.initialize(this); } public function loadClients():Array { var clientarray:Array = new Array(); clientdata = new LoadVars(); clientdata.load("http://internal/database.php?action=loadClients"); clientdata.onLoad = clientdata_loaded; return clientarray; } public function clientdata_loaded() { trace("dispatching"); var responseobj:Object = {}; responseobj.type="onUpdateClient"; responseobj.target=this; responseobj.data=clientarray; dispatchEvent(responseobj); } }
Receiver:
class focuscast.core.Datahandler extends MovieClip { public var databaseproxy; function Datahandler() { databaseproxy = new Databaseproxy(); databaseproxy.addEventListener("onUpdateClient", this); }
function onUpdateClient() { trace("received"); } }
>From: "Erik Bianchi" <erikbianchi@(protected)> >Reply-To: flashcoders@(protected) >To: <flashcoders@(protected)> >Subject: Re: [Flashcoders] Event Dispatcher between classes >Date: Mon, 15 Mar 2004 16:18:19 -0500 > >Take a look at using the MVP design pattern. Sounds like you just need to >work on your architecture a bit and this pattern will help resolve this for >you. > >Basically a Presenter would be responsible for initializing your >components/classes and hooking them together. When using MVP that >relationship would be hooking the model and view together. The Model being >the broadcaster(subject) and the view listening to the broadcast(observer). > >hope that helps. > >-erik >-- -- Original Message -- -- >From: "Jens L?ffler" <jensloeffler@(protected)> >To: <flashcoders@(protected)> >Sent: Monday, March 15, 2004 4:01 PM >Subject: [Flashcoders] Event Dispatcher between classes > > > > Hi, > > > > does anyone know what's the best way to use the Event Dispatcher between >two > > classes to send messages? I've initalized the sending class in the > > constructor with eventdispacher, and extended the listening class to a > > movieclip, so a public function can be used to receive the message, but >it's > > doesn't really work. Is there any standard way? (I don't want to use >code > > outside the classes) > > > > Jens > > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ > > Sch?tzen Sie Ihren Posteingang vor unerw?nschten E-Mails. > > http://www.msn.de/antispam/prevention/junkmailfilter Jetzt > > Hotmail-Junk-Filter aktivieren! > > > > > > =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- > > Supported by Fig Leaf Software > > =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- > > Be sure to check the archives and the wiki: > > http://chattyfig.figleaf.com/ > > =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- > > http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:107037 > > =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- > > To unsubscribe send a blank e-mail to: > > Normal Mode: flashcoders-unsubscribe@(protected) > > Digest Mode: flashcoders-digest-unsubscrive@(protected) > > >=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- >Supported by Fig Leaf Software >=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- >Be sure to check the archives and the wiki: > http://chattyfig.figleaf.com/ >=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- >http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:107040 >=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- >To unsubscribe send a blank e-mail to: >Normal Mode: flashcoders-unsubscribe@(protected) >Digest Mode: flashcoders-digest-unsubscrive@(protected) >
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ Schlu?mit Spam! http://www.msn.de/antispam/prevention/junkmailfilter Wir helfen Ihnen, unerw?nschte E-Mails zu reduzieren.
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Supported by Fig Leaf Software =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Be sure to check the archives and the wiki: http://chattyfig.figleaf.com/ =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:107042 =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe send a blank e-mail to: Normal Mode: flashcoders-unsubscribe@(protected) Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |