c47cb6dc4b18374d4fead1cd71a251463a5bc592
[swftools.git] / lib / as3 / ok / trycatch.as
1 package {
2     import flash.display.MovieClip;
3
4     public class MyError {
5     }
6     public class MyOtherError {
7         var ok5="ok 5/5";
8     }
9     public class Main extends flash.display.MovieClip {
10         function Main() {
11             try {
12                 throw new MyError
13                 trace("error");
14             } catch(error:Error) {
15                 // MyError is not of the Error class
16                 trace("error");
17             } catch(error:MyError) {
18                 trace("ok 1/5");
19             } catch(x) {
20                 trace("error");
21             }
22             
23             try {
24                 throw new MyOtherError
25                 trace("error");
26             } catch(error:MyError) {
27                 trace("error");
28             } catch(x:*) { // ":*" is the same as ""
29                 trace("ok 2/5");
30             }
31             
32             try {
33                 trace("ok 3/5");
34                 // don't throw any error
35             } catch(error:MyError) {
36                 trace("error");
37             } catch(error:MyOtherError) {
38                 trace("error");
39             } catch(x:*) { // ":*" is the same as ""
40                 trace("error");
41             }
42
43             trace("ok 4/5");
44
45             try {throw new MyOtherError} 
46             catch(x:*) {
47                 trace((x as MyOtherError).ok5);
48             }
49             trace("[exit]");
50
51         }
52     }
53 }