In Flex/Actionscript, How Can I Know WHICH LocalConnection.send Generated A Status Error?
Consider The Following Actionscript/Flex code:
var LC:LocalConnection=new LocalConnection();
LC.addEventListe开发者_如何学JAVAner(StatusEvent.STATUS, Status);
LC.send('A', 'SomeMethodName', 'Message');
LC.send('B', 'SomeMethodName', 'Message');
LC.send('C', 'SomeMethodName', 'Message');
public function Status(event:StatusEvent):void {
if (event.level=='error') {
// How Can I Know if the error came from 'A', 'B', or 'C' above?
}
}
Assuming I do NOT want to run the sends in series, but in paralell (all at once), as above, and further assuming that one, and only one of the send commands will generate a status event where level='error':
How can I detect which send command produced the status error?
if i had to use multiple LocalConnections i'd used a different instance for every ConnectionID and created a holder class to manage them.
I believe a status even will be raised for every message that you send. So if you got 2 status messages before then error, then it's C.
You could have some wrapper around LocalConnection that stores messages that it sends in some array, and removes them every time a status message is received. When you get an error the message at the head of the queue would be the one that errored out.
精彩评论