jeudi 9 février 2017

How to handle error dialog boxes in ActionScripts 3

I write some code to check an XML from a URL, it works when Internet connection exist, but when i manually disable internet for test an Error dialog box show, i coudn't handle it with try() catch().

try {
    var myXML: XML = new XML();
    var XML_URL: String = "http://ift.tt/2kMNUKN";
    var myXMLURL: URLRequest = new URLRequest(XML_URL);
    var myLoader: URLLoader = new URLLoader(myXMLURL);
    myLoader.addEventListener(Event.COMPLETE, xmlLoaded);

    function xmlLoaded(event: Event): void {
        myXML = XML(myLoader.data);
        trace("LOCK CODE: " + myXML.LOCK);
        if (myXML.LOCK == 0) {
            gotoAndStop(71);
        };
    }
} catch (e: Error) {
    gotoAndStop(71);
    trace("FAILED TO CHECK LOCK.");
} finally {
    gotoAndStop(71);
    trace("FAILED TO CHECK LOCK.");
}

How can i hide this dialog from user?

Aucun commentaire:

Enregistrer un commentaire