User Guide
Responding to error events and status 269
{
myMP3.load(new URLRequest(mp3));
myMP3.play();
}
catch(err:Error)
{
trace(err.message);
// your error handling code here
}
myMP3.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
}
private function linkHandler(linkEvent:TextEvent):void
{
playMP3(linkEvent.text);
// your error handling code here
}
private function errorHandler(errorEvent:IOErrorEvent):void
{
trace(errorEvent.text);
// your error handling code here
}
}
}
Working with status change events
Flash Player dynamically changes the value of the netStatus.info.level or status.level
properties for the classes that support the
level property. The classes that have the
netStatus.info.level property are NetConnection, NetStream, and SharedObject. The
classes that have the
status.level property are HTTPStatusEvent, Camera, Microphone,
and LocalConnection. You can write a handler function to respond to the change in
level
value and track communication errors.
The following example uses a
netStatusHandler() function to test the value of the level
property. If the
level property indicates that an error has been encountered, the code traces
the message “Video stream failed”.
package
{
import flash.display.Sprite;
import flash.events.NetStatusEvent;
import flash.events.SecurityErrorEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;