How about using a wrapper class?


package {
        
        import flash.events.Event;
        import flash.events.IEventDispatcher;
        
        public final class Wrapper {
                
                private var _contextInfo:Object;
                private var _a:IEventDispatcher;
                
                public function get content():IEventDispatcher {
                        return _a;
                }
                
                public function get contextInfo():Object {
                        return _contextInfo;
                }
                
                public function Wrapper(url:String, contextInfo:Object)
{
                        _contextInfo = contextInfo;
                        // new instance
                        _a = new A();
                        // or reference
                        _a = A.getInstance();
                        //
                        _a.addEventListener(Event.COMPLETE,
onCompleteEvent);
                        _a.loadSomething(url);
                }
                
                private function onCompleteEvent(eventObj:Event):void {
                        // implement custom event to which class B will
listen
                        dispatchEvent(new CustomEvent(eventObj.type,
_contextInfo));
                        // or specify a getter for contextInfo from this
Wrapper class
                }
                
        }
}

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ian
Thomas
Sent: 25 July 2007 15: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


_______________________________________________
[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

Reply via email to