Chris
Chris

Reputation: 1

How do you make an error in flash somehow display once it's a .swf?

The error I have is

Error opening URL "http://www.website.com/something.php?query=someinvalidquery"

The query isn't actually supposed to go through, but I'd like some sort of error message saying so.

Upvotes: 0

Views: 130

Answers (1)

Brent
Brent

Reputation: 23722

Assuming you're using a URLLoader or something, you want to attach an event to it to catch the error. Then you can display a text field or whatever you want.

var url = "http://www.website.com/something.php?query=someinvalidquery";
var loader = new URLLoader();
loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
loader.load(url);

function errorHandler(event:IOErrorEvent):void {
    trace('do whatever to handle the error here.');
}

You can also track the httpstatus etc, in case you want to handle redirects and whatnot. The event used are in the docs

Upvotes: 1

Related Questions