X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=lib%2Fas3%2Fok%2Ftrycatch.as;fp=lib%2Fas3%2Fok%2Ftrycatch.as;h=0a890b9828a4b11ac108d0a529cdc93f7e7f6b64;hb=a43e097bc7958c5739ef3e77cdcedd56ddc060b9;hp=0000000000000000000000000000000000000000;hpb=a5b0a0bab5c721e9d0771d840947d7a0625e26d3;p=swftools.git diff --git a/lib/as3/ok/trycatch.as b/lib/as3/ok/trycatch.as new file mode 100644 index 0000000..0a890b9 --- /dev/null +++ b/lib/as3/ok/trycatch.as @@ -0,0 +1,52 @@ +package { + import flash.display.MovieClip; + + public class MyError { + } + public class MyOtherError { + var ok5="ok 5/5"; + } + public class Main extends flash.display.MovieClip { + function Main() { + try { + throw new MyError + trace("error"); + } catch(error:Error) { + // MyError is not of the Error class + trace("error"); + } catch(error:MyError) { + trace("ok 1/5"); + } catch(x) { + trace("error"); + } + + try { + throw new MyOtherError + trace("error"); + } catch(error:MyError) { + trace("error"); + } catch(x:*) { // ":*" is the same as "" + trace("ok 2/5"); + } + + try { + trace("ok 3/5"); + // don't throw any error + } catch(error:MyError) { + trace("error"); + } catch(error:MyOtherError) { + trace("error"); + } catch(x:*) { // ":*" is the same as "" + trace("error"); + } + + trace("ok 4/5"); + + try {throw new MyOtherError} + catch(x:*) { + trace((x as MyOtherError).ok5); + } + + } + } +}