开发者

Alert event handler

I have 2 functions which are dependent on each other. func1 is a method returning a value from database. If there is an error executing func1, an alert box shows and I dont want to execute func2. If func1 开发者_高级运维executes successfully without an error, then only I want func2 to get executed. I dont know how to achieve this. Any help will be greatly appreciated. Thank you in advance.

Regards, Kevin.


Perhaps I'm missing something, but isn't as simple as:

    private function getData():void
    {
        //get data

        if (data)
        {
            onDataLoad();
        }
        else
        {
           //alert();
        }
    }

    private function onDataLoad():void
    {
        //do something
    }

Or, if your data load function returns a boolean, just work it into a similar scenario.


the function func1 should throw an error (A) or return an error code / null pointer (B).

(A)

try {
    func1();
    func2(); // only executed if func1 does not throw any errors
} catch (e:Error) {
    // error handling
}

(B)

var myData:Object = func1();
if(myData != null) {
    func2();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜