Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 268

Programming actionscript 3.0
Table of Contents

Advertisement

Status-based error events
The status-based error events are related to the
networking and communication classes. If Flash Player encounters a problem when
reading or writing data, the value of the
properties (depending on the class object you're using) is set to the value
respond to this error by checking if the
your event handler function.
Working with error events
The ErrorEvent class and its subclasses contain error types for handling errors dispatched by
Flash Player as it tries to read or write data.
The following example uses both a
any errors detected while trying to read a local file. You can add more sophisticated handling
code to provide a user with options or otherwise handle the error automatically in the places
indicated by the comment "your error handling code here":
package
{
import flash.display.Sprite;
import flash.errors.IOError;
import flash.events.IOErrorEvent;
import flash.events.TextEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.text.TextField;
public class LinkEventExample extends Sprite
{
private var myMP3:Sound;
public function LinkEventExample()
{
myMP3 = new Sound();
var list:TextField = new TextField();
list.autoSize = TextFieldAutoSize.LEFT;
list.multiline = true;
list.htmlText = "<a href=\"event:track1.mp3\">Track 1</a><br>";
list.htmlText += "<a href=\"event:track2.mp3\">Track 2</a><br>";
addEventListener(TextEvent.LINK, linkHandler);
addChild(list);
}
private function playMP3(mp3:String):void
{
try
268
Handling Errors
netStatus
netStatus.info.level
property contains the value
level
statement and error event handlers to display
try..catch
and
properties of the
status
or
status.level
"error"
"error"
. You
in

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents