added jpeg3 extraction support to swfextract
[swftools.git] / lib / as3 / ok / trycatch.as
1 package {
2     import flash.display.MovieClip;
3     import flash.net.navigateToURL;
4
5     public class MyError {
6     }
7     public class MyOtherError {
8         var ok5="ok 5/8";
9     }
10     public class ClassWithStaticFunctions {
11         static function ok7() {
12             trace("ok 7/8");
13         }
14     }
15     public class Main extends flash.display.MovieClip {
16
17         public function getClass():Class {
18             return ClassWithStaticFunctions;
19         }
20                 
21         public function checkScope():void
22         {
23             try {
24                 flash.net.navigateToURL;
25             } catch (e:Error) {
26             }
27             trace("ok 6/8");
28
29             with(getClass()) {
30                 try {
31                   throw new Error;
32                 } catch(e:Error) {
33                     ok7();
34                 }
35             }
36         }
37         public function checkActivation():void
38         {
39             var yy:uint = 0;
40             var inc_y = function() {
41                 yy = yy + 1;
42             }
43             
44             try {
45               inc_y();
46               throw new Error;
47             } catch(e:Error) {
48                 inc_y();
49             }
50             if(yy!=2) trace("error ("+yy+")")
51             else      trace("ok 8/8");
52         }
53                 
54
55         function Main() {
56             try {
57                 throw new MyError
58                 trace("error");
59             } catch(error:Error) {
60                 // MyError is not of the Error class
61                 trace("error");
62             } catch(error:MyError) {
63                 trace("ok 1/8");
64             } catch(x) {
65                 trace("error");
66             }
67             
68             try {
69                 throw new MyOtherError
70                 trace("error");
71             } catch(error:MyError) {
72                 trace("error");
73             } catch(x:*) { // ":*" is the same as ""
74                 trace("ok 2/8");
75             }
76             
77             try {
78                 trace("ok 3/8");
79                 // don't throw any error
80             } catch(error:MyError) {
81                 trace("error");
82             } catch(error:MyOtherError) {
83                 trace("error");
84             } catch(x:*) { // ":*" is the same as ""
85                 trace("error");
86             }
87
88             trace("ok 4/8");
89
90             try {throw new MyOtherError} 
91             catch(x:*) {
92                 trace((x as MyOtherError).ok5);
93             }
94
95             checkScope();
96             checkActivation();
97             
98             trace("[exit]");
99         }
100     }
101 }