Still not getting it :(
I'm using this code with the class Mischa provided but it doesn't work.
Beware, this is my first time working with listeners so I could do
something incredibly stupid ;)
var listeningObj:Object = new Object();
listeningObj.result = function(eventObj:Object):Void {
trace("###");
trace( eventObj.company );
}
var ws:wsproxy = new wsproxy(
"http://www.flash-db.com/services/ws/companyInfo.wsdl" );
ws.addEventListener( "result", listeningObj );
ws.doCompanyInfo("any","any","macr");
I already used different methods for the listeningobj but none of them
seem to work.
Please help :)
Jeroen
-----Original Message-----
From: NEILHIGHLEY.COM [mailto:[EMAIL PROTECTED]
Sent: woensdag 2 november 2005 19:59
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Autopopulating from a webservice
Well, with a little bit of guidance from Mischa I have this sorted.
I had to use an event proxy which was visible from the root, to
courier the event from the webservice class I created back to the
consuming class, as the addEventListener was not returning to the
class if the listener was added to the webservice class...phew..
e.g.
The following worked (note: this is a selection of code)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
(in standard class)
public function getCategorys(){
_root.eventProxy.addEventListener( "categoriesLoaded",
populateCategorys );
webservice.getCategorys();
}
(in webservice class)
function getCategorys():Void{
wsCall=webService.getCategories(wsPassword);
wsCall.onResult=function(result):Void{
trace("webservice returned");
_root.eventProxy.triggerEvent("categoriesLoaded",result);
}
}
(eventProxy class)
import mx.events.EventDispatcher;
class event_sender{
//broadcaster
private var controller:Object;
public var dispatchEvent:Function;
public var addEventListener:Function;
public var removeEventListener:Function;
function event_sender(){
EventDispatcher.initialize( this );
}
function triggerEvent(sEvent:String,oValue:Object){
trace("proxy triggered");
var eventObject:Object = {target:this,
type:sEvent,result:oValue};
dispatchEvent(eventObject);
}
}
(and in root..)
var eventProxy:event_sender=new event_sender();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
It seems to me that actionscript still loses references to remote
objects within its code and without referring to a global you cannot
link two objects via events.
If you can suggest an easier way of doing this, or point out that Im a
noob and show me a proper way, Im all ears.
Neil
--
www.neilhighley.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders