Hi Ian,
In one of my previous posts I was gonna suggest a custom Event that holds the
contextInfo stuff as well, but then decided not to.
Basically because I don't know what exactly this piece of the puzzle fits into.
What I mean is, there's several ways of doing what you want to do. Two of them
I already mentioned.
- store them in B (Dictionary)
- pass them onto A (getter/setter)
Third would be to have class A dispatch a custom event which holds the
contextInfo, but this also means you'll have to pass the
contextInfo to A in the first place (in B) and since you wanted to avoid that,
I didn't mention this solution earlier.
In Flex (AS3), the third option is what I use now, dispatching custom events.
For instance:
// pseudo code (I'm in a hurry, sorry)
class LoginEvent extends Event {
public static const LOGIN:String = "login";
public var data:UserVO;
function LoginEvent(type:String, vo:UserVO=null) {
super(type);
data = vo;
}
}
// somewhere in app
function loginUser() {
var vo:UserVO = new UserVO();
vo.name = "foo";
vo.password = "bar";
// create new event which holds user data
var evt:LoginEvent = new LoginEvent(LoginEvent.LOGIN, vo);
SystemEventManager.getInstance().dispatchEvent(evt):
}
// somewhere else in app -> some class that listens for LoginEvent.LOGIN
function loginHandler(event:LoginEvent):void {
trace(event.data.name);
trace(event.data.password);
}
regards,
Muzak
----- Original Message -----
From: "Ian Thomas" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, July 25, 2007 3:15 PM
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!)
>
_______________________________________________
[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