Hi Ian, Sorry, it's not very clear in all that garbled code.
If you make a new instance of B each time then only 1 request would be made to each instance. The event could then be sent to the same listener for each instance but with the appropriate parameter as part of the (custom) event. If you think about it, it's very similar to how Delegate works by creating a "holding" area but now you have a (custom) event dispatched which is fully typed. I suppose you have to decide if it's worth the extra time or not based on what you're doing. :) Sunil -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ian Thomas Sent: 25 July 2007 16:10 To: [email protected] Subject: Re: [Flashcoders] AS3 Events Hi Sunil, That won't work if multiple requests are filtering through the same B - which is where the whole problem starts from. :-) Because request 2 overwrites the contextInfo written by request 1 - which is why both Muzak (and I) suggested B has an internal list of contextInfos. But that gets more tricky... But thanks! Ian On 7/25/07, Sunil Jolly <[EMAIL PROTECTED]> wrote: > Hi Ian, > > I didn't fully understand your reply to Muzak's suggestion, but this is > based on that and seems to fit the bill. > > Sorry it's a bit messy but you get the idea... > > Are there still issues with this one? > > ------- > > //call class b passing extra param > var b:B = new B(); > b.addEventListener(Event.COMPLETE, onBComplete); > b.loadSomethingAndProcessIt("url.swf", someParameter); > > function onBComplete(event:Event) { > var thingYouWant:Object = event.customEventValue; > } > > //Class B based on Muzak's(thanks!) > >> class B { > >> > private var contextInfo:Object; > > >> public function loadSomethingAndProcessIt(url:String, > ontextInfo:Object):void{ > >> contextInfo = contectInfo; > >> r a:A = new A(); > >> a.addEventListener(Event.COMPLETE,onALoaded); > >> a.loadSomething(url); > >> } > >> > >> function onALoaded(event:Event):void { > >> dispatchEvent(new CustomEvent(contextInfo)); > >> } > >> > >> } > > //Custom Event to be fired from Class B > package etc... > public class CustomEvent extends Event > { > private var customEventValue:Object; > Function CustomEvent(contextInfo) { > super(etc...) > customEventValue = contextInfo; > } > } > > Sunil > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Ian > Thomas > Sent: 25 July 2007 14:16 > To: [email protected] > Subject: Re: [Flashcoders] AS3 Events > > Oh, and reading the link you supplied, the only concrete suggestion is > from Aral Balkan, who suggests (as someone did in an earlier thread) > that you subclass the Event class. > > How would that help in my case? Any suggestions? To go back to my > original example, if you assume class A is a black box that fires an > event of class Event (Event.COMPLETE), we have no way (to the best of > my knowledge) to make class A produce subclasses of Event instead; > unless the suggestion is to subclass A to produce different events, > which (depending on A's implementation) could be very difficult. > > Ian > > (Getting frustrated!) > > On 7/25/07, Ian Thomas <[EMAIL PROTECTED]> wrote: > > On 7/25/07, Sunil Jolly <[EMAIL PROTECTED]> wrote: > > > Hi Ian, > > > > > > It seems like the "proper" way would be to create the extra > > > functions/classes to handle this. That would solve those two issues > > > which aren't major, but would make your code cleaner. _______________________________________________ [email protected] 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

