X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fok%2Ftrycatch.as;h=3b5fd3949496d6b56669a7ecba116a19957b22a3;hb=d2900b017d9db40a7dd63ee13baefa8bd2a1c49d;hp=0a890b9828a4b11ac108d0a529cdc93f7e7f6b64;hpb=a43e097bc7958c5739ef3e77cdcedd56ddc060b9;p=swftools.git diff --git a/lib/as3/ok/trycatch.as b/lib/as3/ok/trycatch.as index 0a890b9..3b5fd39 100644 --- a/lib/as3/ok/trycatch.as +++ b/lib/as3/ok/trycatch.as @@ -1,12 +1,57 @@ package { import flash.display.MovieClip; + import flash.net.navigateToURL; public class MyError { } public class MyOtherError { - var ok5="ok 5/5"; + var ok5="ok 5/8"; + } + public class ClassWithStaticFunctions { + static function ok7() { + trace("ok 7/8"); + } } public class Main extends flash.display.MovieClip { + + public function getClass():Class { + return ClassWithStaticFunctions; + } + + public function checkScope():void + { + try { + flash.net.navigateToURL; + } catch (e:Error) { + } + trace("ok 6/8"); + + with(getClass()) { + try { + throw new Error; + } catch(e:Error) { + ok7(); + } + } + } + public function checkActivation():void + { + var y:uint = 0; + var inc_y = function() { + y = y + 1; + } + + try { + inc_y(); + throw new Error; + } catch(e:Error) { + inc_y(); + } + if(y!=2) trace("error") + else trace("ok 8/8"); + } + + function Main() { try { throw new MyError @@ -15,7 +60,7 @@ package { // MyError is not of the Error class trace("error"); } catch(error:MyError) { - trace("ok 1/5"); + trace("ok 1/8"); } catch(x) { trace("error"); } @@ -26,11 +71,11 @@ package { } catch(error:MyError) { trace("error"); } catch(x:*) { // ":*" is the same as "" - trace("ok 2/5"); + trace("ok 2/8"); } try { - trace("ok 3/5"); + trace("ok 3/8"); // don't throw any error } catch(error:MyError) { trace("error"); @@ -40,13 +85,17 @@ package { trace("error"); } - trace("ok 4/5"); + trace("ok 4/8"); try {throw new MyOtherError} catch(x:*) { trace((x as MyOtherError).ok5); } + checkScope(); + checkActivation(); + + trace("[exit]"); } } }