Professional Documents
Culture Documents
Manual
Manual
Contents
1 Tutorials 29 1.1 Converting your ash movies to an executable program . . . . . 29 1.2 Add more functions to your application . . . . . . . . . . . . . . 33 1.3 Using FFish script objects synchronously in ActionScript 2/3 . . 36 1.3.1 Setting the class path for ActionScript 2/3 . . . . . . . . 36 1.3.2 Dening hot keys for SWFKit plug-in commands . . . . . 37 1.3.3 Installing the plug-in and commands manually . . . . . . 37 1.3.4 Attaching to a SWFKit project . . . . . . . . . . . . . . . 38 1.3.5 Adding functions, preview, and testing . . . . . . . . . . . 38 1.3.6 About the trace method of SWFKit . . . . . . . . . . . . 40 1.3.7 Handling events of the FFish script objects . . . . . . . . 41 1.3.8 How does the synchronous calls work . . . . . . . . . . . . 41 1.3.9 Wrapping ActiveX components . . . . . . . . . . . . . . . 46 1.3.10 Dierences between wrapper classes for actionscript 2 and actionscript 3 48 1.3.11 Calling methods written in sh script from within actionscript 2 or 3 49 1.3.12 Calling actionscript methods from within sh script . . . 49 1.3.13 Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 1.4 Data exchanging between Action Script and FFish Script . . . . 51 1.4.1 The setVariable method and the getVariable method . . . 51 1.4.2 The updateData method . . . . . . . . . . . . . . . . . . . 51 1.4.3 getArray, putArray, getObject, putObject . . . . . . . . . 52 1.5 Protecting your applications . . . . . . . . . . . . . . . . . . . . . 52 1.5.1 Bypassing the default handler . . . . . . . . . . . . . . . . 53 1.5.2 Check if it is expired . . . . . . . . . . . . . . . . . . . . . 53 1.5.3 Registration . . . . . . . . . . . . . . . . . . . . . . . . . . 53 1.6 Protecting your resource les . . . . . . . . . . . . . . . . . . . . 54 1.7 Using menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 1.7.1 The main menu . . . . . . . . . . . . . . . . . . . . . . . . 55 1.7.2 The context menu . . . . . . . . . . . . . . . . . . . . . . 56 1.8 Using ActiveX Objects . . . . . . . . . . . . . . . . . . . . . . . . 56 1.8.1 Registering ActiveX objects manually . . . . . . . . . . . 56 1.8.2 Registering ActiveX objects on end users systems I - using the register method 57 1.8.3 Registering ActiveX objects on end users systems II - let the setup programs do it 58 1.8.4 Using ActiveX dlls without registration . . . . . . . . . . 60
CONTENTS Stand alone programs and the Flash Player . . . . . . . . . . . . 60 The trace method . . . . . . . . . . . . . . . . . . . . . . . . . 60 The variable scope in FFish Script . . . . . . . . . . . . . . . . . 61 Using SWFKit Pro to call functions in dynamic-linked libraries(dlls) 61 1.12.1 Declaring the dll functions . . . . . . . . . . . . . . . . . . 61 1.12.2 Calling dll functions and get results . . . . . . . . . . . . 63 Building windowless projectors . . . . . . . . . . . . . . . . . . . 69 Accessing disk les . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Launching external applications . . . . . . . . . . . . . . . . . . . 70 Opening system dialog boxes . . . . . . . . . . . . . . . . . . . . 71 Accessing databases . . . . . . . . . . . . . . . . . . . . . . . . . 72 Programming the tray icons . . . . . . . . . . . . . . . . . . . . . 74 Downloading and uploading les . . . . . . . . . . . . . . . . . . 75 Sending and receiving emails . . . . . . . . . . . . . . . . . . . . 77 Creating multiple forms . . . . . . . . . . . . . . . . . . . . . . . 78 Changing screen resolutions . . . . . . . . . . . . . . . . . . . . . 79 Screen capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 Reusing the web browser control . . . . . . . . . . . . . . . . . . 80 Playing avi, rm, mov, wmv, etc movies . . . . . . . . . . . . . . . 82 Opening pdf les . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Calling Active scripting languages . . . . . . . . . . . . . . . . . 85 Using shared objects in packed movies . . . . . . . . . . . . . . . 86 Using autoupdate . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 . 89 . 89 . 89 . 90 . 90 . 90 . 91 . 91 . 92 . 93 . 93 . 94 . 94 . 95 . 97 . 97 . 98 . 98 . 99 . 99 . 100
1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22 1.23 1.24 1.25 1.26 1.27 1.28 1.29
2 FFish Script Objects Reference 2.1 Global Object . . . . . . . . . . 2.1.1 Properties . . . . . . . . 2.1.1.1 NaN . . . . . . 2.1.1.2 Innity . . . . 2.1.2 Methods . . . . . . . . . 2.1.2.1 parseFloat . . 2.1.2.2 parseInt . . . . 2.1.2.3 escape . . . . . 2.1.2.4 unescape . . . 2.1.2.5 eval . . . . . . 2.1.2.6 isNAN . . . . 2.1.2.7 isFinit . . . . . 2.1.2.8 trace . . . . . 2.1.2.9 createControl . 2.1.2.10 getMainWnd . 2.1.2.11 getAppDir . . 2.1.2.12 getMovies . . . 2.1.2.13 setWindowless 2.1.2.14 readProle . . 2.1.2.15 writeProle . . 2.1.2.16 processMsg . .
CONTENTS 2.1.2.17 getAdditionalFile . . . 2.1.2.18 getExeName . . . . . . 2.1.2.19 invoke . . . . . . . . . . 2.1.2.20 evals . . . . . . . . . . . 2.1.2.21 decodeURI . . . . . . . 2.1.2.22 encodeURI . . . . . . . 2.1.2.23 decodeURIComponent . 2.1.2.24 encodeURIComponent . Boolean object . . . . . . . . . . . . . . Number object . . . . . . . . . . . . . . 2.3.1 Properties . . . . . . . . . . . . . 2.3.1.1 MAX VALUE . . . . . 2.3.1.2 MIN VALUE . . . . . . 2.3.1.3 NaN . . . . . . . . . . . 2.3.1.4 NEGATIVE INFINITY 2.3.1.5 POSITIVE INFINITY 2.3.2 methods . . . . . . . . . . . . . . 2.3.2.1 format . . . . . . . . . String object . . . . . . . . . . . . . . . 2.4.1 Properties . . . . . . . . . . . . . 2.4.1.1 length . . . . . . . . . . 2.4.2 Methods . . . . . . . . . . . . . . 2.4.2.1 charAt . . . . . . . . . 2.4.2.2 charCodeAt . . . . . . . 2.4.2.3 concat . . . . . . . . . . 2.4.2.4 fromCharCode . . . . . 2.4.2.5 indexOf . . . . . . . . . 2.4.2.6 lastIndexOf . . . . . . . 2.4.2.7 slice . . . . . . . . . . . 2.4.2.8 split . . . . . . . . . . . 2.4.2.9 substr . . . . . . . . . . 2.4.2.10 substring . . . . . . . . 2.4.2.11 toLowerCase . . . . . . 2.4.2.12 toUpperCase . . . . . . 2.4.2.13 match . . . . . . . . . . 2.4.2.14 replace . . . . . . . . . 2.4.2.15 search . . . . . . . . . . 2.4.2.16 anchor . . . . . . . . . 2.4.2.17 big . . . . . . . . . . . . 2.4.2.18 blink . . . . . . . . . . 2.4.2.19 bold . . . . . . . . . . . 2.4.2.20 xed . . . . . . . . . . . 2.4.2.21 fontColor . . . . . . . . 2.4.2.22 fontSize . . . . . . . . . 2.4.2.23 italics . . . . . . . . . . 2.4.2.24 link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5 100 101 102 102 102 103 103 103 104 104 105 105 105 105 106 106 106 106 107 108 108 108 108 109 109 110 111 111 112 113 114 114 115 116 117 117 118 119 119 120 120 121 122 122 123 124
2.2 2.3
2.4
6 2.4.2.25 small . . . . . . . . 2.4.2.26 strike . . . . . . . . 2.4.2.27 sub . . . . . . . . . 2.4.2.28 sup . . . . . . . . . Function Object . . . . . . . . . . . 2.5.1 Properties . . . . . . . . . . . 2.5.1.1 arguments . . . . . Array Object . . . . . . . . . . . . . 2.6.1 Properties . . . . . . . . . . . 2.6.1.1 length . . . . . . . . 2.6.2 Methods . . . . . . . . . . . . 2.6.2.1 concat . . . . . . . . 2.6.2.2 join . . . . . . . . . 2.6.2.3 pop . . . . . . . . . 2.6.2.4 push . . . . . . . . . 2.6.2.5 reverse . . . . . . . 2.6.2.6 shift . . . . . . . . . 2.6.2.7 slice . . . . . . . . . 2.6.2.8 sort . . . . . . . . . 2.6.2.9 splice . . . . . . . . 2.6.2.10 unshift . . . . . . . Date Object . . . . . . . . . . . . . . 2.7.1 Methods . . . . . . . . . . . . 2.7.1.1 getDate . . . . . . . 2.7.1.2 getDay . . . . . . . 2.7.1.3 getFullYear . . . . . 2.7.1.4 getHours . . . . . . 2.7.1.5 getMilliseconds . . . 2.7.1.6 getMinutes . . . . . 2.7.1.7 getMonth . . . . . . 2.7.1.8 getSeconds . . . . . 2.7.1.9 getTime . . . . . . . 2.7.1.10 getTimezoneOset . 2.7.1.11 getUTCDate . . . . 2.7.1.12 getUTCDay . . . . 2.7.1.13 getUTCFullYear . . 2.7.1.14 getUTCHours . . . 2.7.1.15 getUTCMilliseconds 2.7.1.16 getMinutes . . . . . 2.7.1.17 getUTCMonth . . . 2.7.1.18 getUTCSeconds . . 2.7.1.19 getYear . . . . . . . 2.7.1.20 setDate . . . . . . . 2.7.1.21 setFullYear . . . . . 2.7.1.22 setHours . . . . . . 2.7.1.23 setMilliseconds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 125 125 126 126 128 128 129 130 130 130 130 131 132 132 133 133 134 135 135 136 137 138 138 138 139 140 140 141 141 142 142 143 143 144 144 145 145 146 146 147 147 148 148 149 149
2.5
2.6
2.7
CONTENTS 2.7.1.24 setMinutes . . . . . 2.7.1.25 setMonth . . . . . . 2.7.1.26 setSeconds . . . . . 2.7.1.27 setTime . . . . . . . 2.7.1.28 setUTCDate . . . . 2.7.1.29 setUTCFullYear . . 2.7.1.30 setUTCHours . . . 2.7.1.31 setUTCMilliseconds 2.7.1.32 setUTCMinutes . . 2.7.1.33 setUTCMonth . . . 2.7.1.34 setUTCSeconds . . 2.7.1.35 setYear . . . . . . . 2.7.1.36 UTC . . . . . . . . 2.7.1.37 parse . . . . . . . . 2.7.1.38 toGMTString . . . . 2.7.1.39 toLocaleString . . . Math . . . . . . . . . . . . . . . . . . 2.8.1 Properties . . . . . . . . . . . 2.8.1.1 E . . . . . . . . . . 2.8.1.2 LN2 . . . . . . . . . 2.8.1.3 LOG2E . . . . . . . 2.8.1.4 LN10 . . . . . . . . 2.8.1.5 LOG10E . . . . . . 2.8.1.6 PI . . . . . . . . . . 2.8.1.7 SQRT1 2 . . . . . . 2.8.1.8 SQRT2 . . . . . . . 2.8.2 Methods . . . . . . . . . . . . 2.8.2.1 abs . . . . . . . . . 2.8.2.2 acos . . . . . . . . . 2.8.2.3 asin . . . . . . . . . 2.8.2.4 atan . . . . . . . . . 2.8.2.5 atan2 . . . . . . . . 2.8.2.6 ceil . . . . . . . . . 2.8.2.7 cos . . . . . . . . . . 2.8.2.8 exp . . . . . . . . . 2.8.2.9 oor . . . . . . . . . 2.8.2.10 log . . . . . . . . . . 2.8.2.11 max . . . . . . . . . 2.8.2.12 min . . . . . . . . . 2.8.2.13 pow . . . . . . . . . 2.8.2.14 random . . . . . . . 2.8.2.15 round . . . . . . . . 2.8.2.16 sin . . . . . . . . . . 2.8.2.17 sqrt . . . . . . . . . 2.8.2.18 tan . . . . . . . . . Dialogs Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7 150 150 151 151 152 152 153 153 154 154 155 155 156 156 157 158 158 158 158 159 159 159 160 160 160 160 161 161 161 162 162 163 163 164 164 165 165 166 166 166 167 167 167 168 169 169
2.8
2.9
8 Methods . . . . . . . . . . . . . . . . 2.9.1.1 msgBox . . . . . . . . . . . 2.9.1.2 leOpen . . . . . . . . . . . 2.9.1.3 leSave . . . . . . . . . . . 2.9.1.4 chooseColor . . . . . . . . . 2.9.1.5 chooseFont . . . . . . . . . 2.9.1.6 browse . . . . . . . . . . . 2.10 Shell Object . . . . . . . . . . . . . . . . . . 2.10.1 Methods . . . . . . . . . . . . . . . . 2.10.1.1 run . . . . . . . . . . . . . 2.10.1.2 runConsole . . . . . . . . . 2.10.1.3 runAndWait . . . . . . . . 2.10.1.4 open . . . . . . . . . . . . . 2.10.1.5 print . . . . . . . . . . . . 2.10.1.6 explore . . . . . . . . . . . 2.10.1.7 ndExecutable . . . . . . . 2.10.1.8 getSpecialFolder . . . . . . 2.10.1.9 addToRecentDocs . . . . . 2.10.1.10 clearRecentDocs . . . . . . 2.10.1.11 emptyRecycleBin . . . . . 2.10.1.12 getEnvironmentStrings . . 2.10.1.13 getEnvironmentVariable . . 2.10.1.14 setEnvironmentVariable . . 2.10.1.15 delEnvironmentVariable . . 2.10.1.16 expandEnvironmentStrings 2.10.1.17 setDesktopWallpaper . . . 2.10.1.18 getFileVersionInfo . . . . . 2.11 MCI Object . . . . . . . . . . . . . . . . . . 2.11.1 Properties . . . . . . . . . . . . . . . 2.11.1.1 alias . . . . . . . . . . . . . 2.11.1.2 canEject . . . . . . . . . . 2.11.1.3 canPlay . . . . . . . . . . . 2.11.1.4 canRecord . . . . . . . . . 2.11.1.5 canStep . . . . . . . . . . . 2.11.1.6 deviceID . . . . . . . . . . 2.11.1.7 deviceType . . . . . . . . . 2.11.1.8 leName . . . . . . . . . . 2.11.1.9 frames . . . . . . . . . . . . 2.11.1.10 from . . . . . . . . . . . . . 2.11.1.11 length . . . . . . . . . . . . 2.11.1.12 mode . . . . . . . . . . . . 2.11.1.13 notify . . . . . . . . . . . . 2.11.1.14 position . . . . . . . . . . . 2.11.1.15 recordMode . . . . . . . . . 2.11.1.16 sharable . . . . . . . . . . . 2.11.1.17 channel . . . . . . . . . . . 2.9.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 170 171 172 173 173 174 175 175 175 176 177 178 179 180 181 182 184 185 185 186 186 187 187 188 188 189 190 194 194 194 195 195 196 196 196 196 197 197 198 198 199 199 199 200 201
CONTENTS 2.11.1.18 start . . . . . . 2.11.1.19 timeFormat . . 2.11.1.20 to . . . . . . . 2.11.1.21 track . . . . . 2.11.1.22 trackLength . 2.11.1.23 trackPosition . 2.11.1.24 wait . . . . . . 2.11.1.25 playerWindow 2.11.1.26 error . . . . . . 2.11.1.27 errorMsg . . . 2.11.1.28 command . . . 2.11.1.29 left . . . . . . 2.11.1.30 top . . . . . . 2.11.1.31 width . . . . . 2.11.1.32 height . . . . . 2.11.2 Methods . . . . . . . . . 2.11.2.1 sendCmdString 2.11.2.2 getDevices . . 2.11.2.3 hmsHour . . . 2.11.2.4 hmsMinute . . 2.11.2.5 hmsSecond . . 2.11.2.6 makeHMS . . 2.11.2.7 makeMSF . . . 2.11.2.8 makeTMSF . . 2.11.2.9 msfFrame . . . 2.11.2.10 msfMinute . . 2.11.2.11 msfSecond . . 2.11.2.12 tmsfMinute . . 2.11.2.13 tmsfFrame . . 2.11.2.14 tmsfSecond . . 2.11.2.15 tmsfTrack . . . 2.11.3 Events . . . . . . . . . . 2.11.3.1 onNotify . . . 2.12 Application Object . . . . . . . 2.12.1 Properties . . . . . . . . 2.12.1.1 Appearance . . 2.12.1.2 SizeAndPos . . 2.12.1.3 Interaction . . 2.12.1.4 Behaviour . . . 2.12.1.5 SysTray . . . . 2.12.1.6 Preferences . . 2.12.1.7 Expiry . . . . 2.12.1.8 dragdrop . . . 2.12.1.9 clipboard . . . 2.12.1.10 StatusBar . . . 2.12.1.11 cmdLine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
9 201 202 202 203 204 204 204 205 205 205 205 207 207 208 208 208 208 209 209 210 210 211 211 212 212 213 213 214 214 215 215 216 216 216 217 217 217 217 218 218 218 219 219 219 219 219
10 2.12.1.12 cmdItems . . . . . . . 2.12.1.13 cursor . . . . . . . . . 2.12.1.14 isScr . . . . . . . . . . 2.12.1.15 traceWnd . . . . . . . 2.12.1.16 captureMouse . . . . 2.12.1.17 setFocus . . . . . . . 2.12.2 Methods . . . . . . . . . . . . . 2.12.2.1 getBasePath . . . . . 2.12.2.2 setBasePath . . . . . 2.12.2.3 associate . . . . . . . 2.12.2.4 setInterval . . . . . . 2.12.2.5 clearInterval . . . . . 2.12.2.6 traceToFile . . . . . . 2.12.2.7 about . . . . . . . . . 2.12.2.8 setDragRegion . . . . 2.12.2.9 sendMessage . . . . . 2.12.2.10 registerASMethods . . 2.12.3 Events . . . . . . . . . . . . . . 2.12.3.1 onGetMovie . . . . . 2.12.3.2 onMovieLoaded . . . 2.13 Application.Appearance . . . . . . . . 2.13.1 Properties . . . . . . . . . . . . 2.13.1.1 windowShape . . . . . 2.13.1.2 borderStyle . . . . . . 2.13.1.3 borderIcons . . . . . . 2.13.1.4 scaleMode . . . . . . 2.13.1.5 caption . . . . . . . . 2.13.1.6 icon . . . . . . . . . . 2.14 Application.SizeAndPos . . . . . . . . 2.14.1 properties . . . . . . . . . . . . 2.14.1.1 windowSize . . . . . . 2.14.1.2 pos . . . . . . . . . . 2.14.1.3 bKeepRatio . . . . . . 2.14.2 methods . . . . . . . . . . . . . 2.14.2.1 setCustomPos . . . . 2.14.2.2 setCustomSize . . . . 2.14.2.3 setCustomSizeAndPos 2.15 Application.Interaction . . . . . . . . . 2.15.1 Properties . . . . . . . . . . . . 2.15.1.1 lBtnClk . . . . . . . . 2.15.1.2 rBtnClk . . . . . . . . 2.15.1.3 keyPress . . . . . . . 2.15.1.4 exitKeys . . . . . . . 2.15.1.5 hotKey . . . . . . . . 2.15.1.6 bDisableAltTab . . . 2.15.1.7 bDisableCursor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 220 221 221 221 221 222 222 222 224 225 226 226 227 227 228 228 229 229 230 230 230 230 231 231 232 232 233 233 233 233 234 235 235 235 235 236 236 236 236 237 237 238 238 238 239
CONTENTS 2.15.1.8 bDisableScr . . . . . . . . . 2.16 Application.Behaviour . . . . . . . . . . . . 2.16.1 Properties . . . . . . . . . . . . . . . 2.16.1.1 bAllowExtendContextMenu 2.16.1.2 extendContextMenu . . . . 2.16.1.3 bAutoPlay . . . . . . . . . 2.16.1.4 bStartMinimized . . . . . . 2.16.1.5 bAlwaysOnTop . . . . . . . 2.16.1.6 bShowInSystemTray . . . . 2.17 Application.Expiry . . . . . . . . . . . . . . 2.17.1 Properties . . . . . . . . . . . . . . . 2.17.1.1 bEnable . . . . . . . . . . . 2.17.1.2 expireOn . . . . . . . . . . 2.17.1.3 leftDays . . . . . . . . . . . 2.17.1.4 bEnableUnlock . . . . . . . 2.17.1.5 isExpired . . . . . . . . . . 2.17.1.6 isRegistered . . . . . . . . 2.17.1.7 expiryMsg . . . . . . . . . 2.17.1.8 rbCustomized . . . . . . . 2.17.1.9 rbCaption . . . . . . . . . . 2.17.1.10 rbInfo . . . . . . . . . . . . 2.17.1.11 rbShow3rdBtn . . . . . . . 2.17.1.12 rb3rdBtnCaption . . . . . . 2.17.1.13 rb3rdBtnLink . . . . . . . 2.17.1.14 username . . . . . . . . . . 2.17.1.15 serialNumber . . . . . . . . 2.17.2 Methods . . . . . . . . . . . . . . . . 2.17.2.1 showRegisterDlg . . . . . . 2.17.2.2 register . . . . . . . . . . . 2.17.3 Events . . . . . . . . . . . . . . . . . 2.17.3.1 onExpiry . . . . . . . . . . 2.18 Application.SysTray . . . . . . . . . . . . . 2.18.1 Properties . . . . . . . . . . . . . . . 2.18.1.1 tip . . . . . . . . . . . . . . 2.18.1.2 icon . . . . . . . . . . . . . 2.18.1.3 balloonTip . . . . . . . . . 2.18.1.4 balloonTitle . . . . . . . . 2.18.1.5 balloonTimeout . . . . . . 2.18.1.6 balloonIcon . . . . . . . . . 2.18.1.7 useDefaultHandler . . . . . 2.18.2 Methods . . . . . . . . . . . . . . . . 2.18.2.1 add . . . . . . . . . . . . . 2.18.2.2 modify . . . . . . . . . . . 2.18.2.3 remove . . . . . . . . . . . 2.18.2.4 showBalloonTip . . . . . . 2.18.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11 239 239 239 239 240 240 240 241 241 241 241 241 242 242 242 243 243 243 243 244 244 244 244 245 245 245 245 245 246 247 247 248 249 249 249 249 249 250 250 250 251 251 252 253 253 253
12 2.18.3.1 onMouseMove . . . 2.18.3.2 onLClicked . . . . . 2.18.3.3 onRClicked . . . . . 2.18.3.4 onLDblClicked . . . 2.18.3.5 onRDblClicked . . . Application.Preferences . . . . . . . 2.19.1 Properties . . . . . . . . . . . 2.19.1.1 wakeupMethod . . . 2.19.1.2 hotKey . . . . . . . 2.19.1.3 disableCursor . . . . 2.19.1.4 disableCDAutoRun Application.dragdrop . . . . . . . . . 2.20.1 Properties . . . . . . . . . . . 2.20.1.1 enable . . . . . . . . 2.20.2 Events . . . . . . . . . . . . . 2.20.2.1 onDragEnter Text . 2.20.2.2 onDragEnter Files . 2.20.2.3 onDragOver Text . 2.20.2.4 onDragOver Files . 2.20.2.5 onDragLeave . . . . 2.20.2.6 onDropText . . . . 2.20.2.7 onDropFiles . . . . 2.20.2.8 onDragGetData . . Application.clipboard . . . . . . . . 2.21.1 Methods . . . . . . . . . . . . 2.21.1.1 copyBitmap Screen 2.21.1.2 copyBitmap Movie . 2.21.1.3 copyText . . . . . . 2.21.1.4 paste . . . . . . . . 2.21.1.5 pasteBitmap . . . . Application.StatusBar . . . . . . . . 2.22.1 Properties . . . . . . . . . . . 2.22.1.1 progress . . . . . . . 2.22.2 Methods . . . . . . . . . . . . 2.22.2.1 init . . . . . . . . . 2.22.2.2 setPaneText . . . . 2.22.2.3 setPaneIcon . . . . 2.22.2.4 setPaneWidth . . . 2.22.2.5 disablePane . . . . . 2.22.2.6 setPaneBorder . . . 2.22.2.7 show . . . . . . . . 2.22.2.8 hide . . . . . . . . . Menu . . . . . . . . . . . . . . . . . 2.23.1 Properties . . . . . . . . . . . 2.23.1.1 enableAccel . . . . . 2.23.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 254 254 254 255 255 255 255 256 256 256 256 257 257 257 257 258 258 258 259 259 259 260 260 261 261 261 262 262 262 263 263 263 263 263 264 265 265 266 266 267 267 267 268 268 268
2.19
2.20
2.21
2.22
2.23
CONTENTS 2.23.2.1 load . . . . . . . . 2.23.2.2 setMenu . . . . . . 2.23.2.3 createMenu . . . . 2.23.2.4 createPopupMenu 2.23.2.5 appendItem . . . . 2.23.2.6 insertItem . . . . 2.23.2.7 removeItem . . . . 2.23.2.8 getSubMenu . . . 2.23.2.9 show . . . . . . . 2.23.3 Events . . . . . . . . . . . . 2.23.3.1 onCommand . . . 2.23.3.2 onUpdateItem . . Encryption . . . . . . . . . . . . . 2.24.1 Methods . . . . . . . . . . . 2.24.1.1 blowshEncode . . 2.24.1.2 blowshDecode . . 2.24.1.3 md5 . . . . . . . . 2.24.1.4 md5File . . . . . . 2.24.1.5 desEncode . . . . 2.24.1.6 desDecode . . . . 2.24.1.7 encFile . . . . . . 2.24.1.8 decFile . . . . . . DiskInfo . . . . . . . . . . . . . . . 2.25.1 Properties . . . . . . . . . . 2.25.1.1 modelNumber . . 2.25.1.2 revisionNumber . 2.25.1.3 driveType . . . . . 2.25.1.4 buerSize . . . . . 2.25.1.5 cylinders . . . . . 2.25.1.6 heads . . . . . . . 2.25.1.7 sectors . . . . . . DataFile . . . . . . . . . . . . . . . 2.26.1 Methods . . . . . . . . . . . 2.26.1.1 load . . . . . . . . 2.26.1.2 loadAndDec . . . 2.26.1.3 save . . . . . . . . 2.26.1.4 saveAndEnc . . . 2.26.1.5 remove . . . . . . DesktopToy . . . . . . . . . . . . . 2.27.1 Properties . . . . . . . . . . 2.27.1.1 followCursor . . . 2.27.2 Methods . . . . . . . . . . . 2.27.2.1 act . . . . . . . . . 2.27.2.2 stop . . . . . . . . 2.27.3 Events . . . . . . . . . . . . 2.27.3.1 onStop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13 268 269 269 270 270 271 272 272 273 274 274 275 276 276 276 277 277 278 278 279 279 280 280 281 281 281 281 282 282 282 282 282 283 283 283 284 285 285 285 286 286 286 286 287 287 287
2.24
2.25
2.26
2.27
14 2.28 Window Object . . . . . . . . . . . . . 2.28.1 Properties . . . . . . . . . . . . 2.28.1.1 caption . . . . . . . . 2.28.1.2 left . . . . . . . . . . 2.28.1.3 top . . . . . . . . . . 2.28.1.4 width . . . . . . . . . 2.28.1.5 height . . . . . . . . . 2.28.1.6 parent . . . . . . . . . 2.28.1.7 handle . . . . . . . . . 2.28.1.8 className . . . . . . 2.28.1.9 visible . . . . . . . . . 2.28.1.10 enable . . . . . . . . . 2.28.1.11 clientRect . . . . . . . 2.28.1.12 windowState . . . . . 2.28.2 Methods . . . . . . . . . . . . . 2.28.2.1 show . . . . . . . . . 2.28.2.2 hide . . . . . . . . . . 2.28.2.3 close . . . . . . . . . . 2.28.2.4 getChildren . . . . . . 2.28.2.5 getWindowsByName . 2.28.2.6 nd . . . . . . . . . . 2.28.2.7 bringToTop . . . . . . 2.28.2.8 modifyStyle . . . . . . 2.28.2.9 modifyStyleEx . . . . 2.28.2.10 move . . . . . . . . . 2.28.2.11 update . . . . . . . . 2.28.2.12 animate . . . . . . . . 2.28.2.13 y . . . . . . . . . . . 2.28.2.14 y2 . . . . . . . . . . 2.28.2.15 center . . . . . . . . . 2.28.3 Events . . . . . . . . . . . . . . 2.28.3.1 onClose . . . . . . . . 2.28.3.2 onQueryClose . . . . 2.28.3.3 onEnter . . . . . . . . 2.28.3.4 onLeave . . . . . . . . 2.28.3.5 onHover . . . . . . . . 2.28.3.6 onSize . . . . . . . . . 2.28.3.7 onMessage . . . . . . 2.29 FlashPlayer Object . . . . . . . . . . . 2.29.1 Properties . . . . . . . . . . . . 2.29.1.1 totalFrames . . . . . . 2.29.1.2 playing . . . . . . . . 2.29.1.3 quality . . . . . . . . 2.29.1.4 scaleMode . . . . . . 2.29.1.5 alignMode . . . . . . 2.29.1.6 backgroundColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288 288 288 289 289 289 290 290 290 291 291 291 292 292 292 292 293 294 294 295 296 296 297 297 298 299 299 300 301 302 302 302 302 303 304 304 305 305 306 307 307 308 308 308 309 309
CONTENTS 2.29.1.7 loop . . . . . . . . . . . 2.29.1.8 movie . . . . . . . . . . 2.29.1.9 frameNum . . . . . . . 2.29.1.10 wmode . . . . . . . . . 2.29.1.11 salign . . . . . . . . . . 2.29.1.12 base . . . . . . . . . . . 2.29.1.13 scale . . . . . . . . . . . 2.29.1.14 bgColor . . . . . . . . . 2.29.1.15 showPrintDlg . . . . . . 2.29.1.16 printerProperties . . . . 2.29.2 Methods . . . . . . . . . . . . . . 2.29.2.1 bindData . . . . . . . . 2.29.2.2 unbindData . . . . . . . 2.29.2.3 unbindAll . . . . . . . . 2.29.2.4 updateData . . . . . . . 2.29.2.5 getArray . . . . . . . . 2.29.2.6 putArray . . . . . . . . 2.29.2.7 getObject . . . . . . . . 2.29.2.8 putObject . . . . . . . 2.29.2.9 setZoomRect . . . . . . 2.29.2.10 zoom . . . . . . . . . . 2.29.2.11 pan . . . . . . . . . . . 2.29.2.12 play . . . . . . . . . . . 2.29.2.13 stop . . . . . . . . . . . 2.29.2.14 back . . . . . . . . . . . 2.29.2.15 forward . . . . . . . . . 2.29.2.16 rewind . . . . . . . . . 2.29.2.17 gotoFrame . . . . . . . 2.29.2.18 currentFrame . . . . . . 2.29.2.19 isPlaying . . . . . . . . 2.29.2.20 percentLoaded . . . . . 2.29.2.21 ashVersion . . . . . . 2.29.2.22 loadMovie . . . . . . . 2.29.2.23 setVariable . . . . . . . 2.29.2.24 getVariable . . . . . . . 2.29.2.25 targetGotoFrame . . . . 2.29.2.26 targetGotoLabel . . . . 2.29.2.27 targetCurrentFrame . . 2.29.2.28 targetCurrentLabel . . 2.29.2.29 targetPlay . . . . . . . 2.29.2.30 targetStopPlay . . . . . 2.29.2.31 targetGetProperty . . . 2.29.2.32 targetSetProperty . . . 2.29.2.33 targetCallFrame . . . . 2.29.2.34 targetCallLabel . . . . 2.29.2.35 targetGetPropertyNum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15 309 309 310 310 310 310 311 311 311 311 312 312 312 313 313 314 314 315 315 316 316 317 317 318 318 318 319 319 320 320 320 321 321 322 322 323 323 324 324 324 325 325 326 327 327 328
16 2.29.2.36 targetSetPropertyNum 2.29.2.37 getMovieInfo . . . . . . 2.29.2.38 movieToWindow . . . . 2.29.3 Events . . . . . . . . . . . . . . . 2.29.3.1 onContextMenu . . . . RegExp Object . . . . . . . . . . . . . . 2.30.1 Properties . . . . . . . . . . . . . 2.30.1.1 source . . . . . . . . . . 2.30.1.2 global . . . . . . . . . . 2.30.1.3 ignoreCase . . . . . . . 2.30.1.4 multiline . . . . . . . . 2.30.1.5 lastIndex . . . . . . . . 2.30.1.6 input (or $ ) . . . . . . 2.30.1.7 lastMatch . . . . . . . . 2.30.1.8 leftContext . . . . . . . 2.30.1.9 rightContext . . . . . . 2.30.1.10 $1 . . . $9 . . . . . . . . . 2.30.1.11 lastParen . . . . . . . . 2.30.2 Methods . . . . . . . . . . . . . . 2.30.2.1 compile . . . . . . . . . 2.30.2.2 exec . . . . . . . . . . . 2.30.2.3 test . . . . . . . . . . . ActiveXObject Object . . . . . . . . . . 2.31.1 Methods . . . . . . . . . . . . . . 2.31.1.1 register . . . . . . . . . 2.31.1.2 unregister . . . . . . . . 2.31.1.3 setProperty . . . . . . . 2.31.1.4 addObjectInfo . . . . . 2.31.2 ActiveXObject Object Events . . 2.31.2.1 EnablePropertyNotify . 2.31.2.2 OnPropertyChanged . . 2.31.2.3 OnPropertyWillChange 2.31.2.4 onError . . . . . . . . . Enumerator Object . . . . . . . . . . . . 2.32.1 Properties . . . . . . . . . . . . . 2.32.1.1 atEnd . . . . . . . . . . 2.32.1.2 item . . . . . . . . . . . 2.32.2 Methods . . . . . . . . . . . . . . 2.32.2.1 moveFirst . . . . . . . . 2.32.2.2 moveEnd . . . . . . . . 2.32.2.3 moveNext . . . . . . . . RegKey Object . . . . . . . . . . . . . . 2.33.1 Properties . . . . . . . . . . . . . 2.33.1.1 className . . . . . . . 2.33.1.2 newCreated . . . . . . . 2.33.1.3 lastWriteTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 329 329 330 330 331 334 334 334 334 335 335 335 336 336 336 336 337 337 337 338 338 338 340 340 340 341 341 343 344 344 344 345 345 346 346 346 347 347 347 347 348 348 348 349 349
2.30
2.31
2.32
2.33
CONTENTS 2.33.2 Methods . . . . . . . . . . . 2.33.2.1 create . . . . . . . 2.33.2.2 open . . . . . . . . 2.33.2.3 getSubkeyNames . 2.33.2.4 getValues . . . . . 2.33.2.5 getValue . . . . . 2.33.2.6 write . . . . . . . 2.33.2.7 deleteKey . . . . . 2.33.2.8 deleteValue . . . . RegValue Object . . . . . . . . . . 2.34.1 Properties . . . . . . . . . . 2.34.1.1 name . . . . . . . 2.34.1.2 type . . . . . . . . 2.34.1.3 data . . . . . . . . Ini Object . . . . . . . . . . . . . . 2.35.1 Methods . . . . . . . . . . . 2.35.1.1 getInt . . . . . . . 2.35.1.2 getSection . . . . 2.35.1.3 getSectionNames . 2.35.1.4 getString . . . . . 2.35.1.5 writeSection . . . 2.35.1.6 writeString . . . . 2.35.1.7 deleteSection . . . 2.35.1.8 deleteKey . . . . . FontObject Object . . . . . . . . . 2.36.1 Properties . . . . . . . . . . 2.36.1.1 bold . . . . . . . . 2.36.1.2 color . . . . . . . . 2.36.1.3 italic . . . . . . . 2.36.1.4 name . . . . . . . 2.36.1.5 size . . . . . . . . 2.36.1.6 underline . . . . . 2.36.2 Methods . . . . . . . . . . . 2.36.2.1 getFonts . . . . . Shortcut Object . . . . . . . . . . . 2.37.1 Properties . . . . . . . . . . 2.37.1.1 arguments . . . . 2.37.1.2 description . . . . 2.37.1.3 hotKey . . . . . . 2.37.1.4 iconLocation . . . 2.37.1.5 targetPath . . . . 2.37.1.6 windowStyle . . . 2.37.1.7 workingDirectory 2.37.2 Methods . . . . . . . . . . . 2.37.2.1 save . . . . . . . . URLShortcut Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17 350 350 351 352 353 353 354 355 355 356 357 357 357 359 360 361 361 361 362 362 363 363 364 364 365 365 365 365 365 366 366 366 366 366 367 368 368 369 369 369 370 370 371 372 372 372
2.34
2.35
2.36
2.37
2.38
18 2.38.1 Properties . . . . . . . . . . . . . . . . 2.38.1.1 url . . . . . . . . . . . . . . . 2.38.2 Methods . . . . . . . . . . . . . . . . . 2.38.2.1 save . . . . . . . . . . . . . . 2.39 Mail Object . . . . . . . . . . . . . . . . . . . 2.39.1 Properties . . . . . . . . . . . . . . . . 2.39.1.1 from . . . . . . . . . . . . . . 2.39.1.2 replyTo . . . . . . . . . . . . 2.39.1.3 to . . . . . . . . . . . . . . . 2.39.1.4 subject . . . . . . . . . . . . 2.39.1.5 cc . . . . . . . . . . . . . . . 2.39.1.6 bcc . . . . . . . . . . . . . . 2.39.1.7 date . . . . . . . . . . . . . . 2.39.1.8 priority . . . . . . . . . . . . 2.39.1.9 size . . . . . . . . . . . . . . 2.39.1.10 text . . . . . . . . . . . . . . 2.39.1.11 html . . . . . . . . . . . . . . 2.39.1.12 attachmentCount . . . . . . 2.39.1.13 htmlItemCount . . . . . . . . 2.39.2 Methods . . . . . . . . . . . . . . . . . 2.39.2.1 save . . . . . . . . . . . . . . 2.39.2.2 load . . . . . . . . . . . . . . 2.39.2.3 asText . . . . . . . . . . . . . 2.39.2.4 getAttachmentContentType 2.39.2.5 getAttachmentName . . . . . 2.39.2.6 saveAttachment . . . . . . . 2.39.2.7 addAttachment . . . . . . . . 2.39.2.8 removeAttachment . . . . . . 2.39.2.9 getHtmlItemName . . . . . . 2.39.2.10 getHtmlItemID . . . . . . . . 2.39.2.11 saveHtmlItem . . . . . . . . 2.39.2.12 addHtmlItem . . . . . . . . . 2.40 SendMail Object . . . . . . . . . . . . . . . . 2.40.1 Properties . . . . . . . . . . . . . . . . 2.40.1.1 server . . . . . . . . . . . . . 2.40.1.2 port . . . . . . . . . . . . . . 2.40.1.3 username . . . . . . . . . . . 2.40.1.4 password . . . . . . . . . . . 2.40.2 Methods . . . . . . . . . . . . . . . . . 2.40.2.1 send . . . . . . . . . . . . . . 2.40.2.2 connect . . . . . . . . . . . . 2.40.2.3 command . . . . . . . . . . . 2.40.2.4 write . . . . . . . . . . . . . 2.40.2.5 close . . . . . . . . . . . . . . 2.40.3 Events . . . . . . . . . . . . . . . . . . 2.40.3.1 onSend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373 373 373 373 374 376 376 376 377 377 377 377 378 378 378 378 379 379 380 380 380 380 381 382 382 383 383 384 384 385 385 386 387 389 389 389 389 390 390 390 390 391 391 392 392 392
CONTENTS 2.41 RecvMail Object . . . . . . . . . . . . . . . . . 2.41.1 Properties . . . . . . . . . . . . . . . . . 2.41.1.1 server . . . . . . . . . . . . . . 2.41.1.2 port . . . . . . . . . . . . . . . 2.41.1.3 Username . . . . . . . . . . . . 2.41.1.4 password . . . . . . . . . . . . 2.41.2 Methods . . . . . . . . . . . . . . . . . . 2.41.2.1 connect . . . . . . . . . . . . . 2.41.2.2 close . . . . . . . . . . . . . . . 2.41.2.3 dele . . . . . . . . . . . . . . . 2.41.2.4 list . . . . . . . . . . . . . . . . 2.41.2.5 noop . . . . . . . . . . . . . . 2.41.2.6 quit . . . . . . . . . . . . . . . 2.41.2.7 retr . . . . . . . . . . . . . . . 2.41.2.8 rset . . . . . . . . . . . . . . . 2.41.2.9 stat . . . . . . . . . . . . . . . 2.41.2.10 top . . . . . . . . . . . . . . . 2.41.2.11 uidl . . . . . . . . . . . . . . . 2.41.3 Events . . . . . . . . . . . . . . . . . . . 2.41.3.1 onRecv . . . . . . . . . . . . . 2.42 Inet Object . . . . . . . . . . . . . . . . . . . . 2.42.1 Methods . . . . . . . . . . . . . . . . . . 2.42.1.1 ping . . . . . . . . . . . . . . . 2.42.1.2 mxnd . . . . . . . . . . . . . 2.42.1.3 isInetConnected . . . . . . . . 2.42.1.4 getDNS . . . . . . . . . . . . . 2.42.1.5 getIPCong . . . . . . . . . . . 2.42.1.6 getUrl . . . . . . . . . . . . . . 2.42.1.7 getHttpFileSize . . . . . . . . 2.42.1.8 getHttpFileLastModiedTime 2.42.1.9 getHttpFileStatus . . . . . . . 2.42.1.10 getHttpFileHeader . . . . . . . 2.42.1.11 openFtp . . . . . . . . . . . . 2.42.2 Events . . . . . . . . . . . . . . . . . . . 2.42.2.1 onPinging . . . . . . . . . . . . 2.42.2.2 onGetUrl . . . . . . . . . . . . 2.43 Inet.Ftp Object . . . . . . . . . . . . . . . . . . 2.43.1 Methods . . . . . . . . . . . . . . . . . . 2.43.1.1 connect . . . . . . . . . . . . . 2.43.1.2 createDir . . . . . . . . . . . . 2.43.1.3 removeDir . . . . . . . . . . . 2.43.1.4 deleteFile . . . . . . . . . . . . 2.43.1.5 rename . . . . . . . . . . . . . 2.43.1.6 getFileInfo . . . . . . . . . . . 2.43.1.7 list . . . . . . . . . . . . . . . . 2.43.1.8 download . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19 393 394 394 394 394 395 395 395 395 396 396 397 397 397 398 398 399 399 400 400 401 401 401 402 403 403 404 404 405 406 406 407 407 408 408 409 410 411 411 412 412 413 413 414 414 415
20 2.43.1.9 upload . . . . . . . 2.43.1.10 close . . . . . . . . . 2.43.2 Properties . . . . . . . . . . . 2.43.2.1 currentDir . . . . . 2.43.3 Events . . . . . . . . . . . . . 2.43.3.1 onDownload . . . . 2.43.3.2 onUpload . . . . . . 2.44 IPCong Object . . . . . . . . . . . 2.44.1 Properties . . . . . . . . . . . 2.44.1.1 ifNum . . . . . . . . 2.44.2 Methods . . . . . . . . . . . . 2.44.2.1 ifType . . . . . . . . 2.44.2.2 ifIP . . . . . . . . . 2.44.2.3 ifIPMask . . . . . . 2.44.2.4 ifDefaultGateway . 2.44.2.5 ifMac . . . . . . . . 2.44.2.6 ifDesc . . . . . . . . 2.45 SysInfo Object . . . . . . . . . . . . 2.45.1 Properties . . . . . . . . . . . 2.45.1.1 computerName . . . 2.45.1.2 userName . . . . . . 2.45.1.3 version . . . . . . . 2.45.1.4 workarea . . . . . . 2.45.1.5 totalPhysMemory . 2.45.1.6 availPhysMemory . 2.45.1.7 cpuSpeed . . . . . . 2.45.1.8 screenSaver . . . . . 2.45.1.9 screenSaverActive . 2.45.1.10 screenSaverTimeout 2.45.1.11 displaySetting . . . 2.45.2 Methods . . . . . . . . . . . . 2.45.2.1 powerO . . . . . . 2.45.2.2 logO . . . . . . . . 2.45.2.3 reboot . . . . . . . . 2.45.2.4 shutdown . . . . . . 2.45.2.5 getDisplaySettings . 2.46 Folder . . . . . . . . . . . . . . . . . 2.46.1 Properties . . . . . . . . . . . 2.46.1.1 attributes . . . . . . 2.46.1.2 dateCreated . . . . 2.46.1.3 dateLastAccessed . 2.46.1.4 dateLastModied . 2.46.1.5 drive . . . . . . . . 2.46.1.6 isRootFolder . . . . 2.46.1.7 name . . . . . . . . 2.46.1.8 parentPath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 416 416 416 417 417 417 418 418 418 418 418 419 419 420 420 421 421 421 421 422 422 422 423 423 423 423 424 424 424 425 425 426 426 426 427 427 428 428 428 429 429 429 430 430 430
CONTENTS 2.46.1.9 path . . . . . . . . 2.46.1.10 shortName . . . . 2.46.1.11 shortPath . . . . . 2.46.1.12 size . . . . . . . . 2.46.1.13 subFolders . . . . 2.46.1.14 les . . . . . . . . 2.46.2 Methods . . . . . . . . . . . 2.46.2.1 copy . . . . . . . . 2.46.2.2 remove . . . . . . 2.46.2.3 move . . . . . . . 2.46.2.4 les . . . . . . . . 2.46.2.5 exists . . . . . . . 2.47 File Object . . . . . . . . . . . . . 2.47.1 Properties . . . . . . . . . . 2.47.1.1 attributes . . . . . 2.47.1.2 dateCreated . . . 2.47.1.3 dateLastAccessed 2.47.1.4 dateLastModied 2.47.1.5 drive . . . . . . . 2.47.1.6 name . . . . . . . 2.47.1.7 parentPath . . . . 2.47.1.8 path . . . . . . . . 2.47.1.9 shortName . . . . 2.47.1.10 shortPath . . . . . 2.47.1.11 size . . . . . . . . 2.47.1.12 type . . . . . . . . 2.47.2 Methods . . . . . . . . . . . 2.47.2.1 copy . . . . . . . . 2.47.2.2 remove . . . . . . 2.47.2.3 move . . . . . . . 2.47.2.4 exists . . . . . . . 2.48 Drive Object . . . . . . . . . . . . 2.48.1 Properties . . . . . . . . . . 2.48.1.1 availableSpace . . 2.48.1.2 driveLetter . . . . 2.48.1.3 driveType . . . . . 2.48.1.4 leSystem . . . . . 2.48.1.5 freeSpace . . . . . 2.48.1.6 isReady . . . . . . 2.48.1.7 path . . . . . . . . 2.48.1.8 rootFolder . . . . 2.48.1.9 serialNumber . . . 2.48.1.10 totalSize . . . . . 2.48.1.11 volumeName . . . 2.48.1.12 drives . . . . . . . 2.49 StringStream Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21 431 431 431 432 432 432 433 433 433 434 434 435 435 436 436 436 437 437 437 438 438 438 439 439 439 440 440 440 440 441 441 441 442 442 442 443 443 444 444 445 445 445 446 446 446 447
22 2.49.1 Properties . . . . . . . . . . . 2.49.1.1 length . . . . . . . . 2.49.1.2 getPos . . . . . . . . 2.49.1.3 putPos . . . . . . . 2.49.1.4 eof . . . . . . . . . . 2.49.1.5 crc . . . . . . . . . . 2.49.2 Methods . . . . . . . . . . . . 2.49.2.1 get . . . . . . . . . . 2.49.2.2 getLong . . . . . . . 2.49.2.3 getShort . . . . . . 2.49.2.4 getFloat . . . . . . . 2.49.2.5 getDouble . . . . . . 2.49.2.6 read . . . . . . . . . 2.49.2.7 readLine . . . . . . 2.49.2.8 put . . . . . . . . . 2.49.2.9 putShort . . . . . . 2.49.2.10 putFloat . . . . . . 2.49.2.11 write . . . . . . . . 2.49.2.12 writeLine . . . . . . 2.49.2.13 unget . . . . . . . . 2.49.2.14 ush . . . . . . . . . 2.49.2.15 close . . . . . . . . . 2.49.2.16 readString . . . . . 2.49.2.17 readUnicodeString . 2.49.2.18 writeUnicodeString 2.49.2.19 compress . . . . . . 2.49.2.20 uncompress . . . . . 2.49.2.21 readFromFile . . . . 2.49.2.22 saveToFile . . . . . 2.50 FileStream(Stream) Object . . . . . 2.50.1 Properties . . . . . . . . . . . 2.50.1.1 length . . . . . . . . 2.50.1.2 pos . . . . . . . . . 2.50.1.3 eof . . . . . . . . . . 2.50.2 Methods . . . . . . . . . . . . 2.50.2.1 get . . . . . . . . . . 2.50.2.2 getLong . . . . . . . 2.50.2.3 getShort . . . . . . 2.50.2.4 getFloat . . . . . . . 2.50.2.5 getDouble . . . . . . 2.50.2.6 read . . . . . . . . . 2.50.2.7 readLine . . . . . . 2.50.2.8 put . . . . . . . . . 2.50.2.9 putShort . . . . . . 2.50.2.10 putFloat . . . . . . 2.50.2.11 write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447 447 448 448 448 448 449 449 449 450 450 451 451 451 452 452 452 453 453 453 454 454 454 455 455 455 456 456 456 457 458 458 458 458 458 458 459 459 460 460 460 461 461 461 462 462
CONTENTS 2.50.2.12 writeLine . . . . . . 2.50.2.13 unget . . . . . . . . 2.50.2.14 ush . . . . . . . . . 2.50.2.15 close . . . . . . . . . 2.50.2.16 readString . . . . . 2.50.2.17 readUnicodeString . 2.50.2.18 writeUnicodeString 2.51 Socket Object . . . . . . . . . . . . . 2.51.1 Properties . . . . . . . . . . . 2.51.1.1 error . . . . . . . . . 2.51.2 Methods . . . . . . . . . . . . 2.51.2.1 accept . . . . . . . . 2.51.2.2 asyncSelect . . . . . 2.51.2.3 bind . . . . . . . . . 2.51.2.4 close . . . . . . . . . 2.51.2.5 connect . . . . . . . 2.51.2.6 create . . . . . . . . 2.51.2.7 getPeerName . . . . 2.51.2.8 getSockName . . . . 2.51.2.9 getSockOpt . . . . . 2.51.2.10 setSockOpt . . . . . 2.51.2.11 ioctl . . . . . . . . . 2.51.2.12 listen . . . . . . . . 2.51.2.13 receive . . . . . . . 2.51.2.14 receiveFrom . . . . 2.51.2.15 send . . . . . . . . . 2.51.2.16 sendTo . . . . . . . 2.51.2.17 shutDown . . . . . . 2.51.2.18 htonl . . . . . . . . 2.51.2.19 htons . . . . . . . . 2.51.2.20 ntohl . . . . . . . . 2.51.2.21 ntohs . . . . . . . . 2.51.3 Events . . . . . . . . . . . . . 2.51.3.1 onAccept . . . . . . 2.51.3.2 onClose . . . . . . . 2.51.3.3 onConnect . . . . . 2.51.3.4 onOOBData . . . . 2.51.3.5 onReceive . . . . . . 2.51.3.6 onSend . . . . . . . 2.52 SplashWnd . . . . . . . . . . . . . . 2.52.1 Properties . . . . . . . . . . . 2.52.1.1 timeout . . . . . . . 2.52.1.2 window . . . . . . . 2.52.2 Methods . . . . . . . . . . . . 2.52.2.1 loadSWF . . . . . . 2.52.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23 463 463 463 464 464 464 465 465 466 466 468 468 469 469 470 470 471 472 472 473 474 475 476 476 477 478 478 479 479 480 480 481 481 481 481 482 482 482 483 483 484 484 484 484 484 485
24 2.52.3.1 onFSCommand . . . . . 2.52.3.2 onTimeout . . . . . . . 2.53 Splash2 . . . . . . . . . . . . . . . . . . 2.53.1 Methods . . . . . . . . . . . . . . 2.53.1.1 close . . . . . . . . . . . 2.54 Printer . . . . . . . . . . . . . . . . . . . 2.54.1 Properties . . . . . . . . . . . . . 2.54.1.1 printers . . . . . . . . . 2.54.1.2 printerIndex . . . . . . 2.54.1.3 title . . . . . . . . . . . 2.54.1.4 pageCount . . . . . . . 2.54.1.5 silent . . . . . . . . . . 2.54.1.6 orientation . . . . . . . 2.54.1.7 paperSize . . . . . . . . 2.54.1.8 copies . . . . . . . . . . 2.54.1.9 continuePrinting . . . . 2.54.1.10 pageHeight . . . . . . . 2.54.1.11 pageWidth . . . . . . . 2.54.1.12 font . . . . . . . . . . . 2.54.1.13 brush . . . . . . . . . . 2.54.1.14 pen . . . . . . . . . . . 2.54.1.15 bkColor . . . . . . . . . 2.54.1.16 textColor . . . . . . . . 2.54.1.17 bkMode . . . . . . . . . 2.54.2 Methods . . . . . . . . . . . . . . 2.54.2.1 print . . . . . . . . . . 2.54.2.2 printPreview . . . . . . 2.54.2.3 printText . . . . . . . . 2.54.2.4 printText2 . . . . . . . 2.54.2.5 getWrappedTextExtent 2.54.2.6 getTabbedTextExtent . 2.54.2.7 getTextHeight . . . . . 2.54.2.8 getTextExtent . . . . . 2.54.2.9 printImage . . . . . . . 2.54.2.10 getImageSize . . . . . . 2.54.2.11 line . . . . . . . . . . . 2.54.2.12 rectangle . . . . . . . . 2.54.2.13 roundRect . . . . . . . 2.54.2.14 ellipse . . . . . . . . . . 2.54.2.15 llRect . . . . . . . . . 2.54.3 Events . . . . . . . . . . . . . . . 2.54.3.1 onPreparePrinting . . . 2.54.3.2 onBeginPrinting . . . . 2.54.3.3 onNewPage . . . . . . . 2.54.3.4 onPrint . . . . . . . . . 2.54.3.5 onEndPrinting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 485 485 486 486 487 489 489 490 490 490 491 491 491 496 496 496 497 497 497 498 499 499 500 500 500 500 501 502 502 503 504 504 505 505 506 506 507 507 508 509 509 509 509 510 510
CONTENTS 2.55 Image . . . . . . . . . . . . . . . . . 2.55.1 Properties . . . . . . . . . . . 2.55.1.1 width . . . . . . . . 2.55.1.2 height . . . . . . . . 2.55.1.3 bitCount . . . . . . 2.55.1.4 twainReady . . . . . 2.55.1.5 twainSourceSelected 2.55.2 Methods . . . . . . . . . . . . 2.55.2.1 load . . . . . . . . . 2.55.2.2 save . . . . . . . . . 2.55.2.3 mirror . . . . . . . . 2.55.2.4 ip . . . . . . . . . 2.55.2.5 rotate90 . . . . . . . 2.55.2.6 rotate270 . . . . . . 2.55.2.7 zoom . . . . . . . . 2.55.2.8 adjustRGB . . . . . 2.55.2.9 adjustBrightness . . 2.55.2.10 adjustContrast . . . 2.55.2.11 adjustHS . . . . . . 2.55.2.12 invert . . . . . . . . 2.55.2.13 blur . . . . . . . . . 2.55.2.14 blurGauss . . . . . . 2.55.2.15 sharpen . . . . . . . 2.55.2.16 emboss . . . . . . . 2.55.2.17 to24Bits . . . . . . . 2.55.2.18 toGray . . . . . . . 2.55.2.19 crop . . . . . . . . . 2.55.2.20 getCount . . . . . . 2.55.2.21 captureScreen . . . 2.55.2.22 captureMovie . . . . 2.55.2.23 loadImage . . . . . 2.55.2.24 twainInit . . . . . . 2.55.2.25 twainSelectSource . 2.55.2.26 twainAcquire . . . . 2.55.3 Events . . . . . . . . . . . . . 2.55.3.1 onCopyImage . . . . 2.56 DirectX . . . . . . . . . . . . . . . . 2.56.1 Properties . . . . . . . . . . . 2.56.1.1 joysticks . . . . . . 2.56.2 Methods . . . . . . . . . . . . 2.56.2.1 setDisplayMode . . 2.56.2.2 restore . . . . . . . 2.57 Joystick . . . . . . . . . . . . . . . . 2.57.1 Properties . . . . . . . . . . . 2.57.1.1 buttons . . . . . . . 2.57.1.2 x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25 510 511 511 512 512 512 512 513 513 513 514 514 515 515 515 516 516 517 517 518 518 518 519 519 519 520 520 520 521 521 522 522 522 523 523 523 523 524 524 524 524 525 525 525 525 526
26 2.57.1.3 y . . . . . . . . . . . . . . . . . . . . 2.57.1.4 z . . . . . . . . . . . . . . . . . . . . 2.57.1.5 rx . . . . . . . . . . . . . . . . . . . 2.57.1.6 ry . . . . . . . . . . . . . . . . . . . 2.57.1.7 rz . . . . . . . . . . . . . . . . . . . 2.57.1.8 uaxis . . . . . . . . . . . . . . . . . 2.57.1.9 vaxis . . . . . . . . . . . . . . . . . 2.57.1.10 pov0, pov1, pov2, pov3 . . . . . . . 2.57.1.11 range . . . . . . . . . . . . . . . . . 2.57.1.12 deadzone . . . . . . . . . . . . . . . 2.57.2 Methods . . . . . . . . . . . . . . . . . . . . . 2.57.2.1 read . . . . . . . . . . . . . . . . . . 2.57.2.2 buttonState . . . . . . . . . . . . . . 2.57.3 Events . . . . . . . . . . . . . . . . . . . . . . 2.57.3.1 onLeft . . . . . . . . . . . . . . . . . 2.57.3.2 onRight . . . . . . . . . . . . . . . . 2.57.3.3 onUp . . . . . . . . . . . . . . . . . 2.57.3.4 onDown . . . . . . . . . . . . . . . . 2.57.3.5 onPress . . . . . . . . . . . . . . . . 2.58 Dll . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.58.1 Methods . . . . . . . . . . . . . . . . . . . . . 2.58.1.1 registerFunction . . . . . . . . . . . 2.58.1.2 unregisterFunction . . . . . . . . . . 2.58.1.3 getPointerValue . . . . . . . . . . . 2.58.1.4 getPointerStringValue . . . . . . . . 2.58.1.5 getPointerWideStringValue . . . . . 2.59 Struct . . . . . . . . . . . . . . . . . . . . . . . . . . 2.59.1 Properties . . . . . . . . . . . . . . . . . . . . 2.59.1.1 align . . . . . . . . . . . . . . . . . . 2.59.1.2 structSize . . . . . . . . . . . . . . . 2.60 Sound . . . . . . . . . . . . . . . . . . . . . . . . . . 2.60.1 Properties . . . . . . . . . . . . . . . . . . . . 2.60.1.1 mixerName . . . . . . . . . . . . . . 2.60.1.2 Sound.playback.masterMute . . . . 2.60.1.3 Sound.playback.masterVolume . . . 2.60.1.4 Sound.playback.waveMute . . . . . 2.60.1.5 Sound.playback.waveVolume . . . . 2.60.1.6 Sound.playback.midiMute . . . . . . 2.60.1.7 Sound.playback.midiVolume . . . . 2.60.1.8 Sound.playback.CDMute . . . . . . 2.60.1.9 Sound.playback.CDVolume . . . . . 2.60.1.10 Sound.playback.lineInMute . . . . . 2.60.1.11 Sound.playback.lineInVolume . . . . 2.60.1.12 Sound.playback.microphoneMute . . 2.60.1.13 Sound.playback.microphoneVolume 2.60.1.14 Sound.recording.lineInSelect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526 526 526 527 527 527 527 528 528 528 529 529 530 531 531 531 531 532 532 532 538 538 540 541 541 542 542 542 542 543 543 543 543 543 544 544 544 544 545 545 545 545 546 546 546 546
CONTENTS 2.60.1.15 Sound.recording.lineInVolume . . . . . . . . . 2.60.1.16 Sound.recording.microphoneSelect . . . . . . . 2.60.1.17 Sound.recording.microphoneVolume . . . . . . 2.60.2 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.60.2.1 Sound.playback.onMasterMute . . . . . . . . . 2.60.2.2 Sound.playback.onMasterVolumeChange . . . 2.60.2.3 Sound.playback.onWaveMute . . . . . . . . . . 2.60.2.4 Sound.playback.onWaveVolumeChange . . . . 2.60.2.5 Sound.playback.onMidiMute . . . . . . . . . . 2.60.2.6 Sound.playback.onMidiVolumeChange . . . . . 2.60.2.7 Sound.playback.onCDMute . . . . . . . . . . . 2.60.2.8 Sound.playback.onCDVolumeChange . . . . . 2.60.2.9 Sound.playback.onLineInMute . . . . . . . . . 2.60.2.10 Sound.playback.onLineInVolumeChange . . . . 2.60.2.11 Sound.playback.onMicrophoneMute . . . . . . 2.60.2.12 Sound.playback.onMicrophoneVolumeChange . 2.60.2.13 Sound.recording.lineInSelect . . . . . . . . . . 2.60.2.14 Sound.recording.onLineInVolumeChange . . . 2.60.2.15 Sound.recording.onMicrophoneSelect . . . . . . 2.60.2.16 Sound.recording.onMicrophoneVolumeChange 2.61 PConn Object . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.61.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.61.1.1 listen . . . . . . . . . . . . . . . . . . . . . . . 2.61.1.2 send . . . . . . . . . . . . . . . . . . . . . . . . 2.62 Form Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.62.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.62.1.1 show . . . . . . . . . . . . . . . . . . . . . . . 2.62.1.2 close . . . . . . . . . . . . . . . . . . . . . . . . 2.62.1.3 getVariable . . . . . . . . . . . . . . . . . . . . 2.62.1.4 setVariable . . . . . . . . . . . . . . . . . . . . 2.62.1.5 targetGotoFrame . . . . . . . . . . . . . . . . . 2.62.1.6 targetGotoLabel . . . . . . . . . . . . . . . . . 2.62.1.7 targetCallFrame . . . . . . . . . . . . . . . . . 2.62.1.8 targetCallLabel . . . . . . . . . . . . . . . . . 2.62.1.9 setBase . . . . . . . . . . . . . . . . . . . . . . 2.62.1.10 loadMovie . . . . . . . . . . . . . . . . . . . . 2.62.1.11 createControl . . . . . . . . . . . . . . . . . . . 2.62.2 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . 2.62.2.1 movie . . . . . . . . . . . . . . . . . . . . . . . 2.62.2.2 showCaption . . . . . . . . . . . . . . . . . . . 2.62.2.3 canDrag . . . . . . . . . . . . . . . . . . . . . . 2.62.2.4 clipRegion . . . . . . . . . . . . . . . . . . . . 2.62.2.5 caption . . . . . . . . . . . . . . . . . . . . . . 2.62.2.6 initVars . . . . . . . . . . . . . . . . . . . . . . 2.62.2.7 window . . . . . . . . . . . . . . . . . . . . . . 2.62.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
27 547 547 547 547 547 548 548 548 548 549 549 549 549 550 550 550 550 551 551 551 551 552 552 553 553 554 554 555 556 556 557 557 558 558 559 559 560 560 560 561 561 561 561 562 562 562
28 2.62.3.1 onExit . . . . . 2.63 ScriptHost Object . . . . . . . . 2.63.1 Methods . . . . . . . . . . 2.63.1.1 open . . . . . . . 2.63.1.2 close . . . . . . . 2.63.1.3 runScript . . . . 2.63.1.4 runScriptFile . . 2.63.1.5 getScriptObject 3 FSCommands 3.1 FSCommands 3.2 FSCommands 3.3 FSCommands 3.4 FSCommands 3.5 FSCommands 3.6 FSCommands FFish Eval . FFish Run . Quit . . . . . FullScreen . exec . . . . . FFish Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562 563 565 565 566 566 567 567 569 569 569 570 571 571 571
Chapter 1
Tutorials
The tutorials in this chapter discuss both the topics for the beginners such as how to start converting ash movies to .exe les, adding more functions to your SWFKit projects, protecting your resource les, etc, and the topics for the advanced users such as using the synchronous methods to call FFish Scriting language elements directly from within Action Script, building windowless projectors, opening, reading, writing, moving and deleting les, launching external applications, opening system dialog boxes, accessing databases, programming the tray icons, downloading and uploading les, sending and receiving emails, creating multiple forms, changing screen resolutions, screen capture, reusing the web browser control, playing avi, rm, mov, wmv movies, opening pdf les, calling Active scripting languages such as jscript, vbscript, perlscript, pythonscript, ect, calling dynamic linked libraries and ActiveX components, etc. Although the tutorials in this chapter cover only the details of how to build executable les(.exe les), the methods introduced in these tutorials are also helpful for building screen savers(.scr les).
1.1
In this tutorial you will learn how to create a simple SWFKit project to convert your ash movies to an executable program(.exe le). If you have a ash project, say, a ash presentation or a ash game, which may contain more than one ash movie(.swf le) in several folders, with many other resource les such as XML les, sounds, images, text les, etc, and you would like to convert them all to a single .exe le, or an .exe le that can launch and play your ash presentation or ash game, you can do as follows. The rst step is to launch SWFKit (either SWFKit Express, SWFKit or SWFKit Pro) and create a new SWFKit project. After saving your new SWFKit project, you can then set the output details options such as the output directory, what to build, an .exe le or a .scr le(the default setting is to build an
30
Tutorials
Figure 1.1: Creating a new SWFKit project application, that is, to build an .exe le), the icons for the output .exe le or .scr le, etc, as shown in gure 1.1 If you check the standalone option, SWFKit will pack the Flash Player into the output .exe le so that it can work on a computer without the most current version of Flash Player, or without Flash Player at all. The Create AutoRun.inf enables your project to create an autorun.inf le, that is, your project can produce an autorun CD. If the pack resources option is checked, SWFKit will produce a single .exe le, that is, all the resource les are packed into the output .exe le. Now you can begin the second step - adding resource les into your SWFKit project. Going to the resources panel, you will see a tree view on the left side of the panel and a list view on the right side of the panel, as shown in the gure1.1. The tree view is used to organize the directory structure of the resource les, and the list view is used to manage the resource les in a folder. Typically your resource les are added into the Application folder in the tree view, and the Windows folder is only used by the installers to copy some special les to the Windows folder or system folder. The simplest way to add your resource les is to use the Import button. In this way, all les in your ash project will be added into the Application folder and the directory structure of your
31
Figure 1.2: Adding resource les ash project keeps unchanged. You can also add your resource les by creating folders and adding les manually. The resource les can be of any le type. After adding the resource les you must specify the main movie, which is the ash movie that the output .exe le will load rst. You may notice that before each le in the list view there is a check box. It is used to protect your resource les. You may read the relative tutorials to learn how to use it. The third step is to go to the Application Denition panel to set the options such as appearance, size, position, behavior, etc of your output .exe le. For example, in this panel you can set the caption of the main window of your output program, check the show in system tray option to show an icon in the system tray, dene the exit keys, etc. See gure 1.1 Finally, you would have to insert a line of code into the initialize script as follows, //Initialize getAdditionalFile(); return true; The purpose of calling the getAdditionalFile method in the initialize script
32
Tutorials
33
is to extract the resource les if they are packed into the output .exe le, or the output .exe le cannot work properly. Now your SWFKit project is ready to work. Before building the output .exe le, you can preview it rst by pressing the hot key F9 (for screen savers it is CTRL+F9), and in this case SWFKit does not produce any .exe les. When you feel everything is ok, you can build the output .exe le by pressing F7 and run it by pressing F5. To go to the directory that the output .exe le resides in, you can press F10. From what have been discussed above, you can see that it is very easy to convert your ash project to an .exe le - just some mouse clicks.
1.2
Besides simply converting a ash project to an .exe le, you may want to add more functions to your application such as reading and writing disk les, accessing databases, encrypting and decrypting les, etc, which Flash itself does not provide. In this case, you would have to use the FFish Scripting language. The FFish Scripting language is a javascript style scripting language, that is, if you know the javascript programming or the actionscript programming, you also know the shscript programming. The FFish scripting language provides many objects to extend the power of Flash. More details of these objects can be found in the FFish scripting language manual. The general way of using the FFish scripting language is to insert scripts into SWFKit, add code into the scripts and call the script in Action scripts. If you use Flash 8, however, you can call the FFish script objects directly from within Action script. This way is more clear and convenient. Calling the FFish script objects directly in Action script will be introduced in another tutorial, at here we only discuss how to use the FFish scripting language in the former way. First, we would like to introduce the initialize script. Maybe you have found that for every newly created SWFKit project, there is a predened initialize script. SWFKit automatically inserts an initialize script for each SWFKit project, and the initialize script will be called after the produced .exe le or .scr le is launched. It is called just after the main window is created and about to be visible, but before the main ash movie is loaded. Hence, you can use the initialize script to do some initialization tasks, for example, loading a data le, checking some registry entry, etc. A useful example is to make a program has only one instance at a time. The idea of doing this job is to nd whether there is already a window has the same caption as the current program that is about to run. If such a window is found, we will bring the found window to top and stop the current program; otherwise, we will continue the current program. The following code shows how to do this: var var var for wnds = Window.getWindowsByName(your window name); w = getMainWnd(); has = false; (i = 0; i < wnds.length; i++)
34 { if (wnds[i].handle != w.handle) { has = true; break; } } if (has) { wnds[i].bringToTop(); return false; } return true;
Tutorials
What you should notice is that when calling the initialize script the main movie is not loaded yet. All Attempts in the initialize script to set the values of the variables in the main movie will have no eect. Second, you can add as many scripts in SWFKit as you can and call them in Action script. At here we only discuss the asynchronous way of calling FFish scripts - using the sh run fscommand. For example, say you have a script named recordSound in SWFKit, and you want to call it when you press a button, you can do as follows in Action script: on (click) { fscommand("ffish_run", "recordSound"); } However, the fscommands does not run immediately after you click the button. It will not be called until the Flash Player has time to process user messages, that is, Action script code and fscommand are not called synchronously. For example, your call a script to change the value of a variable in the main movie, however, you cannot think that the value of the variable is changed immediately after the script is called by fscommand, because the value of the variable may be changed after all the Action script instructions in this frame has been executed. Notice: fscommands are always called synchronously, for example, if you have more than one fscommands, such as ... fscommand("ffish_run", "script1"); ... ... fscommand("ffish_run", "script2"); script2 will always be called after script1, that is, the order of calling fscommands will never be reversed. Now we use an example to show how to use the FFish scripting language to add more functions to your SWFKit project.
35
Providing you are creating a game with ash, which will save and load the scores of players, that is, the game needs read and write a disk le to load and save data. To implement this feature, we would have to maintain an array to save the score data for each user, and add functions to add, load and save score data. The score information of a player is represented by the following object: function scoreInfo(playerName, score) { this.playerName = playerName; this.score = score; } First, when the game is launched, we should load the score data from a data le. We will do it in the initialize script. function scoreInfo(playerName, score) { this.playerName = playerName; this.score = score; } // gets the data file name // The scoreRecords array is used to maintain all score data scoreRecords = []; var scoreFile = getAppDir() + "\\scores.txt"; // loads the data DataFile.load(scoreFile); // traces the data to see how many score data is loaded for (i = 0; i < scoreRecords.length; i++) { var score = scoreRecords[i]; trace(score.playerName); trace(score.score); } Second, we would have to add a new script to add a score record for a new player. Generally there should be a button in the main movie; when pressing the button, we call the FFish script to add the a score record. After creating a new script called newplayer in SWFKit, we add the following code into the script: // Get player name and score from flash movie var playerName = FlashPlayer.getVariable("_root.playerName"); var score = parseInt(FlashPlayer.getVariable("_root.score")); // Create a new score record and save into the array var scoreRecord = new scoreInfo(playerName, score); scoreRecords.push(scoreRecord);
Tutorials
Finally, we would have to add a function to save the score data when the game exits. We may also add a button in the movie to save the score data, however, it is better to make the game save the score data automatically when it is about to exit. This can be done by handling the onClose event of the main window of the game. When the main window of the game is about to close, this event handler will be called. Hence, we can call the saving score data function in this event handler. We put this event handler into the initialize script because the initialize script has already been loaded into memory when the game starts. If you put the event handler in another script, you must make sure that the script is loaded, or the game cannot nd the event handler. function saveScores() { var df = getAppDir() + "\\scores.txt"; // remove the old file DataFile.remove(df); DataFile.save(df, "scoreRecords"); } var wnd = getMainWnd(); wnd.onClose = function() { saveScores(); }
1.3
SWFKit 3 supports calling FFish script objects synchronously in Action script 2 or 3. Moreover, it comes with a plug-in that enables you to preview and test your SWFKit projects from within Flash 8 or 9. Now we will introduce this feature step by step as follows:
1.3.1
Most of the FFish script objects have been wrapped in Action script classes. The wrapper classes reside in the classes subfolder of the SWFKit installed folder, whose typical paths are c:\program les\swfkit pro 3\classes (for actionscript 2), and c:\program les\swfkit pro 3\classes 3 (for actionscript 3). To call
Figure 1.4: Adding the class path the classes in Action script, you must add the path into the class path for actionscript 2 or 3. The gure 1.3.1 shows how to set the class path in Flash 8:
1.3.2
After SWFKit is installed, ve commands are added into the command menu of Flash 8 or 9. Dening hot keys for these newly added commands will make your developing works more convenient. In the Edit menu of Flash 8 or 9, choose the keyboard shortcuts command, duplicate a new shortcut set, e.g. New, and then assign hot keys for the new commands. Please see the gure1.3.2
1.3.3
If the plug-in and the commands are not installed properly, e.g. your Flash 8 or 9 is installed after SWFKit, you would have to install them manually. First, the plug-in and commands reside in the plug-in subfolder of the SWFKit installed folder, whose typical path is c:\program les\swfkit pro 3\plug-in. Second, copy the skp plugin.dll into the C:\Documents and Settings\{current user}\Local Settings\Application Data\Macromedia\Flash 8\{language}\Conguration\External Libraries folder, and copy the ve .js les into the C:\Documents and Settings\{current user}\Local Settings\Application Data\Macromedia\Flash 8\language}\Conguration\Commands
38
Tutorials
folder. Finally, you would have to follow the above two steps to add class path and dene hot keys. For ash 9, the directories will be C:\Documents and Settings\{current user}\Local Settings\Application Data\Adobe\Flash CS3\{language}\Conguration\E Libraries and C:\Documents and Settings\{current user}\Local Settings\Application Data\Adobe\Flash CS3\language}\Conguration\Commands
1.3.4
Now we can start working on our SWFKit projects. First, you must create a new SWFKit project as we have introduced in the start converting your ash movies to an executable program tutorial. Second, we open a ash project in Flash 8 (it will export one of the movies that have been added into the opened SWFKit project), and run the swfkit attach command in the command menu. A dialog box will be launched to attach the current ash movie to a .swf le in an opened SWFKit project, that is, you must keep both the Flash 8 and SWFKit opened.
1.3.5
After the current ash project is attached to a SWFKit project, you can begin to call FFish script in your ash project. For example, to launch a le open dialog by click a button. on (click)
Now we can check whether the code could work by running the swfkit previewapp command, which is used to preview an .exe le, whereas the swfkit previewscr command is used to preview a .scr le. After running the command, the preview window is displayed and the output messages are displayed in the output panel of Flash 8. The swfkit previewapp command will also display a oating information panel. If the preview window is freezing, you can kill it by closing the information panel. The x button of the information panel will appear about 30 seconds after the preview window is launched. However, if the preview window works well, please do not kill it by closing the information panel, because the preview window would have no chance to remove temporary folder or release memory if it is killed. So normally you should rst close the preview window and then the information panel will disappear automatically. Similarly, you can run the swfkit testapp command to build the output .exe le, launch and test it. As you can see, most of your developing works can be done directly in Flash 8.
40
Tutorials
1.3.6
When you preview a SWFKit project, the trace method of action script cannot work. In this case, you would have to use the trace method of FFish script, which is SWFKit.Global.trace. In the above example, we added a function called strace into root: function strace(value) { SWFKit.Global.trace(value); } Although this function does nothing in the output .exe le, the ash player will always pass the value parameter to FFish scripting language. It will do harm to the eciency of the output .exe le in this case. Hence, we recommend you to modify the strace function to the following form when you are ready to build the release version of your .exe le. /* function strace(value) { SWFKit.Global.trace(value); } */ strace = trace;
1.3.7
For example, to handle the onContextMenu event, that is, to do something when right click the ash movie. First, we would have to create an instance of the corresponding FFish script object even if all its methods are static. Second, add an event handler in Action script. Finally, call the setEventHandler to set the event handler. import SWFKit.*; function onContextMenu() { Dialogs.msgBox("Right click!"); } var fp = new FlashPlayer; fp.setEventHandler("onContextMenu", onContextMenu);
1.3.8
The reason that the synchronous calls can work is that the Flash 8 supports external interface, that is, you can use ExternalInterf ace.call method to call a method provided by the container of the Flash Player. SWFKit support the following methods that can be called by the external interface. sh new Creating an instance of a FFish script object. The rst parameter is the name of the FFish script object, the other parameters are passed to the constructor of the FFish script object. E.g. var identifier = ExternalInterface.call("ffish_new", "ActiveXObject", "ShockwaveFlash.ShockwaveFlash"); This function will returns an identier of the newly created FFish script object that can be used to access its properties and methods. sh delete Deleting a FFish script object ExternalInterface.call("ffish_delete", identifier); sh call Calling a method of a FFish script. The rst parameter is the identier of the FFish script object, or the name of the object if the method is static, the second parameter is the name of the method, and the other parameters are passed to the method of the object. If the method accepts an FFish script object as a parameter, you must also use an identier of the object. var devices = ExternalInterface.call("ffish_call", "MCI", "getDevices"); sh call2 Similar to sh call. The third parameter of this method is an array that contains all parameters that will be passed to the method of the FFish script to call.
42
Tutorials
sh getprop Get the value of a property of a FFish script object. The rst parameter is the identifer of the object, or the name of the object if the property is static. var command = ExternalInterface.call("ffish_getprop", identifier, "command"); sh setprop Set the value of a property of a FFish script object. The rst parameter is the identifer of the object, or the name of the object if the property is static. The second parameter is the value to set to the property of the object. ExternalInterface.call("ffish_setprop", identifier, "command", "open"); sh run, sh eval The sh run method is used to call a FFish script, and the sh eval method is used to execute FFish script code. These two methods are almost the same as the sh run and sh eval fscommands. The only dierence is that these two methods will call the scripts or code synchronously, whereas the fscommands are asynchronous. fscommand("ffish_run", "newplayer"); function _swfkitcmd(name, args) { ExternalInterface.call(name, args); } _swfkitcmd("ffish_run", "newplayer"); exec Similar to the exec fscommand. The only dierence between this method and the exec fscommand is that this method is synchronous. Both this method and the exe fscommand can launch any external applications. Besides the above methods, the ExternalInterface.call method can also be used to call global methods dened in FFish script. For example, you can write a function in the initialize script in SWFkit and call it in Action script synchronously. For example, in SWFKit: // save a XML file function saveXML(fileName, xml) { var f = new File(fileName, "w"); f.write(xml); f.close(); } In Action script var xml = new XML; ... ExternalInterface.call("saveXML", "c:\\test.xml", xml.toString(); Using the above methods to call FFish script is not so convenient, so we wrapped most of the FFish script objects in action script classes and you can call them in action script using almost the same syntax as in sh script. For example, the Form object:
1.3 Using FFish script objects synchronously in ActionScript 2/3 43 import flash.external.*; class SWFKit.Form extends SWFKit.BaseObj { public function Form() { super("Form"); } public static function fromID(id: Number) { var form = new Form; form.Release(); form.Identifier = id; } public function get movie() { return ExternalInterface.call("ffish_getprop", this.Identifier, "movie"); } public function set movie(value: String) { ExternalInterface.call("ffish_setprop", this.Identifier, "movie", value); } public function get showCaption() { return ExternalInterface.call("ffish_getprop", this.Identifier, "showCaption"); } public function set showCaption(value: Boolean) { ExternalInterface.call("ffish_setprop", this.Identifier, "showCaption", value); } public function get canDrag() { return ExternalInterface.call("ffish_getprop", this.Identifier, "canDrag"); } public function set canDrag(value: Boolean) { ExternalInterface.call("ffish_setprop", this.Identifier, "canDrag", value); }
44
Tutorials public function get clipRegion() { return ExternalInterface.call("ffish_getprop", this.Identifier, "clipRegion"); } public function set clipRegion(value: String) { ExternalInterface.call("ffish_setprop", this.Identifier, "clipRegion", value); } public function get caption() { return ExternalInterface.call("ffish_getprop", this.Identifier, "caption"); } public function set caption(value: String) { ExternalInterface.call("ffish_setprop", this.Identifier, "caption", value); } public function get initVars() { return ExternalInterface.call("ffish_getprop", this.Identifier, "initVars"); } public function set initVars(value: String) { ExternalInterface.call("ffish_setprop", this.Identifier, "initVars", value); } public function get window() { var win = ExternalInterface.call("ffish_getprop", this.Identifier, "window"); if (win == null || win == undefined) return null; return new SWFKit.Window(win); } public function show() { return ExternalInterface.call("ffish_call2", this.Identifier, "show", arguments); } public function close(value) { return ExternalInterface.call("ffish_call", this.Identifier,
1.3 Using FFish script objects synchronously in ActionScript 2/3 45 "close", value); } public function getVariable(variable) { return ExternalInterface.call("ffish_call", this.Identifier, "getVariable", variable); } public function setVariable(variable, value) { return ExternalInterface.call("ffish_call", this.Identifier, "setVariable", variable, value); } public function targetGotoFrame(target, frame) { return ExternalInterface.call("ffish_call", this.Identifier, "targetGotoFrame", target, frame); } public function targetGotoLabel(target, label) { return ExternalInterface.call("ffish_call", this.Identifier, "targetGotoLabel", target, label); } public function targetCallFrame(target, frame) { return ExternalInterface.call("ffish_call", this.Identifier, "targetCallFrame", target, frame); } public function targetCallLabel(target, label) { return ExternalInterface.call("ffish_call", this.Identifier, "targetCallLabel", target, label); } public function setBase(path) { return ExternalInterface.call("ffish_call", this.Identifier, "setBase", path); } public function loadMovie(layer, movie)
46 {
Tutorials
return ExternalInterface.call("ffish_call", this.Identifier, "loadMovie", layer, movie); } public function createControl() { var axc = ExternalInterface.call("ffish_call2", this.Identifier, "createControl", arguments); if (axc == null) return null; return new SWFKit.AXControl(axc); } } So you can create a form in action script in the same way as in sh script import SWFKit.*; var form = new Form; form.movie = Global.getAdditionalFile("forform.swf"); form.caption = "hello"; form.showCaption = true; form.canDrag = true; form.show(true);
1.3.9
Each ActiveX component has its own property and method set, and Action script classes do not support to add methods dynamically, so you would have to wrap ActiveX components by yourself. We have already created a base class - SWFKit.ActiveXObject, although it has methods to access properties or methods of an ActiveX component, it is not so convenient and distinct: import flash.external.*; class SWFKit.ActiveXObject extends SWFKit.BaseObj { public function ActiveXObject(progID) { if (progID == null) { this.Identifier = 0; } else { var ret = ExternalInterface.call("ffish_new", "ActiveXObject", progID); if (ret == null || ret == undefined) this.Identifier = 0; else this.Identifier = ret;
1.3 Using FFish script objects synchronously in ActionScript 2/3 47 } } public static function fromID(id: Number) { var ax = new ActiveXObject(null); ax.Identifier = id; return ax; } public static function register(filename: String) { return ExternalInterface.call("ffish_call", "ActiveXObject", "register"); } public static function unregister(filename: String) { return ExternalInterface.call("ffish_call", "ActiveXObject", "unregister"); } public function getProperty(prop: String) { return ExternalInterface.call("ffish_getprop", this.Identifier, prop); } public function setProperty(prop: String, value) { ExternalInterface.call("ffish_setprop", this.Identifier, prop, value); } public function callMethod() { var args = arguments; if (args.length >= 1) { var argForFFish = new Array(); var i; for (i = 1; i < args.length; i++) argForFFish.push(args[i]); return ExternalInterface.call("ffish_call2", this.Identifier, args[0], argForFFish); } return undefined; }
48 }
Tutorials
To wrap an ActiveX component, you would have to inherit this class. For example, wrapping a method of the Flash Player activex control. import flash.external.*; import SWFKit.*; class FPActiveX extends SWFKit.ActiveXObject { public function FPActiveX(progID) { super(progID); } public function FlashVersion() { return ExternalInterface.call("ffish_call", this.Identifier, "FlashVersion"); } } To call it var fp = new FPActiveX("ShockwaveFlash.ShockwaveFlash"); _root.strace(fp.FlashVersion());
1.3.10
The wrapper classes for actionscript 2 are in the classes sub folder of the swfkit installed folder, while the wrapper classes for actionscript 3 are in the classes 3 sub folder of the swfkit installed folder. The two sets of classes have same objects, methods, properties and events. However, there are some dierences between them. First, the ActiveXObject class for actionscript 3 can access any method or property of the ActiveXObject object it wraps; whereas, the ActiveXObject class for actionscript 2 can only access properties of the ActiveXObject it wraps. Second, except the Global class, the sound.playback class and the sound.recording class, all wrapper classes for actionscript 3 have no static methods or properties. That is to say, you will have to rst create a new instance of the class before you can call its methods, even if the methods in sh script is static. For example, in actionscript, you can show a message box by calling Dialogs.msgBox(Hello world);, while in actionscript 3, you will have to create an instance of the Dialogs class rst. For example import SWFKit.*; var dlg = new Dialogs; dlg.msgBox("hello world"); dlg.Release();
1.3.11
From swfkit v3.2, you can use the Global class to call any methods written in sh script. For example, to call a method named add dened in sh script import SWFKit.*; var g = Global; var result = g._add(100, 200); The above code will work in both actionscript 2 and 3. And please be sure that you must construct an instance of the Global class before you can use it to call sh script methods.
1.3.12
First, you must dene the methods in actionscript and export them. For example, in actionscript 2 (Flash 8) function myFunc(x, y) { return x + y; } function myMethod(x, y) { return x + y + y; } ExternalInterface.addCallback("myFunc", null, myFunc); ExternalInterface.addCallback("myFunc2", null, myMethod); in actionscript 3 (Flash cs3 or Flex 2) function myFunc(x, y) { return x + y; } function myMethod(x, y) { return x + y + y; } ExternalInterface.addCallback("myFunc", myFunc); ExternalInterface.addCallback("myFunc2", myMethod); And then you can register the methods in sh script and call them // The "registerASMethods" method turns any as2 or as3 // callback functions into ffish script global functions. That is to say,
50
Tutorials
// you can call the action script functions directly in ffish script // after calling this method Application.registerASMethods("myFunc", "myFunc2"); trace(myFunc("hello ", "world")); trace(myFunc2("hello ", "world"));
1.3.13
Remarks
The global functions of SWFKit are wrapped in the SWFKit.Global class. For example, the getAdditional le is a global method of SWFKit, in action script you should call it in the following form: import SWFKit.*; Global.getAdditionalFile("my.file"); To avoid conicts, the Application.* object in SWFKit such as Application.Appreance, Application.dragdrop, etc are wrapped in SWFKit.application.* and Inet.Ftp object is wrapped in SWFKit.inet.Ftp. Unlike the FFish scripting language, in which an instance of an object can call static methods or properties, the action script supports only to call a static method or property by using the class name. For example, the following code works, import SWFKit.application.*; dragdrop.enable = true; whereas the following code does not work, import SWFKit.application.*; var dd = new dragdrop; dd.enable = true; However, if you want to set the event handler of an object, you must create an instance of the class and call the setEventHandler method. Each wrapper class has a Release method that is used to delete the instances of the FFish script objects. Although the FFish script objects are created and accessed from within Action script, the instances of the objects are maintained in the FFish scripting language. In this case, the FFish scripting language does not know when you have nished using these instances of the objects, that is, the instances will be kept in memory unless you delete them explicitly. Hence, calling the Release method after you have nished using a FFish script object will save memory, especially if you have created a lot of FFish script objects in your ash movie. The instances of the objects will be released automatically when the output executable le exits even if you do not call the Release method. import SWFKit.*; var fs = new FileStream("c:\\demo.txt", "w");
1.4 Data exchanging between Action Script and FFish Script ... ... fs.close(); fs.Release();
51
Some objects, such as Printer, Dll, PConn, etc, which are not suitable for calling directly in action script, or do not work by directly calling them in action script at all, are not wrapped. If you have any problem with the wrapper classes, you can look into their source code to get help.
1.4
We often need to exchange data between Action Script and FFish Script if we use asynchronous fscommands to call FFish scripts in Action script. In the section Add more functions to your application we discussed a sample about saving game scores. The score variable for a player is dened in FFish Script, how can the Flash movie access the variable to update the score of the player? SWFKit provides the following tree ways.
1.4.1
The most direct way to exchange data between AS and FS is to use these two methods. In fact, in all other two ways these two methods will be called at last implicitly. The methods are provided by the Macromedia Flash Player ActiveX Object and SWFKit wraps them in the FlashPlayer object. In the game score sample, you can declare two variables in Action Script, providing they are playerName and score in level 0, To get the value of the variables from Action Script score.playerName = FlashPlayer.getVariable( "_level0.playerName"); score.score = parseInt(FlashPlayer.getVariable( "_level0.score")); To update the value of the variables in Action Script FlashPlayer.setVariable("_level0.playerName", score.playerName.toString()); FlashPlayer.setVariable("_level0.score", score.score.toString());
1.4.2
52 FlashPlayer.bindData("_level0.playerName", "_level0.score"); To get the value of the variables from Action Script FlashPlayer.updateData(); score.playerName = FlashPlayer._level0.playerName; score.score = FlashPlayer._level0.score; To update the value of the variables in Action Script FlashPlayer._level0.playerName = score.playerName; FlashPlayer._level0.score = score.score; FlashPlayer.updateData(false);
Tutorials
1.4.3
These four methods provide an easier way to exchange arrays and objects between the Action Script and FFish Script. In the game score sample, you need to declare a score object. To get the value of the variables in Action Script score = FlashPlayer.getObject("score", "playerName", "score"); To update the value of the variables in Action Script FlashPlayer.putObject("score", score); As you can see, the methods provide a way to transfer arrays or objects by only one call. However, you must declare the arrays or objects in Action Script explicitly before data exchanging. However, we recommend you to use synchronous FFish script objects directly in Action script if you have Flash 8. The synchronous objects will return values directly to Action script, and you need not transfer any data between FFish script and Action script.
1.5
In the [operation panel]->[Application Denitions]->[Expiry] dialog box, you can check the Enable expiry option to protect your application. When the application is expired, a dialog box will appear and tell the users the application is expired. If the enable unlock option is checked, the dialog box will show a Register button. The users can click the button to nish the registration. The registration codes can be generated by the Serial Number creator in SWFKit. In SWFKit 3, you can do all these things in your own way. A new object Application.Expiry is provided.
53
1.5.1
When the application has expired, the onExpiry event will be triggered. The following code will tell SWFkit to keep silent. Application.Expiry.onExpired = function (bypass) { bypass.value = true; }
1.5.2
Check if it is expired
Since the default handler is passed by, you should check if it is expired by yourself. In frame 1 of the main movie add a FSCommand. FSCommand("FFish_Run", "CheckExpiry"); Insert the CheckExpiry script in SWFKit, and insert the following code into it if (Application.isExpired && !isRegistered()) { // the application is expired FlashPlayer.targetGotoLabel("_root", "Expired"); }
1.5.3
Registration
In this sample, if the application is expired, the isRegistered method will be called. The isRegistered method checks if the application has been registered. We can save the registration information in the Windows Registry, the isRegistered method reads data from Windows Registry and check if it is valid. var key = "mysample"; function isRegistered() { var userName = readProfile("Registration", "UserName"); var password = readProfile("Registration", "password"); if (Encryption.desEncode(key, userName) == password) return true; return false; } function register(userName, password) { if (Encryption.desEncode(key, userName) != password)
54 return false; writeProfile("Registration", "userName", userName); writeProfile("Registration", "password", password); return true; }
Tutorials
Insert the above codes into the Initialize script to make them can be accessed in the CheckExpiry and the doRegister scripts. When the application nds that it is expired and not registered, it will jump to the Expired frame, in the frame, you can let the users to input their user names and passwords to register the application. Providing the Expired frame has two input text boxes, associate with two variables userName and password, and a Register button, the action for the Register button is on(release) { FSCommand("FFish_Run", "doRegister"); } In SWFKit, insert a doRegister script, and input the following code var un = FlashPlayer.getVariable("userName"); var pw = FlashPlayer.setVariable("password"); if (!register(un, pw)) Dialogs.msgBox("invalid user name or password!"); else { Dialogs.msgBox("Thanks to register mysample!"); FlashPlayer.targetGotoLabel("_root", "good"); }
1.6
From SWFKit 3 it provides a unique feature to protect your resource les, including ash movies(.swf les), XML les, images, mp3 sounds, FLV movies, etc, that is, the ash movies and the resource les that can be loaded into a ash movie can be protected. How does SWFKit protects these resource les and are they easily be decompiled by some reverse engineering tools? No, the
55
protected resource les are encrypted so that they cannot be decompiled by any reverse engineering tool, nor be loaded into any ash player or movie player. In a word, they can only be played in a specic .exe le produced by SWFKit. Another advantage of this feature is that although the resource les are encrypted, they can be loaded into the ash movies as if they are not changed at all. That is to say, the decryption process is transparent, no decrypted data is written to local disk, and you need not call any function in Action script to decrypt the resource les explicitly. Even if you do not pack the protected resource les into the output .exe le, nobody could play them, import them into Flash, or decompile them. To protect your resource les is very simple: before each le added into the resources panel there is a check box; if you want to protect the le, just check it. And do not forget to set a strong password in the resources panel for your SWFKit project. SWFKit uses this password to encrypt the resource les. At this time, the les such as .exe les, HTML les, PDF les, etc cannot be protected by this feature, because they all need external program to open them. The default le type that SWFKit will automatically check it to protect it is .swf les. You can change this setting in the [M ainM enu] > [V iew] > [Options]setting box. SWFKit also supports to stream an remote encrypted FLV le on Internet, only if the FLV le is encrypted by the same password as the main movie. In this case, you can start playing an encrypted FLV le without waiting for it to be downloaded completely.
1.7
Using menus
From SWFKit 2 it provides a WYSIWYG menu editor, you can use menus in the SWFKit projects conveniently.
1.7.1
The applications built by SWFKit have no main menus. But you can assign one for them by calling the setMenu method of the Menu object. menu = new Menu; menu.load("main"); menu.setMenu(); When a menu item in the main menu is clicked, the onCommand event res. menu = new Menu; menu.load("main");
Tutorials
SWFKit will pass the identier of the menu item to the event handler. So you must assign an unique identier for each menu item, or you cannot distinguish which one is clicked. The menu items can have shortcuts, you can set the enableAccel property of the menu object to true to enable the shortcuts.
1.7.2
You can customize the context menu by handling the FlashPlayer.onContextMenu event. FlashPlayer.onContextMenu = function () { var menu = new Menu; menu.load("contextMenu"); menu = menu.getSubMenu(0); if (menu.show() == "new") { //do something } }
1.8
1.8.1
An ActiveX object must be registered before you can use it. In the developing environment, you can register it manually by typing a command, as shown in the following gure1.8.1. When you want to unregister the ActiveX object, say swfgen.dll, you can use the command regsvr32 -u c: myproject dll swfgen.dll.
57
Figure 1.8: Registers an ActiveX object by typing a command After the ActiveX object has been registered, you can use it in SWFKit developing environment. But the ActiveX object is only registered on your computer, you must also ensure that it will be registered on the end users computers correctly.
1.8.2
Registering ActiveX objects on end users systems I - using the register method
The ActiveXObject object provides a method register to register an ActiveX object. If you only want to use the ActiveX objects privately and need to remove them after the application closed, you can use this method. 1. Adding the ActiveX objects into the attachment list. For example, creating a sub folder called ActiveX under the Application folder, adding the SWFGen.dll into it. As shown in gure 1 2. In the Initialize script, extracting the SWFGen.dll and register it var swfgen = getAdditionalFile("ActiveX\\SWFGen.dll"); ActiveXObject.register(swfgen); After the ActiveX object has been registered, you can invoke its methods and properties in FFish Script. 3. When the application is about to close, you need to unregister it. var mainWnd = getMainWnd(); mainWnd.onClose = function () { ActiveXObject.unregitser(swfgen); } All additional les include the ActiveX object will be removed after the application is closed.
58
Tutorials
1.8.3
Registering ActiveX objects on end users systems II - let the setup programs do it
This is the recommended way to register ActiveX objects on end users systems. The setup program can install the ActiveX objects by doing version comparison, and checks if it needs to restart the computer. The ActiveX objects can be unregistered and removed by the uninstall program. If you dont want to build setup programs using SWFKit, you need to follow the instructions of your installer making tool to install ActiveX objects. In SWFKit, you can install ActiveX objects like this
1. Checks the Enable the setup program to register ActiveX objects in Main MenuViewOptions. As shown in gure 1 2. Adds the Activex Objects into the attachment list. Remember to add it under the WindowsSystem folder. That is to say, the ActiveX object wont be packed into the output executable les, but be packed into the setup.exe. The setup.exe will install the ActiveX objects into the specied folder, for example, if youve added the ActiveX objects into the folder WindowsSystemActiveX, the installer will create a ActiveX sub folder in the system folder and copy the ActiveX objects into it then register them. As shown in gure 2
59
Figure 1.10: Checks the Enable the setup program to register ActiveX objects option
60
Tutorials
1.8.4
From SWFKit 3.2, you can use activex dlls in sh script without rst registering them in Windows Registry. As you already know, the activex dlls must store their information in Windows Registry so that the COM functions can create instances of the activex objects exposed by the activex dlls. Now swfkit provides a method ActiveXObject.addObjectInfo. By using this method you can register the activex objects only in the sh script engine, without writing anything into the Windows Registry. For more details, please read the help document for the ActiveXObject.addObjectInfo method.
1.9
The .exe les built by SWFKit requires the Flash Player to run. However, the end user computers may have no ash player installed. The standalone option in SWFKit resolves this problem. If you check this option, a most current version of ash player will be packed into the output .exe les. When such a stand alone .exe le is launched and it nds that there is no ash player in system, or the ash player in system is of the older version, it will use the packed ash player. The ash player that will be packed into a stand alone .exe le resides in the data subfolder of the folder that SWFKit was installed into. E.g. a typical path is c:\program les\SWFKit Pro 3\data. The le name of the ash player is install ash player active x.exe, whose version is 9.0.16.0. If Adobe upgrades it, SWFKit will download it automatically by using the auto update feature. Another important le about the ash player is the ash player.ini, which denes the version and le name of the ash player. If you want to use some special version of ash player, you can copy it into the folder and modify the ash player.ini le. SWFKit will read the information of the ash player to create stand alone .exe les from the ash player.ini le. The ash player should be an installer of the ash player that can be downloaded from Adobe after you get a distribution license. Because we have got a distribution license from Adobe, our distribution of the ash player is legal.
1.10
You can use the trace method to watch the value of the FFish Script variables during preview. The trace method does nothing while the output executable le is running. But the trace method in FFish script cannot display the value of variables in Action Script, and the trace method in Action Script does nothing while you preview a project in SWFKit. SWFKit 2 provides a FSCommand FFish Trace to do this. The FFish Trace works like the trace method, for its called in Action Script, it can
61
display the value of variables in Action Script. It does nothing while the output executable le is running. If you want to save the trace messages while the application is running, you can direct the output to a le by calling the traceToFile method.
1.11
In FFish Scripting language, you can dene global variables and local variables. The global variable is declared without the keyword var. // decares a local variable var obj = new Object; // declares a global variable arr = [1, 2, "string"]; After a FFish Script has nished running, all local variables declared inside a block will be cleared, as well as the interim variables. That is to say, they are not accessible in the followed scripts. The global variables, local variables that are not inside any blocks and named function can be accessible in the later scripts. To access a function dened in another script, you must load the script contains the function into memory rstly. It can be done by the invoke method.
1.12
SWFKit Pro has the ability to call functions in dlls, thus providing you with unlimited possibility of extending the power of Adobe Flash. For instance, you may call any Windows API functions from within Action Script now. Furthermore, if you need some feature that both Flash and SWFKit do not include, you can rst implement it in a dll using c/c++, Pascal, Basic, etc, and then call the dll in SWFKit Pro. It is no doubt that you can do anything with SWFKit Pro. In this tutorial, you will learn how to declare dll functions, pass parameters from sh script to dll functions, and get function results.
1.12.1
The rst thing you would have to do before you can call a dll function in SWFKit Pro is to declare the function. The new dllimport keyword and the new structure type make things easier: the dllimport keyword makes function declarations in FFish Script very distinct just like in c/c++, and the structure
62
Tutorials
type gives the FFish Script the power of supporting complex data types. More details about dll function declaration can be found at 2.58. Some dll function declaration examples are as follows: A function without structure type parameters The GetSystemDirectory function is exported by kernel32.dll and is used to retrieve the path of the system directory. The declaration of this function in SWFKit Pro should be dllimport "kernel32.dll" stdcall unsigned int GetSystemDirectoryA(char *lpBuffer, unsigned int uSize) as getSysDir; where kernel32.dll indicates the library name (name of the dll le that exports the function). Since kernel32.dll is a system le that SWFKit Pro can nd it, at here we need not use a full path name like c: windows system32 kernel32.dll. However, for a dll created by yourself, e.g. in the Resources of SWFKit Pro, you would have to specify the full path name of the dll le: var myDll = getAdditionalFile("mydll.dll"); dllimport myDll stdcall void MyFunc(); stdcall indicates the calling convention. SWFKit Pro 3 now supports two kinds of calling convention: stdcall and cdecl. Typically, Windows API functions use stdcall calling convention, whereas c/c++ functions use cdecl calling convention. After stdcall is the return value, function name, and the parameter list in a pair of brackets You can also omit the parameter names of the functions, e.g. dllimport "kernel32.dll" stdcall unsigned int GetSystemDirectoryA(char *, unsigned int) as getSysDir; The data types that can be used in function declaration is listed in 2.58. And void can only be used for the return type, which means no return. A parameter cannot be of void type. After the as keyword is the alias of the function. If you specify an alias for a function, you must use its alias to call it in FFish Script; otherwise the name of the function will be used. A function with structure type parameters or returns a structure In this case, you would have to declare the structure type rst. E.g. the FindFirstFile function: struct { unsigned int dwLowDateTime; unsigned int dwHighDateTime; } FILETIME; struct
1.12 Using SWFKit Pro to call functions in dynamic-linked libraries(dlls) { unsigned int dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; unsigned int nFileSizeHigh; unsigned int nFileSizeLow; unsigned int dwReserved0; unsigned int dwReserved1; char cFileName[260]; char cAlternateFileName[14]; } WIN32_FIND_DATA; dllimport "kernel32.dll" stdcall pointer FindFirstFileA(char *, WIN32_FIND_DATA*) as findFirstFile;
63
1.12.2
As you can see, calling a dll function is as easy as calling a native FFish Script function, because SWFKit Pro hides the details of type conversion between FFish Script variables and dll function parameters. You need not know how the data type conversion works, SWFKit Pro does everything for you. All you need to learn is the following rules of data type conversion: A Number object in FFish Script can be passed to a dll function as a parameter of character type, integer type or oating-point number type, or as a pointer to these data types. For instance, the GetSystemMetrics function can be used to retrieve various system metrics (widths and heights of display elements) and system conguration settings: dllimport "user32.dll" stdcall int GetSystemMetrics(int) as getSysMetrics; //get the width and height of the screen var SM_CXSCREEN = 0; var SM_CYSCREEN = 1; // A Number object can be passed to a function as an integer parameter var scr_width = getSysMetrics(SM_CXSCREEN); var scr_height = getSysMetrics(SM_CYSCREEN); trace("The width of the screen: ", scr_width); trace("The height of the screen: ", scr_height); The Beep function, which can be used to generate simple tones on the speaker dllimport "kernel32.dll" stdcall Boolean Beep(int, int) as beep; trace(beep(500, 1000)); Calculates the arcsine: dllimport "msvcrt.dll" cdecl double asin(double); // A Number object can be passed to a function as a floating-point parameter trace(asin(1.0));
64
Tutorials
A String object in FFish Script can be passed as a parameter of string(char*) type or wide string(short*) type. For instance, nding the task bar: dllimport "user32.dll" stdcall pointer FindWindowA(String, String) as findWindow; // To find a window, we need specify the class name or window name // of the window to find. At here we use the class name of the // task bar, which is "Shell_TrayWnd". trace(findWindow("Shell_TrayWnd", null)); where Shell TrayWnd is the class name of the window to nd. The second parameter of this function is the name of window, which can be NULL. The result of this function is the handle of the found window, which is a pointer. SWFKit Pro always converts pointer results to Numbers, that is, it will always returns the addresses of the pointers. The unicode version of the FindWindow function (on Windows NT, 2000 or XP): dllimport "user32.dll" stdcall pointer FindWindowW(short*, short*) as findWindow; // A String object can also be passed as a wide string parameter trace(findWindow("Shell_TrayWnd", null)); As you can see, String objects can be passed as both parameters of string type and parameters of wide string type. A Number object can be passed as a pointer to an unspecied type. In this case, the Number object must represent the address the pointer. As we have just discussed in the above part, SWFKit Pro always converts function results of pointer type to Number objects, that is, you can pass these returned Number objects to functions that require pointer parameters. For instance, in the above example, the FindWindow function returns the found window handle, which is a pointer. Now you can use the returned window handle to get the size of the window: struct { int int int int } RECT;
dllimport "user32.dll" stdcall pointer FindWindowA(String, String) as findWindow; dllimport "user32.dll" stdcall Boolean GetWindowRect(pointer, RECT*) as getWinRect; var handle = findWindow("Shell_TrayWnd", null); var obj = new Object; obj.value = new Struct(RECT); // "handle", a Number object represents the address of a pointer, is // passed to the "getWinRect" as a pointer parameter.
1.12 Using SWFKit Pro to call functions in dynamic-linked libraries(dlls) if (getWinRect(handle, obj)) { trace("left: ", obj.value.left); trace("top: ", obj.value.top); trace("right: ", obj.value.right); trace("bottom: ", obj.value.bottom); }
65
A StringStream object in FFish Script can be passed as a parameter of structure type or as a pointer to any data type. If the data size of the StringStream object is smaller than that of the structure type, the remain data area will be lled with zero. The StringStream object is very useful when the dll functions need allocated data buers. We will discuss this in more detail in the passing parameters by reference part. A Struct object in FFish Script can be passed as a parameter of structure type or as a pointer to structure type. The struct keyword only declares a structure type, you must use the new Struct(structName); clause to create a Struct object of that structure type. For instance, connes the cursor to a rectangular area on the screen: // first we should declare the structure type for the // "ClipCursor" function struct { int left; int top; int right; int bottom; } RECT; dllimport "user32.dll" stdcall Boolean ClipCursor(RECT*) as clipCursor; // then we should create a Struct object and initialize its members var rc = new Struct(RECT); rc.left = 0; rc.top = 0; rc.right = 100; rc.bottom = 100; clipCursor(rc); Note: when you assign a FFish Script variable to a member of a structure object, the rule is similar to that of passing parameters to dll functions. Passing parameters by reference. Generally, SWFKit Pro pass parameters to functions by value. However, many dll functions have out parameters, that is, these parameters will be used for output so that they must be passed by reference. The sh scripting language does not support to pass parameters by reference directly, so an alternative calling method is introduced into the
66
Tutorials
sh scripting language to support this feature. The method is to use Object objects to pass parameters to functions. The objects used to do this must have a value property, which is the actual variable to pass to the functions. After calling the functions, the value property of the objects will contain the new value output by the functions. For instance, to get the system directory, the GetSystemDirectory function has an output parameter to receive the path of the system directory. In order to get the output value, we must use an Object object to pass parameter by reference: dllimport "kernel32.dll" stdcall int GetSystemDirectoryA(char*, int) as getSysDir; // to get the output value, we must pass parameter by reference var obj = new Object; // the "value" property of the obj object must be a buffer whose // size is big enough to hold the output path name of the system // directory. To prepare a buffer, the StringStream object is // recommended. We just need to create a StringStream object and // set its size to meet our requirement. var buffer = new StringStream; buffer.length = 260; obj.value = buffer; if (getSysDir(obj, buffer.length) > 0) { // if the function call is successful, the value property // will contain the output value trace(obj.value); } // Of course you can use String object to hold the output value, // however, it is not as convenient as using the StringStream // object, because we must initialize the String object to be // long enough buffer = new String; buffer = "aaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaa"; obj.value = buffer; if (getSysDir(obj, buffer.length) > 0) { trace(obj.value); } From the example you may nd that the StringStream is suitable for allocate
67
buers. Although you can use a very long string object to provide a buer, it is not so convenient as using a StringStream object. The GetWindowRect example in another part of this tutorial also shows how to pass a parameter of structure type by reference so that we can get the output coordinations of the specied window. Sometimes a member of a structure object may be used to receive output value, for instance, the GetOpenFileName function outputs the le name to the lpstrFile member of the OPENFILENAME structure. In this case, you must do two things: the rst one is to use a StringStream to allocate a buer to hold the output value, the second one is to use an Object object to pass the parameter by reference since you want to get output value. struct { unsigned int lStructSize; pointer hwndOwner; pointer hInstance; char *lpstrFilter; char *lpstrCustomFilter; unsigned int nMaxCustFilter; unsigned int nFilterIndex; char *lpstrFile; unsigned int nMaxFile; char *lpstrFileTitle; unsigned int nMaxFileTitle; char *lpstrInitialDir; char *lpstrTitle; unsigned int Flags; unsigned short nFileOffset; unsigned short nFileExtension; char *lpstrDefExt; pointer lCustData; pointer lpfnHook; char *lpTemplateName; pointer pvReserved; unsigned int dwReserved; unsigned int FlagsEx; } OPENFILENAME; dllimport "comdlg32.dll" stdcall Boolean GetOpenFileNameA(OPENFILENAME*) as getOpenFileName; var ofn = new Struct(OPENFILENAME); ofn.lStructSize = ofn.structSize; trace(ofn.lStructSize); ofn.hwndOwner = getMainWnd().handle; var filter = new StringStream;
68 filter.write("All"); filter.put(0); filter.write("*.*"); filter.put(0); filter.put(0); ofn.lpstrFilter = filter; var buffer = new StringStream; buffer.write("1.txt"); buffer.length = 260; trace(buffer.length); ofn.lpstrFile = buffer; trace(ofn.lpstrFile); ofn.nMaxFile = buffer.length; ofn.nFilterIndex = 0; ofn.Flags = 0x80000; var obj = new Object; obj.value = ofn; trace(getOpenFileName(obj)); trace(obj.value.lpstrFile); trace(ofn.lpstrFile); One more example shows how to list les in c: struct { unsigned int dwLowDateTime; unsigned int dwHighDateTime; } FILETIME; struct { unsigned int dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; unsigned int nFileSizeHigh; unsigned int nFileSizeLow; unsigned int dwReserved0; unsigned int dwReserved1; char cFileName[260]; char cAlternateFileName[14]; } WIN32_FIND_DATA;
Tutorials
dllimport "kernel32.dll" stdcall pointer FindFirstFileA(char *, WIN32_FIND_DATA*) as findFirstFile; dllimport "kernel32.dll" stdcall Boolean
1.13 Building windowless projectors FindNextFileA(pointer, WIN32_FIND_DATA*) as findNextFile; dllimport "kernel32.dll" stdcall Boolean FindClose(pointer) as findClose; var obj = new Object; obj.value = new Struct(WIN32_FIND_DATA); var hFind = findFirstFile("c:\\*.*", obj); if (hFind != 0xFFFFFFFF) { do { trace(obj.value.cFileName); trace(obj.value.cAlternateFileName); } while (findNextFile(hFind, obj)) findClose(hFind); }
69
About the return values. If the return values are numbers, they will be converted to Number objects automatically. However, if the return values are pointers, they will be converted to Number objects, even if they are strings, and you would have to use the Dll.getPointerStringValue method to get the value of the string. Finally, if the return values are structures, they will be converted to structure objects automatically. If some members of the returned structures are pointers, they are also converted to numbers, and you would have to use Dll.getPointerXXXValue method to get the values that the pointers point to.
1.13
SWFKit supports to build windowless projectors. You can do this by simply setting the window shape to transparent in the [application denition]>[appearance] panel. Under Windows 2000 and XP, it also supports alpha blending so that you can get dazzling display eects.
1.14
SWFKit provides three objects for operating disk les or folders, which are the File object, the Folder object, and the FileStream object. The File and Folder objects can be used to get the properties of a le or a folder. For example, you can use the File object to get the modied time of a le, or get its size, le type, short name, parent path, etc. Moreover, you can use them to determine whether a le or folder exists. The following code is used to get properties of a le in FFish script:
Tutorials
Furthermore, the File object and the Folder object can also be used to copy, move or delete les or folders. For example, copy a le var file = new File("c:\\sounds\\demo.mp3"); file.copy("d:\\demo.mp3"); The FileStream object is used to read data from a le or write data to a le. It can not only read or write strings, but read or write binary data. For example, the get method is used to read a byte from a le, while the readLine method can read a line of string from a le. The following Action script code for Flash 8 shows how to write a XML object to a le import SWFKit.*; var xml = new XML; // XML operations ... ... // Save a XML file var fs = new FileStream("c:\\my.xml", "w"); fs.writeLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); fs.write(xml.toString()); fs.close(); fs.Release();
1.15
SWFKit provides two ways to launch an external application. One way is to use the exec command, and the other way is to call the Shell object. The exec can be used either synchronously or asynchronously. To use it synchronously in action script: function runApp(args) { ExternalInterface.call("exec", args); } runApp("notepad.exe c:\\1.txt");
1.16 Opening system dialog boxes To use it asynchronously fscommand("exec", "notepad c:\\1.txt");
71
The exec can launch an external application at anywhere on local disk. If you pass the absolute path name of an application to the exec command, it will launch it directly; if the relative path name of an application is passed to it, it will rst search for the application and then launch the application. It searches for an application in this way: rst, searches in the resource les, if found, launches the application and returns; second, searches in the same folder of the .exe le, if found, launches the application and returns; If still not found, it will search in the system directory and the directories listed in the PATH environment variable. The Shell object provides more powerful methods to launch an external application or open an external document. The run method can launch an application and return a Window object that represents the main window of the running application. The open method can open an external document. The runAndWait method can launch an external application and wait for it to exit. The following code shows how to use the Shell object in action script in Flash 8 import SWFKit.*; var window = Shell.run("notepad.exe c:\\1.txt"); Dialogs.msgBox(window.caption);
1.16
The following code shows how to open the system dialog boxes in action script in Flash 8 import SWFKit.*; Dialogs.msgBox("Hi, SWFKit!"); var fileName = Dialogs.fileOpen("SWF files(*.swf)|*.swf|All files(*.*)|*.*|"); if (fileName) { loadMovie("mc", fileName); } fileName = Dialogs.fileSave("XML files(*.xml)|*.xml|"); if (fileName) { var fs = new FileStream(fileName, "w"); ... ... }
72
Tutorials
1.17
Accessing databases
By using ADO, SWFKit and SWFKit Pro can access almost all types of databases such as Access, MySql, dBase, Firebird, SQL Server, Oracle, etc, only if you have OLEDB drivers for the databases. ADO is the popular and high performance database accessing tool of Microsoft. Using ADO in SWFKit is very simple and convenient, and you can easily copy your database accessing code from ASP to SWFKit. Another advantage of using ADO in SWFKit to access databases is that you can immigrate from one type of database to another without rewriting all your code, just by changing the connection string. From SWFKit v3, you can also use ADO directly in action script in Flash 8. However, you would have to wrap the ADO objects in Action script classes by yourself. At here we will just discuss how to use ADO in FFish script. Connect to the database Before a database can be accessed from a SWFKit application, a database connection has to be established. The steps to make a database connection are as follows. First, creating an ADO.Connection object var conn = new ActiveXObject("ADODB.Connection"); Second, creating a connection string and opening the connection. The connection string contains the provider, db name, etc. For example, to connect to a MS Access DB c: mydata sample.mdb, the connection string is var connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydata\sample.mdb"; conn.open(connStr); If you want to change the type of your database, you just need to modify this connect string. To connect to a MS SQL SERVER DB Northwind on server mysite, the connection string is var connStr = "Provider=SQLOLEDB;Server=mysite;Database=Northwind;" + "User Id=MyId;Password=123aBc"; conn.open(connStr); SWFKit can connect to any database like VB, Delphi, VC or ASP can do. How to ensure the connection has been made successfully? You can handle the ConnectComplete event of the ADO.Connection object. The event res when the connection is completed. var conn = new ActiveXObject("ADODB.Connection"); conn.connectOK = false; conn.ConnectComplete = function (err, status, cnt)
1.17 Accessing databases { if (typeof err != "undefined") { trace(err.Description); return; } else { trace("Connect complete!"); conn.connectOK = true; } trace("status: ", status.value); }
73
var connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\mydata\sample.mdb"; conn.open(connStr); if (!conn.connectOK) { trace("Failed to connect to the DB"); return; } Retrieving Data from the Databases After the connection has been made, you can retrive data from database using the ADO.Recordset object. The steps are listed as follows First, creating the ADO.Recordset object var record = new ActiveXObject("ADODB.Recordset"); Second, opening the ADO.Recordset object with a specied command string record.Open("select id, name, age, sex, score from student", conn, /*adOpenKeyset*/1, /*adLockPessimistic*/2); Third, moving to the start of the record set record.moveFirst(); Finally, fetching Data while (!record.eof) { trace(record.Fields(0).Value.toString()); trace(record.Fields(1).Value.toString()); trace(record.Fields(2).Value.toString()); trace(record.Fields(3).Value.toString());
74 trace(record.Fields(4).Value.toString()); record.moveNext(); } Tips: 1) Moving to the start of the record set record.MoveFirst(); 2) Moving to the end of the record set record.MoveLast(); 3) Moving to the previous record record.MovePrevious(); if (record.bof()) record.MoveFirst(); 4) Moving to the next record record.MoveNext(); if (record.eof) record.MoveLast();
Tutorials
Links ADO Reference http : //msdn.microsof t.com/library/def ault.asp?url = /library/en us/ado270/htm/dasdkadooverview.asp ADO Tutorial http : //www.w3schools.com/ado/def ault.asp
1.18
If you check the Show in the system tray option in Application denitions panel, the output .exe le will display a tray icon. However, the function of the tray icon is too simple. If you want to fully customized the tray icon for your applications, please use the Application.SysTray object. In this tutorial, we will discuss how to customize tray icons in action script in Flash 8. First, we would have to disable the default tray icon behavior of SWFKit: import SWFKit.*; import SWFKit.application.*; SysTray.useDefaultHandler = false; Second, add an icon into the system tray area. The icon le is loaded from the resources list SysTray.icon = Global.getAdditionalFile("NET01.ICO"); SysTray.tip = A test; SysTray.add();
1.19 Downloading and uploading les Finally, add event handler for the tray icon function onRClicked() { var menu = new Menu; menu.createPopupMenu(); menu.appendItem("id0", "item menu.appendItem("id1", "item menu.appendItem(); menu.appendItem("id2", "item menu.appendItem("id3", "item
75
Global.getMainWnd().bringToTop(); var id = menu.show(); Dialogs.msgBox(id); } function onLClicked() { SysTray.balloonTip = "Happy New Year!"; SysTray.balloonTitle = "Hello"; SysTray.balloonIcon = "warning"; SysTray.showBalloonTip(); } var st = new SysTray; st.setEventHandler("onRClicked", onRClicked); st.setEventHandler("onLClicked", onLClicked);
1.19
SWFKit provides the Inet object and the Inet.Ftp object to download and upload les. Downloading a HTTP le is very simple, the following code shows how to do this in action script import SWFKit.*; function on_geturl(type, msg) { _root.strace(msg); if (!SWFKit.Global.processMsg()) return false; return type; } var inet = new Inet; inet.setEventHandler("onGetUrl", on_geturl);
76 inet.getUrl(http://www.swfkit.com, c:\\1.html);
Tutorials
To download or upload a ftp le, you would have to use the Inet.Ftp object. The following code shows how to do this in action script import SWFKit.*; import SWFKit.inet.Ftp; //1. Open an Inet.Ftp object //The Inet.Ftp object is created by the Inet.openFtp method. var ftp = Inet.openFtp("ftp://192.168.1.3"); //2. Connect to the ftp server ftp.connect(); //3. Change the current directory _root.strace(ftp.currentDir); ftp.currentDir = "songs"; //4. List the files and folders var i; var list = ftp.list(); for (i = 0; i < list.files.length; i++) _root.strace(list.files[i]); for (i = 0; i < list.folders.length; i++) _root.strace(list.folders[i]); //5. Get the file size var info = ftp.getFileInfo("test.rar"); _root.strace(info.size); //6. Download or upload files function onDownload(percent) { _root.strace(percent); return true; } ftp.setEventHandler("onDownload", onDownload); ftp.download("test.rar", "c:\\sample\\test.rar");
77
1.20
Before sending an email, you must rst create a Mail object to set the subject, text, attachments, etc import SWFKit.*; var mail = new Mail; mail.from = "someone@swfkit.com"; mail.to = "support@some.com;sales@some.com"; mail.subject = "This is an Email"; mail.text = "Hello, SWFKit!"; mail.date = (new Date).toString(); mail.addAttachment("c:\\myfile.mp3"); Then you can use the SendMail object to send the email out. function onSendIt(type, msg) { _root.strace("type is: " + type + " " + msg); if (!SWFKit.Global.processMsg()) return false; return true; } var sm = new SendMail; sm.server = "myserver"; sm.port = 25; sm.username = "myname"; sm.password = "mypassword"; sm.setEventHandler("onSend", onSendIt); sm.send(mail); To receive emails, you would have to use the RecvMail object. import SWFKit.*; // The event handler of the RecvMail object function onRecieve(type, msg) { _root.strace(msg); if (!SWFKit.Global.processMsg()) return false; return true; }
78
Tutorials
var rm = new RecvMail; rm.server = "myserver"; rm.port = 110; rm.username = "myname"; rm.password = "mypassword"; // Connect to the POP3 server rm.connect(); rm.setEventHandler("onRecv", onRecieve); // Get email count on the POP3 server var count = rm.list(); _root.strace(count); if (count.length > 0) { // Receive only the first 10 emails for (var i = 1; i <= 10; i++) { // Receive the ith email, it returns // a Mail object var mail = rm.retr(i); if (mail != null) { _root.strace(mail); _root.strace(mail.text); if (mail.attachmentCount > 0) { // Extract the attachments ... } } } } rm.quit(); rm.close();
1.21
With SWFKit Pro, you can create modal or modeless forms. The following code shows how to create a form in action script in Flash 8. import SWFKit.*; var form = new Form; form.movie = Global.getAdditionalFile("forform.swf");
1.22 Changing screen resolutions form.caption = "Hello, Form!"; form.showCaption = true; form.canDrag = true; form.initVars = "formid=" + form.Identifier; form.show(true);
79
As you can see from the above code, a Form is a child window that displays another ash movie. The form object is created in the main movie, how can we programming the form object in another ash movie? This can be done by pass the identier of the form object to the form movie: form.initVars = formid= + form.Identier;. In this case, we can get the form object in the rst frame of the form view. The following code is in the rst frame of the forform.swf import SWFKit.*; var id = parseInt(formid); SWFKit.Global.trace(formid); var form = Form.fromID(id); SWFKit.Global.trace(form.Identifier); After getting the form object, we can create an ActiveX control in the form, for example, the web browser control import SWFKit.*; var id = parseInt(formid); SWFKit.Global.trace(formid); var form = Form.fromID(id); SWFKit.Global.trace(form.Identifier); var ax = form.createControl("Shell.Explorer.2", 0, 0, 200, 200); var activex = ActiveXObject.fromID(ax.activex); activex.callMethod("Navigate2", "http://www.topcmm.com"); // To fill the activex control in the entire form var width = form.window.clientRect.width; var height = form.window.clientRect.height; ax.window.move(0, 0, width, height);
1.22
The DirectX object can change the screen resolution without restarting the computer. When you play a movie in full screen mode, changing the screen resolution to a lower one will improve the performance. // List all available screen resolutions in system
80 var ds = SysInfo.getDisplaySettings(); var i; for (i = 0; i < ds.length; i++) { _root.strace(ds[i].pelsWidth); _root.strace(ds[i].pelsHeight); _root.strace(ds[i].bitsPerPel); _root.strace(ds[i].displayFrequency); } // Change the screen resolution DirectX.setDisplayMode(800, 600, 32);
Tutorials
1.23
Screen capture
SWFKit Pro supports to capture screen and copy onto clipboard or save to an Image object. Besides screen capture, it can also capture the current movie. The following code shows how to capture screen or the current movie and get an Image object. import SWFKit.*; var image = Image.captureScreen(); // Load the captured image into the current movie. image.loadImage(1); // Save the captured image to a disk file image.save("c:\\screen.jpg");
1.24
You can embed the web browser control in the main movie or forms to display web sites or web pages. In fact, the createControl method in SWFKit and SWFKit Pro can embed any ActiveX control in the main movie. First, you would have to call the createControl method to create the ActiveX control window and embed it in the main movie. The method will returns an object, which has two properties, one is window, a Window object that represents the ActiveX control window, and the other is activex, an ActiveXObject object that can be used to access the methods and properties of the ActiveXControl. To reuse the web browser control, the code in FFish script would be // Create the web browser control var ax = createControl("Shell.Explorer.2", 0, 0, 200, 200); // Fill the web browser control in the entire client area of the main window getMainWnd().onSize = function(type, width, height) {
1.24 Reusing the web browser control ax.window.move(0, 0, width, height); } // handle event of the ActiveX control ax.activex.NavigateComplete2 = function (control, url) { trace(url); } // Browse web site // The ActiveXObject accepts case insensitive method names. // Please be careful that both FFish script and Action script // are case sensitive ax.activex.navigate2("http://www.topcmm.com");
81
Although you can also write code in action script to embed a web browser control, you would have to wrap the web browser control in an Action script class, because Action script does not allow you to call a dynamic method that is not dened in a class. A sample wrapper class, WebBrowser.as, which denes only one method of the web browser, is as follows import SWFKit.*; import flash.external.*; class WebBrowser extends SWFKit.ActiveXObject { public function WebBrowser(progID) { super(progID); } public static function fromID(id: Number) { var ax = new WebBrowser(null); ax.Identifier = id; return ax; } public function Navigate2() { return ExternalInterface.call("ffish_call2", this.Identifier, "Navigate2", arguments); } // the other methods ... }
82
Tutorials
The following code shows how to use the web browser in action script in Flash 8 import SWFKit.*; import WebBrowser; // Create the web browser control var ax = Global.createControl("Shell.Explorer.2", 0, 0, 200, 200); // Fill the web browser control in the entire client area of the // main window var win = Global.getMainWnd(); ax.window.move(0, 0, win.clientRect.width, win.clientRect.height); function onSize(type, width, height) { ax.window.move(0, 0, width, height); } win.setEventHandler("onSize", onSize); var wb = WebBrowser.fromID(ax.activex); // handle event of the ActiveX control function NavigateComplete2(control, url) { _root.strace(url); } wb.setEventHandler("NavigateComplete2", NavigateComplete2); // Browse web site wb.Navigate2("http://www.topcmm.com");
To learn how to embed an ActiveX control in a form, please read the Creating multiple forms tutorial. The reference of reusing the web browser can be found at http : //msdn.microsof t.com/library/def ault.asp? url = /workshop/browser/webbrowser/W ebBr
1.25
By embedding the popular movie players in the main window, SWFKit can play almost all popular movie types. Just like reusing the web browser, embedding a movie player requires that you rst use the createControl method to create the movie player, then call the methods and properties of the movie player to play movies. All methods, properties, and events of the ActiveX controls can be accessed in FFish script. To embed the Windows Media Player 9+ var ax = createControl("WMPlayer.OCX", 0, 0, 200, 200); ax.activex.url = "c:\\my.wmv"; ax.activex.controls.play();
1.26 Opening pdf les To embed the Windows Media Player 6.4
83
var ax = createControl("MediaPlayer.MediaPlayer", 0, 0, 200, 200); ax.activex.open("c:\\my.wmv"); ax.activex.play(); The reference of the Windows media player can be found at http : //msdn.microsof t.com/library/def ault.asp? url = /library/en us/wmplay10/mmp sdk/windowsmediaplayer10sdk.asp To embed the Real Player var ax = createControl("rmocx.RealPlayer G2 Control", 0, 0, 200, 200); ax.activex.src = "c:\\my.rm"; ax.activex.DoPlay(); The reference of the Real Player can be found at http : //service.real.com/help/library/guides/extend/embed.htm To embed the QuickTime Player var ax = createControl("QuickTime.QuickTime", 0, 0, 200, 200); ax.activex.setUrl("c:\\my.mov"); ax.activex.play();
The reference of the QuickTime can be found at http : //developer.apple.com/documentation/QuickT ime/ Conceptual/QT Scripting JavaScript/bQT Scripting chapter 1000 section 1.html If you want to use these ActiveX controls directly in action script in Flash 8, you would have to wrap them in action script classes.
1.26
You can use the Shell.open method or the exec command to open pdf les with an external application, which is generally the Adobe Acrobat PDF Reader. However, you still can display a pdf le in the main window or in a form, by embedding a Adobe Acrobat PDF reader ActiveX control. var ax = createControl("AcroPDF.PDF", 0, 0, 200, 200); ax.activex.loadFile("c:\\my.pdf"); The methods and properties of the Adobe Acrobat PDF ActiveX control are listed as follows: dispinterface IAcroAXDocShim { properties: methods: [id(0x00000001), propget, helpstring("property src")] BSTR src(); [id(0x00000001), propput, helpstring("property src")]
84
Tutorials void src([in] BSTR rhs); [id(0x00000002), helpstring("method LoadFile")] VARIANT_BOOL LoadFile([in] BSTR fileName); [id(0x00000003), helpstring("method setShowToolbar")] void setShowToolbar([in] VARIANT_BOOL On); [id(0x00000004), helpstring("method gotoFirstPage")] void gotoFirstPage(); [id(0x00000005), helpstring("method gotoLastPage")] void gotoLastPage(); [id(0x00000006), helpstring("method gotoNextPage")] void gotoNextPage(); [id(0x00000007), helpstring("method gotoPreviousPage")] void gotoPreviousPage(); [id(0x00000008), helpstring("method setCurrentPage")] void setCurrentPage([in] long n); [id(0x00000009), helpstring("method goForwardStack")] void goForwardStack(); [id(0x0000000a), helpstring("method goBackwardStack")] void goBackwardStack(); [id(0x0000000b), helpstring("method setPageMode")] void setPageMode([in] BSTR pageMode); [id(0x0000000c), helpstring("method setLayoutMode")] void setLayoutMode([in] BSTR layoutMode); [id(0x0000000d), helpstring("method setNamedDest")] void setNamedDest([in] BSTR namedDest); [id(0x0000000e), helpstring("method Print")] void Print(); [id(0x0000000f), helpstring("method printWithDialog")] void printWithDialog(); [id(0x00000010), helpstring("method setZoom")] void setZoom([in] single percent); [id(0x00000011), helpstring("method setZoomScroll")] void setZoomScroll( [in] single percent, [in] single left, [in] single top); [id(0x00000012), helpstring("method setView")] void setView([in] BSTR viewMode); [id(0x00000013), helpstring("method setViewScroll")] void setViewScroll( [in] BSTR viewMode, [in] single offset); [id(0x00000014), helpstring("method setViewRect")] void setViewRect( [in] single left, [in] single top,
85
[in] single width, [in] single height); [id(0x00000015), helpstring("method printPages")] void printPages( [in] long from, [in] long to); [id(0x00000016), helpstring("method printPagesFit")] void printPagesFit( [in] long from, [in] long to, [in] VARIANT_BOOL shrinkToFit); [id(0x00000017), helpstring("method printAll")] void printAll(); [id(0x00000018), helpstring("method printAllFit")] void printAllFit([in] VARIANT_BOOL shrinkToFit); [id(0x00000019), helpstring("method setShowScrollbars")] void setShowScrollbars([in] VARIANT_BOOL On); [id(0x0000001a), helpstring("method GetVersions")] VARIANT GetVersions(); [id(0x0000001b), helpstring("method setCurrentHightlight")] void setCurrentHightlight( [in] long a, [in] long b, [in] long c, [in] long d); [id(0x0000001c), helpstring("method setCurrentHighlight")] void setCurrentHighlight( [in] long a, [in] long b, [in] long c, [in] long d); }; Please read the Reusing the web browser control tutorial to learn more details about using ActiveX controls.
1.27
By using the ScriptHost object in SWFKit Pro, you can call Active scripting languages such as jscript, vbscript, perlscript, pythonscript, rubyscript, etc. Please read more details about the ScriptHost object from the FFish scripting language manual of SWFKit Pro. At here we just show how to use the ScriptHost object in Action script. import SWFKit.*;
86 var sh = new ScriptHost; sh.open("perlscript"); sh.runScriptFile("c:\\test.pl"); sh.close(); sh.open("jscript"); sh.runScript("function add(a, b) {return a + b;}"); var ax = ActiveXObject.fromID(sh.getScriptObject()); var value = ax.callMethod("add", "Hello,", "world"); _root.strace(value); sh.Release();
Tutorials
As you can see from the above code, the getScriptObject method returns an ActiveXObject object, which contains the global functions and variables in the running script.
1.28
Generally, shared objects are relative to the full path name of the movie that creates them. However, the path name of a packed movie changes each time the application launches. The reason is that the SWFKit applications will extract the packed movies to a temporary folder, and will remove the temporary folder when they are about to exit. Each time the temporary folder changes, so the path names of the unpacked movies change. In this case, shared objects do not work in packed movies. However, there is still a way to make the shared objects work in packed movies. var aso = SharedObject.getLocal("testso.testso.swfkitproject.topcmm", "/"); trace(aso); if (aso.data.score == undefined) { aso.data.score = new Object; aso.data.score.minValue = 0; aso.data.score.maxValue = 100; } else { _root.minValue = aso.data.score.minValue; _root.maxValue = aso.data.score.maxValue; } In the above example, the second parameter / of the getLocal method means that the shared objects will be saved in a root folder that any local ash movies can access it. In this case, however, it may cause conicts between two dierent ash movies because they might use the same shared object name. Hence, we should specify a longer shared object name like that in the above example.
87
1.29
Using autoupdate
The autoupdate feature is implemented in the AutoUpdate.dll that can be called in SWFKit or SWFKit Pro. In SWFKit Pro you can use the Dll object to call the functions exported by the AutoUpdate.dll. The rst thing you would have to do is to add the AutoUpdate.dll into the resources list. The AutoUpdate.dll le is in the SWFKit installed folder, typically, it is c:\program les\swfkit pro 3. var autoupdate = getAdditionalFile("AutoUpdate.dll"); dllimport autoupdate stdcall void AutoUpdate_Check(char*, char*, Boolean); dllimport autoupdate stdcall void AutoUpdate_UICheck(char*, char*); The AutoUpdate Check function is used to search for an update at the background. That is to say, it does not display a wizard. The rst parameter of this function is the url of the ini le created by the UpdateMaker, the second parameter is the name of your application, and the third parameter is used to determine whether the function will be called silently. The function is called silently means that if there is no update found, it will do nothing. If the parameter is set to false, it will display a message box to say that there is no new update. If a new update has been found, it will display a message box even if it is set to run silently. AutoUpdate_Check("http://www.mysite.com/updata/update.ini", "My Application", true); Adding the above code to the initialize script will let your application check the update silently when it is launched. You can also let your application explicitly check the update by calling the AutoUpdate UICheck function, it will display a wizard for you to search for new updates. AutoUpdate_UICheck("http://www.mysite.com/updata/update.ini", "My Application"); In SWFKit, you cannot call dll functions. However, the AutoUpdate.dll exports an ActiveX component to search for new updates. First, you should add the AutoUpdate.dll into the resources list and register it. The AutoUpdate.dll le is in the SWFKit installed folder, typically, it is c: program les swfkit 3. The ActiveX components exported by AutoUpdate.dll contains the following methods and properties: updateINI The ini le produced by the UpdateMaker appName The name of your application Check(bSilent) Check whether there is a new update. If bSilent is set to true, this method will search for the new update silently, that is, if there is no new update, it will do nothing; otherwise, it will display a message box to say that there is no new update. If a new update is found, it will display a message
88
Tutorials
box even if bSilent is set to true. This function does not display a wizard. So you can call this method in the initialize script to check the updates silently. UICheck This method is used to check updates explicitly. It will display a wizard. var autoupdate = getAdditionalFile("AutoUpdate.dll"); ActiveXObject.register(autoupdate); var ax = new ActiveXObject("AutoUpdate.SWFKitAutoUpdate"); ax.updateINI = "http://www.mysite.com/update/update.ini"; ax.appName = "Test Plug-in"; ax.check(true);
Chapter 2
Description
2.1.1
2.1.1.1
Properties
NaN
90 Remarks
The NaN property (not a number) is a member of the Global object, and is made available when the scripting engine is initialized.
2.1.1.2
Innity
Description Contains an initial value of number positive innity Syntax Innity Remarks The Innity property is a member of the Global object, and is made available when the scripting engine is initialized.
2.1.2
2.1.2.1
Methods
parseFloat
Description Converts strings into oating-point numbers. Syntax parseFloat(string) Parameters string The string to read and convert to a oating-point number. Returns The parseFloat method returns an numerical value equal to the number contained in string. If no prex of string can be successfully parsed into a oating-point number, NaN (not a number) is returned. Example parseFloat("abc") // Returns NaN. parseFloat("1.2abc") // Returns 1.2.
91
Description Converts strings into integers. Syntax parseInt(string, [radix]) Parameters string Required. A string to convert into a number. radix Optional. A value between 2 and 36 indicating the base of the number contained in string. If not supplied, strings with a prex of 0x are considered hexidecimal and strings with a prex of 0 are considered octal. All other strings are considered decimal. Returns The parseInt method returns an integer value equal to the number contained in string. If no prex of string can be successfully parsed into an integer, NaN (not a number) is returned. Examples parseInt("abc") // Returns NaN. parseInt("12abc") // Returns 12. //You can test for NaN by using the isNaN method.
2.1.2.3
escape
Description Encodes String objects so they can be read on all computers. Syntax escape(expression) Parameters expression The expression to convert into a string and encode in a URLencoded format Returns
92
FFish Script Objects Reference The escape method returns a new String that contains the contents of expression. All spaces, punctuation, accented characters, and any other non-ASCII characters are replaced with %xx encoding, where xx is equivalent to the hexadecimal number representing the character. For example, a space is returned as %20. Characters with a value greater than 255 are stored using the %uxxxx format.
Example //Running the following code gives the result, //Hello%7B%5BWorld%5D%7D. escape("Hello{[World]}");
2.1.2.4
unescape
Description Decodes String objects encoded with the escape method. Syntax unescape(x) Parameters x A string with hexadecimal sequences to escape. Returns The unescape method returns a new string that contains the contents of x. All characters encoded with the %xx hexadecimal form are replaced by their ASCII character set equivalents. Characters encoded in %uxxxx format (Unicode characters) are replaced with the Unicode character with hexadecimal encoding xxxx. Examples unescape("Hello%7B%5BWorld%5D%7D") //The result is: Hello{[World]}
93
Description Evaluates FFish Script code. Syntax eval(expression) Parameters expression A string containing the name of a variable, property, object, or movie clip to retrieve. Returns The eval function allows dynamic execution of Fsh Script source code and returns the result of the expression. Example value = [1, 2, 3]; x = 1; eval("value" + "[" + x + "]"); //returns 2
2.1.2.6
isNAN
Description Determines whether a value is the reserved value NaN (not a number). Syntax isNaN(value) Parameters value The value to be tested against NaN. Returns The isNaN function returns true if the value is NaN, and false otherwise. You typically use this function to test return values from the parseInt and parseFloat methods. Alternatively, a variable could be compared to itself. If it compares as unequal, it is NaN. This is because NaN is the only value that is not equal to itself.
94 2.1.2.7 isFinit
Description Determines if a supplied number is nite. Syntax isFinite(value) Parameters value The value to be tested.. Returns The isFinite method returns true if number is any value other than NaN, negative innity, or positive innity. In those three cases, it returns false.
2.1.2.8
trace
Description Print the value of the parameters in the trace window. This method works only in the preview mode. Syntax trace(exp1 , exp2 , ..., expn ) Parameters exp1 , exp2 , ..., expn a variable number of expressions. Returns Nothing. Example var x = "Hello world"; trace(x);
95
Description Creates an embedded ActiveX control in the projector. available: SWFKit and SWFKit Pro Syntax createControl(progid, left, top, right, bottom[, param[, licensekey]]) Parameters progid A string species the ProgID of the ActiveX to be created. left, top, right, bottom Integer. Species the controls size and position in the projector. param Optional. String. Initializes the properties of the ActiveX control. It contains several name=value pairs conjoined by character & licensekey Optional. String. Species the license key of the ActiveX control. Returns An object contains two properties 1. The window property The window property is a Window object that represents the window of the created ActiveX control. You can use this property to set the placement of the ActiveX control, show or hide it, ect. 2. The activex property The activex property is an ActiveXObject object. You can use this property to access the properties, methods and events of the ActiveX control. Remarks If the method creates a windowless control, the window property of the returned object will be undened. The Windows Media Player control will always be windowless activated, if you want to close it, you cannot use the close method of the window object but should do in this way
96
FFish Script Objects Reference //Embed a Microsoft Media Player in the projector: var mplayer = createControl( "MediaPlayer.MediaPlayer.1", 0, 0, 200, 200); ... //destroy it delete mplayer; mplayer = null; SWFKit doesnt support windowless activating for any other controls. It doesnt draw it, so you will get nothing in the main window if you create a control activated in windowless mode. //Activate a Flash Player in windowless mode. //For SWFKit doesnt draw the windowless control //The control wont be visible in the main window //fp.window returns undefined var fp = createControl(ShockwaveFlash.ShockwaveFlash, 0, 0, 320, 240, wmode=transparent&movie=c:\\test.swf&bgcolor=0xFF0000); fp.activex.play(); trace(fp.window.handle);
Example //Embed a Microsoft Media Player: var mplayer = createControl( "MediaPlayer.MediaPlayer.1", 0, 0, 200, 200); //Open an avi file mplayer.activex.Open("c:\\demo.avi"); //Embed a Microsoft Media Player: var mplayer = createControl("MediaPlayer.MediaPlayer.1", 0, 0, 200, 200, "filename=c:\\demo.avi"); //Embed a Flash Player: var fp = createControl(ShockwaveFlash.ShockwaveFlash, 0, 0, 320, 240, wmode=window&movie=c:\\test.swf&bgcolor=0xFF0000); fp.activex.play(); trace(fp.window.handle);
97
Description Gets a Window object that represents the main window of the application or screen saver. Syntax getMainWnd() Parameters None Returns A Window Object. Example //Close the projector var mw = getMainWnd(); mw.Close();
2.1.2.11
getAppDir
Description Retrieves the pathname of the directory that the application or screen saver locates in. Syntax getAppDir() Parameters None Returns A String. Example var path = getAppDir(); trace(path);
98 2.1.2.12 getMovies
Description Get all movies added to the application or screen saver. Obsolete. Syntax getMovies() Parameters None Returns An array of Strings.
2.1.2.13
setWindowless
Description Customize the window shape of the application. Wont work for screen savers Syntax setWindowless(clip region name or mode) Parameters clip region name or mode A string represents a clip region name or a boolean value species the transparent mode. If the parameter is a string it species a clip region name. The method set the window shape according to the specied clip region. If the clip region specied by the parameter does not exist, the window shape is reset to the regular shape. If the parameter is a boolean value of true, the method will make the application transparent. Otherwise, it will make the application reset to regular shape. Returns Nothing.
99
Description Retrieves a value from an entry within a specied section of the applications registry or .INI le. Syntax readProle(section, entry) Parameters section A string species the section containing the entry entry A string that contains the entry whose value is to be retrieved Returns A string value. Example readProfile("score", "Mary");
2.1.2.15
writeProle
Description Writes the specied value into the specied section of the applications registry or .INI le. Syntax writeProle(section, entry, value) Parameters section A string species the section containing the entry entry A string that contains the entry whose value is to be written. value A string contains the value to be written Returns Nothing. Example writeProfile("score", "Mary", "100");
Description Process the Windows messages of the application or screen saver. Syntax processMsg() Parameters None Returns Boolean. If the user has taken an action to close the application by clicking the close button, pressing the ALT+F4 keys, etc, the method returns false; otherwise, it returns true. Remarks The method is used to avoid the blocking of the application while executing a script takes times. The method peeks messages from the message queue of the main thread of the application, then translates the messages and dispatches them. Users inputs just like key presses or mouse clicks during the executing of the script will be handled by this method. If the method returns false, you should return from the script and the main process of the application will stop. Example var i = 0; while (1) { trace(i++); if (!processMsg()) break; }
2.1.2.17
getAdditionalFile
2.1 Global Object getAdditionalFile(name) Parameters name String. Species the name of the le or folder to extract. The name contains a relative path to the Application folder. If the name species a lename, the method extracts the specied le to the temporary folder and returns the pathname of the extracted le. E.g. extract media1.swf var m = getAdditionalFile(\\movies\\media1.swf"); If the name species a path, the method extracts the specied folder and all its les and subfolders to the temporary folder and returns the pathname of the folder. Invoking the method without parameter or with a empty string extracts all les and folders. E.g. extract the movies folder: var movies = getAdditionFile(\\movies"); var m = movies + \\" + media1.swf; Note: This method works only with les and folders under the Application folder. SWFKit does not pack any les under the Windows folder. Only the setup program uses that les. Returns String. If the le or folder does not exist, returns null.
101
2.1.2.18
getExeName
Description Get the full pathname of the running application. Syntax getExeName() Parameters None Returns String.
Description Invokes a pre-compiled FFish Script. Syntax invoke(name) Parameters name Species the name of the pre-compiled FFish Script to invoke. Returns Nothing.
2.1.2.20
evals
Description Evaluates a FFish Script le. Syntax evals(lename) Parameters lename Species the full pathname of the FFish Script to evaluate.. Returns Nothing.
2.1.2.21
decodeURI
Description Returns the unencoded version of an encoded Uniform Resource Identier(URI). Syntax decodeURI(str) Parameters str String. Represents an encoded URI. Returns String.
103
Description Encodes a text string as a valid Uniform Resource Identier (URI) Syntax encodeURI(str) Parameters str String. Returns A string represents the encoded URI.
2.1.2.23
decodeURIComponent
Description Returns the unencoded version of an encoded component of a Uniform Resource Identier (URI). Syntax decodeURIComponent(str) Parameters str String. Returns String
2.1.2.24
encodeURIComponent
Description Encodes a text string as a valid component of a Uniform Resource Identier (URI). Syntax encodeURIComponent(str) Parameters str String. Returns String
104
2.2
Boolean object
Creates a new Boolean value.
Description
Syntax new Boolean([x]) Parameters x Optional. It is the initital Boolean value for the new object. If this value is omitted, or is false, 0, null, NaN, or an empty string, the initial value of the Boolean object is false. Otherwise, the initial value is true. Remarks The Boolean object is a wrapper for the Boolean data type. Fsh Script implicitly uses the Boolean object whenever a Boolean data type is converted to a Boolean object. You rarely call the Boolean object explicitly.
2.3
Number object
An object representation of the number data type and placeholder for numeric constants.
Description
Syntax new Number(value) Parameters value The numeric value of the Number object being created, or a value to be converted to a number. Remarks FFish Script creates Number objects as required from numerical values. It is rarely necessary to create Number objects explicitly.
105
2.3.1
2.3.1.1
Properties
MAX VALUE
Description The largest representable number (doubleprecision IEEE754). This number is approximately 1.79e308 . Syntax Number.MAX VALUE Remarks This property can be accessed without having number object created.
2.3.1.2
MIN VALUE
Description The smallest representable number (double-precision IEEE754). This number is approximately 5e324 . Syntax Number.MIN VALUE Remarks This property can be accessed without having number object created.
2.3.1.3
NaN
Description The IEEE754 value representing Not A Number (NaN). Syntax Number.NAN Remarks This property can be accessed without having number object created.
Description A value more negative than the largest negative number (Number.MAX VALUE) representable in Fsh Script. Syntax Number.NEGATIVE INFINITY Remarks The value of this property behaves mathematically as innity. This property can be accessed without having number object created
2.3.1.5
POSITIVE INFINITY
Description A value larger than the largest number (Number.MAX VALUE) representable in Fsh Script Syntax Number.POSITIVE INFINITY Remarks The value of this property behaves mathematically as innity. This property can be accessed without having number object created.
2.3.2
2.3.2.1
methods
format
Description Convert the number to string in the specication format Syntax Number.format(fmt)() Parameters
2.4 String object fmt format control string, it is the same as the format parameter of the C function sprintf. returns String. Example Print PI: trace(Math.PI.format("%.8f")); //output: 3.1415926
107
2.4
String object
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
Description
Syntax 1. StringObj[.method] 2. String Literal[.method] Remarks You can call any of the methods of the String object using the constructor method new String or using a string literal value. You can convert the value of any object into a string using the String() function. All string indexes are zero-based, the index of the last character for any string x is as this: x.length - 1 Constructor Description creates a new String object. Syntax new String(value) Parameters value The initial value of the new String object. Example s = new String("Hello World");
108
2.4.1
2.4.1.1
Properties
length
Description The length property contains an integer that indicates the number of characters in the String object. The last character in the String object has an index of length 1. Syntax 1. StringObj.length 2. String Literal.length Example s = new String("Hello World"); s.length; //returns 11
2.4.2
2.4.2.1
Methods
charAt
Description Retrieves the character at the index specied. Syntax 1. StringObj.charAt(index) 2. String Literal.charAt(index) Parameters index The number of the character in the string to be returned. returns returns the character in the position specied by the parameter index. The index of the rst character in a string is 0. If index is not a number from 0 to string.length 1, an empty string is returned. Example s = new String("Hello World"); s.charAt(2); //returns "l"
109
Description Returns the ascii code of the specied character. Syntax 1. StringObj.charCodeAt(index) 2. String Literal.charCodeAt(index) Parameters index An integer that species the position of a character in the string. The rst character is indicated by 0, and the last character is indicated by stringObj.length-1. returns Returns an integer represents the character specied by index. If index is not a number from 0 to stringObj.length - 1, returns NAN. Example s = new String("Chris"); i = s.charCodeAt(0); // i = 67
2.4.2.3
concat
Description Combines the value of the String object with the parameters and returns the newly formed string; the original value of the String object is unchanged. Syntax 1. StringObj.concat(value1 , . . . , valuen ) 2. String Literal.concat(value1 , . . . , valuen ) Parameters value1 , . . . , valuen Zero or more values to be concatenated. returns
110
FFish Script Objects Reference The result of the concat method is equivalent to: result = StringObj + value1 + . . . + valuen
Example s0 = "This is an "; s1 = "example for "; s2 = "String.concat"; r = s0.concat(s1, s2); //r = "This is an example for String.concat";
2.4.2.4
fromCharCode
Description Combines the value of the String object with the parameters and returns the newly formed string; the original value of the String object is unchanged. Syntax 1. StringObj.fromCharCode(c1 , c2 , . . . , cn ) 2. String Literal.fromCharCode(c1 , c2 , . . . , cn ) Parameters c1 , c2 , . . . , cn Decimal integers that represent ASCII values. Returns returns a string made up of the characters represented by the ASCII values in the parameters Example A String object need not be created before calling fromCharCode. This example uses the fromCharCode method to insert an character in the e-mail address. address = "support" + String.fromCharCode(64) + "swfkit.com"; trace(address); //output: support@swfkit.com
111
Description Finds the rst occurrence a substring within a String object. Syntax 1. StringObj.indexOf(substring, [startIndex]) 2. String Literal.indexOf(substring, [startIndex]) Parameters substring An integer or string specifying the substring to be searched for within stringObj. startIndex Optional. An integer specifying the starting point in stringObj to search for substring. Returns The indexOf method returns an integer value indicating the beginning of the substring within the String object. If the substring is not found, a -1 is returned. If startindex is negative, startindex is treated as zero. If it is larger than the greatest character position index, it is treated as the largest possible index. Searching is performed from left to right. Example s = "This is an example for String.indexOf"; i = s.indexOf("example"); trace(i);//output: 11
2.4.2.6
lastIndexOf
Description Finds the last occurrence of a substring within a String object. Syntax 1. StringObj.lastIndexOf(substring, [startIndex]) 2. String Literal.lastIndexOf(substring, [startIndex])
112 Parameters
substring An integer or string specifying the substring to be searched for within stringObj. startIndex Optional. An integer specifying the starting point in stringObj to search for substring. Returns The lastIndexOf method returns an integer value indicating the beginning of the substring within the String object. If the substring is not found, a -1 is returned. If startindex is negative, startindex is treated as zero. If it is larger than the greatest character position index, it is treated as the largest possible index. Searching is performed right to left. Example s = "That is an example for String.indexOf. This is an example for String.lastIndexOf"; i = s.lastIndexOf("example"); trace(i); //output: 50
2.4.2.7
slice
Description Returns a section of a string. Syntax 1. StringObj.slice(start, [end]) 2. String Literal.slice(start, [end]) Parameters start A number specifying the index of the starting point for the slice. If start is a negative number, the starting point is determined from the end of the string, where -1 is the last character. end Optional. A number specifying the index of the ending point for the slice. If end is not specied, the slice includes all characters from start to the end of the string. If end is a negative number, the ending point is determined from the end of the string, where -1 is the last character.
2.4 String object Returns The slice method returns a String object containing the specied portion of stringObj without modifying the original String object. The returned string includes the start character and all characters up to (but not including) the end character. Example s = "This is an example of String.slice"; r = s.slice(5, 7); trace(r); //output: is
113
2.4.2.8
split
Description Splits a String object into an array of strings by separating the string into substrings. Syntax 1. StringObj.split(delimiter, [limit]) 2. String Literal.split(delimiter, [limit]) Parameters delimiter The character or string at which stringObj splits. If the delimiter parameter is undened, the entire string is placed in the rst element of the array. limit optional . The number of items to place into the array. Returns The result of the split method is an array of strings split at each point where delimiter occurred in stingObj. If you use an empty string () as a delimiter, each character in the string is placed as an element in the array. Example s = "This is an example of String.split"; r = s.split(" "); trace(r); //output: This,is,an,example,of,String.split
Description Returns a substring beginning at a specied location and having a specied length. Syntax 1. StringObj.split(start, [length]) 2. String Literal.split(start, [length]) Parameters start An integer that indicates the position of the rst character in stringObj to be used to create the substring. If start is a negative number, the starting position is determined from the end of the string, where the -1 is the last character. length optional. The number of characters in the substring being created. If length is not specied, the substring includes all of the characters from the start to the end of the string. Returns If length is zero or negative, an empty string is returned. If not specied, the substring continues to the end of stringvar. The substr method does not change the string specied by stringObj, it returns a new string. Example s = "This is an example for String.substr"; r = s.substr(0, 4); trace(r); //output: This
2.4.2.10
substring
Description Retrieves the substring at the specied location within a String object. Syntax 1. StringObj.substring(from, to)
2.4 String object 2. String Literal.substring(from, to) Parameters from An integer that indicates the position of the rst character of StringObj used to create the substring. Valid values for from are 0 through string.length - 1. If from is a negative value, 0 is used. to An integer that is 1+ the index of the last character in StringObj to be extracted. Valid values for to are 1 through string.length. The character indexed by the to parameter is not included in the extracted string. If this parameter is omitted, string.length is used. If this parameter is a negative value, 0 is used. Returns The substring method returns a String object containing the substring derived from the original object. If from is not an integer, it returns an empty string. If from is greater than or equal to to, it also returns an empty string. Example s = "Hello world"; r = s.substring(6, 11); trace(r); //output: world
115
2.4.2.11
toLowerCase
Description Places the text in a String object in lowercase characters. Syntax 1. StringObj.toLowerCase() 2. String Literal.toLowerCase() Parameters None Returns
116
FFish Script Objects Reference This method returns a copy of the String object, with all of the uppercase characters converted to lowercase. The original value is unchanged. The toLowerCase method has no eect on nonalphabetic characters.
2.4.2.12
toUpperCase
Description Places the text in a String object in uppercase characters. Syntax 1. StringObj.toUpperCase() 2. String Literal.toUpperCase() Parameters None Returns It returns a copy of the String object, with all of the lowercase characters converted to uppercase. The original value is unchanged. It has no eect on nonalphabetic characters. Example s = "Hello World"; r = s.toUpperCase(); trace(r); //output: HELLO WORLD
117
Description Performs a search on a string using the supplied Regular Expression object. Syntax 1. StringObj.match(rgExp) 2. String Literal.match(rgExp) Parameters rgExp The regular expression to use in the search. Returns It returns an array of values. Element zero of the array contains the last matched characters. Elements 1...n contain matches to any parenthesized substrings in the regular expression. The method updates the contents of the RegExp object.
2.4.2.14
replace
Description Replaces the text found by a regular expression or a string with other text. Syntax 1. StringObj.replace(rgExp, replaceText) 2. String Literal.replace(rgExp, replaceText) 3. String Literal.replace(text, replaceText[, bReplaceAll]) 4. StringObj.replace(text, replaceText[, bRepalceAll]) Parameters rgExp A Regular Expression object describing what to search for. replaceText A String object or literal containing the text to replace for every successful match of rgExp in stringObj. text String. Species the text to search for. bReplaceAll Optional. Boolean. Determines whether to replace all found patterns in the string.
118 Returns
The result of the replace method is a copy of stringObj after all replacements have been made.
Example var str = "thanksHellosfsdgfsdgHello"; while (str.search("Hello") >= 0) str = str.replace("Hello", "world");
2.4.2.15
search
Description Searches a string for matches to a regular expression or a string. Syntax 1. StringObj.search(rgExp) 2. String Literal.search(rgExp) 3. StringObj.search(text) 4. String Literal.search(text) Parameters rgExp A Regular Expression object containing the pattern to search for. text String. Species the text to search for. Returns The search method indicates if a match is present or not. If a match is found, the search method returns an integer value that indicates the oset from the beginning of the string where the match occurred. If no match is found, it returns -1. To get further information, use the match method. The method updates the contents of the RegExp object.
119
Description Places an HTML anchor with a NAME attribute around specied text in the object. Syntax 1. StringObj.anchor(anchorstring) 2. String Literal.anchor(anchorstring) Parameters anchorstring Text you want to place in the NAME attribute of an HTML anchor. Returns It creates a named anchor out of a String object. Example s = "SWFKit FFish Script Demo"; r = s.anchor("anchor1"); trace(r); //output: //<A NAME="anchor1">SWFKit FFish Script Demo</A>
2.4.2.17
big
Description Places HTML BIG tags around text in a String object. Syntax 1. StringObj.big() 2. String Literal.big() Parameters None Returns
120
FFish Script Objects Reference It returns a string with HTML BIG tags around text in the stringObj. It does change the content of the stringObj
Example s = "SWFKit FFish Script Demo"; r = s.big(); trace(r); //output: <BIG>SWFKit FFish Script Demo</BIG>
2.4.2.18
blink
Description Places HTML BLINK tags around text in a String object. Syntax 1. StringObj.blink() 2. String Literal.blink() Parameters None Returns It returns a string with HTML BLINK tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.blink(); trace(r); //output: <BLINK>SWFKit FFish Script Demo</BLINK>
2.4.2.19
bold
2.4 String object 1. StringObj.bold() 2. String Literal.bold() Parameters None Returns It returns a string with HTML B tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.bold(); trace(r); //output: <B>SWFKit FFish Script Demo</B>
121
2.4.2.20
xed
Description Places HTML TT tags around text in a String object. Syntax 1. StringObj.xed() 2. String Literal.xed() Parameters None Returns It returns a string with HTML TT tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.fixed(); trace(r); //output: <TT>SWFKit FFish Script Demo</TT>
Description Places an HTML FONT tag with the COLOR attribute around the text in a String object. Syntax 1. StringObj.fontColor(color) 2. String Literal.fontColor(color) Parameters color It is a string containing a color value. This can either be the hexadecimal value for a color, or the predened name for a color. Returns It returns a string with HTML FONT tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.fontColor("RED"); trace(r); //output: //<FONT COLOR="RED">SWFKit FFish Script Demo</FONT>
2.4.2.22
fontSize
Description Places an HTML FONT tag with the SIZE attribute around the text in a String object. Syntax 1. StringObj.fontSize(size) 2. String Literal.fontSize(size) Parameters size It is an integer value that determines the size of the text.
2.4 String object Returns It returns a string with HTML FONT tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.fontSize(-1); trace(r); //output: //<FONT SIZE="-1">SWFKit FFish Script Demo</FONT>
123
2.4.2.23
italics
Description Places HTML I tags around text in a String object. Syntax 1. StringObj.italics() 2. String Literal.italics() Parameters None Returns It returns a string with HTML I tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.italics(); trace(r); //output: <I>SWFKit FFish Script Demo</I>
Description Places an HTML anchor with an HREF attribute around the text in a String object. Syntax 1. StringObj.link(link) 2. String Literal.link(link) Parameters link It is the text that you want to place in the HREF attribute of the HTML anchor. Returns It returns a string with an HREF attribute around the text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.link("www.swfkit.com"); trace(r); //output: //<A HREF="www.swfkit.com">SWFKit FFish Script Demo</A>
2.4.2.25
small
Description Places HTML SMALL tags around text in a String object. Syntax 1. StringObj.small() 2. String Literal.small() Parameters None Returns
2.4 String object It returns a string with HTML SMALL tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.small(); trace(r); //output: <SMALL>SWFKit FFish Script Demo</SMALL>
125
2.4.2.26
strike
Description Places HTML STRIKE tags around text in a String object. Syntax 1. StringObj.strike() 2. String Literal.strike() Parameters None
2.4.2.27
sub
Description Places HTML SUB tags around text in a String object. Syntax 1. StringObj.sub() 2. String Literal.sub() Parameters None Returns It returns a string with HTML SUB tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.sub(); trace(r); //output: <SUB>SWFKit FFish Script Demo</SUB>
Description Places HTML SUP tags around text in a String object. Syntax 1. StringObj.sup() 2. String Literal.sup() Parameters None Returns It returns a string with HTML SUP tags around text in the stringObj. Example s = "SWFKit FFish Script Demo"; r = s.sup(); trace(r); //output: <SUP>SWFKit FFish Script Demo</SUP>
2.5
Function Object
Creates a new function.
Description
Syntax 1. function functionname([argname1 [, . . . , argnameN ]]) { body } 2. var functionname = new Function( [argname1 , [. . . argnameN ,]] body); Parameters functionname The name of the newly created function argname1 . . . argnameN An optional list of arguments that the function accepts
2.5 Function Object body A string that contains the block of Fsh Script code to be executed when the function is called. Remarks Syntax 1 is the standard way to create new functions in Fsh Script. Syntax 2 is an alternative form used to create function objects explicitly. Fsh script also support nested functions. A nested function object is a function placed in another function, it will become a member of the Object object constructed by the outer function. For example, we create an object to calculate the square roots: function GetRoot(value) { this.value = value; function root() { return Math.sqrt(this.value); } } gr = new GetRoot(4); trace(gr.root()); //output: 2 an alternative version: function GetRoot(value) { function root(value) { return Math.sqrt(value); } return GetRoot.root(value); } trace(GetRoot(4)); //output: 2
127
Example For example, to create a function that calculates summation of three numbers, you can do it in either of two ways:
128
return x + y + z;}
//Example 2 var sum = new Function("x, y", "z", "return(x+y+z)"); //In either case, //you call the function with a line of code similar //to the following: sum(1, 2, 3);
2.5.1
2.5.1.1
Properties
arguments
Description A local object variable containing each argument passed to the currently executing function. It is automatically created by Fsh script for the currently executing function. The variable can be accessed just like an array. The only dierence is that it has a callee property, which refers to the function being called. Syntax arguments[] Examples //Use arguments property to //handle variant number of arguments function sum() { s = 0; for (i = 0; i < arguments.length; i++) s += arguments[i]; return s; } sum(1,2,3,4,5,6,7); //The callee property of arguments //often used in the anonymous functions. function sum() {
2.6 Array Object this.cal = function () { o = arguments; if (o[0] <= 0) return o[0]; return o[0] + o.callee(o[0] - 1); } } r = new sum(); trace(r.cal(100)); //output: 5050
129
2.6
Array Object
Provides support for creation of arrays of any data type.
Description
Syntax . . . . new Array() new Array(size) new Array(element0 , element1 , ..., elementn ) [element0 , element1 , ..., elementn ]
Parameters size The size of the array. As arrays are zero-based, created elements will have indexes from zero to size 1 element0 , element1 , ..., elementn The elements to place in the array. This creates an array with n + 1 elements. Remarks Fsh script only supports one dimension array. To access the elements of an array, use the array access operator ([ ]). Example a = new Array(); //the length of a is 0 a = new Array("e", "f", "g", "h"); //the length of a is 4 b = [1, 2, 3, 4]; //the length of b is 4
130
2.6.1
2.6.1.1
Properties
length
Description Species an integer value one higher than the highest element index dened in an array. Syntax Array.length Remarks The elements in an array do not have to be contiguous and the length property may not be the number of elements in the array. For example: var demo = new Array( ); demo[0] = 1; demo[99999] = 2; trace(demo.length); //output not 2 but 100000. If a value smaller than its previous value is assigned to the length property, the array is truncated, and any elements with array indexes equal to or greater than the new value of the length property are lost. If a value larger than its previous value is assigned to the length property, the array is expanded, and any new elements created have the value undened.
2.6.2
2.6.2.1
Methods
concat
Description concatenates the elements specied in the parameters, if any, with the elements in array1, and creates a new array. If the value parameters specify an array, the elements of that array are concatenated, rather than the array itself. The array array1 is left unchanged Syntax array1.concat(value0 , value1 , . . . , valueN )
2.6 Array Object Parameters value0 , value1 , . . . , valueN Numbers, elements, or strings to be concatenated in a new array. Returns An new Array object containing the concatenation of array1 and value0 , value1 , . . . , valueN . For example: a = new Array(); b = new Array("e", "f", "g", "h"); a[0] = "a"; a[1] = "b"; r = a.concat("c", "d", b); trace(r); //output: a, b, c, d, e, f, g, h If a value smaller than its previous value is assigned to the length property, the array is truncated, and any elements with array indexes equal to or greater than the new value of the length property are lost. If a value larger than its previous value is assigned to the length property, the array is expanded, and any new elements created have the value undened.
131
2.6.2.2
join
Description Converts the elements in an array to strings, inserts the specied separator between the elements, concatenates them, and returns the resulting string. A nested array is always separated by a comma, not by the separator passed to the join method. Syntax array1.join([separator]) Parameters separator A character or string that separates array elements in the returned string. If you omit this parameter, a comma is used as the default separator. Returns
a = new Array("a", "b", "c", "d"); b = new Array(a, "e", "f", "g", "h"); trace(b.join(:)); //output: a,b,c,d:e:f:g:h
2.6.2.3
pop
Description Removes the last element from an array and returns the value of that element. Syntax array1.pop() Parameters None Returns The last element of the array1.. For example: a = new Array("a", "b", "c", "d"); trace(a.pop()); //output: d trace(a); //output: a,b,c
2.6.2.4
push
Description Adds one or more elements to the end of an array and returns the arrays new length. Syntax array1.push(value, . . . ) Parameters
2.6 Array Object value One or more values to append to the array. Returns The length of the new array. example: a = new Array("a", "b", "c", "d"); trace(a.push("e", "f")); //output: 6 trace(a); //output: a,b,c,d,e,f
133
2.6.2.5
reverse
Description Reverses the array in place. Syntax array1.reverse() Parameters None Returns Nothing. example: a = new Array("a", "b", "c", "d"); a.reverse(); trace(a); //output: d,c,b,a
2.6.2.6
shift
Description Removes the rst element from an array and returns that element. Syntax array1.shift()
The rst element in an array. example: a = new Array("a", "b", "c", "d"); trace(a.shift()); //output: a trace(a); //output: b,c,d
2.6.2.7
slice
Description Extracts a slice or a substring of the array and returns it as a new array without modifying the original array. The returned array includes the start element and all elements up to, but not including, the end element. Syntax array1.slice(start, end) Parameters start A number specifying the index of the starting point for the slice. If start is a negative number, the starting point begins at the end of the array, where 1 is the last element. end A number specifying the index of the ending point for the slice. If you omit this parameter, the slice includes all elements from the start to the end of the array. If end is a negative number, the ending point is specied from the end of the array, where -1 is the last element. Returns Nothing. Example a = new Array("a", "b", "c", "d", "e", "f", "g", "h"); trace(a.slice(1, 3)); //output: b,c
135
Description Sorts the array in place, without making a copy. If the compareFunction parameter has not been specied, Fsh Script sorts the elements in place using the comparison operator. Syntax array1.sort([compareFunction]) Parameters compareFunction An optional comparison function used to determine the sorting order of elements in an array. It must return one of the following values: A negative value if the rst argument passed is less than the second argument. Zero if the two arguments are equivalent. A positive value if the rst argument is greater than the second argument. Returns Nothing. Example function sortfunc(a, b) { num1 = parseInt(a.substr(1)); num2 = parseInt(b.substr(1)); return num1 - num2; } a = ["a0", "a1", "a11", "a2", "a21", "a3", "a31"]; a.sort(sortfunc); trace(a); //output: a0,a1,a2,a3,a11,a21,a31
2.6.2.9
splice
Description Adds and removes elements from an array. This method modies the array without making a copy. The elements deleted by this method are put into a new array as the return.
136 Syntax
array1.splice(start, deleteCount, value0 , value1 , . . . , valueN ) Parameters start The index of the element in the array where the insertion or deletion begins. deleteCount The number of elements to be deleted. This number includes the element specied in the start parameter. If no value is specied for deleteCount, the method deletes all of the values from the start element to the last element in the array. If the value is 0, no elements are deleted. value0 , value1 , . . . , valueN Zero or more values to insert into the array at the insertion point specied in the start parameter. This parameter is optional. Returns An array contains all deleted elements Example data = new Array(); for (i = 0; i < 10; i++) data[i] = "data" + i; trace(data.splice(2, 7, "data2", "data3")); //output:data2,data3,data4,data5,data6,data7,data8 trace(data); //output: data0,data1,data2,data3,data9
2.6.2.10
unshift
Description Adds one or more elements to the beginning of an array and returns the arrays new length. Syntax array1.unshift(value0 , value1 , . . . , valueN ) Parameters value0 , value1 , . . . , valueN One or more numbers, elements, or variables to be inserted at the beginning of the array.
2.7 Date Object Returns The new length of the array. Example a = [3, 4, 5, 6]; trace(a.unshift(2, 1, 0)); //output: 7 trace(a); //output: 0,1,2,3,4,5,6
137
2.7
Date Object
Enables basic storage and retrieval of dates and times.
Description
Syntax 1. new Date() 2. new Date(value) 3. new Date(year, month, date[, hours[, minutes[, seconds[,ms]]]]) Parameters value If a numeric value, value represents the number of milliseconds in Universal Coordinated Time between the specied date and midnight January 1, 1970. If a string, value is parsed according to the rules in the parse method. year The full year, all digits of the year must be specied.e.g.1982 and 82 refers to the dierent year. month The month as an integer between 0 (January) and 11 (December). date The date as an integer between 1 and 31. hours An integer from 0 (midnight) to 23 (11pm) that species the hour. minutes An integer from 0 to 59 that species the minutes. seconds An integer from 0 to 59 that species the seconds. ms An integer from 0 to 999 that species the milliseconds. Remarks
138
FFish Script Objects Reference A Date object contains a oat value representing the numbers of millisecond intervals since Jan 1, 1970. If a date object is contracted without parameters, it represents the current time. The range of dates that can be represented in a Date object is approximately 285,616 years on either side of Jan 1, 1970. If you have specied a value exceed the range, the date is set to Jan 1, 1970. The Date object has two static methods that are called without creating a Date object. They are parse and UTC.
2.7.1
2.7.1.1
Methods
getDate
Description Gets the day of the month (an integer from 1 to 31) of the specied Date object according to local time. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.getDate() Parameters None Returns An integer. Example d = new Date(2002, 6, 15); trace(d.getDate()); //return 15
2.7.1.2
getDay
Description Gets the day of the week (0 for Sunday, 1 for Monday, and so on) of the specied Date object according to local time. Local time is determined by the operating system on which the Fsh Script is running.
2.7 Date Object Syntax date1.getDay() Parameters None Returns An integer. Example d = new Date(2002, 6, 15); trace(d.getDay()); //output: 1
139
2.7.1.3
getFullYear
Description Gets the year as an absolute number (For example, 1974) of the specied Date object, according to local time. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.getFullYear() Parameters None Returns An integer. Example d = new Date(1997, 6, 15); trace(d.getFullYear()); //output 1997
Description Gets the hour (an integer from 0 to 23) of the specied Date object, according to local time. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.getHours() Parameters None Returns An integer. Example d = new Date(1997, 6, 15); trace(d.getHours()); //output: 0
2.7.1.5
getMilliseconds
Description Gets the milliseconds (an integer from 0 to 999) of the specied Date object, according to local time. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.getMilliseconds() Parameters None Returns An integer.
141
Description Gets the minutes (an integer from 0 to 59) of the specied Date object, according to local time. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.getMinutes() Parameters None Returns An integer.
2.7.1.7
getMonth
Description Gets the month (0 for January, 1 for February, and so on) of the specied Date object, according to local time. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.getMonth() Parameters None Returns An integer.
Description Gets the seconds (an integer from 0 to 59) of the specied Date object, according to local time. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.getSeconds() Parameters None Returns An integer.
2.7.1.9
getTime
Description Gets the number of milliseconds since midnight January 1, 1970, universal time, for the specied Date object. You use this method to compare two or more Date objects. Syntax date1.getTime() Parameters None Returns An Integer value. Example d = new Date(1997, 6, 15); trace(d.getTime()); //output: 868896000000
143
Description Gets the dierence, in minutes, between the computers local time and universal time Syntax date1.getTimezoneOset() Parameters None Returns An integer. Example d = new Date(1997, 6, 15); trace(d.getTimezoneOffset()); //output: -480 trace(d.toLocaleString()); //output: Tue Jul 15 00:00:00 GMT+800 () 1997
2.7.1.11
getUTCDate
Description Gets the day (date) of the month in the specied Date object, according to universal time. Syntax date1.getUTCDate() Parameters None Returns An integer.
Description Gets the day of the week of the specied Date object, according to universal time. Syntax date1.getUTCDate() Parameters None Returns An integer.
2.7.1.13
getUTCFullYear
Description Gets the year as an absolute number of the specied Date object, according to universal time. Syntax date1.getUTCFullYear() Parameters None Returns An integer.
145
Description Gets the hours of the specied Date object, according to universal time. Syntax date1.getUTCHours() Parameters None Returns An integer.
2.7.1.15
getUTCMilliseconds
Description Gets the milliseconds of the specied Date object, according to universal time. Syntax date1.getUTCMilliseconds() Parameters None Returns An integer.
Description Gets the minutes (an integer from 0 to 59) of the specied Date object, according to local time. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.getMinutes() Parameters None Returns An integer.
2.7.1.17
getUTCMonth
Description Gets the month of the specied Date object, according to universal time. Syntax date1.getUTCMonth() Parameters None Returns An integer.
147
Description Gets the seconds in the specied Date object, according to universal time. Syntax date1.getUTCSeconds() Parameters None Returns An integer.
2.7.1.19
getYear
Description Gets the year of the specied Date object, according to local time. Local time is determined by the operating system on which the Fsh Script is running. If the full year is between 1900 and 2000, the result is the full year minus 1900. For example, the year 2000 is represented as 100. Syntax date1.getYear() Parameters None Returns An integer.
Description Sets the day of the month for the specied Date object, according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.setDate(date) Parameters date An integer from 1 to 31. Returns An integer. Example d = new Date(1997, 6, 15); trace(d.setDate(32)); //output: 870364800000 trace(d.toLocaleString()); //output: Fri Aug 01 00:00:00 GMT+800 () 1997
2.7.1.21
setFullYear
Description Sets the year of the specied Date object, according to local time, and returns the new time in milliseconds. If the month and date parameters are specied, they are also set to local time. Local time is determined by the operating system on which the FFish Script is running. Syntax date1.setFullYear(year[, month [, date]]) Parameters year A numeric value equal to the year.
2.7 Date Object month Optional. An integer from 0 (January) to 11 (December). This parameter is optional. date Optional. A number from 1 to 31. This parameter is optional. Returns The new time in milliseconds.
149
2.7.1.22
setHours
Description Sets the hours for the specied Date object according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.setHours(hour) Parameters hour An integer from 0 (midnight) to 23 (11 p.m.). Returns An integer
2.7.1.23
setMilliseconds
Description Sets the milliseconds for the specied Date object according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.setMilliseconds(millisecond) Parameters millisecond An integer from 0 to 999. Returns An integer
Description Sets the minutes for a specied Date object according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.setMinutes(minute) Parameters minute An integer from 0 to 59. Returns An integer
2.7.1.25
setMonth
Description Sets the month for the specied Date object in local time, and returns the new time in milliseconds. Local time is determined by the operating system on which the Fsh Script is running. Syntax myDate.setMonth(month[, date ]) Parameters month An integer from 0 (January) to 11 (December). date Optional. An integer from 1 to 31. This parameter is optional. Returns An integer
151
Description Sets the seconds for the specied Date object in local time, and returns the new time in milliseconds. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.setSeconds(second) Parameters second An integer from 0 to 59. Returns An integer
2.7.1.27
setTime
Description Sets the date for the specied Date object in milliseconds since midnight on January 1, 1970, and returns the new time in milliseconds. Syntax date1.setTime(millisecond) Parameters millisecond An integer value where 0 is 0:00 GMT 1970 Jan 1. Returns An integer Example d = new Date(); d.setTime(0); trace(d.toLocaleString()); //output: Thu Jan 01 08:00:00 GMT+800 () 1970
Description Sets the date for the specied Date object in universal time, and returns the new time in milliseconds. Syntax date1.setUTCDate(date) Parameters date An integer from 1 to 31. Returns An integer
2.7.1.29
setUTCFullYear
Description Sets the year for the specied Date object in universal time, and returns the new time in milliseconds. Syntax date1.setUTCFullYear(year[, month [, date]]) Parameters year A numeric value equal to the year. month Optional. An integer from 0 (January) to 11 (December). date Optional. An integer from 1 to 31. Returns An integer
153
Description Sets the hour for the specied Date object in universal time, and returns the new time in milliseconds. Syntax date1.setUTCHours(hour[, minute [, second[, millisecond]]]) Parameters hour An integer from 0 (midnight) to 23 (11 p.m.). minute Optional. An integer from 0 to 59. second Optional. An integer from 0 to 59. millisecond Optional. An integer from 0 to 999. Returns An integer
2.7.1.31
setUTCMilliseconds
Description Sets the milliseconds for the specied Date object in universal time, and returns the new time in milliseconds. Syntax date1.setUTCMilliseconds(millisecond) Parameters millisecond An integer from 0 to 999. Returns An integer
Description Sets the minute for the specied Date object in universal time, and returns the new time in milliseconds. Syntax date1.setUTCMinutes(minute[, second [, millisecond]]) Parameters minute An integer from 0 to 59. second Optional. An integer from 0 to 59. millisecond Optional. An integer from 0 to 999. Returns An integer
2.7.1.33
setUTCMonth
Description Sets the month for the specied Date object in universal time, and returns the new time in milliseconds. Syntax date1.setUTCMonth(month[, date]) Parameters month An integer from 0 (January) to 11 (December). date Optional. An integer from 1 to 31. Returns An integer
155
Description Sets the seconds for the specied Date object in universal time, and returns the new time in milliseconds. Syntax date1.setUTCSeconds(second[, millisecond])) Parameters second An integer from 0 to 59. millisecond Optional. An integer from 0 to 999. Returns An integer
2.7.1.35
setYear
Description Sets the year for the specied Date object in local time, and returns the new time in milliseconds. Local time is determined by the operating system on which the Fsh Script is running. Syntax date1.setYear(year) Parameters year If year is an integer between 0-99, setYear sets the year at 1900 + year; otherwise, the year is the value of the year parameter. Returns An integer
Description Computes the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) and the supplied date. Syntax Date.UTC(year, month[, date [, hour[, minute [, second[, millisecond]]]]]) Parameters year A four-digit number, for example, 2000. month Optional. An integer from 0 (January) to 11 (December). date Optional. An integer from 1 to 31. hour Optional. An integer from 0 (midnight) to 23 (11 p.m.). minute Optional. An integer from 0 to 59. second Optional. An integer from 0 to 59. millisecond Optional. An integer from 0 to 999. Returns An integer Example d = new Date(Date.UTC(1989, 11, 28, 10, 30, 5)); trace(d.toLocaleString()); //output: Thu Dec 28 18:30:05 GMT+800 () 1989
2.7.1.37
parse
Description Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. Syntax Date.parse(value)
2.7 Date Object Parameters value A string contains date Returns An integer Example d = new Date(Date.parse("1989/12/28 12:30:5 GMT-700")); trace(d.toGMTString()); //output: Thu, 28 Dec 1989 19:30:05 GMT
157
2.7.1.38
toGMTString
Description Converts the date to a string using GMT convention. Syntax Date1.toGMTString() Parameters None Returns A string object Example d = new Date(Date.UTC(1989, 11, 28, 10, 30, 5)); trace(d.toGMTString()); //output: Thu, 28 Dec 1989 10:30:05 GMT
Description Converts the date to a string using the current locale. Syntax Date1.toLocaleString( ) Parameters None Returns A string object Example d = new Date(Date.UTC(1989, 11, 28, 10, 30, 5)); trace(d.toLocaleString()); //output: Thu Dec 28 18:30:05 GMT+800 () 1989
2.8
Math
The Math object can be accessed without using a constructor. Besides the root method which returns an integer value, all methods of Math Object return a oat number.
Description
2.8.1
2.8.1.1
Properties
E
Description Represents a mathematical constant for the base of natural logarithms, expressed as e. The approximate value of e is 2.71828. Syntax Math.E
159
2.8.1.2
LN2
Description Represents a mathematical constant for the natural logarithm of 2, expressed as loge 2, with an approximate value of 0.69314718055994528623. Syntax Math.LN2
2.8.1.3
LOG2E
Description Represents a mathematical constant for the base-2 logarithm of the constant e (Math.E), expressed as log2 e, with an approximate value of 1.442695040888963387. Syntax Math.LOG2E
2.8.1.4
LN10
Description Represents a mathematical constant for the natural logarithm of 10, expressed as loge 10, with an approximate value of 2.3025850929940459011. Syntax Math.LN10
Description Represents a mathematical constant for the base-10 logarithm of the constant e (Math.E), expressed as log10 e, with an approximate value of 0.43429448190325181667. Syntax Math.LOG10E
2.8.1.6
PI
Description Represents a mathematical constant for the ratio of the circumference of a circle to its diameter, expressed as , with a value of 3.14159265358979. Usage Math.PI
2.8.1.7
SQRT1 2
Description Represents a mathematical constant for the reciprocal of the square root of one half Syntax Math.SQRT1 2
1 2,
2.8.1.8
SQRT2
Description Represents a mathematical constant for the square root of 2, with an approximate value of 1.414213562373. Syntax Math.SQRT2
2.8 Math
161
2.8.2
2.8.2.1
Methods
abs
Description Computes and returns an absolute value for the number specied by the parameter x. Syntax Math.abs(x) Parameters x A number. Returns A number.
2.8.2.2
acos
Description Computes and returns the arc cosine of the number specied in the parameter x, in radians. Syntax Math.acos(x) Parameters x A number from 1.0 to 1.0. Returns A number.
Description Computes and returns the arc sine for the number specied in the parameter x, in radians. Syntax Math.asin(x) Parameters x A number from 1.0 to 1.0. Returns A number.
2.8.2.4
atan
Description Computes and returns the arc tangent for the number specied in the parameter x. The return value is between , and . 2 2 Syntax Math.atan(x) Parameters x A number. Returns A number.
163
Description
y Computes and returns the arc tangent of x in radians. The return value represents the angle opposite the opposite angle of a right triangle, where x is the adjacent side length and y is the opposite side length.
Syntax Math.atan2(y, x) Parameters x A number specifying the x coordinate of the point. y A number specifying the y coordinate of the point. Returns A number.
2.8.2.6
ceil
Description Returns the ceiling of the specied number or expression. The ceiling of a number is the closest integer that is greater than or equal to the number. Syntax Math.ceil(x) Parameters x A number or expression. Returns A number.
Description Returns the cosine (a value from 1.0 to 1.0) of the angle specied by the parameter x. The angle x must be specied in radians. Syntax Math.cos(x) Parameters x An angle measured in radians. Returns A number. Remarks To convert between radians values and degree values, use these functions: //Degree to Radians function D2R(degree) { return Math.PI * degree / 180; } //Radians to Degree function R2D(radians) { return radians / Math.PI * 180; }
2.8.2.8
exp
Description Returns the value of the base of the natural logarithm (e), to the power of the exponent specied in the parameter x. The constant Math.E can provide the value of e. Syntax
2.8 Math Math.exp(x) Parameters x The exponent; a number or expression. Returns A number.
165
2.8.2.9
oor
Description Returns the oor of the number or expression specied in the parameter x. The oor is the closest integer that is less than or equal to the specied number or expression. Syntax Math.oor(x) Parameters x A number or expression. Returns A number.
2.8.2.10
log
Description Returns the natural logarithm of the parameter x. Syntax Math.log(x) Parameters x A number or expression with a value greater than 0. Returns A number.
Description Evaluates x0, x1, xN and returns the largest value. Syntax Math.max(x0, x1, xN) Parameters x0xN A number or expression. Returns A number.
2.8.2.12
min
Description Evaluates x0, x1, xN and returns the smallest value. Syntax Math.min(x0 , x1 , . . . , xN ) Parameters x0 , x1 , . . . , xN A number or expression. Returns A number.
2.8.2.13
pow
Description Computes and returns x to the power of y. Syntax Math.pow(x , y) Parameters x A number to be raised to a power. y A number specifying a power the parameter x is raised to. Returns A number.
167
Description Generates a pseudorandom number in the range 0 to 1 Syntax Math.random() Parameters None Returns A number in the range 0 to 1.
2.8.2.15
round
Description Rounds the value of the parameter x up or down to the nearest integer and returns the value. Syntax Math.round(x) Parameters x A number. Returns A number.
2.8.2.16
sin
Description Computes and returns the sine of the specied angle in radians. Syntax Math.sin(x)
To convert between radians values and degree values, use these functions: //Degree to Radians function D2R(degree) { return Math.PI * degree / 180; } //Radians to Degree function R2D(radians) { return radians / Math.PI * 180; }
2.8.2.17
sqrt
Description Computes and returns the square root of the specied number. Syntax Math.sqrt(x) Parameters x A number or expression greater than or equal to 0. Returns A number.
169
Description Computes and returns the tangent of the specied angle. The angle x must be specied in radians. Syntax Math.tan(x) Parameters x An angle measured in radians. Returns A number.
2.9
Dialogs Object
Description Provides methods to take advantage of windows common dialogs. FFish Script Dialogs Object supports message boxes, le open dialogs, le save dialogs, color dialogs and the browse for folder dialogs. available: SWFKit Express, SWFKit, SWFKit Pro Syntax Dialogs.some method Parameters The Dialogs object can be accessed directly without construct a new instance.
170
2.9.1
2.9.1.1
Methods
msgBox
Description Creates, displays, and operates a message box. Syntax Dialogs. msgBox(text[, caption[, type]]) Parameters text Species the message to be displayed caption Optional. Species the string used for the dialog box title type Optional. Species a set of bit ags that determine the contents and behavior of the dialog box . This parameter can be a combination of a button type value and a icon type value shown in the following table. Button Type Value 0 1 2 3 4 5 Icon Type Value 16 32 48 64 Returns An integer indicates which button of the message box has been clicked. Value 1 2 3 4 5 6 7 Description [OK] button [Cancel] button [Abort] button [Retry] button [Ignore] button [Yes] button [No] button
Description Show [OK] button Show [OK] and [Cancel] buttons Show [Abort], [Retry] and [Ignore] buttons Show [Yes], [No] and [Cancel] buttons Show [Yes] and [No] buttons Show [Retry] and [Cancel] buttons Description Show Stop Mark icon Show Question Mark icon Show Exclamation Mark icon Show Information Mark icon
171
2.9.1.2
leOpen
Description Creates, displays and operates a le open dialog box. Syntax Dialogs.leOpen([lter[, default ext[, lename[, multiselect]]]]) Parameters lter Optional. A series of string pairs that specify lters you can apply to the le. If you specify le lters, only selected les will appear in the Files list box. The rst string in the string pair of the lter describes the lter; the second string indicates the le extension to use. Multiple extensions may be specied using ; as the delimiter. The strings and the string pairs are delimited by the character |. The lter must end with a character |. E.g. Zip les(*.zip; *.gz)|*.zip; *.gz|Text les(*.txt)|*.txt|All les(*.*)|*.*| default ext Optional. The default lename extension. If the user does not include an extension in the Filename edit box of the le open dialog, the extension specied by this parameter is automatically appended to the lename. lename Optional. The initial lename that appears in the lename edit box of the le open dialog. multiselect Optional. To allow users to select multiple les, set this parameter to true. Returns If succeed, returns a string represents the selected le name. If parameter multiselect is set to true, the result is an array that contains the path to the current directory followed by the lenames of the selected les. If failed, returns false. Example
172
FFish Script Objects Reference var f = "Zip files(*.zip; *.gz)|*.zip; *.gz| Text files(*.txt)|*.txt|All files(*.*)|*.*|"; var res = Dialogs.fileOpen(f, "", "", true); var i, path = res[0]; if (path.charAt(path.length - 1) != \\) path += \\; for (i = 1; i < res.length; i++) trace(path + res[i]);
2.9.1.3
leSave
Description Creates, displays and operates a le save dialog box. Syntax Dialogs. leSave ([lter[, default ext[, lename]]]) Parameters lter lter Optional. A series of string pairs that specify lters you can apply to the le. If you specify le lters, only selected les will appear in the Files list box. The rst string in the string pair of the lter describes the lter; the second string indicates the le extension to use. Multiple extensions may be specied using ; as the delimiter. The strings and the string pairs are delimited by the character |. The lter must end with a character |. E.g. Zip les(*.zip; *.gz)|*.zip; *.gz|Text les(*.txt)|*.txt|All les(*.*)|*.*| default ext Optional. The default lename extension. If the user does not include an extension in the Filename edit box of the le save dialog, the extension specied by this parameter is automatically appended to the lename. lename Optional. The initial lename that appears in the lename edit box of the le save dialog. Returns If succeed, returns a string represents the selected le name. If failed, returns false.
2.9 Dialogs Object Example var f = "Zip files(*.zip; *.gz)|*.zip;*.gz| Text files(*.txt)|*.txt|All files(*.*)|*.*|"; var res = Dialogs.fileSave(f, "", ""); trace(res);
173
2.9.1.4
chooseColor
Description Creates, displays and operates a color dialog box. Syntax Dialogs.chooseColor([color]) Parameters color Optional. Species the color initially selected when the dialog box is created. Returns If succeed, returns an integer represents the selected color. If failed, returns false. Example clr = Dialogs.chooseColor(0); trace(clr.format("0x%06X"));
2.9.1.5
chooseFont
Description Creates, displays and operates a font dialog box. Syntax Dialogs.chooseFont([font])
174 Parameters
font Optional. A FontObject object to initialize the font dialog. Returns If succeed, returns a FontObject object. If failed, returns null. Example var ft_init = new FontObject; ft_init.name = "System"; ft_init.size = 12; ft_init.color = 0xFF0000; var ft = Dialogs.chooseFont(ft_init); trace(ft.name); trace(ft.size); trace(ft.color);
2.9.1.6
browse
Description Creates, displays and operates a browse for folder dialog box. Syntax Dialogs.browse([title[, path[, browsecomputer]]]) Parameters title Optional. Species a string that is displayed above the tree view control in the dialog box. path Optional. Species the folder selected initially when the dialog box is created. browsecomputer Optional. If this parameter is set to true, users can select computers name only. Returns If succeed, returns the selected folder name. If failed, returns false. Example var f = Dialogs.browse("Test", "c:\\"); trace(f);
175
2.10
Shell Object
Description Provides ability to invoke Windows shell functions just like execute applications, get environment variables, get special foldersetc. available: SWFKit Express, SWFKit, SWFKit Pro In SWFKit Express, only the run, open, explore, print and the getSpecialFolder folder methods are available. Syntax Shell.a method() Remarks The Dialogs object can be accessed directly without construct a new instance.
2.10.1
2.10.1.1
Methods
run
Description Executes an application. Syntax Shell.run(app[, show ags[, x, y[, dx, dy]]]); Parameters app Species the application name to execute. show ags Optional. Species the show state of the application main window. It can be one of the following values.
176 Values 0 1
FFish Script Objects Reference Description Hides the window Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position Activates the window and displays it as a minimized window Activates the window and displays it as a maximized window Displays a window in its most recent size and position. The active window remains active Activates the window and displays it in its current size and position Minimizes the specied window and activates the next top-level window in the Z order Displays the window as a minimized window. The active window remains active Displays the window in its current state. The active window remains active Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this ag when restoring a minimized window Minimizes a window. For windows 2000, xp
2 3 4 5 6 7 8 9
11
x, y Optional. Species the position of the application window. dx, dy Optional. Species the size of the application window. Returns If succeed, returns a Window Object represents the main window of the application. Otherwise, returns null. Example Shell.run("Notepad.exe");
2.10.1.2
runConsole
177
2.10.1.3
runAndWait
Description Executes an application. This method does not return until the application is ended.
Parameters app Species the application name to execute. show ags Optional. Species the show state of the application main window. It can be one of the following values.
178 Values 0 1
FFish Script Objects Reference Description Hides the window Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position Activates the window and displays it as a minimized window Activates the window and displays it as a maximized window Displays a window in its most recent size and position. The active window remains active Activates the window and displays it in its current size and position Minimizes the specied window and activates the next top-level window in the Z order Displays the window as a minimized window. The active window remains active Displays the window in its current state. The active window remains active Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this ag when restoring a minimized window Minimizes a window. For windows 2000, xp
2 3 4 5 6 7 8 9
11
x, y Optional. Species the position of the application window. dx, dy Optional. Species the size of the application window. Returns Nothing Example Shell.runAndWait("Notepad.exe");
2.10.1.4
open
2.10 Shell Object Syntax Shell.open(app[, param]) Parameters app Species the le to open. param Species the command line arguments. Returns Nothing Remarks To determine whether there is an application can open the specied le, use the method ndExecutable. Example Shell.open("c:\\test.doc");
179
2.10.1.5
Description Prints a specied le. Syntax Shell.print(app) Parameters app Species le to print. Returns Nothing Remarks To determine whether there is an application can print the specied le, check the registry key: HKEY CLASSES ROOT\ le type \shell\print\command. The le ext is stored in the registry key: HKEY CLASSES ROOT\ le ext .
180
FFish Script Objects Reference function getPrintApp(file) { //get the ext of the file var i = file.indexOf(.); var ext = file.substring(i); //get the file type var rk = new RegKey("HKCR\\" + ext); if (rk == null) return null; //get the default value var rv = rk.getValue(); if (rv == null) return null; var filetype = rv.data; //get the application rk = new RegKey("HKCR\\" + filetype + "\\shell\\print\\command"); if (rk == null) return null; rv = rk.getValue(); if (rv != null) return rv.data; return null; } var app = getPrintApp("C:\\test.doc"); trace(app);
Example Shell.print("c:\\test.doc");
2.10.1.6
explore
2.10 Shell Object Parameters path Species the folder to explore. Returns Nothing Example Shell.explore("c:\\");
181
2.10.1.7
ndExecutable
Description Retrieves the name of the application associated with the specied le name. Syntax Shell.ndExecutable(lename) Parameters lename Species the le name. Returns A string represents the application name associated with the specied le name if successful, or returns false otherwise. Example r = Shell.findExecutable("c:\\test.doc"); trace(r);
Description
Syntax
Shell.getSpecialFolder(name)
Parameters
name Species the special folder name. It can be one of the following value:
2.10 Shell Object Values appdata cookies desktop desktop all favorites fonts history internet cache my documents nethood printers program les programs programs all
183 Description File system directory that serves as a common repository for application-specic data File system directory that serves as a common repository for Internet cookies File system directory used to physically store le objects on the desktop File system directory that contains les and folders that appear on the desktop for all users File system directory that serves as a common repository for the users favorite items Virtual folder containing fonts File system directory that serves as a common repository for Internet history items File system directory that serves as a common repository for temporary Internet les File system directory that serves as a common repository for documents File system directory containing objects that appear in the network neighborhood File system directory that serves as a common repository for printer links The propgram les folder File system directory that contains the users program groups File system directory that contains the directories for the common program groups that appear on the Start menu for all users File system directory that contains the users most recently used documents File system directory that contains Send To menu items File system directory containing Start menu items File system directory that contains the programs and folders that appear on the Start menu for all users File system directory that corresponds to the users Startup program group File system directory that contains the programs that appear in the Startup folder for all users The system folder The temporaty folder File system directory that serves as a common repository for document templates The windows folder
184 Returns
A string represents the full path of the special folder. Example var names = ["appdata", "cookies", "desktop", "desktop all", "favorites", "fonts", "history", "internet cache", "my documents", "nethood", "printers", "program files", "programs", "programs all", "recent", "sendto", "startmenu", "startmenu all", "startup", "startup all", "system", "temp", "templates", "windows"]; var i; for (i = 0; i < names.length; i++) trace(Shell.getSpecialFolder(names[i]));
2.10.1.9
addToRecentDocs
Description Adds a document to the shells list of recently used documents. Syntax Shell. addToRecentDocs(lename) Parameters lename Species the document name to add. Returns Nothing Example Shell.addToRecentDocs("c:\\1.zip");
185
Description Clears all documents from the shells list of recently used documents. Syntax Shell.clearRecentDocs() Parameters None Returns Nothing Example Shell.clearRecentDocs();
2.10.1.11
emptyRecycleBin
Description Empties the recycle bins. Syntax Shell.emptyRecycleBin() Parameters None Returns Nothing Example Shell.emptyRecycleBin();
Description Gets the environment variable names. Syntax Shell.getEnvironmentStrings() Parameters None Returns An array of strings contains all the environment variable names. Example r = Shell.getEnvironmentStrings(); trace(r(0));
2.10.1.13
getEnvironmentVariable
Description Retrieves the value of the specied variable. Syntax Shell.getEnvironmentVariable(name) Parameters name Species the environment variable name. Returns A String represents the variable value.. Example var r = Shell.getEnvironmentStrings(); var i; for (i = 0; i < r.length; i++) trace(r[i]+ " = "" + Shell.getEnvironmentVariable(r[i]));
187
Description Sets the value of an environment variable. Syntax Shell.setEnvironmentVariable(name, value) Parameters name The name of the variable value The value of the variable Returns Returns true if successful, or false otherwise. Example Shell.setEnvironmentStrings("test", "test value");
2.10.1.15
delEnvironmentVariable
Description Deletes an environment variable. Syntax Shell.delEnvironmentVariable(name) Parameters name The name of the variable to delete Returns Returns true if successful, or false otherwise. Example Shell.delEnvironmentStrings("test");
188 2.10.1.16
Description Expands environment-variable strings and replaces them with their dened values. Syntax Shell.expandEnvironmentStrings(str) Parameters str Species a string that might contain references to environmentvariable strings. Returns Returns the expanded string. Example Shell.expandEnvironmentStrings("%ProgramFiles%");
2.10.1.17
setDesktopWallpaper
Description Sets the desktop wallpaper Syntax Shell.setDesktopWallpaper(name[, update[, notify]]); Parameters name String. Species the lename of the bitmap to set as the desktop wallpaper. update Boolean. Optional. Species whether the user prole is to be updated. The default value is true. notify Boolean. Optional. Species whether the WM SETTINGCHANGE message is to be broadcast to all top-level windows to notify them of the change. The default value is true. Returns Boolean.
189
Description Gets the version information of the specied le. Syntax Shell.getFileVersionInfo(lename) Parameters lename String. Species the full pathname of the le. Returns Returns an object contains following properties if successful: Name comments Description Contains any additional information about the le companyName Identies the company that produced the le leDescription Describes the le leVersionNum Integer. Identies the version of this le leVersion Identies the version of this le internalName Identies the les internal name legalCopyright Describes all copyright notices, trademarks, and registered trademarks that apply to the le legalTrademarks Describes all trademarks and registered trademarks that apply to the le originalFilename Identies the original name of the le, not including a path privateBuild Describes by whom, where, and why this private version of the le was built productName Identies the name of the product with which this le is distributed productVersionNum Integer. Identies the version of the product with which this le is distributed productVersion Identies the version of the product with which this le is distributed specialBuild Describes how this version of the le diers from the normal version. If failed, returns null. Example
190
FFish Script Objects Reference var x = Shell.getFileVersionInfo( "c:\\WINNT\\system32\\Macromed\\Flash\\flash.ocx"); trace("Comments: " + x.comments); trace("CompanyName: " + x.companyName); trace("FileDescription: " + x.fileDescription); trace("FileVersion: " + x.fileVersion); trace("InternalName: " + x.internalName); trace("LegalCopyright: " + x.legalCopyright); trace("LegalTrademarks: " + x.legalTrademarks); trace("OriginalFilename: " + x.originalFilename); trace("PrivateBuild: " + x.privateBuild); trace("ProductName: " + x.productName); trace("ProductVersion: " + x.productVersion); trace("SpecialBuild: " + x.specialBuild);
2.11
MCI Object
Description Provides access to the Media Control Interface (MCI), which provides standard commands for playing multimedia devices and recording multimedia resource les. available: SWFKit Express, SWFKit, SWFKit Pro Syntax new MCI(); Remarks MCI provides two ways to play multimedia devices. The rst is the sendCmdString method, which represents the command-string interface of MCI. You can call it directly for it is a static method. E.g.
//opens the CD-ROM then close it. MCI.sendCmdString("open cdaudio alias cd"); MCI.sendCmdString("set cd door open wait"); MCI.sendCmdString("set cd door closed wait"); MCI.sendCmdString("close cd");
2.11 MCI Object The second is the command property, which represents the commandmessage interface of MCI. The MCI object provides some other properties to work with the command property. The following examples demonstrating how to use these properties: 1. Opens a device You can open a device by specifying the deviceType and the lename. //Example 1. Opens a cdaudio var m = new MCI; //specifies the device type m.deviceType = "cdaudio"; //open the cdaudio device m.command = "open"; //Example 2. Opens a waveform-audio file var m = new MCI; //specifies the device type m.deviceType = "waveaudio"; //specifies the file name m.fileName = "test.wav"; //open the cdaudio device m.command = "open"; 2. Handling MCI Errors You should check the error property for errors. If it indicates an error, use the errorMsg property to get a textual description of the error. E.g. var m = new MCI; m.command = "open"; if (m.error) trace(m.errorMsg); 3. Using the wait property MCI commands usually return to the user immediately, even if it takes several minutes to complete the action initiated by the command. You can set the wait property to true to direct the device to wait until the requested action is completed before returning control to the FFish script. E.g. var m = new MCI; m.wait = true; m.deviceType = "cdaudio"; m.command = "open";
191
192
//The continuous scripts wont //run until the CDAudio is opened ... 4. Using the notify property MCI object res the onNotify events if the notify property is set to true. The events are red after an action is completed. You can handle this event by specifying a handler function. E.g. //Example. //Closes the device after playing the wave function on\_notify(flag) { m.notify = false; m.command = "close"; if (flag == 1) trace("OK."); } m = new MCI; m.deviceType = "waveaudio"; m.fileName = "d:\\1.wav"; m.command = "open"; m.notify = true; m.onNotify = on\_notify; m.command = "play"; 5. Playing a CD //Example. Playing a CD function on\_notify(flag) { m.notify = false; m.command = "close"; } m = new MCI; m.deviceType = "cdaudio"; m.command = "open"; //set the time format to TMSF m.timeFormat = 10; //plays track 12 m.from = MCI.makeTMSF(12, 0, 0, 0); m.to = MCI.makeTMSF(13, 0, 0, 0); m.notify = true;
2.11 MCI Object m.onNotify = on\_notify; m.command = "play"; 6. Playing a movie Before open a video device you must set the location of the playing movie. //Example: playing a movie m = new MCI; m.deviceType = "avivideo"; m.fileName = "D:\\1.avi"; //set the loaction of the playing window m.left = 0; m.top = 0; m.width = 320; m.height = 240; m.command = "open"; m.command = "play"; 7. Changing the Current Position You can use the commands prev, next, step, back and seek to change the current position of the device. //Example: use command "seek" //change the current position var m = new MCI; m.deviceType = "cdaudio"; m.command = "open"; m.timeFormat = 10; m.to = MCI.makeTMSF(10, 1, 0, m.command = "seek"; m.to = MCI.makeTMSF(11, 0, 0, m.command = "play"; to of the CD
193
0); 0);
8. Recording with a Waveform-Audio Device m = new MCI; m.deviceType = "waveaudio"; m.fileName = ""; m.wait = true; m.command = "open"; //set the time format to milliseconds m.timeFormat = 0; //Set the record length to 10 seconds m.to = 10000;
//save the recording to file m.fileName = "d:\\1.wav"; m.command = "save"; m.command = "close";
2.11.1
2.11.1.1
Properties
alias
Description String. Represents the alias of the device. You can send commands to a device by using its alias. Syntax mci.alias Example mci.fileName = ""; mci.alias = "myrecorder"; mci.command = "open"; mci.from = 0; mci.status = "recording"; mci.sendCmdString("set myrecorder bitspersample 8 channels 2 samplespersec 44100"); mci.command = "record";
2.11.1.2
canEject
Description Boolean. Determines if the device can eject the media. Read-only Syntax mci.canEject Example
2.11 MCI Object m = new MCI; m.deviceType = "cdaudio"; m.command = "open"; if (m.canEject) m.command = "eject"; m.command = "close";
195
2.11.1.3
canPlay
Description Boolean. Determines if the device can play. Read-only Syntax mci.canPlay Example m = new MCI; m.deviceType = "cdaudio"; m.command = "open"; trace(m.canPlay); m.command = "close";
2.11.1.4
canRecord
Description Boolean. Determines if the device support recording. Read-only Syntax mci.canRecord Example m = new MCI; m.deviceType = "waveaudio"; m.command = "open"; trace(m.canRecord); m.command = "close";
Description Boolean. Determines if the device support stepping. Read-only Syntax mci.canStep
2.11.1.6
deviceID
2.11.1.7
deviceType
Description String. Represents the device type. The method getDevices can get all device types supported in the system. Syntax mci.deviceType
2.11.1.8
leName
2.11 MCI Object m = new MCI; m.deviceType = "sequencer"; m.fileName = "c:\\test.rmi"; m.wait = true; m.command = "open"; m.command = "play"; m.command = "close"; //Tip: How to work with multiple CDAudio devices? //Set the fileName property to //the drive letter of the CD-ROM drive. //E.g. m = new MCI; m.deviceType = "cdaudio"; m.filename = "e:";
197
2.11.1.9
frames
Description Integer. Species the number of frames to step or back. Syntax mci.frames
2.11.1.10
from
Description Integer. Species the starting location to play or record. If this property is negative, the starting location defaults to the current position. When a device is opened, the property is reset to -1. Syntax mci.from Example
198 m = new MCI; m.deviceType = "avivideo"; m.fileName = "c:\\1.avi"; m.from = 50; m.to = 100; m.wait = true; m.x = 0; m.y = 0; m.width = 200; m.height = 200; m.command = "open"; m.command = "play"; m.command = "close";
2.11.1.11
length
Description Integer. Represents the total length of the media. Read-only Syntax mci.length
2.11.1.12
mode
Description Integer. Represents the current mode of the device. Read-only Syntax mci.mode Remarks The device mode can be one of the following values: value 524 525 526 527 528 529 530 Meaning MCI MODE MCI MODE MCI MODE MCI MODE MCI MODE MCI MODE MCI MODE NOT READY STOP PLAY RECORD SEEK PAUSE OPEN
199
Description Boolean. Directs the device to trigger an onNotify event. Syntax mci.notify Example function m_notify(flag) { trace("command finished."); m.notify = false; m.command = "close"; } m = new MCI; m.deviceType = "cdaudio"; m.command = "open"; m.notify = true; m.onNotify = m_notify; m.command = "eject";
2.11.1.14
position
Description Integer. Represents the current position of the media. Read-only Syntax mci.position
2.11.1.15
recordMode
Description
200
FFish Script Objects Reference Boolean. Represents the record mode of the device. The following table describes the meaning of this property. Value true false Description Overwrite mode. Data should overwrite existing data. Insert mode. Newly recorded information should be inserted or pasted into the existing data.
Syntax mci.recordMode Example m = new MCI; m.deviceType = "waveaudio"; m.fileName = "c:\\system.wav"; m.wait = true; m.recordMode = false; m.command = "open"; m.from = m.length; m.to = 10000; m.command = "record"; m.fileName = "d:\\1.wav"; m.command = "save"; m.command = "close";
2.11.1.16
sharable
Description Boolean. Species if the device or le should be opened as sharable. Syntax mci.sharable Remarks Set the property to true if you want to open a device as sharable. You should also set the property to true if you want to open a device that has already been opened as sharable.
201
Description Integer. Species the audio channel of the device. The following table describes the meaning of the property. Value 0 1 2 Syntax mci.channel Example m = new MCI; m.deviceType = "mpegvideo"; m.fileName = "c:\\ 01.DAT"; m.x = 0; m.y = 0; m.width = 480; m.height = 320; m.wait = true; m.command = "open"; m.channel = 1; m.wait = false; m.command = "play"; Description All audio channels Left channel Right channel
2.11.1.18
start
Description Integer. Obtains the starting position of the media. Read-only Value 0 1 2 Description All audio channels Left channel Right channel
2.11.1.19
timeFormat
Description Integer. Species the time format of the device. This property can be one of the following values: Values 0 1 2 3 4 5 6 7 8 Description MCI FORMAT MILLISECONDS. Species the time in milliseconds. MCI FORMAT HMS. Species time in HMS (hours/minutes/seconds) format. MCI FORMAT MSF. Species the time in MSF (minutes/seconds/frames) format. MCI FORMAT FRAMES. Species the time in frames. MCI FORMAT SMPTE 24. Species the time in 24 frame SMPTE format. MCI FORMAT SMPTE 25. Species the time in 25 frame SMPTE format. MCI FORMAT SMPTE 30. Species the time in 30 frame SMPTE format. MCI FORMAT SMPTE 30DROP. Species the time in 30 drop-frame SMPTE format. MCI FORMAT BYTES. Species the time member in bytes within a PCM (Pulse Code Modulation) data format. MCI FORMAT SAMPLES. Species the time in samples for input or output. MCI FORMAT TMSF. Changes the time format to tracks, minutes, seconds, and frames.
9 10
Syntax mci.timeFormat
2.11.1.20
to
Description
2.11 MCI Object Integer. Species the ending location to play or record. If the property is negative, the ending location defaults to the end of the content. When a device is opened, the property is reset to -1. Syntax mci.to Example m = new MCI; m.deviceType = "avivideo"; m.fileName = "c:\\1.avi"; m.from = 50; m.to = 100; m.wait = true; m.x = 0; m.y = 0; m.width = 200; m.height = 200; m.command = "open"; m.command = "play"; m.command = "close";
203
2.11.1.21
track
Description Integer. Use with the property trackPosition and trackLength to specify the track number. Syntax mci.track
Description Integer. Gets the length of the specied track. Read-only Syntax mci.trackLength Example m = new MCI; m.deviceType = "cdaudio"; m.command = "open"; m.timeFormat = 2; for (i = 1; i <= m.tracks; i++) { m.track = i; var l = m.trackLength; trace("Track " + i + " " + MCI.msfMinute(l) + ":" + MCI.msfSecond(l)); }
2.11.1.23
trackPosition
Description Integer. Gets the position of the specied track. Read-only. Syntax mci.trackPosition
2.11.1.24
wait
Description Boolean. Species whether to direct the device to wait until the requested action is completed before returning control to the scripts. Syntax mci.wait
205
Description A Window object. Represents the window for playing videos. Readonly Syntax mci.playerWindow
2.11.1.26
error
Description Boolean. Represents if there is an error after an action is accomplished. The value true indicates there is an error. Read-only. Syntax mci.error
2.11.1.27
errorMsg
2.11.1.28
command
Description String. Sets the action to perform. Syntax mci.command = action; Remarks
206
FFish Script Objects Reference FFish Script supports the following actions:
open Opens a device. Species the deviceType and the leName property before using this action. If you want the device to be shareable, set the sharable property to true. If the device needs a playing window, you must set the left, top, width and height property to dene the location of the playing window embedded in the propjector. E.g.
m = new MCI; m.deviceType = "cdaudio"; m.wait = true; m.command = "open"; Remember to close the device after you have nished using it. close Closes an device. E.g.
m.command = "close"; play Plays the specied media. Species the from and the to property before using this action. pause Pauses the specied media. stop Stops the device. back Steps back. The frames property species the back frames. If this action is successfully nished, the from property is reset to C1. step Steps forward. The frames property species the frame number to step. If this action is successfully nished, the from property is reset to C1. prev Seeks to the begin of the track. If this action is successfully nished, the from property is reset to C1. next Seeks to the end of the next track. If this action is successfully nished, the from property is reset to C1.
2.11 MCI Object seek Seeks to the position specied by the to property. If this action is successfully nished, the from property is reset to C1. record Records. Species the from and the to property before using this action. The recordMode property species the record mode. eject Ejects the media. resume Resumes the device. save Saves the opened le. update Updates the playing window. where Obtains the clipping rectangle for the video device. If the action nished successfully, the width property contains the width of the video and the height property contains the height of the video. All of the action strings are case-insensitive.
207
2.11.1.29
left
Description Integer. Sets the x-coordinate of the upper-left corner of the playing window for video devices. The playing window is embedded in the projector. Syntax mci.left
2.11.1.30
top
Description Integer. Sets the y-coordinate of the upper-left corner of the playing window for video devices. The playing window is embedded in the projector. Syntax mci.top
Description Integer. Sets the width of the playing window for video devices. The playing window is embedded in the projector. Syntax mci.width
2.11.1.32
height
Description Integer. Sets the height of the playing window for the video devices. The playing window is embedded in the projector. Syntax mci.height
2.11.2
2.11.2.1
Methods
sendCmdString
Description Sends a command to the MCI interface. static. Syntax MCI.sendCmdString(cmd) Parameters cmd Species the command string to send. Returns A string represents result information or error message Example MCI.sendCmdString("open c:\\test.rmi type sequencer alias test"); MCI.sendCmdString("play test wait"); MCI.sendCmdString("close test");
209
Description Retrieves the device names in the system. Static Syntax MCI.getDevices() Parameters None Returns An array contains the device names.
2.11.2.3
hmsHour
Description Retrieves the hours component from a parameter containing packed hours/minutes/seconds (HMS) information. Static Syntax MCI.hmsHour(value) Parameters value Species time in HMS format. Returns Integer. Returns the hours component of the specied HMS information
Description Retrieves the minutes component from a parameter containing packed hours/minutes/seconds (HMS) information. Static Syntax MCI.hmsMinute(value) Parameters value Species time in HMS format. Returns Integer. Returns the minutes component of the specied HMS information
2.11.2.5
hmsSecond
Description Retrieves the seconds component from a parameter containing packed hours/minutes/seconds (HMS) information. Static Syntax MCI.hmsSecond(value) Parameters value Species time in HMS format. Returns Integer. Returns the seconds component of the specied HMS information
211
Description Creates a time value in packed hours/minutes/seconds (HMS) format from the given hours, minutes, and seconds values. Static Syntax MCI.makeHMS(h, m, s) Parameters h Species the number of hours. m Species the number of minutes. s Species the number of seconds. Returns Integer. Returns the time in packed HMS format.
2.11.2.7
makeMSF
Description Creates a time value in packed minutes/seconds/frames (MSF) format from the given minutes, seconds, and frame values. Static Syntax MCI.makeMSF(m, s, f) Parameters m Species the number of minutes. s Species the number of seconds. f Species the number of frames. Returns Integer. Returns the time in packed MSF format.
Description Creates a time value in packed tracks/minutes/seconds/frames (TMSF) format from the given tracks, minutes, seconds, and frames values. Static Syntax MCI.makeTMSF(t, m, s, f) Parameters t Species the number of tracks. m Species the number of minutes. s Species the number of seconds. f Species the number of frames. Returns Integer. Returns the time in packed TMSF format.
2.11.2.9
msfFrame
Description Retrieves the frames component from a parameter containing packed minutes/seconds/frames (MSF) information. Static Syntax MCI.msfFrame(value) Parameters value Species time in MSF format. Returns Integer. Returns the frames component of the specied MSF information.
213
Description Retrieves the minutes component from a parameter containing packed minutes/seconds/frames (MSF) information. Static Syntax MCI.msfMinute(value) Parameters value Species time in MSF format. Returns Integer. Returns the minutes component of the specied MSF information.
2.11.2.11
msfSecond
Description Retrieves the seconds component from a parameter containing packed minutes/seconds/frames (MSF) information. Static Syntax MCI.msfSecond(value) Parameters value Species time in MSF format. Returns Integer. Returns the minutes component of the specied MSF information.
Description Retrieves the minutes component from a parameter containing packed tracks/minutes/seconds/frames (TMSF) information. Static Syntax MCI.tmsfMinute(value) Parameters value Species time in TMSF format. Returns Integer. Returns the minutes component of the specied TMSF information.
2.11.2.13
tmsfFrame
Description Retrieves the frames component from a parameter containing packed tracks/minutes/seconds/frames (TMSF) information. Static Syntax MCI.tmsfFrame(value) Parameters value Species time in TMSF format. Returns Integer. Returns the frames component of the specied TMSF information.
215
Description Retrieves the seconds component from a parameter containing packed tracks/minutes/seconds/frames (TMSF) information. Static Syntax MCI.tmsfSecond(value) Parameters value Species time in TMSF format. Returns Integer. Returns the seconds component of the specied TMSF information.
2.11.2.15
tmsfTrack
Description Retrieves the tracks component from a parameter containing packed tracks/minutes/seconds/frames (TMSF) information. Static Syntax MCI.tmsfTrack(value) Parameters value Species time in TMSF format. Returns Integer. Returns the tracks component of the specied TMSF information.
216
2.11.3
2.11.3.1
Events
onNotify
Description If the notify property is set to true before an action, the onNotify event will be triggered after the action is completed. The event handler is: mci.onNotify = function (flag) { body } The ag will be one of the following values: Value 1 2 4 8 Syntax mci.onNotify = handler-func; Description The device has completed the command The current notication conditions have been superseded by a new command. The device has received a command that prevents it from meeting the notication conditions. A device error occurred while the device was executing the command.
2.12
Application Object
Description Provides a series of objects, properties and methods, which oer the ability to change the appearance, behavior and many other options of the applications or screen savers at runtime. Syntax Application.method or properties Availability 1. SWFKit Express 2+ 2. SWFKit 2+ 3. SWFKit Pro 2+
217
2.12.1
2.12.1.1
Properties
Appearance
Description Gains access to the Application.Appearance object. Syntax Application.Appearance Availability Not supported by Screen savers
2.12.1.2
SizeAndPos
Description Gains access to the Application.SizeAndPos object. Syntax Application.SizeAndPos Availability Not supported by Screen savers
2.12.1.3
Interaction
Description Gains access to the Application.Interaction object. Syntax Application.Interaction Availability Not supported by Screen savers
Description Gains access to the Application.Behaviour object. Syntax Application.Behaviour Availability Not supported by Screen savers
2.12.1.5
SysTray
Description Gains access to the Application.SysTray object. Syntax Application.SysTray Availability Not supported by Screen savers
2.12.1.6
Preferences
Description Gains access to the Application.Preferences object. Syntax Application.Preferences Availability Only supported by Screen savers
219
Description Gains access to the Application.Expiry object. Syntax Application.Expiry 2.12.1.8 dragdrop
Description Gains access to the Application.dragdrop object. Syntax Application.dragdrop 2.12.1.9 clipboard
Description Gains access to the Application.clipboard object. Syntax Application.clipboard 2.12.1.10 StatusBar
Description Gains access to the Application.StatusBar object. Syntax Application.StatusBar 2.12.1.11 cmdLine
Description Gets the command-line string of the application or screen saver. Read-only Syntax Application.cmdLine
Description Array. Returns the parsed command line items. Read-only Syntax Application.cmdItems Remarks The Application.cmdLine property will include the path name of the application, but this property wont. // For command line string "untitled.exe -s -p" for (i = 0; i < Application.cmdItems.length; i++) trace(Application.cmdItems[i]); //output: -s // -p
2.12.1.13
cursor
Description Sets the cursor of the application or screen saver. String Syntax Application.cursor Remarks If the property is set to null, the application or screen saver will use the default cursor. You can specify a full path name of a cursor le on disk or path name of a cursor in the attachment list. To hide the cursor, set the property to string hide. Any other values will show the cursor. // Hide the cursor Application.cursor = "hide"; Examples // Uses a cursor on attachments list Application.cursor = "1.cur"; // Uses a cursor on disk Application.cursor = "c:\\1.cur"; // Restores to the default cursor Application.cursor = null;
221
Description Returns true if the output le is a screen saver, or false otherwise. Syntax Application.isScr
2.12.1.15
traceWnd
Description Returns a Window object represents the trace window. Only works under preview mode. Syntax Application.traceWnd
2.12.1.16
captureMouse
Description Boolean. Captures the mouse. If its set to true, the application will receive mouse events even if the cursor is out of the main window. Syntax Application.captureMouse
2.12.1.17
setFocus
222
2.12.2
2.12.2.1
Methods
getBasePath
Description Gets the base directory of the Flash Player. See: setBasePath Syntax Application.getBasePath() Parameters None Returns A string.
2.12.2.2
setBasePath
Description Sets the base path of the Flash Player to load movies. The base path is base to nd your movies specied by a relative path name. E.g. If the base path is c:/my projects, the path name of the movie is movies/test.swf, the full path name of the movie will be c:/my projects/movies/test.swf. Its very useful when you are working with attachments. For example, providing you have added a movie demo.swf to the attachments list under folder myswfs You can load the movie more easily in the main movie like this, 1. In the main movie, load the movie in the action script like this: loadMovieNum("myswfs\\demo.swf", 1); In FFish script, you need to call Application.setBasePath(attachments); 2. In the main movie, load the movie directly without any folder name like this: loadMovieNum(demo.swf, 1); in FFish Script, you need to set the base directory to the folder that the demo.swf has been put in: var name = getAddtionalFile("myswfs\\demo.swf"); Application.setBasePath((new File(name)).parentPath); Syntax
2.12 Application Object 1. Application.setBasePath(); 2. Application.setBasePath(movies); 3. Application.setBasePath(attachments); 4. Application.setBasePath(path-name); Parameters path-name Optional. String. The directory you want to set as the base directory. 1. If the parameter is not set, the base directory will be set to the directory contains the applications or screen savers. 2. If the parameter is set to movies, the base directory will be set to the directory contains the movies. If the movies were packed into the executable le, they will be extracted to a temporary folder before the main window appears on screen, then the base directory is set to the temporary folder. Otherwise, its the same directory as the executable les. 3. If the parameter is set to attachments, the base directory will be set to the temporary folder that the attachments were extracted into (If the Pack attachments option is checked). Returns Nothing Remarks Generally, you use a relative path name to load another movie in a movie. For example, you have two movies master.swf and slave.swf in a same folder. You can load the slave.swf in the master.swf like this: loadMovie(slave.swf, root); And it works well in Macromedia Flash authorizing environment. Then you can create a project with SWFKit by adding the master.swf to the movie list and build a output executable le, providing it is master.exe. At last you can copy the the slave.swf and the master.exe to a same folder and run the master.exe. But it may not work. The reason is that SWFKit supports packing movies into the output
223
224
FFish Script Objects Reference executable les. When the executable le is beginning to run, the packed movie will be extracted to a temporary folder. That is to say, the slave.swf and the extracted master.swf can be in dierent folders. In SWFKit 1, you have to uncheck the pack movies option (makes the master.swf and the slave.swf are in the same folder) or pass the full path name of slave.swf to the loadMovie method to resolve the problem. From SWFKit 2, it provides a better solution. Just call Application.setBasePath() before loading the slave.swf, the base directory is set to the folder contains master.exe, and the Flash Player can nd the slave.swf now. You dont need to uncheck the pack movies option or modify the parameter of the loadMovie method in Action Script.
2.12.2.3
associate
Description Associates a le type with the application. Syntax Application.associate(extension, identier); Parameters extension String. The extension of the les to be associated with. identier String. The identier of the le type Returns Nothing Example Application.associate(".ccc", "Demo.type"); var cmdItems = Application.cmdItems; if (cmdItems.length > 0) { //cmdItems[0] is the name of the file Dialogs.msgBox(cmdItems[0]); }
2.12 Application Object Run the executable le for the rst time and close it. Double-click a .ccc le in the Windows Explorer, the executable le will be launched again and a message box will popup and display the path name of the .ccc le.
225
2.12.2.4
setInterval
Description calls a function or a method of an object at periodic intervals. Syntax Application.setInterval(functionName, interval [, param1, param2, ..., paramN]) Application.setInterval(obj, methodname, interval [, param1, param2, ..., paramN]) Parameters functionName Function. The instance of a Function Object. obj Object. The instance of an Object whose method is to be called. methodname String. The name of the method of the object interval Integer. The time in milliseconds between calls to the function or method. param1, param2, ..., paramN Optional. The parameters passed to the function or method Returns Integer. An interval identier that you can pass to clearInterval method to cancel the interval. Examples function DoTrace(str) { trace(str); } timer = Application.setInterval(DoTrace, 100, (new Date).toString());
Description Clears a call started by the setInterval method. Syntax Application.clearInterval(id); Parameters id Integer. Returns by the setInterval method. Returns Nothing. Example Application.clearInterval(timer);
2.12.2.6
traceToFile
Description Directs the trace output to a le. Wont work in preview mode. Syntax Application.traceToFile(lename); Parameters lename String. The name of the le to write the trace messages. Returns Nothing.
227
Description Display the about box. Syntax Application.about(); Parameters None Returns Nothing.
2.12.2.8
setDragRegion
Description The setDragRegion method changes the drag region of the application (doesnt available for screen savers). The drag region is an area of the main window in which the main window can be dragged by holding the left mouse button down. Syntax Application.setDragRegion(); Application.setDragRegion(region); Application.setDragRegion(left, top, width, height); Parameters region string. species the name of a pre-created clip region. The drag region will be changed to the pre-created clip region. left, top, width, height interger. The four parameters represents a rectangle region in the client of the main window. The drag region will be changed to the rectangle region. Returns Nothing. Remarks
228
FFish Script Objects Reference If the method is called without a parameter it will reset the drag region to the whole client area of the main window. To drag the applications by holding the left mouse button down in the drag region, the option [operation panel]->[application denition]>[interaction]->[left mouse button click]->[drag window] must has been set. The option can also be set by the sh script code Application.Interaction.lBtnClk = $LBDRAG; The default drag region is the whole client area of the main window.
2.12.2.9
sendMessage
Description Sends a message to the specied window Syntax Application.sendMessage(handle, msg, wparam, lparam); Parameters handle The handle of the window to send a message. You can use Window.handle property to get the handle of a window. msg, wparam, lparam See the SendMessage API in Microsoft MSDN: http://msdn2.microsoft.com/en-us/library/ms644950.aspx Returns Number
2.12.2.10
registerASMethods
Description Registers methods in actionscript 2/3 so that they can be called in sh script. Syntax Application.registerASMethods(method0, method1, ..., methodN); Parameters
229
method0, method1, ..., methodN String. Names of the methods in actionscript 2/3. The methods must have be exported by calling the ExternalInterface.addCallback method. Returns Nothing
2.12.3
2.12.3.1
Events
onGetMovie
Description SWFKit triggers the event while its about to load the main movie. Syntax Application.onGetMovie = function (movie) Parameters movie An object which has a value property. You can specify the path name of your movie to this property. Remarks Generally, SWFKit loads the rst movie in the movie list. But if this event handler returns true and movie.value is assigned with a movie name, SWFKit will load it instead. Example Tells SWFKit to load the test.swf in attachment list as the main movie Application.onGetMovie = function (movie) { movie.value = getAdditionalFile("test.swf"); return true; }
Description SWFKit triggers the event while the Flash Player has just loaded a movie. Syntax Application.onMovieLoaded = function (movie) Parameters movie String. Species the movie name has been loaded. Example Application.onMovieLoaded = function(movie) { trace(movie); }
2.13
Application.Appearance
Description Changes the appearance options of the application at runtime. The appearance options are predened in the option box Operation panel->Application Denition->Appearance of SWFKit UI available: SWFKit Express, SWFKit, SWFKit Pro
2.13.1
2.13.1.1
Properties
windowShape
Description Sets or gets the window shape option of the main window. This property corresponds to the Window Shape group box in the option box Operation panel->Application Denition->Appearance of SWFKit UI Syntax Application.Appearance.windowShape
2.13 Application.Appearance Remarks If the window shape is rectangle or transparent, the property will return an Integer. If the window is custom shaped by a clip region, the property will return a string represents name of the clip region. The property can be one of the following values: 1. $WSRECTANGLE 2. $WSTRANSPARENT 3. or a string represents name of a clip region
231
2.13.1.2
borderStyle
Description Sets or gets the border style of the main window of the application. Integer. This property corresponds to the Border style group box in the dialog box Operation panelApplication Denition Appearance of SWFKit UI Syntax Application.Appearance.borderStyle Remarks It can be one of the following values: 1. $BSNONE 2. $BSSINGLE 3. $BSRESIZABLE and combine with the following values: 1. $BSSMALLCAPTION 2. $BSHIDETASKBUTTON
2.13.1.3
borderIcons
Description Sets or gets the border icons option(buttons on the right end of the caption bar) of the main window. Integer. This property corresponds to the Border Icons group box in the dialog box Operation panelApplication DenitionAppearance of SWFKit UI
It can be one or more of the following values: 1. $BIMAXIMIZE 2. $BIMINIMIZE 3. $BISYSTEMMENU 4. $BIHELP
2.13.1.4
scaleMode
Description Sets or gets the scale mode of the Flash Player. Integer This property corresponds to the Scale Mode group box in the dialog box Operation panelApplication DenitionAppearance of SWFKit UI Syntax Application.Appearance.scaleMode Remarks It can be one or more of the following values: 1. $SMSHOWALL 2. $SMNORMAL 3. $SMNOBORDER 4. $SMSTRETCHFIT
2.13.1.5
caption
Description Sets or gets the caption of the main window. String Syntax Application.Appearance.caption
233
Description Sets the icon of the main window. String Syntax Application.Appearance.icon Remarks You should specify the full path name of the icon on the disk. If the icon is in the attachment list, you need to get its path name by using method getAdditionalFile.
2.14
Application.SizeAndPos
Description Sets or gets the size and position options of the main window. The size and position options are predened in the dialog box Operation panelApplication DenitionSize and Position of SWFKit UI available: SWFKit Express, SWFKit, SWFKit Pro
2.14.1
2.14.1.1
properties
windowSize
Description Sets or gets the size option of the main window. Integer. This property corresponds to the Window Size group box in the dialog box Operation panelApplication DenitionSize and position of SWFKit UI Syntax Application.SizeAndPos.windowSize Remarks It can be one of the following values: 1. $SSDEFAULT 2. $SSFULLSCREEN
Note: You cannot set window size with customized width and height by this property, use the setCustomSize method instead. The Application.SizeAndPos object doesnt oer any method to set window size to some percents of the desktop.
2.14.1.2
pos
Description Sets or gets the position option of the main window. Integer. This property corresponds to the Position group box in the dialog box Operation panelApplication DenitionSize and position of SWFKit UI Syntax Application.SizeAndPos.pos Remarks It can be one of the following values: 1. $ASTOPLEFT 2. $ASTOPCENTER 3. $ASTOPRIGHT 4. $ASCENTERLEFT 5. $ASSCREENCENTER 6. $ASCENTERRIGHT 7. $ASBOTTOMLEFT 8. $ASBOTTOMCENTER 9. $ASBOTTOMRIGHT Note: You cannot set window position with customized left and top value by this property, use the setCustomPos method instead.
235
Description Keeps the aspect ratio of the main window while resizing if set to true. Boolean. Syntax Application.SizeAndPos.bKeepRatio
2.14.2
2.14.2.1
methods
setCustomPos
Description Sets the position of the main window Syntax Application.SizeAndPos.setCustomPos(left, top) Parameters left Integer. top Integer. Returns Nothing
2.14.2.2
setCustomSize
Description Sets the size of the main window with the specied width and height. Syntax Application.SizeAndPos.setCustomSize(width, height) Parameters width Integer. Species the new width of the main window height Integer. Species the new height of the main window Returns Nothing
Description Combination of the setCustomSize method and the setCustomPos method. Syntax Application.SizeAndPos.setCustomSizeAndPos(left, top, width, height) Parameters left Integer. top Integer. width Integer. height Integer. Returns Nothing.
2.15
Application.Interaction
Description Changed the interaction options of the applications at runtime. The interaction options are predened in the dialog box Operation panel Application DenitionInteraction of SWFKit UI available: SWFKit Express, SWFKit, SWFKit Pro
2.15.1
2.15.1.1
Properties
lBtnClk
Description Sets or gets the action of the left mouse clicks. This property corresponds to the Left mouse button click group box in the dialog box Operation panelApplication DenitionInteraction of SWFKit UI Syntax Application.Interaction.lBtnClk
2.15 Application.Interaction Remarks It can be one of the following values: 1. $LBSEND 2. $LBDRAG 3. $LBIGNORE
237
2.15.1.2
rBtnClk
Description Sets or gets the action of the right mouse clicks. This property corresponds to the Right mouse button click group box in the dialog box Operation panelApplication DenitionInteraction of SWFKit UI Syntax Application.Interaction.rBtnClk Remarks It can be one of the following values: 1. $RBSEND 2. $RBCONTEXTMENU 3. $RBIGNORE
2.15.1.3
keyPress
Description Sets or gets the action of the application when a key is pressed. This property corresponds to the Key Press group box in the dialog box Operation panelApplication DenitionInteraction of SWFKit UI Syntax Application.Interaction.keyPress Remarks It can be one of the following values: 1. $KPSEND 2. $KPIGNORE
Description Sets or gets the way to exit the application. This property corresponds to the Exit Keys group box in the dialog box Operation panelApplication DenitionInteraction of SWFKit UI Syntax Application.Interaction.exitKeys Remarks It can be one or more of the following values: 1. $EKESC 2. $EKHOTKEY
2.15.1.5
hotKey
Description Sets or gets the hot key used to exit the application. String Syntax Application.Interaction.hotKey Example Application.Interaction.exitKeys = $EKESC | $EKHOTKEY; Application.Interaction.hotKey = "Alt+T";
2.15.1.6
bDisableAltTab
Description Boolean. Disable the key combination ALTTAB or ALTCTRL DELETE when the application is running. Only works under Win9x Syntax Application.Interaction.bDisableAltTab
239
2.15.1.8
bDisableScr
Description Boolean. Prevents the screen savers from running when the application is running Syntax Application.Interaction.bDisableScr
2.16
Application.Behaviour
Description Changes the behavior options of the applications at runtime. The behavior options are pre-dened in the dialog box Operation panel Application DenitionBehaviour of SWFKit UI available: SWFKit Express, SWFKit, SWFKit Pro
2.16.1
2.16.1.1
Properties
bAllowExtendContextMenu
Description Boolean. If the property is set to false, the context menu of the application is not allowed to be extended. Syntax Application.Behaviour.bAllowExtendContextMenu
Description Integer. Sets or gets the items to be inserted into the context menu. This property corresponds to the Add to context menu group box in the dialog box Operation panelApplication Denition Behaviour of SWFKit UI Syntax Application.Behaviour.extendContextMenu Remarks It can be one or more of the following values: 1. $CMCONFIGURE 2. $CMFLASHPLAY 3. $CMABOUT 4. $CMHELP
2.16.1.3
bAutoPlay
Description Boolean. If the property is set to true, the application will start to play the movies automatically. Syntax Application.Behaviour.bAutoPlay
2.16.1.4
bStartMinimized
Description Boolean. If the property is set to true, the application is minimized after starting. Syntax Application.Behaviour.bStartMinimized
241
Description Boolean. If the property is set to true, the main window of the application will always be placed on top of the desktop. Syntax Application.Behaviour.bAlwaysOnTop 2.16.1.6 bShowInSystemTray
Description Boolean. If the property is set to true, the icon of the application will be placed in the system tray. When you click the icon in the system tray, it will popup a menu. If you want to change the behavior of the system tray icon, you should set the useDefaultHandler property of the Application.SysTray object to false and handle the mouse events. You still can add an icon into the system tray by using the Application.SysTray object even if this property is set to false. Syntax Application.Behaviour.bShowInSystemTray
2.17
Application.Expiry
Description Sets or gets the expiry options of the applications or screen savers. The expiry options are pre-dened in the dialog box Operation panelApplication DenitionExpiry of SWFKit UI available: SWFKit Express, SWFKit, SWFKit Pro
2.17.1
2.17.1.1
Properties
bEnable
Description Boolean. if the Expiry option is enabled in the Expiry setting dialog, this property will return true. Read-only. Syntax Application.Expiry.bEnable
Description Integer. Returns the date when the program will expire. Read-only. only valid when the Application.Expiry.bEnable property returns true. Syntax var date = new Date(Application.Expiry.expireOn);
2.17.1.3
leftDays
Description returns the count of the days left before the expiry of the program. Read-only. Only valid when the Application.Expiry.bEnable property returns true. Syntax Application.Expiry.leftDays Example if (Application.Expiry.leftDays <= 0) trace("Expired!");
2.17.1.4
bEnableUnlock
Description If the Enable unlock option is enabled in the Expiry setting dialog, this property will return true. Read-only. If this option hasnt been checked, and Application.Expiry.onExpired event hasnt been handled either, when the program is expired it wont run anymore. However, even if this option hasnt been checked, you still can let the end users to register your applications by handling the Application.Expiry.onExpired event. The registration can be done by the Application.Expiry.register method. To verify if the application has been registered, check the Application.Expiry.isRegistered property. Syntax Application.Expiry.bEnableUnlock
243
Description Boolean. returns true when the program is expired. Syntax Application.Expiry.isExpired
2.17.1.6
isRegistered
2.17.1.7
expiryMsg
Description returns expiry message input in the Expiry setting dialog box. Syntax Application.Expiry.expiryMsg
2.17.1.8
rbCustomized
Description Boolean. Species if the registration box can be customized by the properties such as rbCaption, rbInfo, rbShow3rdBtn, and so on. Set it to true if you want to customize the registration box. Syntax Application.Expiry.rbCustomized
Description String. This property is used to customize the caption of the registration box. Only works if the rbCustomized property is set to true. Syntax Application.Expiry.rbCaption
2.17.1.10
rbInfo
Description String. This property is used to customize the registration information in the registration box. Only works if the rbCustomized property is set to true. Syntax Application.Expiry.rbInfo
2.17.1.11
rbShow3rdBtn
Description Boolean. If this property is set to true, the third button (the Help button) in the registration box will be displayed. If its set to false, the button will be hidden. Only works if the rbCustomized property is set to true. Syntax Application.Expiry.rbShow3rdBtn
2.17.1.12
rb3rdBtnCaption
Description String. Species the caption of the third button(the Help button). Only works if the rbCustomized and the rbShow3rdBtn properties are set to true. Syntax Application.Expiry.rb3rdBtnCaption
245
Description String. Species the link to be opened when users click the third button. Only works if the rbCustomized and the rbShow3rdBtn properties are set to true. Syntax Application.Expiry.rb3rdBtnLink
2.17.1.14
username
Description String. Read-only. Returns the user name used to register the application. If the application has not been registered, returns undened. Syntax Application.Expiry.username
2.17.1.15
serialNumber
Description String. Read-only. Returns the serial number used to register the application. If the application has not been registered, returns undened. Syntax Application.Expiry.serialNumber
2.17.2
2.17.2.1
Methods
showRegisterDlg
2.17.2.2
register
Description Register the application or screen saver. You can create serial numbers by using the serial number creator. Syntax Application.Expiry.register(username, sn, password) Parameters username String. Species the user name sn String. Species the serial number password String. Species the password Returns Boolean. returns true if the registration is successful. Examples Application.Expiry.register("topcmm", "0000000000", "LYCRYVUBKQDG8WW9"); Notice: the password is LYCR-YVUB-KQDG-8WW9, you must remove the - when you pass it to the method.
2.17 Application.Expiry
247
2.17.3
2.17.3.1
Events
onExpiry
Description If the application or screen saver is expired, this event will be triggered and will be only triggered for one time just after the main window is appeared on the screen. The default action of SWFKit is to display an dialog box, with a register button (if the application supports unlock) and a exit button when the application is expired. If the user click the exit button, the application will terminate; if the user click the register button, the registration box will be displayed. If the registration is succeeded, the application will continue to run, otherwise it will terminate. You can change the default action by handling this event. if the donot call the default handler.value is set to true, the SWFKit wont do the default action. You can display your own message box and registration box later. But you must do something to prevent the users from continuing using the application without registration in this case, or the lock system is passed by the event handler and cannot protect you application. Syntax Application.Expiry.onExpired = function (donot_call_the_default_handler) { //donot_call_the_default_handler.value = true; } Examples The example shows how to make your own registration method. registered = readProfile("main", "registered") == "OK"; function myRegister(username, sn, pass) { if (sn != guest || pass != guest) { registered = false; } else registered = true;
248
if (registered) { writeProfile("main", "registered", "OK"); } return registered; } function myIsRegistered() { return registered; } Application.Expiry.onExpired = function (donot_call_the_default_handler) { if (Application.Expiry.isExpired && !myIsRegistered()) { trace("Expired, you must register"); //get the user name, pass, and sn //... if (!myRegister(username, sn, pass)) { trace("wrong pass or sn, you wont get full function"); } } donot_call_the_default_handler.value = true; }
2.18
Application.SysTray
Description Adds icon to the system tray. available: SWFKit Express, SWFKit, SWFKit Pro
2.18 Application.SysTray
249
2.18.1
2.18.1.1
Properties
tip
Description String. Sets or gets the text of the tooltip appears when the cursor is moved on the icon in system tray. Syntax Application.SysTray.tip
2.18.1.2
icon
Description String. Sets or gets the icon to be add into system tray. It must be the full path name of an icon on the disk. If the icon is in the attachments list, you should get its pathname by using the getAdditionalFile method. Syntax Application.SysTray.icon
2.18.1.3
balloonTip
Description String. Sets or gets the text for the balloon tooltip that can be showed by the showBallonTip method. Syntax Application.SysTray.balloonTip
2.18.1.4
balloonTitle
Description String. Sets or gets the title for the balloon tooltip that can be showed by the showBalloonTip method. Syntax Application.SysTray.balloonTitle
Description Integer. Sets or gets the timeout value, in milliseconds, for the balloon ToolTip. Syntax Application.SysTray.balloonTimeout
2.18.1.6
balloonIcon
Description String. Sets the icon of the balloon tooltip Syntax Application.SysTray.balloonIcon Remarks The property must be one of the following values info An information icon warning A warning icon error An error icon
2.18.1.7
useDefaultHandler
Description Boolean. Always remember to set this property to false. Or it will show a right click menu as SWFKit 1. Syntax Application.SysTray.useDefaultHandler
2.18 Application.SysTray
251
2.18.2
2.18.2.1
Methods
add
Description Adds an icon into the system tray. Syntax Application.SysTray.add() Parameters None Returns Boolean. returns true if the icon is added successfully. Examples Application.Behaviour.bShowInSystemTray = false; Application.SysTray.useDefaultHandler = false; Application.SysTray.icon = getAdditionalFile("35floppy.ico"); Application.SysTray.tip = "A test"; Application.SysTray.add(); Application.SysTray.onRClicked = { var menu = new Menu; menu.createPopupMenu(); menu.appendItem("id0", "item menu.appendItem("id1", "item menu.appendItem(); menu.appendItem("id2", "item menu.appendItem("id3", "item getMainWnd().bringToTop(); trace(menu.show()); } Application.SysTray.onLClicked = function () { this.balloonTip = "Happy New Year!"; this.balloonTitle = "Hello"; this.balloonIcon = "warning"; function ()
252 this.showBalloonTip(); }
Notice: before showing a popup menu for the notication icon, remember to call the bringToTop method for the main window. Otherwise the menu wont disappear when the user click outside the menu.
2.18.2.2
modify
Description Modies the system tray icon. Syntax Application.SysTray.modify() Parameters None Returns Boolean. Examples Application.SysTray.icon = getAdditionalFile("disk01.ico"); Application.SysTray.tip = "A test"; Application.SysTray.add(); var iCount = 0; var icons = [ getAdditionalFile("disk02.ico"), getAdditionalFile("disk03.ico"), getAdditionalFile("disk01.ico") ]; function changeTrayIcon() { Application.SysTray.icon = icons[iCount \% 3]; iCount++; } Application.setInterval(changeTrayIcon, 1000);
253
Description Deletes the system tray icon. Syntax Application.SysTray.remove() Parameters None Returns Boolean.
2.18.2.4
showBalloonTip
Description Displays the balloon tool tip. Syntax Application.SysTray.showBalloonTip() Parameters None Returns Boolean.
2.18.3
2.18.3.1
Events
onMouseMove
Description This even is triggered when the cursor moves over the icon Syntax Application.SysTray.onMouseMove = function () { // do something }
Description This event is triggered when the users left click the icon Syntax Application.SysTray.onLClicked = function () { // do something }
2.18.3.3
onRClicked
Description This event is triggered when the users right click the icon Syntax Application.SysTray.onRClicked = function () { // do something }
2.18.3.4
onLDblClicked
Description This event is triggered when the user double-clicks the left mouse button on the icon Syntax Application.SysTray.onLDblClicked = function () { // do something }
255
Description This event is triggered when the user double-clicks the right mouse button on the icon Syntax Application.SysTray.onRDblClicked = function () { // do something }
2.19
Application.Preferences
Description Changes the preferences options of Screen Savers at runtime. The preferences options are pre-dened in the dialog box Operation panelScreen Saver DenitionPreferences of SWFKit UI available: SWFKit Express, SWFKit, SWFKit Pro
2.19.1
2.19.1.1
Properties
wakeupMethod
Description Sets or gets the method to exit the screen saver. This property corresponds to the Wake up on group box in the dialog box Operation panelScreen Saver DenitionPreferences of SWFKit UI Syntax Application.Preferences.wakeupMethod Remarks The property can be one or more of the following values: 1. 2. 3. 4. 5. 6. $WULEFTBUTTON $WURIGHTBUTTON $WUMOUSEMOVE $WUKEYSTROKE $WUESC $WUHOTKEY
Description Sets or gets the hot key to exit the screen saver Syntax Application.Preferences.hotKey
2.19.1.3
disableCursor
Description Boolean. Set the property to true to hide the cursor. Syntax Application.Preferences.disableCursor
2.19.1.4
disableCDAutoRun
Description Boolean. Set the property to true to disable cd auto run. Syntax Application.Preferences.disableCDAutoRun
2.20
Application.dragdrop
Description The Application.dragdrop object can accept les or text transferred by dragging and dropping. Not available for screen savers. available: SWFKit Pro
2.20 Application.dragdrop
257
2.20.1
2.20.1.1
Properties
enable
Description Boolean. Set the property to true to accept le or text dropping. Syntax Application.dragdrop.enable Example To accept a le or text transferred by dropping it into the main window, 1. turn the enable property on Application.dargdrop.enable = true; 2. write event handlers to accept the les or text Application.dragdrop.onDropText = function (str) { trace(str); } Application.dragdrop.onDropFiles = function (files) { trace(files); }
2.20.2
2.20.2.1
Events
onDragEnter Text
Description This event is triggered when a text string have just been dragged into the main window. Syntax Application.dragdrop.onDragEnter_Text = function () { }
Description This event is triggered when les have just been dragged into the main window. Syntax Application.dragdrop.onDragEnter_Files = function () { }
2.20.2.3
onDragOver Text
Description This event is triggered when a text string is dragging over the main window. Syntax Application.dragdrop.onDragOver_Text = function () { }
2.20.2.4
onDragOver Files
Description This event is triggered when les are dragging over the main window. Syntax Application.dragdrop.onDragOver_Files = function () { }
259
Description This event is triggered when the les or a text string have just been dragged out of the main window. Syntax Application.dragdrop.onDragLeave = function () { }
2.20.2.6
onDropText
Description This event is triggered when a text string has just been dropped into the main window. Syntax Application.dragdrop.onDropText = function (str) { trace(str); } Parameters str String. Represents the text being dragged and dropped
2.20.2.7
onDropFiles
Description This event is triggered when les have just been dropped into the main window. Syntax Application.dragdrop.onDropFiles = function (files) { trace(files); } Parameters les Array. Contains the name of the les being dragged and dropped
Description This event is triggered when a drag and drop operation is taking place (drag data to another application). The data to be dragged to another application can and can only be provided in this event handler. The event handler can return a string object or an image object which represents the data to be dragged. Syntax Application.dragdrop.onDragGetData = function () { return data; } Parameters None
Examples //the following code enables the application //to capture an image and drag the image to //an outside application such as Word Application.dragdrop.enable = true; image = Image.captureMovie(); Application.dragdrop.onDragGetData = function () { return image; }
2.21
Application.clipboard
Description Gains access to clipboard. Not available for screen savers. available: SWFKit Pro
2.21 Application.clipboard
261
2.21.1
2.21.1.1
Methods
copyBitmap Screen
Description Copies screen as a bitmap onto the clipboard. Syntax Application.clipboard.copyBitmap Screen([left, top, right, bottom]) Parameters left, top, right, bottom Optional. Integer. Species the coordinates of the upper-left and lower-right corners of a rectangle. The rectangle denes the area of screen to copy. If you call the method without parameters, it will copy the entire screen onto the clipboard. Returns Boolean. Returns true if successful, or false otherwise.
2.21.1.2
copyBitmap Movie
Description Copies the picture of the playing movie onto the clipboard. Syntax Application.clipboard.copyBitmap Movie([left, top, right, bottom]) Parameters left, top, right, bottom Optional. Integer. Species the coordinates of the upper-left and lower-right corners of a rectangle. The rectangle denes the area of the movie to copy. If you call the method without parameters, it will copy the entire movie onto the clipboard. Returns Boolean. Returns true if successful, or false otherwise.
Description Copies text onto the clipboard. Syntax Application.clipboard.copyText(str) Parameters str Optional. String. Species the text to copy Returns Boolean. Returns true if successful, or false otherwise.
2.21.1.4
paste
Description Gets text from the clipboard. Syntax Application.clipboard.paste() Parameters None Returns String. If the clipboard doesnt contain text, this method will return null.
2.21.1.5
pasteBitmap
Description Gets a bitmap from the clipboard. Syntax Application.clipboard.pasteBitmap() Parameters None Returns An image object. If the clipboard doesnt contain a bitmap, this method will return null.
2.22 Application.StatusBar
263
2.22
Application.StatusBar
Description Controls the status bar. Not available for screen savers. available: SWFKit Pro
2.22.1
2.22.1.1
Properties
progress
Description Integer. If it is set to a value between 0 to 100, a progress bar control will appear on the rst pane of the status bar and the position of the progress bar control is set by the property. To hide the progress bar control, set it to -1. Syntax Application.StatusBar.progress
2.22.2
2.22.2.1
Methods
init
Description Initializes the indicators of the status bar. Syntax Application.StatusBar.init(indicators) Parameters indicators An array of strings. The number of the indicators will be set to Array.length + 1, The text of the indicator 1 to Array.length will be set to the corresponding string in the array. The width of indicator 1 to Array.legnth will be set to t its text. The text of indicator 0 will be set to Ready and will be stretched to ll the unused space. Remarks Retains text for the indicators.
264
CAPS If an indicators text is set to this, it will display the status of the Caps Lock key. If the key is toggled, its enabled. Otherwise, its disabled. NUM If an indicators text is set to this, it will display the status of the Num Lock key. If the key is toggled, its enabled. Otherwise, its disabled. SCRL If an indicators text is set to this, it will display the status of the Scroll Lock key. If the key is toggled, its enabled. Otherwise, its disabled. OVR If an indicators text is set to this, it will display the status of the Insert key. Returns Boolean. If succeeds, returns true. Example Application.StatusBar.init(["256:1730", "CAPS", "NUM", "SCRL"]); Application.StatusBar.show();
2.22.2.2
setPaneText
Description Sets the text of the specied indicator. Syntax Application.StatusBar.setPaneText(index, text) Parameters index Integer. Species the index of the indicator. The index of the rst indicator is 0. text String. Represents the text to set. Remarks Retains text for the indicators. CAPS If an indicators text is set to this, it will display the status of the Caps Lock key. If the key is toggled, its enabled. Otherwise, its disabled.
2.22 Application.StatusBar NUM If an indicators text is set to this, it will display the status of the Num Lock key. If the key is toggled, its enabled. Otherwise, its disabled. SCRL If an indicators text is set to this, it will display the status of the Scroll Lock key. If the key is toggled, its enabled. Otherwise, its disabled. OVR If an indicators text is set to this, it will display the status of the Insert key. Returns Boolean. If succeeds, returns true.
265
2.22.2.3
setPaneIcon
Description Sets the icon of the specied indicator. Syntax Application.StatusBar.setPaneIcon(index, icon) Parameters index Integer. Species the index of the indicator. The index of the rst indicator is 0. icon String. Represents the full path name of the icon on disk. Returns Boolean. If succeeds, returns true.
2.22.2.4
setPaneWidth
Description Sets the width of the specied indicator. Syntax Application.StatusBar.setPaneWidth(index, width); Parameters
266
index Integer. Species the index of the indicator. The index of the rst indicator is 0. width Integer. Represents the new width of the indicator. The method does nothing when index is set to 0, for the rst pane will always ll the unused space. Returns Boolean. If succeeds, returns true.
2.22.2.5
disablePane
Description Disables or enables the specied indicator. Syntax Application.StatusBar.disablePane(index, disable); Parameters index Integer. Species the index of the indicator. The index of the rst indicator is 0. disable Boolean. Set it to true to disable the pane, or false to enable it. If the pane is disabled, its text wont be drawn. Returns Boolean. If succeeds, returns true.
2.22.2.6
setPaneBorder
Description Shows or hides the 3-D border around the specied indicator. Syntax Application.StatusBar.setPaneBorder(index, show) Parameters index Integer. Species the index of the indicator. The index of the rst indicator is 0. show Boolean. Set it to true to show the 3-D border around the specied indicator. Returns Boolean. If succeeds, returns true.
267
Description Displays the status bar. Syntax Application.StatusBar.show() Parameters None Returns Boolean. If succeeds, returns true.
2.22.2.8
hide
Description Hides the status bar. Syntax Application.StatusBar.hide() Parameters None Returns Boolean. If succeeds, returns true.
2.23
Menu
Description An object to load, create or display menus. available: SWFKit Express, SWFKit, SWFKit Pro
268
2.23.1
2.23.1.1
Properties
enableAccel
Description Boolean. You must set this property to true to enable the shortcuts of the menu items. Syntax Menu.enableAccel Remarks A menu item can have a shortcut key (does not have to) associated with it. Text that identies the shortcut key is added to the menuitem text string. The shortcut text appears to the right of the menu item name, after a backslash and tab character (). For example, \&Close\\tAlt+F4 represents a Close command with the ALT+F4 key combination as its shortcut key. When the property is set to true, SWFKit will enable all shortcut keys of the sub items of the menu at once. Otherwise, it will disable all of the shortcut keys.
2.23.2
2.23.2.1 add
Methods
load
Loads a pre-created menu Syntax Menu.load(name) Parameters name String. Species the name of the menu to load. The menu must have been created by the Menu Creator. Returns Boolean. returns true if the menu has been loaded successfully.
2.23 Menu Examples var m = new Menu; m.load("test"); m.setMenu(); m.enableAccel = true;
269
2.23.2.2
setMenu
Description Sets the menu as the main menu. The menu must have been created by the createMenu method or loaded by the load method. Syntax Menu.setMenu() Parameters None Returns Boolean.
2.23.2.3
createMenu
Description Creates a menu. The menu is initially empty, but it can be lled with menu items by using the appendItem and insertItem methods Syntax Menu.createMenu() Parameters None Returns Boolean. Examples
270
FFish Script Objects Reference var m = new Menu; m.createMenu(); var n = new Menu(); n.createPopupMenu(); n.appendItem("new", "&New\tAlt+N"); n.appendItem("exit", "&Exit\tAlt+X"); n.insertItem(1); m.appendItem(n, "File"); m.setMenu();
2.23.2.4
createPopupMenu
Description creates a popup menu. The menu is initially empty, but it can be lled with menu items by using the appendItem and insertItem methods. You can display the popup menu by using the show method. Syntax Menu.createPopupMenu() Parameters None Returns Boolean.
2.23.2.5
appendItem
Description Appends a new menu item to the end of the menu. Syntax 1. Menu.appendItem(submenu, name);// Appends a popup menu 2. Menu.appendItem(identier, name[, icon]); // Appends a menu item with identier and caption 3. Menu.appendItem(); // Appends a separator
2.23 Menu Parameters submenu A menu object. Represents a pop up menu to be appended. name String. Species the caption of the menu item. Eg. &New\tAlt+N identier String. Species the unique identier of the menu item. icon String. Optional. Species the icon name of the menu item. It can be the full path name of an icon on the disk, or a relative path of an icon in the attachment list. If the method takes no parameters, a separator will be appended. Returns Boolean.
271
2.23.2.6
insertItem
Description Inserts a new menu item to the specied position of the menu. Syntax 1. Menu.insertItem(pos, submenu, name);// Inserts a popup menu 2. Menu.insertItem(pos, identier, name[, icon]); // Inserts a menu item with identier and caption 3. Menu.insertItem(pos); // Inserts a separator Parameters pos Integer. Starts from 0. Species the position of the insertion to take place. submenu A menu object. Represents a pop up menu to be inserted. name String. Species the caption of the menu item. Eg. &New\tAlt+N identier String. Species the unique identier of the menu item. icon String. Optional. Species the icon name of the menu item. It can be the full path name of an icon on the disk, or a relative path of an icon in the attachment list. Returns Boolean.
Description Removes a menu item at the specied position of the menu. Syntax Menu.removeItem(pos); Parameters pos Integer. Starts from 0. Species the position of menu item to be removed. Returns Boolean.
2.23.2.8
getSubMenu
Description Gets the drop-down or popup menu activated by the menu item at the specied position Syntax Menu.getSubMenu(pos); Parameters pos Integer. Starts from 0. Species the position of menu item that activates the drop-down menu or popup menu to be retrieved. Remarks When the parent of the sub menu is destroyed, the sub menu returned by this method will be invalid. For example, var menu = new Menu; menu.load("main"); menu = menu.getSubMenu(0); FlashPlayer.onContextMenu = function () { menu.show(); }
2.23 Menu The code wont work, for the menu variable represents the sub menu, when the script is nished, the parent menu will be destroyed, and the menu variable will be invalid. The following code can work var menuMain = new Menu; menuMain.load("main"); var menu = menuMain.getSubMenu(0); FlashPlayer.onContextMenu = function () { menu.show(); } Returns A menu object. If failed, returns null.
273
2.23.2.9
show
Description Displays a popup menu Syntax Menu.show([x, y]); Parameters x, y Integer. Optional. Species the position to show the popup menu. If the method takes no parameters, the menu will be displayed at the position of the cursor. Returns String. The identier of the menu item that has been chosen. If failed, returns null. The method wont return until a menu item has been clicked or user clicked outside the menu. If the users click outside the menu, it also returns null. Examples
274 var menu = new Menu; menu.createPopupMenu(); menu.appendItem("id0", "item menu.appendItem("id1", "item menu.appendItem(); menu.appendItem("id2", "item menu.appendItem("id3", "item switch (menu.show()) { case "id0": trace("item 0!"); break; }
2.23.3
2.23.3.1
Events
onCommand
Description Fires when a menu item has been clicked or a shortcut key of the menu item has been pressed(if the shortcut keys are enabled) Syntax Menu.onCommand = function (identifier) { // do something } SWFKit transfers the identier of the menu item to the event handler. Examples var mainMenu = new Menu; mainMenu.createMenu(); var menu = new Menu; menu.createPopupMenu(); menu.appendItem("id0", "item menu.appendItem("id1", "item menu.appendItem(); menu.appendItem("id2", "item menu.appendItem("id3", "item
2.23 Menu
275
Menu.onCommand = function (id) { switch (id) { case "id0": trace("item 0!"); break; } }
2.23.3.2
onUpdateItem
Description Fires when a menu item is about to appear. You can handle this event to change the state of the menu item. Not available for Screen savers. Syntax Menu.onUpdateItem = function (identifier, state) { // do something } SWFKit transfers the identier of the menu item to the event handler. The state parameter is an object contains three write-only properties enable Boolean. If you set it to false in the event handler, the menu item will be disabled. check Boolean. If you set it to true in the event handler, the menu item will be checked. caption String. You can change the caption of the menu item by setting this property. Examples Menu.onUpdateItem = function (id, state) { switch (id) { case "id0": // disable the menu item
2.24
Encryption
Description An object can do encrypt and decrypt. available: SWFKit Express, SWFKit, SWFKit Pro
2.24.1
2.24.1.1
Methods
blowshEncode
Description Do blowsh encode. Syntax Encryption.blowshEncode(key, string); Parameters key String. An unique key used to encode or decode the messages string String. The message to encode Returns String. You can get the original message by calling the blowshDecode method with the same key and the returned string value. Examples trace(Encryption.blowfishEncode("test", "message")); trace(Encryption.blowfishDecode("test", "2KRNdy7o/90="));
277
Description Do blowsh decode. Syntax Encryption.blowshDecode(key, string); Parameters key String. An unique key used to encode or decode the messages string String. The encoded message Returns String. Examples trace(Encryption.blowfishEncode("test", "message")); trace(Encryption.blowfishDecode("test", "2KRNdy7o/90="));
2.24.1.3
md5
Description Calculates MD5 message digest Syntax Encryption.md5(text); Parameters text String. The input message Returns A string with 32 characters. Examples trace(Encryption.md5("Hello world")); //output: 3e25960a79dbc69b674cd4ec67a72c62
Description Calculates MD5 message digest of a le Syntax Encryption.md5File(le); Parameters le String. Species the input le name. Returns A string with 32 characters.
2.24.1.5
desEncode
Description Does DES encode. Syntax Encryption.desEncode(key, string); Parameters key String. An unique key used to encode or decode the messages string String. The message to encode Returns String. You can get the original message by calling the desDecode method with the same key and the returned string value. Examples trace(Encryption.desEncode("test", "message")); trace(Encryption.desDecode("test", "QrfRWpfYc9Q="));
279
Description Does DES decode. Syntax Encryption.desDecode(key, string); Parameters key String. An unique key used to encode or decode the messages string String. The encoded message Returns String. Examples trace(Encryption.desEncode("test", "message")); trace(Encryption.desDecode("test", "QrfRWpfYc9Q="));
2.24.1.7
encFile
Description Encrypts a disk le. A le encrypted by this method can be decrypted by the method decFile. Static Syntax Encryption.encFile(key, inputFile, outputFile); Parameters key String. An unique key used to encrypt les inputFile String. Species a disk le to encrypt outputFile String. Species a disk le to save the encrypted data Returns Boolean. Returns true if successful; otherwise returns false;
Description Decrypts a disk le that is encrypted by the encFile method. Static Syntax Encryption.decFile(key, inputFile, outputFile); Parameters key String. An unique key used to encrypt les inputFile String. Species a disk le to decrypt outputFile String. Species a disk le to save the decrypted data Returns Boolean. Returns true if successful; otherwise returns false;
2.25
DiskInfo
Description Retrieves the information of the specied hard disk available: SWFKit Express, SWFKit, SWFKit Pro Syntax new DiskInfo(index) Parameters index Integer. It can be 0, 1, 2, 3. 0 1 2 3 Examples The The The The master disk of the primary controller slave disk of the primary controller master disk of the secondary controller slave disk of the secondary controller
2.25 DiskInfo for (i = 0; i < 4; i++) { var di = new DiskInfo(i); if (di != null) { trace(di.modelNumber); trace(di.serialNumber); trace(di.revisionNumber); trace(di.driveType); trace(di.bufferSize); trace(di.cylinders); trace(di.heads); trace(di.sectors); } }
281
2.25.1
2.25.1.1
Properties
modelNumber
Description String. Returns the model number of the hdd. Read-only. Syntax di.modelNumber
2.25.1.2
revisionNumber
Description String. Returns the revision number of the hdd. Read-only. Syntax di.revisionNumber
2.25.1.3
driveType
Description String. Returns the drive type of the hdd. Read-only. Syntax di.driveType
Description Integer. Returns the buer size of the hdd. Read-only. Syntax di.buerSize
2.25.1.5
cylinders
Description Integer. Returns the number of the cylinders of the hdd. Read-only. Syntax di.cylinders
2.25.1.6
heads
Description Integer. Returns the number of the heads of the hdd. Read-only. Syntax di.heads
2.25.1.7
sectors
Description Integer. Returns the number of the sectors of the hdd. Read-only. Syntax di.sectors
2.26
DataFile
Description An object can load FFish Script variables from le or save to le. available: SWFKit Express, SWFKit, SWFKit Pro
2.26 DataFile
283
2.26.1
2.26.1.1
Methods
load
Description Loads all variables from a data le. The variables are saved in the le by using the save method. Syntax DataFile.load(le) Parameters le String. Species the data le name Returns Boolean. Returns false if failed. Examples trace(DataFile.load("c:\\1.txt")); trace(x); trace(x[0]); trace(x[1]); trace(x[2]); trace(y); trace(z); trace(z.x); trace(z.y); trace(z.z); trace(m);
2.26.1.2
loadAndDec
Description Loads a data le, decrypts its content and read values of the variables in the data le. The data le must be saved by the saveAndEnc method. Syntax DataFile.loadAndDec(le) Parameters
284
2.26.1.3
save
Description Saves variables into a data le. If the data le exists, new variables will be appended to the end of the le. Syntax DataFile.save(le, var0[, var1, ..., varn]) Parameters le String. Species the data le name var0, var1, ..., varn String. Species the names of the variables to be saved. Only the global variables can be saved, and supported data types are: Integer, Float, String, Array, Object, Boolean. The array to be saved cannot contain any item with unsupported types. So does the objects. Returns Boolean. Returns false if failed. Examples var var var var z.x z.y z.z x y z m = = = = [1, [0.5, "string", 3], "sdf"]; = 9; = new Object; = false; [1, 2, 3]; "string"; 1.23;
285
Description Saves variables into a data le and encrypts the data le. Whether the data le exists or not, it will be overwrite by this method. Syntax DataFile.saveAndEnc(le, var0[, var1, ..., varn]) Parameters le String. Species the data le name var0, var1, ..., varn String. Species the names of the variables to be saved. Only the global variables can be saved, and supported data types are: Integer, Float, String, Array, Object, Boolean. The array to be saved cannot contain any item with unsupported types. So does the objects. Returns Boolean. Returns false if failed.
2.26.1.5
remove
Description Removes a data le from disk. Syntax DataFile.remove(le) Parameters le String. Species the data le name Returns Nothing
2.27
DesktopToy
Description Controls a desktop toy. available: SWFKit Express, SWFKit, SWFKit Pro
286
2.27.1
2.27.1.1
Properties
followCursor
Description Boolean. If set to true, the desktop toy will move and follow the cursor. Syntax DesktopToy.followCursor
2.27.2
2.27.2.1
Methods
act
Description Makes the desktop toy to moving on the screen. Syntax DesktopToy.act(v, vangle, a, aangle, attenuation, bouncing) Parameters v Integer. Species the initial velocity. 2.1 vangle Integer. Species the angle of the initial velocity. a Integer. Species the initial acceleration aangle Integer. Species the angle of the initial acceleration 2.1 attenuation Integer. Species the bouncing attenuation. bouncing Boolean. Set it to true to support bouncing when it reaches the bounds of the screen. Otherwise it stops while reaches the bounds of the screen. Returns Nothing. Examples //do throwing DesktopToy.act(100, 315, 100, 90, 30, true);
2.27 DesktopToy
287
2.27.2.2
stop
Description Stops the action started by the act method. Syntax DesktopToy.stop() Parameters Nothing Returns Nothing
2.27.3
2.27.3.1
Events
onStop
Description Fires when the moving desktop toy stops. This event can be red by the stop method, or the desktop toy reaches the bounds of the screen while the parameter bouncing is set to false. Syntax
288
FFish Script Objects Reference dt.onStop = function(left, top) { // Do something } SWFKit will pass the left and top position of the desktop toy window to the event handler.
2.28
Window Object
Description Provides access to windows. available: SWFKit Express, SWFKit, SWFKit Pro Syntax new Window(handle); Parameter handle Integer. Species the handle of the window.
2.28.1
2.28.1.1
Properties
caption
Description String. Gets or sets the caption of the specied window. Syntax wnd.caption Example var wnd = getMainWnd(); wnd.caption = "This is a demo";
289
Description Integer. Gets or sets the position of the left side of the specied window. Syntax wnd.left Example var wnd = getMainWnd(); trace(wnd.left);
2.28.1.3
top
Description Integer. Gets or sets the position of the top of the specied window. Syntax wnd.top Example var wnd = getMainWnd(); trace(wnd.top);
2.28.1.4
width
Description Integer. Gets or sets the width of the specied window. Syntax wnd.width Example var wnd = getMainWnd(); trace(wnd.width);
Description Integer. Gets or sets the height of the specied window. Syntax wnd.height Example var wnd = getMainWnd(); trace(wnd.height);
2.28.1.6
parent
Description Window Object. Gets or sets the parent window of the specied window. Syntax wnd.parent Example var wnd = getMainWnd(); w.parent = wnd;
2.28.1.7
handle
Description Integer. Gets the handle of the specied window. Read-only. Syntax wnd.handle Example var wnd = getMainWnd(); trace(wnd.handle);
291
Description String. Retrieves the name of the class to which the specied window belongs. Read-only. Syntax wnd.className Example var wnd = getMainWnd(); trace(wnd.className);
2.28.1.9
visible
Description Boolean. Gets the visibility of the specied window. Read-only. Syntax wnd.visible Example var wnd = getMainWnd(); trace(wnd.visible);
2.28.1.10
enable
Description Boolean. Enables or disables the specied window. Syntax wnd.enable Example var wnd = getMainWnd(); wnd.enable = false;
Description Object. Returns the client rectangle width and height. Read-only Syntax wnd.clientRect Example var wnd = getMainWnd(); trace(wnd.clientRect.left); trace(wnd.clientRect.top); trace(wnd.clientRect.width); trace(wnd.clientRect.height);
2.28.1.12
windowState
Description String. Sets or gets the state of the specied window. It can be one of the following values: Value normal maximized minimized Syntax wnd.windowState Example var wnd = getMainWnd(); trace(wnd.windowState); Description The window is in normal state The window is maximized The window is minimize
2.28.2
2.28.2.1
Methods
show
293
2.28.2.2
hide
Description Hides the specied window. Syntax wnd.hide() Parameters None Returns Nothing. Example //Hides the taskbar var tb = Window.find("Shell_TrayWnd"); if (tb != null) tb.hide();
Description Closes the specied window. Syntax wnd.close() Parameters None Returns Nothing. Example //Hides the taskbar var wnd = getMainWnd(); wnd.close();
2.28.2.4
getChildren
Description Gets the children of the specied window. Syntax wnd.getChildren() Parameters None Returns An array contains all child windows of the specied window. Example
2.28 Window Object //Get the Flash player window function getFlashPlayerWnd() { var wnd = getMainWnd(); if (wnd == null) return null; var ws = wnd.getChildren(); var i; for (i = 0; i < ws.length; i++) { if (ws[i].className == "MacromediaFlashPlayerActiveX") return ws[i]; } return null; }
295
2.28.2.5
getWindowsByName
Description Gets top-level windows with the specied name. Syntax wnd.getWindowsByName([name]) Parameters name A string represents the name of the windows to retrieve. Returns An array contains all top-level windows with the specied name. If you have not specied a name, the method will return all windows on the desktop. Example //Hides the taskbar var ws = Window.getWindowsByName(); for (i = 0; i < ws.length; i++) trace(ws[i].caption);
296 2.28.2.6 nd
Description Retrieves a window to the top-level window whose class name and window name match the specied strings. Static Syntax wnd.nd([classname[, windowname]]) Parameters classname Optional. Species the class name windowname Optional. Species the window name Returns A window Object. Example //nds the taskbar //finds the windows task bar var tb = Window.find("Shell_TrayWnd");
2.28.2.7
bringToTop
Description Puts the specied window into the foreground and activates the window. Syntax wnd.bringToTop() Parameters None Returns Nothing
297
Description Modies the style of the specied window. Syntax wnd.modifyStyle(remove[, add]) Parameters remove Species the style to remove. add Species the style to add. The windows style can be combine of the following values: WS_OVERLAPPED WS_POPUP WS_CHILD WS_MINIMIZE WS_VISIBLE WS_DISABLED WS_CLIPSIBLINGS WS_CLIPCHILDREN WS_MAXIMIZE WS_CAPTION WS_BORDER WS_DLGFRAME WS_VSCROLL WS_HSCROLL WS_SYSMENU WS_THICKFRAME WS_GROUP WS_TABSTOP WS_MINIMIZEBOX WS_MAXIMIZEBOX Returns Nothing = = = = = = = = = = = = = = = = = = = = 0x00000000 0x80000000 0x40000000 0x20000000 0x10000000 0x08000000 0x04000000 0x02000000 0x01000000 0x00C00000 0x00800000 0x00400000 0x00200000 0x00100000 0x00080000 0x00040000 0x00020000 0x00010000 0x00020000 0x00010000
2.28.2.9
modifyStyleEx
remove Species the extended style to remove. add Optional. Species the extended style to add. The windows extended style can be combine of the following values: WS_EX_DLGMODALFRAME WS_EX_NOPARENTNOTIFY WS_EX_TOPMOST WS_EX_ACCEPTFILES WS_EX_TRANSPARENT WS_EX_MDICHILD WS_EX_TOOLWINDOW WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE WS_EX_CONTEXTHELP WS_EX_RIGHT WS_EX_LEFT WS_EX_RTLREADING WS_EX_LTRREADING WS_EX_LEFTSCROLLBAR WS_EX_RIGHTSCROLLBAR WS_EX_CONTROLPARENT WS_EX_STATICEDGE WS_EX_APPWINDOW Returns Nothing = = = = = = = = = = = = = = = = = = = 0x00000001 0x00000004 0x00000008 0x00000010 0x00000020 0x00000040 0x00000080 0x00000100 0x00000200 0x00000400 0x00001000 0x00000000 0x00002000 0x00000000 0x00004000 0x00000000 0x00010000 0x00020000 0x00040000
2.28.2.10
move
Description Changes the position of the specied window. Syntax wnd.move(left[, top[, right[, bottom]]]) Parameters
2.28 Window Object left Species the new position of the left side of the window top Species the new position of the top of the window right Species the new position of the right side of the window bottom Species the new position of the bottom of the window Returns Nothing
299
2.28.2.11
update
Description Updates the client area of the window Syntax wnd.update() Parameters None Returns Nothing
2.28.2.12
animate
Description Enables you to produce special eects when showing or hiding windows. There are three types of animation: roll, slide, and alphablended fade Syntax wnd.animate(time, ag) Parameters time Species how long it takes to play the animation, in milliseconds. Typically, an animation takes 200 milliseconds to play. ag Species the type of animation. This parameter can be one or more of the following values
300
Value 0x00040000 Name AW SLIDE
Uses a fade eect. This ag can be used only if it is a top-level window. Hides the window. By default, the window is shown. Makes the window appear to collapse inward if AW HIDE is used or expand outward if the AW HIDE is not used. Animates the window from left to right. This ag can be used with roll or slide animation. It is ignored when used with AW CENTER or AW BLEND. Animates the window from right to left. This ag can be used with roll or slide animation. It is ignored when used with AW CENTER or AW BLEND. Animates the window from top to bottom. This ag can be used with roll or slide animation. It is ignored when used with AW CENTER or AW BLEND. Animates the window from bottom to top. This ag can be used with roll or slide animation. It is ignored when used with AW CENTER or AW BLEND.
0x00000001
AW HOR POSITIVE
0x00000002
AW HOR NEGATIVE
0x00000004
AW VER POSITIVE
0x00000008
AW VER NEGATIVE
Returns Boolean
2.28.2.13
Description Makes the window y at the corner of the screen. Syntax wnd.y(corner, direction, in[, time])
2.28 Window Object Parameters corner Integer. Species the corner of the screen. 0 1 2 3 lower-right upper-right upper-left lower-left
301
direction Integer. Species the direction 0 horizon 1 vertical 2 45-degree in Boolean. If true, the window will y in, otherwise y out. time Integer. Species the ying speed in millisecond. Returns Nothing
2.28.2.14
y2
Description Makes the window y. Syntax wnd.y2(x0, y0, x1, y1[, time]) Parameters x0, y0 Integer. Species the start position. x1, y1 Integer. Species the end position. time Integer. Species the ying speed in millisecond. Returns Nothing
Description Places the window at the center of the screen. Syntax wnd.center() Parameters None Returns Nothing
2.28.3
2.28.3.1
Events
onClose
Description Fires when the specied window is about to close. This event is red after the onQueryClose event. Syntax wnd.onClose = function () { body }
2.28.3.2
onQueryClose
Description Fires when the specied window is about to close. The event gives a chance to determine if the window is allowed to close. Syntax
2.28 Window Object wnd.onQueryClose = function () { body } The handler function must return a Boolean value. The value of true indicates that the window is allowed to close. While a return value of false indicates that the window is not allowed to close. Example wnd.onQueryClose = function () { var r = Dialogs.msgBox("Are you sure?", null, 36); if (r == 6) return true; return false; }
303
2.28.3.3
onEnter
Description Fires when the mouse has just entered the client area of the specied window. Syntax wnd.onEnter = function () { body } Remarks If you want to handle the onEnter event in a projector, dene a handler function for the Flash Player window like this. var fp = FlashPlayer.window(); fp.onEnter = function () { trace("mouse enter"); };
Description Fires when the mouse has just left the client area of the specied window. Syntax wnd.onLeave = function () { body } Remarks If you want to handle the onLeave event in a projector, dene a handler function for the Flash Player window like this. var fp = FlashPlayer.window; fp.OnLeave = function () { trace("mouse leave"); };
2.28.3.5
onHover
Description Fires when the mouse hovered over the client area of the specied window. Syntax wnd.onHover = function () { body }
305
Description Fires when the size of the window is changed. Syntax wnd.onSize = function(type, width, height) { body } Parameters type Integer. Species the type of resizing requested 0 The window has been resized, neither maximized nor minimized 1 The window has been minimized. 2 The window has been maximized. width Integer. Species the new width of the client area of the window. height Integer. Species the new height of the client area of the window.
2.28.3.7
onMessage
Description This event will be red whenever a message is sent to the window. Syntax wnd.onMessage = function(msg, wparam, lparam) { body } Parameters msg, wparam, lparam Please see Microsoft MSDN for more details: http://msdn2.microsoft.com/en-us/library/ms633573.aspx
306
2.29
FlashPlayer Object
Description Provides access to the Macromedia Flash Player. This object encapsulates all methods of the Macromedia Flash Player ActiveX object. Furthermore, This object provides a way to exchange data between the FFish Script and the Macromedia Flash ActionScript. available: SWFKit Express, SWFKit, SWFKit Pro Syntax new FlashPlayer Parameter None Returns Returns a new instance of the FlashPlayer object. Its a static object that can be used without construction. Remarks The object provides an easy way to exchange data between the FFish Script and the Macromedia Flash Action Script. The picture 2.2 describes the mechanism of the Data Exchanging. First, the bindData method binds the Action Script variables to the FlashPlayer object. The FlashPlayer Object maintains a property list, which contains properties with the same names as the bound Action Script variables. The FlashPlayer object transfers data between the bound Action Script variables and the corresponding properties.
2.29 FlashPlayer Object Second, the updateData method performs the exchanging. A call to the updateData method with a true argument transfers data from Action script to the FlashPlayer object. While a call to the updateData method with a false argument transfers data from the FlashPlayer object to Action Script. The updateData method transfers data all at once. The unbindData method unbinds Action Script variables. The unbindAll method unbinds all bound Action Script variables. The two methods make the FlashPlayer object to remove the corresponding properties. The FlashPlayer object only binds numbers, Booleans or strings. The bindData method only accepts variables specied in the dot syntax. Furthermore, remember to specify the full path of the variables. With the data exchange mechanism, you can access an Action script variable as if it is a property of the FlashPlayer object. The FlashPlayer object automatically converts the data types. The property name is exactly the same as the variable name you bind. For example, if you bind a variable named root.x, you must access it with expression FlashPlayer. root.x. The expression FlashPlayer.x does not work, though root.x and x species the same variable in Action Script. Example var pla = new FlashPlayer; pla.bindData("_root.x", "_root.y", "_root.w", "_root.h", "_root.play_area.text", "_root.play_area.i"); pla.bindData("_root.play_area.name", "data"); pla.updateData(true); trace(pla._root.x); trace(pla._root.y); trace(pla._root.w); trace(pla._root.h); trace(pla._root.play_area.name); trace(pla._root.play_area.text); trace(pla._root.play_area.i); trace(pla.data);
307
2.29.1
2.29.1.1
Properties
totalFrames
Description
308
FFish Script Objects Reference Integer. Returns the total number of frames in the movie. Readonly.
Syntax FlashPlayer.totalFrames
2.29.1.2
playing
Description Boolean. Sets or gets the playing status of the movie. Syntax FlashPlayer.playing
2.29.1.3
quality
Description Integer. Sets or gets the quality of the movie. 1 high 2 medium 3 low Syntax FlashPlayer.quality
2.29.1.4
scaleMode
Description Integer. Sets or gets the scale mode of the movie. Syntax FlashPlayer.scaleMode
309
Description Integer. Sets or gets the align mode of the movie. Syntax FlashPlayer.alignMode
2.29.1.6
backgroundColor
Description Integer. Sets or gets the background color of the movie. Syntax FlashPlayer.backgroundColor
2.29.1.7
loop
Description Boolean. Sets or gets the loop status of the movie. Syntax FlashPlayer.loop
2.29.1.8
movie
Description String. Sets or gets the full path and name of the movie. Syntax FlashPlayer.movie Example FlashPlayer.movie = getAdditionalFile("1.swf");
Description Integer. Sets or gets the current frame number of the movie. Syntax FlashPlayer.frameNum
2.29.1.10
wmode
Description String. Sets or gets the window mode of the movie. Syntax FlashPlayer.wmode
2.29.1.11
salign
Description String. Sets or gets the align mode of the movie. Syntax FlashPlayer.salign
2.29.1.12
base
Description String. Sets or gets the base of the movie. Syntax FlashPlayer.base
311
Description String. Sets or gets the scale mode of the movie. Syntax FlashPlayer.scale
2.29.1.14
bgColor
Description String. Sets or gets the background color of the movie. Syntax FlashPlayer.bgColor
2.29.1.15
showPrintDlg
Description Boolean. This property controls whether the ash player will launch the print dialog when it is about to process a print something. Generally when you call a print method in Action script, the Flash Player will launch the print dialog for the users to choose a printer to print. If this property is set to false, no print dialog will be launched, and the system default printer will be used to print. Syntax FlashPlayer.showPrintDlg
2.29.1.16
printerProperties
Description Object. When the showPrintDlg is set to false, you can use this property to set the printer properties such as orientation and paperSize. This property is eective only if the showPrintDlg property is set to false. When FlashPlayer.printerProperties.orientation is set to 1, the orientation of the paper will be portrait; if it is set to 2, the orientation will be landscape. The meaning of the FlashPlayer.printerProperties.paperSize property is the same as that of the Printer.paperSize, the only dierence is that the former property is used to control the printer used by the ash player, while the latter is to control the printer used by swfkit.
2.29.2
2.29.2.1
Methods
bindData
Description Binds Action Script variables to the FlashPlayer Object Syntax FlashPlayer.bindData(var0 , var1 , . . . , varn ) Parameters var0 , var1 , . . . , varn Species the names of the Action Script variables to bind. Returns Nothing Example FlashPlayer. bindData("text", "movieClip1.x");
2.29.2.2
unbindData
Description Unbinds Action Script variables. Syntax FlashPlayer.unbindData(var0 , var1 , . . . , varn ) Parameters var0 , var1 , . . . , varn Species the names of the Action Script variables to unbind. Returns Nothing Example FlashPlayer. unbindData("text", "movieClip1.x");
313
Description Unbinds all Action Script variables. Syntax FlashPlayer.unbindAll() Parameters None Returns Nothing Example FlashPlayer.unbindAll();
2.29.2.4
updateData
Description Transfers data between bound Action Script variables and FlashPlayer properties. Syntax FlashPlayer.updateData(get) Parameters get Boolean. If true, data transfer from the bound Action Script variables to the corresponding FlashPlayer properties. Otherwise, transfer from the FlashPlayer variables to the corresponding bound Action Script variables. Returns Nothing Example FlashPlayer. bindData("text", "movieClip1.x"); FlashPlayer.updateData(true); trace(FlashPlayer.text); trace(FlashPlayer.movieClip1.x); FlashPlayer.text = "New text"; FlashPlayer.updateData(false); FlashPlayer. unbindData("text", "movieClip1.x");
Description Gets an array from Action Script. Syntax FlashPlayer.getArray(name) Parameters name Species the name of the array to retrieve. Returns An array Example FlashPlayer.getArray("_root.array0");
2.29.2.6
putArray
Description Puts an array into Action Script. Syntax FlashPlayer.putArray(name, value) Parameters name Species the name of the array to set its value. value An Array object. The value to set. Returns Nothing Example var array0 = [1, 2, 3]; FlashPlayer.putArray("_root.array0", array0); Notice: The root.array0 must have been dened as an array in Action Script explicitly.
315
Description Gets an object from Action Script. Syntax FlashPlayer.getObject(name, prop0[, prop1, ..., propn]) Parameters name Species the name of the object to retrieve. prop0...propn Species the name of the properties of the object. Returns An object Example FlashPlayer.getObject("_root.obj0", "prop0", "prop1");
2.29.2.8
putObject
Description Puts an object into Action Script. Syntax FlashPlayer.putObject(name, value) Parameters name Species the name of the object to set its value. value An object object. The value to set. Returns Nothing Example var obj = new Object; obj.value = "string"; obj.name = 1.24; FlashPlayer.putObject("_root.obj", obj); Notice: The root.obj must have been dened as an object in Action Script explicitly.
Description Zooms in on a rectangular area of the movie. Syntax FlashPlayer.setZoomRect(left, top, right, bottom) Parameters left, top, right, bootom Species the coordinates of the rectangle. The units of the coordinates are in twips (1440 units per inch). variables. Returns Nothing Example var pointsToTwips = 20; FlashPlayer.setZoomRect(0, 0, 200 * pointsToTwips, 200 * pointsToTwips);
2.29.2.10
zoom
Description Zooms the movie by a relative scale factor specied by percent. Syntax FlashPlayer.zoom(percent) Parameters percent Species the scale factor. Returns Nothing Example FlashPlayer.zoom(200);
317
Description Pans a zoomed-in movie. specied by x and y. Use mode to specify whether the values for x and y are pixels or a percent of the window. When mode is 0, the coordinates are pixels; when mode is 1, the coordinates are percent of the window. Pan does not pan beyond the boundaries of the zoomed-in movie. Syntax FlashPlayer.pan(x, y, mode) Parameters x, y Species the coordinates to pan. mode Species whether the values for x and y are pixels or a percent of the window. When mode is 0, the coordinates are pixels; when mode is 1, the coordinates are percent of the window. Returns Nothing
2.29.2.12
play
Description Starts playing the movie. Syntax FlashPlayer.play() Parameters None Returns Nothing
Description Stops playing the movie. Syntax FlashPlayer.stop() Parameters None Returns Nothing
2.29.2.14
back
2.29.2.15
forward
319
Description Goes to the rst frame. Syntax FlashPlayer.rewind() Parameters None Returns Nothing
2.29.2.17
gotoFrame
Description Goes to the specied frame. Syntax FlashPlayer.gotoFrame(frame) Parameters frame Species the frame number. Example FlashPlayer.gotoFrame(24);
Returns Nothing
Description Returns the current frame number. Syntax FlashPlayer.currentFrame() Parameters None Returns Integer
2.29.2.19
isPlaying
Description Returns true if the movie is currently playing. Syntax FlashPlayer.isPlaying() Parameters None Returns Boolean
2.29.2.20
percentLoaded
Description Returns the percent of the movie that has streamed into the player so far; possible values are from 0 to 100. Syntax FlashPlayer.percentLoaded() Parameters None Returns Integer
321
Description Returns the version of the Flash Player. Syntax FlashPlayer.ashVersion() Parameters None Returns Integer
2.29.2.22
loadMovie
Description Loads the specied movie. Syntax FlashPlayer.loadMovie(layerNumber, movie) Parameters layerNumber Species the layer number movie Species the movie to load. Example FlashPlayer.loadMovie(1, "c:\\test.swf");
Returns Nothing
Description Sets the value of the specied variable. Syntax FlashPlayer.setVariable(name, value) Parameters name Species the name of the variable value Species the value to set. Example FlashPlayer.setVariable("_root.var0", "myvalue"); Returns Nothing
2.29.2.24
getVariable
Description Gets the value of the specied variable. Syntax FlashPlayer.getVariable(name) Parameters name Species the name of the variable Example trace(FlashPlayer.getVariable("_root.var0")); Returns String
323
Description For the timeline of the specied target, goes to the specied frame. Syntax FlashPlayer.targetGotoFrame(target, framenumber) Parameters target Species the target framenumber Species the frame number to go. Example FlashPlayer.targetGotoFrame("_root", 24); Returns Nothing
2.29.2.26
targetGotoLabel
Description For the timeline of the specied target, goes to the specied label. Syntax FlashPlayer.targetGotoLabel(target, label) Parameters target Species the target label Species the label to go. Example FlashPlayer.targetGotoLabel("_root", "label"); Returns Nothing
Description Gets the current frame number of the specied target. Syntax FlashPlayer.targetCurrentFrame(target) Parameters target Species the target Returns Integer
2.29.2.28
targetCurrentLabel
Description Gets the current frame label of the specied target. Syntax FlashPlayer.targetCurrentLabel(target) Parameters target Species the target Returns String
2.29.2.29
targetPlay
Description Starts playing the specied target. Syntax FlashPlayer.targetPlay(target) Parameters target Species the target Returns Nothing
325
Description Stops playing the specied target. Syntax FlashPlayer.targetStopPlay(target) Parameters target Species the target Returns Nothing
2.29.2.31
targetGetProperty
Description For the timeline of the specied target, gets the specied property. Syntax FlashPlayer.targetGetProperty(target, property) Parameters target Species the target property Integer. Species the property to get. Remarks The property can be one of the following values: 0 X POSITION ( x) 1 Y POSITION ( y) 2 X SCALE 3 Y SCALE 4 CURRENTFRAME 5 TOTALFRAMES 6 ALPHA 7 VISIBILITY
326 8 9 10 11 12 13 14 15 Returns String Example Gets alpha property of level0 WIDTH HEIGHT ROTATION TARGET FRAMESLOADED NAME DROPTARGET URL( url)
FlashPlayer.targetGetProperty("_root", 6);
2.29.2.32
targetSetProperty
Description For the timeline of the specied target, sets the value of the specied property. See: targetGetProperty Syntax FlashPlayer.targetSetProperty(target, property, value) Parameters target Species the target property Species the property to set. value String. Species the value to set Returns Nothing Example Sets alpha property of level0 to 50 FlashPlayer.targetSetProperty("_root", 6, "50");
327
Description For the timeline of the specied target, executes the action in the specied frame. Syntax FlashPlayer.targetCallFrame(target, framenumber) Parameters target Species the target framenumber Species the frame number to call. Returns Nothing
2.29.2.34
targetCallLabel
Description For the timeline of the specied target, executes the action in the frame specied by label. Syntax FlashPlayer.targetCallLabel(target, label) Parameters target Species the target label Species the frame label. Returns Nothing
Description For the timeline of the specied target, gets the specied property. See: targetGetProperty. This method returns a number. Syntax FlashPlayer.targetGetPropertyNum(target, property) Parameters target Species the target property Species the property to get. Returns Number
2.29.2.36
targetSetPropertyNum
Description For the timeline of the specied target, sets the value of the specied property. See: targetSetProperty. This method sets the property with a oat number. Syntax FlashPlayer.targetSetPropertyNum(target, property, value) Parameters target Species the target property Species the property to set. value Float. Species the value to set Returns Nothing
329
Description Retrieves information of a movie, include frame size, frame rate, version, etc. Syntax FlashPlayer.getMovieInfo(movie) Parameters movie String. Full path name of the movie to retrieve information Returns An object contains the following properties frameSize Object. Represents the frame size of the movie, contains the xMin, xMax, yMin and yMax properties. rate Integer. Represents the frame rate of the movie. size Integer. Represents the size of the movie. frameCount Integer. Represents the frame count of the movie. version Integer. Represents the version of the movie. Returns null if the method fails.
2.29.2.38
movieToWindow
Description Converts a rectangle from the movie coordinates system to the windows client coordinates system Syntax FlashPlayer.movieToWindow(left, right, top, bottom) Parameters left A number species the x-coordinate of the upper-left corner of the rectangle right A number species the x-coordinate of the lower-right corner of the rectangle.
330
FFish Script Objects Reference top A number species the y-coordinate of the upper-left corner of the rectangle
bottom A number species the y-coordinate of the lower-right corner of the rectangle Returns An object with the properties left, top, right, and bottom Example The example shows how to place an ActiveX control onto a MovieClip. //Providing the name of the MovieClip is "mymovie". //Get the placement of the MovieClip //in the Action Script: var pos = mymovie.getBounds(); //Then converts the placement to //the windows client coordinates //system in the FFish Script: FlashPlayer.bindData("pos.xMin", "pos.yMin", "pos.xMax", "pos.yMax"); FlashPlayer.updateData(true); var rect = FlashPlayer.movieToWindow( FlashPlayer.pos.xMin, FlashPlayer.pos.xMax, FlashPlayer.pos.yMin, FlashPlayer.pos.yMax); var mp = createControl("MediaPlayer.MediaPlayer.1"); mp.window.left = rect.left; mp.window.top = rect.top; mp.window.width = rect.right - rect.left; mp.window.height = rect.bottom - rect.top;
2.29.3
2.29.3.1
Events
onContextMenu
331
2.30
RegExp Object
Description Contains a regular expression pattern used when searching strings for character combinations. available: SWFKit Express, SWFKit, SWFKit Pro Syntax 1. /pattern/[switch] 2. new RegExp(pattern, [switch]) Parameters pattern The regular expression pattern to use switch Optional. Available switches are: i g m gi Example r = /ab+/gi; s = "abbdabbcabdaBa"; trace(r.exec(s));//output: abb re = new RegExp("d(b+)(d)","ig"); str = "cdbBdbsbdbdz"; trace(re.exec(str));//output: dbBd,bB,d Remarks The following table describes the subexpression meanings of a regular expression when used for pattern matching: ignore case global search for all occurrences of pattern multiline global search, ignore case
332
Subexpression literal character . Matched Text
Any source character which is a ReLiteralCharacter. Any character except newline. Start of string. The matched substring must begin with the the rst character of the string (after the portion ignored as specied by lastIndex). This character is only special when it appears as the rst character of the regular expression. End of string. The matched substring must end with the the last character of the string. This character is only special when it appears as the last character of the regular expression. Zero or more consecutive matches with subexpression x. The matched substrings need not be identical. One or more consecutive matches with subexpression x. The matched substrings need not be identical. Zero or one consecutive matches with subexpression x. Exactly n consecutive matches with subexpression x. At least n consecutive matches with subexpression x. At least m and at most n consecutive matches with subexpression x. Exactly n consecutive matches with subexpression x. The same pattern as subexpression x. The matched substring is available for use in a subsequent \n pattern. The subexpression x followed by the subexpression y. Either of the subexpressions x or y. Any character in pqr, which is a sequence of one or more source characters and/or subranges of the form s-t. If the Unicode encoding of s is greater than the Unicode encoding of t, a runtime error is generated. Only the characters , -, ] and need to be escaped when intended as literal characters. The character need be escaped only if it is the rst character in pqr. The C character need not be escaped if it is the rst or last character, or if it immediately follows a subrange. The escape sequences have their usual meanings except for \b which matches the backspace character; \B which matches B; and, for subranges only, \d, \D, \s, \S, \w and\W, which match d, D, s, S, w and W, respectively. Any character not matched by [pqr], including newline if pqr does not contain newline. continued on next page
[qr] p
333
Any whitespace character; equivalent to [\f\n\r\t\v]. Any non-whitespace [\f\n\r\t\v]. character; equivalent to
Any decimal digit; equivalent to [0-9]. Any character except a decimal digit; equivalent to [09]. Any character valid in an identier; equivalent to [a-zAZ0-9 ]. Any character not valid in an identier; equivalent to [a-zA-Z0-9 ]. Word boundary: a zero-length substring which is bounded on one side by a character which matches \w and on the other side by a character which matches \W or the start of the string or the end of the string. Non-word boundary: a zero-length substring which does not match \b. The character formed by an exclusive OR of the character code with 64. Either an OctalEscapeSequence or a backreference equivalent to the exact substring most recently matched by the nth parenthesized subexpression, as determined by the opening left parenthesis of each such subexpression. If n begins with 0, or if the value of n (when parsed and converted as DecimalDigits) is greater than 9 and also greater than the number of parenthesized subexpressions, then \n is an OctalEscapeSequence; otherwise \n is a backreference. If there is no corresponding parenthesized subexpression, or if the subexpression does not participate in the match (because of the | operator or a zero count), \n is treated as the empty string. continued on next page
\B \cX \n
334
continued from the previous page Subexpression Matched Text
If the ignoreCase property is true (this property is set by the switch parameter of the constructor) when a pattern match is performed, any letters in the string are matched without considering distinctions between uppercase and lowercase. An empty pattern matches the start of any string including the empty string. The match and search method of String object modify the properties of RegExp just like the exec method of RegExp Object.
2.30.1
2.30.1.1
Properties
source
Description Contains the text of the regular expression pattern. Read-only. Syntax rgexp.source
2.30.1.2
global
Description It is a boolean value indicating whether the most recently specied ags contained the character g. Read-only. Syntax rgexp.global
2.30.1.3
ignoreCase
Description It is a boolean value indicating whether the most recently specied ags contained the character i. Read-only. Syntax rgexp. ignoreCase
335
Description A boolean value indicating whether to perform a newline-sensitive matching Syntax rgexp. multiline
2.30.1.5
lastIndex
Description It is an integer which species the string position at which to start the next match. The lastIndex is modied by the exec or test method when the global property is true. The following rules apply to values of lastIndex: If lastIndex is greater than the length of the string, the test and exec methods fail, and lastIndex is set to zero. If lastIndex is equal to the length of the string, the regular expression matches if the pattern matches the empty string. Otherwise, the match fails and lastIndex is reset to zero. Otherwise, lastIndex is set to the next position following the most recent match. Syntax rgexp.lastIndex
2.30.1.6
input (or $ )
Description Species the most recent string against which a regular expression was matched. Read-only. Static Syntax 1. rgexp.input 2. rgexp.$
Description Species the substring matched in the most recent regular expression match. Read-only. Static Syntax rgexp.lastMatch
2.30.1.8
leftContext
Description Species the portion of the input string which precedes the matched substring in the most recent regular expression match.. Read-only. Static Syntax rgexp. leftContext
2.30.1.9
rightContext
Description Species portion of input string which follows the matched substring in the most recent regular expression match. Read-only. Static Syntax rgexp. rightContext
2.30.1.10
$1 . . . $9
Description Species the substrings matched by the corresponding parenthesized subexpressions in the most recent regular expression match. Readonly. Static Syntax rgexp.$n($1 . . . $9)
2.30 RegExp Object Example re = new RegExp("d(b*)(d)","gi"); str = "cdbBdbsbdbdzdd"; trace(re.exec(str));//output: dbBd,bB,d trace(re.$1);//output: bB trace(re.$2);//output: b
337
2.30.1.11
lastParen
Description Species the substring matched by the last parenthesized subexpression in the most recent regular expression match. Read-only. Static Syntax rgexp. lastParen
2.30.2
2.30.2.1
Methods
compile
Description Compiles a regular expression. Using this method to change the search string dynamicly. Syntax rgexp.compile(pattern, [switch]) Parameters pattern The regular expression pattern to use switch Optional. Available switches are: i ignore case g global search for all occurrences of pattern m multiline gi global search, ignore case Returns A Boolean value, true for success, false for failure
Description Executes a search for a match in a specied string. Syntax rgexp.exec(str) Parameters str The string to perform a search on Returns An array contains the matches
2.30.2.3
test
Description Tests whether a pattern exists in a string. Syntax rgexp.test(str) Parameters str The string to perform a search on Remarks Returns The test method checks to see if a pattern exists within a string and returns true if so, and false otherwise.
2.31
ActiveXObject Object
Description Enables and returns a reference to an ActiveX object. available: SWFKit, SWFKit Pro Syntax
2.31 ActiveXObject Object new ActiveXObject(class | clsid | path) Parameters class This parameter uses the syntax server.type, the meaning of each part is: server The name of the application providing the object. type The type or class of the object to create. clsid The CLSID of the object to create path Full path and name of the le containing the object to retrieve. Returns If Succeed, returns a new instance of the ActiveXObject object that represents a reference to the corresponding ActiveX object. You can access any properties, methods and evens of the ActiveX object with the new instance. If failed, return null. Remarks You can access properties, methods and evens exposed by the ActiveX object just as invoke a method provides by any FFish Script Objects. Dont worry about the details of COM interfaces, Variable types. FFish Script checks and converts variable types automatically. FFish Script supports ActiveX object events. Events are methods dened in the outgoing interfaces of the ActiveX objects used to notify its client of events. You can dene an event handling function and set to the event you care about. FFish Script Engine calls the function when the ActiveX object res the event. FFish Script also provides two static methods register and unregister to register or unregister an ActiveX object. Examples
339
//Example1 - create an ActiveXObject by specified a class name word = new ActiveXObject("word.application"); word.Visible = true; trace(word.Visible); word.Documents.Add(); word.Selection.TypeText("This is a test..."); word.Documents[1].SaveAs("c:\\test.doc"); word.Quit(); //Example2 - create an ActivexObjext from file doc = new ActiveXObject("c:\\test.doc"); doc.SaveAs("c:\\test1.doc");
340
2.31.1
2.31.1.1
Methods
register
Description Registers an ActiveX Object. Syntax ActiveXObject.register(pathname) Parameters pathname Full path and name of the ActiveX server module to register Returns Boolean. If the ActiveX is successfully registered, returns true. Otherwise returns false. Example ActiveXObject.register("D:\\Program Files\\Demo\\Demo.dll");
2.31.1.2
unregister
Description Unregisters an ActiveX Object. Syntax ActiveXObject.unregister(pathname) Parameters pathname Full path and name of the ActiveX server module to unregister Returns Boolean. If the ActiveX is successfully unregistered returns true. Otherwise returns false. Example ActiveXObject.unregister("D:\\Program Files\\Demo\\Demo.dll");
341
Description Sets value of the specied property. This method is useful when a property of the ActiveX object requires parameters. In that case, you can not set value of the property by using syntax like activex.property = value;, as syntax like activex.property(arg) = value; is not supported. However, there is no method like getProperty, as you can get value of such a property by using var value = activex.getProperty(arg);; Syntax ActiveXObject.setProperty(propertyName, arg1, ..., argN) Parameters propertyName The name of the property to set its value arg1, ..., argN The arguments for the property Returns Nothing
2.31.1.4
addObjectInfo
Description Adds information of an ActiveX object to SWFKit, so that it can be accessed by sh script without registering the ActiveX object in Windows Registry. Generally, an ActiveX object must be registered in Windows Registry before it can be accessed by any programming language. However, the registration requires administrator privilege; it is inconvenient to use an ActiveX object in an application that will run from a CD-ROM, therefore. The method resolves the problem, and it can only add information for in-proc ActiveX server dlls. Static. Syntax ActiveXObject.addObjectInfo(pathname, progid, clsid, typelib) Parameters pathname Full path and name of the ActiveX server module to add information.
342
progid The progid of the ActiveX object. An activex server may contain more than one activex objects, and every activex object has its progid. A progid is used to identify an activex object, so that the command new ActiveXObject(progid); will know which activex object to create. clsid Class identier (CLSID) of the object. The activex server uses this class identier to create the object requested. When you call new ActiveXObject(progid);, the sh script engine will have to nd out the corresponding class identier for the progid to create the requested object. If the activex object has been registered, the class identier can be found in Windows Registry; if it is not registered, the sh script engine will use the class identier added by the addObjectInfo method. The sh script engine holds progid-clsid pairs for the activex objects added by the addObjectInfo method. For an activex object that is not registered, the progid can be a unique string specied by yourself, not the original one of the activex object, only if you pass the customized unique progid to the constructor of the ActiveXObject object, as from the progid-clsid pairs, the sh script engine can still nd out the proper class identier. To get the class identier of an activex object, you can use the COM/OLE object viewer, which can be found at http://www.swfkit.com/swfkit/download.html#tools First, use the COM/OLE object viewer to open the ActiveX server dll by using the menu command File >View TypeLib..., for example, the ash.ocx. It will open the ITypeLib viewer. Then click the coclass item of the activex object in the left type tree, for example coclass ShockwaveFlash, and on the top of right window, the uuid is the class identier for the activex object: {D27CDB6E-AE6D-11CF-96B8-444553540000}. As you can see, an ActiveX server may contains more than one activex object, and each activex object has its unique class identier. typelib Identier of the type library of the activex object. Just like nding the class identier of an ActiveX object, after you have opened the ITypeLib viewer, on top of the right window, you will nd comments like // Generated .IDL file (by the OLE/COM Object Viewer) // // typelib filename: Flash9c.ocx , and the followed uuid {D27CDB6B-AE6D-11CF-96B8-444553540000} is the identier of the type library. Returns
2.31 ActiveXObject Object Boolean. If the information of the activex object is added successfully, returns true; otherwise, returns false. Example
343
ActiveXObject.addObjectInfo(getAdditionalFile("sqlite3.dll"), "LiteX.LiteConnection", "{3E22694D-7B92-42A1-89A7-668E2F7AA107}", "{10770BEB-5AFA-4851-B68E-EE891F3DEE7F}"); ActiveXObject.addObjectInfo(getAdditionalFile("sqlite3.dll"), "LiteX.LiteStatement", "{453A51CC-F944-4643-9540-A78253B8019C}", "{10770BEB-5AFA-4851-B68E-EE891F3DEE7F}"); var lc = new ActiveXObject("LiteX.LiteConnection"); lc.path = getAdditionalFile("nwind.db"); lc.open();
2.31.2
Description FFish Script supports ActiveX Object events. Events are methods dened in the outgoing interfaces of the ActiveX Objects used to notify its client of events. You can dene an event handling function and set to the event you care about. FFish Script Engine calls the function when the ActiveX Object res the event. Example //Example: handle events when connect to databasedb_name = "mydb"; function on_will_connect() { trace("Will connect to " + db_name + "..."); } function on_connect_complete() { trace("Connect to " + db_name + " complete!"); } var conn = new ActiveXObject("ADODB.Connection"); conn.WillConnect = on_will_connect; conn.ConnectComplete = on_connect_complete; conn.Open(db_name);
344 conn.Close(); //output: Will connect to mydb... Connect to mydb complete! Remarks
FFish Script also supports ActiveX Object property notications. The property notications are sent when the ActiveX Objects changes or are about to change their properties that are marked with [Binable] and [RequestEdit] attributes. The ActiveXObject object provides users with there property to handle these notications: 1. EnablePropertyNotify 2. OnPropertyChanged 3. OnPropertyWillChange
2.31.2.1
EnablePropertyNotify
Description This property represents a Boolean value. If you want to receive the property notication, set this property to true. Otherwise set to false. The default value of this property is false.
2.31.2.2
OnPropertyChanged
Description This property represents a Boolean value. If you want to receive the property notication, set this property to true. Otherwise set to false. The default value of this property is false.
2.31.2.3
OnPropertyWillChange
Description This property represents a Boolean value. If you want to receive the property notication, set this property to true. Otherwise set to false. The default value of this property is false.
345
Description This event will be triggered when the sh script engine encounters an error when accessing an ActiveX object. Static. Syntax ActiveXObject.onError = function (errorMessage)
2.32
Enumerator Object
Description Enumerate items in a collection object. available: SWFKit Express, SWFKit, SWFKit Pro Syntax new Enumerator(collection) Parameters collection A collection object created or returned by ActiveXObject object. Remarks You can access collections the members of which are not directly accessible. You can also access some collections by using indexes, as if you are working with an array. If you use Enumerator, you can only move the current item pointer to the rst or next element of a collection. Examples //The example shows the two different //ways of accessing collections. var conn = new ActiveXObject("ADODB.Connection"); conn.Open("zqz"); var rs = conn.Execute("SELECT * FROM Topics"); var e = new Enumerator(rs.Fields); var i = 0; for (; !e.atEnd(); e.moveNext()) {
conn.Close(); var conn = new ActiveXObject("ADODB.Connection"); conn.Open("zqz"); var rs = conn.Execute("SELECT * FROM Topics"); var i; for (i = 0; i < rs.Fields.Count; i++) { var fld = rs.Fields[i]; trace(fld.Name); } conn.Close();
2.32.1
2.32.1.1
Properties
atEnd
Description Returns a Boolean value indicating if the enumerator is at the end of the collection. Syntax Enum.atEnd() Returns Returns true if the current item is the last one in the collection. Otherwise, it returns false.
2.32.1.2
item
2.32 Enumerator Object Returns The item method returns the current item. If the collection is empty or the current item is undened, it returns undened.
347
2.32.2
2.32.2.1
Methods
moveFirst
Description Resets the current item in the collection to the rst item. Syntax Enum.moveFirst( ) Returns Nothing
2.32.2.2
moveEnd
Description Moves the current item to the end in the collection. Syntax Enum.moveEnd( ) Returns Nothing
2.32.2.3
moveNext
Description Moves the current item to the next item in the collection. Syntax Enum.moveNext( ) Returns Nothing
348
2.33
RegKey Object
Description Access windows registry. available: SWFKit, SWFKit Pro Syntax new RegKey(keyname) Parameters keyname Species the key name of the registry. This parameter must begin with a predened key name; follow with a series of backslash ( and sub key name groups. The predened key names are: ) Name Meaning HKCR HKEY CLASSES ROOT HKCC HKEY CURRENT CONFIG HKCU HKEY CURRENT USER HKLM HKEY LOCAL MACHINE HKU HKEY USERS HKPD HKEY PERFORMANCE DATA HKDD HKEY DYN DATA Remarks If the registry key specied by the keyname parameter has been successfully opened, a new instance of the RegKey object is created. Otherwise, the constructor returns null. Example r = new RegKey("HKCU\\Software\\Demo1"); d = new Date(r.lastWriteTime); trace(d.toLocaleString());
2.33.1
2.33.1.1
Properties
className
349
2.33.1.2
newCreated
Description Determines whether the key is new created by method create. Readonly Syntax Regkey.newCreated Returns If the key is a new created key, returns true. If the key is already exists and opened by the create method, return false.
2.33.1.3
lastWriteTime
Description Gets the last write time of the key. (For NT, 2000, XP only. Win 9x does not keep track of registry key last write time information). Read-only Syntax Regkey.lastWriteTime Returns An integer represents milliseconds since midnight, 1970, 1, 1.
350
2.33.2
2.33.2.1
Methods
create
Description Create or open a registry key. Static Syntax Regkey.create(keyname[, class[, samDesired]]) Parameters keyname Species the key name of the registry. If keyname begins with a predened key, it denes an absolute key name. The predened key names are: Name Meaning HKCR HKEY CLASSES ROOT HKCC HKEY CURRENT CONFIG HKCU HKEY CURRENT USER HKLM HKEY LOCAL MACHINE HKU HKEY USERS HKPD HKEY PERFORMANCE DATA HKDD HKEY DYN DATA Otherwise, keyname denes a sub key of Regkey. class Optional. Species the class name of the key. SamDesired Optional. Species an access mask that species the desired security access for the new key. This parameter can be a combination of the following values:
Value 0 Name KEY ALL ACCESS Meaning Combination of KEY QUERY VALUE, KEY ENUMERATE SUB KEYS, KEY NOTIFY, KEY CREATE SUB KEY, KEY CREATE LINK, and KEY SET VALUE access Permission to create a symbolic link Permission to create subkeys Permission to enumerate subkeys Permission for read access Permission for change notification Permission to query subkey data Combination of KEY QUERY VALUE, KEY ENUMERATE SUB KEYS, and KEY NOTIFY access Permission to set subkey data Combination of KEY SET VALUE and KEY CREATE SUB KEY access
1 2 3 4 5 6 7
CREATE LINK CREATE SUB KEY ENUMERATE SUB KEYS EXECUTE NOTIFY QUERY VALUE READ
8 9
Returns If the key specied by the keyname already exists, it opens the key and returns a new instance of the RegKey Object. Otherwise it creates a new key in the registry and returns a new instance of the RegKey Object. If failed, returns null.
2.33 RegKey Object Example r = new RegKey("HKCU\\Software\\Demo1"); //create a sub key of r sub = r.create("subkey"); //creates "HKCU\Software\Demo1\subkey" //create a key under HKEY_CURRENT_USER sub2 = r.create("HKCU\\Software\\Demo2"); sub3 = RegKey.create("HKCU\\Software\\Demo2"); sub4 = RegKey.create("subkey"); //returns null because there is no root for "subkey"
351
2.33.2.2
open
Description Opens a windows registry key. Static Syntax Regkey.open(keyname) Parameters keyname Species the key name of the registry. If keyname begins with a predened key, it denes an absolute key name. The predened key names are: Name Meaning HKCR HKEY CLASSES ROOT HKCC HKEY CURRENT CONFIG HKCU HKEY CURRENT USER HKLM HKEY LOCAL MACHINE HKU HKEY USERS HKPD HKEY PERFORMANCE DATA HKDD HKEY DYN DATA Otherwise, keyname denes a sub key of Regkey. Returns If the registry key specied by the keyname parameter has been successfully opened, a new instance of the RegKey object is created. Otherwise, returns null. Example
352
FFish Script Objects Reference r = RegKey.open("HKCU\\Software\\Demo1"); sub = r.open("subkey"); sub2 = RegKey.open("subkey"); //returns null because "subkey" has no root.
2.33.2.3
getSubkeyNames
Description Gets the sub key names. This method gets all sub key names then puts into an array as the result. Syntax Regkey.getSubkeyNames() Parameters None Returns An array of String Objects. Example r = RegKey.create("HKCU\\Software\\Demo1"); for (i = 0; i < 5; i++) { r.create("subkey" + i); } names = r.getSubkeyNames(); trace(names);//output: subkey0,subkey1,subkey2,subkey3,subkey4
353
Description Gets values under the key. This method gets all values under the key then puts into an array as the result. FFish Script uses RegValue object to represent the values of the registry key. Syntax Regkey.getValues() Parameters None Returns An array of RegValue Objects. Example r = RegKey.create("HKCU\\Software\\Demo"); values = r.getValues(); for (i = 0; i < values.length; i++) { trace("The value of " + values[i].name + " is " + values[i].data); }
2.33.2.5
getValue
Description Gets value under the key. Syntax Regkey. getValue ([name]) Parameters name Optional. Species the name of the value to retrieve. The method returns the default value if this parameter is not set.
354 Returns
A RegValue Object represents the value. Example var r = new RegKey("HKCU\\Software\\Demo"); var rv = r.getValue("test"); trace(rv.data);
2.33.2.6
write
Description Writes a value to the registry key. Syntax Regkey.write(value) Parameters value A RegValue Object contains value information you want to write. If the name property of value has not been set, The value is write to the default value. Returns Boolean. True for success, false for failure. Example rv = new RegValue; rv.name = "test"; rv.data = "This is a test"; rv.type = 1;//REG_SZ r = RegKey.create("HKCU\\Software\\Demo"); r.write(rv);
355
Description Deletes a registry key. The key to be deleted must not have sub keys. Static Syntax Regkey.deleteKey(keyname) Parameters keyname Species the key name of the registry. If keyname begins with a predened key, it denes an absolute key name. The predened key names are: Name Meaning HKCR HKEY CLASSES ROOT HKCC HKEY CURRENT CONFIG HKCU HKEY CURRENT USER HKLM HKEY LOCAL MACHINE HKU HKEY USERS HKPD HKEY PERFORMANCE DATA HKDD HKEY DYN DATA Returns Boolean. True for success, false for failure. Example r = RegKey.deleteKey("HKCU\\Software\\Demo1\\subkey1"); r = RegKey.create("HKCU\\Software\\Demo1"); r.deleteKey("subkey2"); Regkey.deleteKey("subkey3");//failed
2.33.2.8
deleteValue
name The value name of the registry key. Returns Boolean. True for success, false for failure. Example r = RegKey.create("HKCU\\Software\\Demo"); r.deleteValue("test");
2.34
RegValue Object
Description Represents value information of registry keys. available: SWFKit, SWFKit Pro Syntax new RegValue Parameters None Remarks Use this object to read values from registry keys or write values into the registry. It provides three properties that store the value information about name, data and type.
357
2.34.1
2.34.1.1
Properties
name
Description Represents the name of the value. If the name is empty string, it species the default value; Syntax Regvalue.name Returns String Example r = RegKey.create("HKCU\\Software\\Demo"); rv = new RegValue; rv.name = "test"; rv.data = "This is a test"; r.write(rv);
2.34.1.2
type
Description Species the type of information to be stored as the values data. The default type if REG SZ. Syntax Regvalue.type Remarks The value types are:
358
Name REG BINARY REG DWORD REG DWORD LITTLE ENDIAN
REG EXPAND SZ
359
2.34.1.3
data
Description Represents the data value. Syntax Regvalue.data Remarks When reads from the registry, FFish Script automatically converts the result for you. If the value type is REG BINARY, REG EXPAND SZ, REG SZ, REG RESOURCE LIST or REG LINK, this property returns a String. If the value type is REG DWORD or REG DWORD BIG ENDIAN, this property returns an integer. And if the value is of type REG MULTI SZ, it returns an array of string. When writes into the registry, this property accepts numbers, strings and arrays. If you want to write a DWORD value, store a number to this property. If you want to store a REG SZ value, assign a string to this property. And If you want to write a value of type REG MULTI SZ, make an array and set it to this property.
360 Example
//Writes a DWORD value rv = new RegValue; rv.name = "number"; rv.type = 4; rv.data = 1; r = RegKey.create("HKCU\\Software\\Demo"); r.write(rv); //Writes a String value rv = new RegValue; rv.name = "string"; rv.data = "Hello world"; r = RegKey.create("HKCU\\Software\\Demo"); r.write(rv); //Writes a multi string value a = ["data0", "data1", "data2"]; rv = new RegValue; rv.name = "multi_string"; rv.data = a; rv.type = 7; r = RegKey.create("HKCU\\Software\\Demo"); r.write(rv);
2.35
Ini Object
Description Access initialization les. available: SWFKit, SWFKit Pro Syntax new Ini(pathname) Parameters pathname Species the full path and name of initialization le.
361
2.35.1
2.35.1.1
Methods
getInt
Description Retrieves an integer associated with a key in the specied section of the initialization le. Syntax ini.getInt(section, key) Parameters section Species the section name of the initialization le. key Species the key name whose value is to be retrieved Returns Returns an integer if succeed. Otherwise returns undened.
2.35.1.2
getSection
Description Retrieves all of the keys and values for the specied section from the initialization le. The result is an array contains the key and value pairs. Syntax ini.getSection(section) Parameters section Species the section name of the initialization le. Returns Returns an array if succeed. Otherwise returns undened. Example ini = new Ini("win.ini"); x = ini.getSection("MCI Extensions"); for (i = 0; i < x.length; i++) trace(x[i]);
Description Retrieves the names of all sections in the initialization le. Syntax ini.getSectionNames() Parameters None Returns Returns an array of section names if succeed. Otherwise returns undened. Example var ini = new Ini("win.ini"); var names = ini.getSectionNames(); for (i = 0; i < names.length; i++) trace(names[i]);
2.35.1.4
getString
Description Retrieves a string from the specied section in the initialization le. Syntax ini.getString(section, key) Parameters section Species the section name of the initialization le. key Species the key name whose value is to be retrieved Returns Returns a string if succeed. Otherwise returns undened. Example var ini = new Ini("win.ini"); var s = ini.getString("Mail", "MAPI"); trace(s);
363
Description Replaces the keys and values under the specied section in the initialization le. Syntax ini.writeSection(section, key value pairs) Parameters section Species the section name of the initialization le. key value pairs Contains the new key names and associated values that are written to the named section. Must be an array. Returns Nothing Example //Read all sections from win.ini and write to demo.ini var ini = new Ini("win.ini"); var demo = new Ini("Demo.ini"); var sect_names = ini.getSectionNames(); var i; for (i = 0; i < sect_names.length; i++) { var sects = ini.getSection(sect_names[i]); demo.writeSection(sect_names[i], sects); }
2.35.1.6
writeString
Description Copies a string into the specied section of the specied initialization le. Syntax ini. writeString (section, key, value)
364 Parameters
section Species the section name of the initialization le. key Species the name of the key to be associated with a string value Species the string to be written to the le Returns Nothing
2.35.1.7
deleteSection
Description Deletes an entire section from the specied initialization le. Syntax ini.deleteSection(section) Parameters section Species the section name to be deleted. Returns Nothing
2.35.1.8
deleteKey
Description Deletes a key in the specied section from the initialization les. Syntax ini.deleteKey(section, key) Parameters section Species the section name. key Species the name of the key to be deleted Returns Nothing
365
2.36
FontObject Object
Description Represents the attributes of a font. Syntax new FontObject Parameters None
2.36.1
2.36.1.1
Properties
bold
2.36.1.2
color
2.36.1.3
italic
Description Boolean. Species an italic font if set to true. Syntax font. italic
Description String. Species the typeface name of the font. Syntax font. name
2.36.1.5
size
Description Integer. Species the point size of the font. Syntax font. size
2.36.1.6
underline
2.36.2
2.36.2.1
Methods
getFonts
Description Gets all font names in the system. Static Syntax font.getFonts([charset[, fontname]]) Parameters
2.37 Shortcut Object charset Optional. If this parameter is set, the method gets only fonts in the specied character set. It can be set to one of the following values: Charset Value ANSI CHARSET 0 DEFAULT CHARSET 1 SYMBOL CHARSET 2 SHIFTJIS CHARSET 128 HANGEUL CHARSET 129 HANGUL CHARSET 129 GB2312 CHARSET 134 CHINESEBIG5 CHARSET 136 OEM CHARSET 255 JOHAB CHARSET 130 HEBREW CHARSET 177 ARABIC CHARSET 178 GREEK CHARSET 161 TURKISH CHARSET 162 VIETNAMESE CHARSET 163 THAI CHARSET 222 EASTEUROPE CHARSET 238 RUSSIAN CHARSET 204 MAC CHARSET 77 BALTIC CHARSET 186 fontname Optional. If this parameter is set, the method gets all fonts with the name specied by fontname. Returns If successfully gets the font names, returns an array of strings. Otherwise returns null. Example var font = new FontObject; var names = font.getFonts(0); trace(names); names = font.getFonts(0, "Arial"); trace(names);
367
2.37
Shortcut Object
Description
368
FFish Script Objects Reference Creates, opens and manipulates a shortcut. available: SWFKit, SWFKit Pro
Syntax new Shortcut(name); Parameters name Species the shortcut le name to open or create. Returns Returns a new instance of the Shortcut object represents the specied shortcut. If failed returns null. Remarks Use the method save to save any changes to the shortcut. Properties
2.37.1
2.37.1.1
Properties
arguments
Description Represents the parameters of the shortcut object. Syntax shortcut.arguments Example shortcut = new Shortcut("c:\\demo.lnk"); shortcut.targetPath = "notepad.exe"; shortcut.arguments = "tmp.txt"; shortcut.save();
369
Description Represents the description of the shortcut object. Syntax shortcut.description Example shortcut = new Shortcut("c:\\demo.lnk"); shortcut.description = "Its a test"; shortcut.save();
2.37.1.3
hotKey
Description Represents the hot key of the shortcut object. A hot key is a keyboard shortcut to start or switch to a program. Syntax shortcut.hotKey Example shortcut = new Shortcut("c:\\demo.lnk"); shortcut.hotKey = "ALT+CTRL+SHIFT+num 0"; shortcut.save();
2.37.1.4
iconLocation
Description Represents the icon location of the shortcut object. The format of the icon location should be Path,index. Syntax
2.37.1.5
targetPath
Description Represents the target path of the shortcut object. Syntax shortcut.targetPath Example shortcut = new Shortcut("c:\\demo.lnk"); shortcut.targetPath = "notepad.exe"; shortcut.arguments = "tmp.txt"; shortcut.save();
2.37.1.6
windowStyle
Description Represents the window style of the shortcut object. Syntax shortcut.windowStyle Remarks
2.37 Shortcut Object The window style of the shortcut object can be one of the following values: Values Description 0 Hides the window 1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position 2 Activates the window and displays it as a minimized window 3 Activates the window and displays it as a maximized window 4 Displays a window in its most recent size and position. The active window remains active 5 Activates the window and displays it in its current size and position 6 Minimizes the specied window and activates the next top-level window in the Z order 7 Displays the window as a minimized window. The active window remains active 8 Displays the window in its current state. The active window remains active 9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this ag when restoring a minimized window 11 Minimizes a window. For windows 2000, xp Example shortcut = new Shortcut("c:\\demo.lnk"); shortcut.windowStyle = 7; shortcut.save();
371
2.37.1.7
workingDirectory
Description Represents the working directory of the shortcut object. Syntax shortcut.workingDirectory
372 Example
2.37.2
2.37.2.1
Methods
save
Description Saves the shortcut object. Syntax shortcut.save() Parameters None Returns Nothing Example shortcut = new Shortcut("c:\\demo.lnk"); shortcut.targetPath = "notepad.exe"; shortcut.arguments = "tmp.txt"; shortcut.save();
2.38
URLShortcut Object
Description Creates, opens and manipulates a url shortcut. available: SWFKit, SWFKit Pro
2.38 URLShortcut Object Syntax new URLShortcut(name); Parameters name Species the url shortcut le name to open or create. Returns Returns a new instance of the URLShortcut object represents the specied shortcut. If failed returns null.
373
2.38.1
2.38.1.1
Properties
url
Description Represents the URL of the url shortcut object. Syntax urlshortcut.url Example shortcut = new URLShortcut("c:\\demo.url"); shortcut.url = "http://www.macromedia.com"; shortcut.save();
2.38.2
2.38.2.1
Methods
save
2.39
Mail Object
Description Handles a mail using the MIME (Multipurpose Internet Mail Extensions) protocol. available: SWFKit, SWFKit Pro Syntax new Mail Parameters None Returns Returns a new instance of the mail object. If failed, returns null. Remarks Using this object to read or write emails that sent or received via Internet. An Email can be viewed as having an envelope and contents. The envelope contains information about the email such as the sender, the recipients, the send time, etc. The contents compose the object to deliver to the recipients. The Mail Object supports multipart contents such as attachments and HTML contents. To write a new email, lling the envelope rst. The Mail Object provides some properties to setup the envelope. The following table describes the properties.
2.39 Mail Object Property from replyTo to subject cc bcc date priority Example mail = new Mail; mail.from = "abc@host.com"; mail.replyTo = "abc@host.com"; mail.to = "someone@server.com"; mail.subject = "A test"; mail.cc = "someoneelse@anotherserver.com"; mail.bcc = "anotherone@bccserver.com"; mail.date = Date(); mail.priority = 3; mail.text = "test!"; mail.save("c:\\test.eml"); After lling the envelope, adding contents to the email. Adding plain texts Using the text property. mail.text = plain\_text\_message; Adding attachments Using the addAttachment method. mail. addAttachment("c:\\attach.zip"); Adding html contents Using the html property and the addHtmlItem method. Using the html property to set the text source of the html contents. Other contents such as images can be added by using the addHtmlItem method. Description Identies the sender of the email Species the mailbox to which responses are to be sent Identies the primary recipients of the email. Species the subject of the email. Identies the secondary (informational) recipients of the email Identies the additional recipients of the email. Species the send date. Species the priority of the email.
375
376
FFish Script Objects Reference Using the save method to store the email to the disk. Using the SendMail object to send it. You can also use the Mail object to read an email. For example: mail = new Mail(); mail.load("c:\\test.eml"); trace("From: " + mail.from); trace("To: " + mail.to); trace("Subject: " + mail.subject); trace("Date: " + mail.date); trace(mail.text); trace("htmlitems: " + mail.htmlItemCount); for (i = 0; i < mail.htmlItemCount; i++) { trace("htmlitems " + i + ": " + mail.getHtmlItemName(i) + "\tCID: " + mail.getHtmlItemID(i)); mail.saveHtmlItem(i, "c:\\" + mail.getHtmlItemName(i)); } trace("attachments: " + mail.attachmentCount); for (i = 0; i < mail.attachmentCount; i++) { trace("attachments " + i + ": " + mail.getAttachmentName(i)); mail.saveAttachment(i, "c:\\" + mail.getAttachmentName(i)); }
2.39.1
2.39.1.1
Properties
from
2.39.1.2
replyTo
377
2.39.1.3
to
Description String. Identies the primary recipients of the email. Syntax mail.to
2.39.1.4
subject
2.39.1.5
cc
Description String. Identies the secondary (informational) recipients of the email. Syntax mail.cc
2.39.1.6
bcc
Description String. Identies the additional recipients of the email. Syntax mail.bcc
2.39.1.8
priority
Description Integer. Species the priority of the email. Valid values: 1 High 3 Normal 5 Low Syntax mail.priority
2.39.1.9
size
Description Integer. Species the point size of the font. Syntax font.size
2.39.1.10
text
Description String. Retrieves or species the text content of the email. Syntax mail.text
379
Description String. Retrieves or species the html content of the email. Syntax mail.html Example //The example shows how to get html content from a file. var mail = new Mail; //envelope mail.from = ...; mail.replyTo = ...; ... //contents mail.text = "the text content"; //get html content from file var stream = new Stream("the file name"); var str = ""; while (stream.pos < stream.length) { var s = stream.readLine(); str += s; str += "\r\n"; } stream.close(); mail.html = str;
2.39.1.12
attachmentCount
Description Integer. Gets the attachment count of the email. Read-only. Syntax mail.attachmentCount
Description Integer. Gets the count of the HTML items in the email. Read-only. Syntax mail.htmlItemCount
2.39.2
2.39.2.1
Methods
save
Description Saves the email to the disk le. Syntax mail.save(lename) Parameters lename The full path and name of the le to save.
2.39.2.2
load
Description Loads an email from disk le. Syntax mail.load(lename) Parameters lename The full path and name of the le to load. Returns Nothing
381
Description Gets the raw text of the email. Syntax mail.asText() Parameters None Returns A String Example mail = new Mail; mail.from = "abc@host.com"; mail.replyTo = "abc@host.com"; mail.to = "someone@server.com"; mail.subject = "A test"; mail.cc = "someoneelse@anotherserver.com"; mail.bcc = "anotherone@bccserver.com"; mail.date = Date(); mail.priority = 3; mail.text = "A test"; mail.html = "<html><body>A test</body></html>"; trace(mail.asText()); //output: From: abc@host.com To: someone@server.com Reply-To: abc@host.com CC: someoneelse@anotherserver.com BCC: anotherone@bccserver.com Subject: =?gb2312?B?QSB0ZXN0?= Date: Thu Aug 15 05:36:33 GMT+800 () 2002 MIME-Version: 1.0 X-Mailer: SWFKit.FFish X-Priority: 3 Content-Type: multipart/related; type="multipart/alternative"; boundary="====_SWFKIT_MAIL_PART_558.2758077.12DE60_====" This is a multi-part message in MIME format.
382
FFish Script Objects Reference --====_SWFKIT_MAIL_PART_558.2758077.12DE60_==== Content-Type: multipart/related; boundary="====_SWFKIT_MAIL_PART_558.2758077.12DDE8_===="; type="multipart/alternative" --====_SWFKIT_MAIL_PART_558.2758077.12DDE8_==== Content-Type: multipart/alternative; boundary="====_SWFKIT_MAIL_PART_558.2758077.12DCB4_====" --====_SWFKIT_MAIL_PART_558.2758077.12DCB4_==== Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable A test= --====_SWFKIT_MAIL_PART_558.2758077.12DCB4_==== Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable <html><body>A test</body></html>= --====_SWFKIT_MAIL_PART_558.2758077.12DCB4_====---====_SWFKIT_MAIL_PART_558.2758077.12DDE8_====---====_SWFKIT_MAIL_PART_558.2758077.12DE60_====--
2.39.2.4
getAttachmentContentType
Description Gets the content type of the specied attachment. Syntax mail.getAttachmentContentType(index) Parameters index Species the index of the attachment. The index of the attachments starts with 0. Returns A String
2.39.2.5
getAttachmentName
2.39 Mail Object mail.getAttachmentName(index) Parameters index Species the index of the attachment. The index of the attachments starts with 0. Returns A String
383
2.39.2.6
saveAttachment
Description Saves the specied attachment to disk le. Syntax mail.saveAttachment(index, lename) Parameters index Species the index of the attachment. The index of the attachments starts with 0. lename Species the full path and name of the le to save Returns Nothing
2.39.2.7
addAttachment
Description Adds an attachment from disk le. Syntax mail.addAttachment(lename) Parameters lename Species the full path and name of the le to add Returns Nothing
Description Removes the specied attachment. Syntax mail.removeAttachment(index) Parameters index Species the index of the attachment to remove. The index of the attachments starts with 0. Returns Nothing
2.39.2.9
getHtmlItemName
Description Gets name of the specied HTML item. Syntax mail.getHtmlItemName(index) Parameters index Species the index of the HTML item. The index of the HTML items starts with 0. Returns A string
385
Description Gets Content-ID of the specied HTML item. The Content-ID is a unique string identies the HTML item. Syntax mail.getHtmlItemID(index) Parameters index Species the index of the HTML item. The index of the HTML items starts with 0. Returns A string
2.39.2.11
saveHtmlItem
Description Saves the specied HTML item to disk le. Syntax mial.saveHtmlItem(index, lename) Parameters index Species the index of the HTML item. The index of the HTML items starts with 0. lename Species full path and name of the le to save. Returns Nothing
Description Adds a HTML item from disk le. Syntax mail.addHtmlItem(lename, cid) Parameters lename Species full path and name of the le to save. cid Species the Content-ID of the HTML item. Returns Nothing Example //The example embedded a flash movie in an email. //read the html file var stream = new FileStream("c:\\demo\\clock.html", "r"); var str = ""; while (stream.pos < stream.length) { var s = stream.readLine(); str += s; str += "\r\n"; } stream.close(); var mail = new Mail; //make the envelope mail.from = "abc@host.com"; mail.replyTo = "abc@host.com"; mail.to = "someone@server.com"; mail.subject = "A test"; mail.cc = "someoneelse@anotherserver.com"; mail.bcc = "anotherone@bccserver.com"; mail.date = Date(); mail.priority = 3; //make the html var re = new RegExp("clock.swf", "gi"); mail.html = str.replace(re, "cid:12345");
387
//load the flash movie mail.addHtmlItem("c:\\demo\\clock.swf", "12345"); //save the mail. It can be opened in the Microsoft Outlook Express mail.save("c:\\demo\\demo.eml");
2.40
SendMail Object
Description Sends an email via Internet using the SMTP (SIMPLE MAIL TRANSFER PROTOCOL) protocol. available: SWFKit, SWFKit Pro Syntax new SendMail Parameters None Returns Returns a new instance of the SendMail object. Remarks Using this object to send emails via Internet. If you are not familiar with the SMTP protocol then use the send method, which send an email all in one step and res onSend events. Otherwise, you can use the command method to send an email by hand. Before using these methods, remember to set the server, port, username and password properties (username and password is used for SMTP authorization. The SendMail Object supports the login authorization). If you use the command method to send an email, you must connect to the server rst. 1. Sending an email by using the send method
388
FFish Script Objects Reference //first make an email var stream = new Stream("c:\\demo\\clock.html"); var str = ""; while (stream.pos < stream.length) { var s = stream.readLine(); str += s; str += "\r\n"; } stream.close(); var mail = new Mail; //make the envelope mail.from = "someone@server.com"; mail.replyTo = "someone@server.com"; mail.to = "recipient@xys.com "; mail.subject = "A test"; mail.cc = "someoneelse@anotherserver.com"; mail.bcc = "anotherone@bccserver.com"; mail.date = Date(); mail.priority = 3; //make the html var re = new RegExp("clock.swf", "gi"); mail.html = str.replace(re, "cid:12345"); //load the flash movie mail.addHtmlItem("c:\\demo\\clock.swf", "12345"); //send the mail var sender = new SendMail; sender.server = "a_smtp_server"; //if need authorization, set username and password sender.username = "username"; sender.password = "passowrd"; sender.send(mail); 2. Sending an email by using the command method var sender = new SendMail; sender.server = " a_smtp_server "; sender.username = "username"; sender.password = "password"; sender.connect(); sender.command("HELO" + sender.username + "\r\n"); sender.command("MAIL FROM:" + mail.from + "\r\n"); sender.command("RCPT TO:" + mail.to + "\r\n"); sender.command("DATA\r\n"); sender.write(mail.asText()); sender.command("\r\n.\r\n"); sender.close();
2.40 SendMail Object 3. Handling an onSend event sender.onSend = function (type, msg) { trace(msg); } sender.send(mail);
389
2.40.1
2.40.1.1
Properties
server
Description String. Species the SMTP server that accepts the email. Using the mxnd method of the Inet Object to get a SMTP server from an email address. Syntax sendmail.server
2.40.1.2
port
Description Integer. Species the SMTP server port. The default value is 25. Syntax sendmail.port
2.40.1.3
username
2.40.2
2.40.2.1
Methods
send
Description Sends an email and res onSend events. Syntax sendmail.send(mail) Parameters mail A Mail Object represents the email to send. Returns Boolean. If the email has been sent successfully returns true. Otherwise returns false.
2.40.2.2
connect
Description Connects to the SMTP server before using the command method. Its unnecessary to call this method before the send method. Syntax sendmail.connect() Parameters None Returns Boolean.
391
Description Sends a SMTP command to the server. The command must end with a CRLF pair ( r n). Syntax sendmail.command(cmd) Parameters cmd Species the command to send. Returns String. Returns the response of the server
2.40.2.4
write
Description Sends data lines to the SMTP server after a DATA command. The dierence between the command method and the write method is that the command method receives a reply while the write method does not. Syntax sendmail.write(data) Parameters data Species the data to send. Returns Boolean. Example sendmail.command("DATA\r\n"); sendmail.write("test\r\n"); sendmail.write("test\r\n"); sendmail.command("\r\n.\r\n"); //indicates the end of the data
Description Closes the connection opened with the connect method. Syntax sendmail.close() Parameters None Returns Nothing
2.40.3
2.40.3.1
Events
onSend
Description Fired by the send method. The handler function is formed as: function on_send(type, msg) { body } The following table describes the meaning of the parameters. type 0 1 2 3 Syntax sendmail.onSend = handler function; Remarks The handler function must return a Boolean value. Returns true to allow the sending process to continue. Otherwise returns false to terminate the sending process. msg Represents Represents Represents ject Represents a socket error message a response of the server a command sent by the SendMail obthe bytes sent by the SendMail object
2.41 RecvMail Object Example var total_bytes = mail.size; var send_bytes = 0; sender.onSend = function (type, msg) { if (type == 3) { send_bytes += parseInt(msg); var percent = send_bytes * 100 / total_bytes; trace("sent " + percent + "%"); } if (!processMsg()) return false; return true; } sender.send(mail);
393
2.41
RecvMail Object
Description Receives emails using the POP3 (Post Oce Protocol - Version 3) protocol. available: SWFKit, SWFKit Pro Syntax new RecvMail Parameters None Returns Returns a new instance of the RecvMail object. Example var rm = new RecvMail; rm.server = "a_pop3_server"; rm.username = "username";
394
FFish Script Objects Reference rm.password = "password"; rm.connect(); var l = rm.list(); var i; for (i = 0; i < l.length; i++) { var mail = rm.retr(i + 1); mail.save("c:\\demo\\" + i + ".eml"); } rm.quit(); rm.close();
2.41.1
2.41.1.1
Properties
server
Description String. Species the POP3 server that your mailbox resides in. Syntax recvmail.server
2.41.1.2
port
Description Integer. Species the POP3 server port. The default value is 110. Syntax recvmail. port
2.41.1.3
Username
Description String. Species the user name of the mailbox. Syntax recvmail.username
395
2.41.2
2.41.2.1
Methods
connect
Description Connects to the POP3 server and performs an authorization. You must call this method rst before you can use any other methods. This method needs the server, port, username and password properties to be set correctly in advance. Syntax recvmail.connect() Parameters None returns Boolean.
2.41.2.2
close
Description Closes the connection opened with the connect method. Syntax recvmail.close() Parameters None returns Nothing.
Description Deletes the specied email. Syntax recvmail.dele(index) Parameters index Species the email to delete. The index of the emails starts with 1. returns Boolean.
2.41.2.4
list
Description Gets the information of the specied email. Syntax recvmail.list([index]) Parameters index Optional. Species the index of the email to list. The index of the emails starts with 1. If this parameter is not specied, the method returns information of all emails. returns If the index parameter is specied, returns a string represents the size of the email. Otherwise returns an array contains strings that represent size of each email in the mailbox. If failed, returns null.
397
Description Does nothing. Syntax recvmail.noop() Parameters None returns Boolean. Returns true for success, false for failure.
2.41.2.6
quit
Description Quit the POP3 server. You should call this method after you have nished all the works. Syntax recvmail.quit() Parameters None returns Boolean. Returns true for success, false for failure.
2.41.2.7
retr
Description Receives the specied email. Syntax recvmail.retr(index) Parameters index Species the email to receive. returns Returns a Mail object represents the email. If failed, returns null.
Description Undelete mails. If you have deleted some mails and the transaction is still open (has not been closed by the quit method yet), this method can get the mails back. Syntax recvmail.rset() Parameters None returns Boolean. Returns true for success, false for failure.
2.41.2.9
stat
Description Gets information of the mails. Syntax recvmail.stat() Parameters None returns Returns a string format as number size. The number eld represents the total number of the mails in the mailbox. The size eld represents the total size of all mails. If failed, returns null.
399
Description Gets the top n lines of the specied email. Syntax recvmail.top(index, n) Parameters index Species the index of the mail. The index of the emails starts with 1. n species how many lines to retrieve. returns String. If failed, returns null.
2.41.2.11
uidl
Description Gets the unique id of the specied email. Syntax recvmail.uidl([index]) Parameters index Optional. Species the index of the mail. The index of the emails starts with 1. returns String. If the index parameter is not specied, returns a string array contains the unique ids of each mail in the mailbox. If failed, returns null.
400
2.41.3
2.41.3.1
Events
onRecv
Description Fired when recieving mails. The handler function is formed as: function on_recv(type, msg) { body } The following table describes the meaning of the parameters. type 0 3 Remarks The handler function must return a Boolean value. Returns true to allow the recieving process to continue. Otherwise returns false to terminate the recieving process. Syntax recvmail.onRecv = handler function; Example var old_p = 0, p, size; pop.onRecv = function on_recv(type, msg) { if (type == 0) trace(msg); else if (type == 3) { p = parseInt(msg) * 100 / size; if (p - old_p > 10) { trace("recieved: " + p + "%"); old_p = p; } } if (!processMsg()) return false; return true; } trace(pop.connect()); msg Represents a socket error message Represents the bytes recieved by the retr method
2.42 Inet Object size = parseInt(pop.list(1)); trace(size); m = pop.retr(1); pop.quit(); pop.close(); m.save("c:\\test\\3.eml");
401
2.42
Inet Object
Description Gets system network congurations, downloads les, checks the Internet connection status, etc. available: SWFKit, SWFKit Pro Syntax new Inet Parameters None Returns Returns a new instance of the Inet object.
2.42.1
2.42.1.1
Methods
ping
Description Pings the specied host. The method res the onPinging event. Syntax inet.ping(host, count) Parameters host Species the host to ping. count Species the number of echo requests to send.
402 Returns
2.42.1.2
mxnd
Description Gets MX (Mail eXchanger) record of the specied domain. Syntax inet.mxnd(domain, dns) Parameters domain Species the domain. dns Species the DNS server to lookup the mx record. Returns An array contains objects. Each object has a name and a pref property. The name property represents a registered mail server in the MX record. The pref property represents the preference of the mail server. The lowest preference indicates the best (primary) mail server. Example mx = inet.mxfind("microsoft.com", "202.96.209.5"); for (i = 0; i < mx.length; i++) { trace(mx[i].name + "\t" + mx[i].pref); } //output: mailc.microsoft.com 10 maila.microsoft.com 10 mailb.microsoft.com 10
403
Description Retrieves the Internet connection state of local system. Syntax inet.IsInetConnected() Parameters None Returns Boolean. Returns true if the local system is online. Otherwise returns false. This method determines the Internet connection state by pinging the site www.swfkit.com.
2.42.1.4
getDNS
Description Retrieves the DNS settings of the local system. Syntax inet.getDNS() Parameters None Returns A string array contains the DNS servers of the local system. Example dns = inet.getDNS(); for (i = 0; i < dns.length; i++) { trace(dns[i]); }
Description Retrieves TCP/IP network conguration values of the local system. Syntax inet.getIPCong() Parameters None Returns An IPCong object. Example dns = inet.getDNS(); for (i = 0; i < dns.length; i++) { trace(dns[i]); } ic = inet.getIPConfig(); trace("Interface Number: " + ic.ifNum.toString()); trace(""); for (i = 0; i < ic.ifNum; i++) { trace("Interface Number " + i.toString() + ":"); trace("\tDesc:\t\t\t" + ic.ifDesc(i)); trace("\tType: \t\t\t" + ic.ifType(i)); trace("\tIP: \t\t\t" + ic.ifIP(i)[0]); trace("\tIP Mask: \t\t" + ic.ifIPMask(i)[0]); trace("\tDefault Gateway: \t\t" + ic.ifDefaultGateway(i)); trace("\tMac: \t\t\t" + ic.ifMac(i)); }
2.42.1.6
getUrl
Description Retrieves Internet resources such as HTML documents, FTP les that specied by the url.
2.42 Inet Object Syntax inet.getUrl(url, localname) Parameters url URL(Uniform Resource Locator) , a standardized string used to specify a resource on the Intenet, such as an HTML document. localname Species full path and name of the local le the Internet resource saves to. Returns Boolean. Returns true for success, false for failure. Example inet.getUrl("http://www.swfkit.com", "d:\\1.html")
405
2.42.1.7
getHttpFileSize
Description Retrieves the size of a Http le. Syntax inet.getHttpFileSize(le) Parameters le string. species the link of the Http le to get its size. Returns Integer. If the le doesnt exists or the method fails, it will return -1. Example var url = "http://www.swfkit.com/download/sp2.exe"; var size = Inet.getHttpFileSize(url);
406 2.42.1.8
Description Retrieves the last modied time of a Http le. Syntax inet.getHttpFileLastModiedTime(le) Parameters le string. species the link of the Http le to get its last modied time. Returns Integer. Example var url = "http://www.swfkit.com/download/sp2.exe"; var t = new Date(Inet.getHttpFileLastModifiedTime(url));
2.42.1.9
getHttpFileStatus
Description Receives the status code returned by the server when requests for the http le. Syntax inet.getHttpFileStatus(le) Parameters le string. species the link of the Http le to get the status code. Returns Integer. Example var url = "http://www.swfkit.com/download/sp2.exe"; var status = Inet.getHttpFileStatus(url);
407
Description Receives the header returned by the server when requests for the http le. Syntax inet.getHttpFileHeader(le, header) Parameters le string. species the link of the Http le to get the header. herader string. species the header name. It can be content-type, content-length, etc. Returns String. If the request fails, the result will be undened. Example var url = "http://www.swfkit.com/download/sp2.exe"; var contentType = Inet.getHttpFileStatus(url, "content-type");
2.42.1.11
openFtp
Description Creates an Inet.Ftp object with the specied parameters. Syntax inet.openFtp(server[, port[, username, password[, passive]]]) Parameters server String. Species the address of the FTP server to connect. port Integer. Species the server port. Optional. The default value is 21. username String. Species the login username. Optional, the default user name is anonymous. password String. Species the login password. Optional. passive Boolean. Species if the Inet.Ftp object uses passive mode to connect to the server. Optional. The default value is false.
408 Returns
An Inet.Ftp object. Returns null if failed. The method doesnt connect to the ftp server. For further operations, please call the methods of the Inet.Ftp object. Example var ftp = Inet.openFtp("ftp.microsoft.com");
2.42.2
2.42.2.1
Events
onPinging
Description Fired by the ping method. The handler function is formed as: function on_pinging(type, t, msg) { body } The parameter msg is a string represents the message generated by the ping method. The parameter type represents the message type; it can be one of the following values: Value 0 1 2 3 4 Description Time out The host is unreachable Socket error Description of the action A response comes. In this case, the parameter t represents the echo time.
Syntax inet.onPinging = handler function; Example var inet = new Inet; function on_ping(type, t, msg) { trace(msg); }
2.42 Inet Object inet.onPinging = on_ping; inet.ping("localhost", 4); //output: Pinging localhost [127.0.0.1]: Reply from 127.0.0.1: bytes=32 Reply from 127.0.0.1: bytes=32 Reply from 127.0.0.1: bytes=32 Reply from 127.0.0.1: bytes=32
409
with 32 bytes of time=0ms TTL=128 time=0ms TTL=128 time=0ms TTL=128 time=0ms TTL=128
2.42.2.2
onGetUrl
Description Fired by the getUrl method. The handler function is formed as: function on_geturl(type, msg) { body } The parameter msg is a string represents the message generated by the getUrl method. The parameter type represents the message type; it can be one of the following values: Value 0 1 Description An error occurs Represents the bytes recieved by the getUrl method
Remarks The handler function must return a Boolean value. Returns true to allow the downloading process to continue. Otherwise returns false to terminate the downloading process. Syntax inet.onGetUrl = handler function; Example var inet = new Inet; function on_geturl(type, msg) {
inet.getUrl("http://www.swfkit.com", "c:\\1.html");
2.43
Inet.Ftp Object
Description Gains access to ftp servers. The object provides abilities to connect a ftp server, list les and directories on the ftp server, download and upload les, create or remove directories, rename or delete les, etc. available: SWFKit, SWFKit Pro Syntax This object must be returned by the Inet.openFtp method. Usage 1. Open an Inet.Ftp object The Inet.Ftp object is created by the Inet.openFtp method. var ftp = Inet.openFtp("ftp://192.168.1.3"); 2. Connect to the ftp server ftp.connect(); 3. Change the current directory trace(ftp.currentDir); ftp.currentDir = "/pub/samples"; 4. List the les and folders var list = ftp.list(); for (i = 0; i < list.files.length; i++) trace(list.files[i]); for (i = 0; i < list.folders.length; i++) trace(list.folders[i]); 5. Get the le size
2.43 Inet.Ftp Object var info = ftp.getFileInfo("test.rar"); trace(info.size); 6. Download or upload les ftp.onDownload = function (percent) { trace(percent); return true; } ftp.download("test.rar", "c:\\samples\\test.rar");
411
2.43.1
2.43.1.1
Methods
connect
Description Connects to the ftp server. Syntax ftp.connect() Parameters None Returns Returns true if successful, or false otherwise.
Description Creates a new directory on the ftp server. Syntax ftp.createDir(dir) Parameters dir String. Species the name of the new directory to create. It can be either a fully qualied path or a name relative to the current directory. Returns Returns true if successful, or false otherwise.
2.43.1.3
removeDir
Description Removes a directory on the ftp server. Syntax ftp.removeDir(dir) Parameters dir String. Species the name of the directory to remove. It can be either a fully qualied path or a name relative to the current directory. Returns Returns true if successful, or false otherwise.
413
Description Deletes a le on the ftp server. Syntax ftp.deleteFile(le) Parameters le String. Species the name of the le to delete. It can be either a fully qualied le name or a name relative to the current directory. Returns Returns true if successful, or false otherwise.
2.43.1.5
rename
Description Changes the name of a le on the ftp server. Syntax ftp.rename(le) Parameters le String. Species the name of the le to rename. It can be either a fully qualied le name or a name relative to the current directory. Returns Returns true if successful, or false otherwise.
Description Gets the size and last modied time of a le on the ftp server. Syntax ftp.getFileInfo(le) Parameters le String. Species the name of the le. It can be either a fully qualied le name or a name relative to the current directory. Returns An object contains two properties size and modiedDate. The size property is an Integer represents the size of the le. The modiedDate property is an Integer. E.g. var info = ftp.getFileInfo("test.rar"); trace(info.size); trace(new Date(info.modifiedDate));
2.43.1.7
list
Description Lists the les and folders in the current directory on the ftp server. Syntax ftp.list() Parameters None Returns An object contains two properties les and folders. The les property is an array contains names of all les in current directory. The folders property is an array contains names of all folders in current directory. E.g. var f = ftp.list(); trace(f.files); trace(f.folders);
415
Description Downloads a le. This method triggers the onDownload event. This method calls the onDownload event handler for many times during the le downloading. It passed the downloading percentage to the event handler. If the event handler returns false, the downloading process will be terminated. For the downloading may take a long time, this method will block the application - the UI of the application cannot be updated. To resolve the problem, you can call the processMsg method in the event handler. Syntax ftp.download(le, localle) Parameters le String. Species the name of the le to download. It can be either a fully qualied le name or a name relative to the current directory. localle String. Species the name of the local le to save the downloaded data. Returns Returns true if successful, or false if failed.
2.43.1.9
upload
Description Uploads a le. This method triggers the onUpload event. This method calls the onUpload event handler for many times during the le uploading. It passed the uploading percentage to the event handler. If the event handler returns false, the uploading process will be terminated. For the uploading may take a long time, this method will block the application - the UI of the application cannot be updated. To resolve the problem, you can call the processMsg method in the event handler. Syntax
le String. Species the name of the le on the server to save the uploaded data. It can be either a fully qualied le name or a name relative to the current directory. localle String. Species the name of the local le to upload. Returns Returns true if successful, or false if failed.
2.43.1.10
close
Description Closes the ftp connection. Syntax ftp.close() Parameters None Returns Returns true if successful, or false if failed.
2.43.2
2.43.2.1
Properties
currentDir
Description String. Sets or gets the current directory of the ftp connection. Syntax ftp.currentDir
417
2.43.3
2.43.3.1
Events
onDownload
Description This event is triggered by the download method. ftp.onDownload = function (percent) { trace(percent + " of the file has been downloaded."); return true; } The parameter percent is a string represents the percentage of the downloading. The event handler will be called for many time during the downloading. Remarks The handler function must return a Boolean value. Returns true to allow the downloading process to continue, or to terminate the downloading otherwise.
2.43.3.2
onUpload
Description This event is triggered by the upload method. ftp.onUpload = function (percent) { trace(percent + " of the file has been uploaded."); return true; } The parameter percent is a string represents the percentage of the uploading. The event handler will be called for many time during the uploading. Remarks The handler function must return a Boolean value. Returns true to allow the uploading process to continue, or to terminate the uploading otherwise.
418
2.44
IPCong Object
Description Represents TCP/IP network conguration values of the local system. This object is returned by the method getIPCong of the Inet object. available: SWFKit, SWFKit Pro Syntax This object has no syntax.
2.44.1
2.44.1.1
Properties
ifNum
Description Integer. Represents the number of network interfaces present on the local system. Read-only. Syntax ipcong.ifNum
2.44.2
2.44.2.1
Methods
ifType
Description Retrieves the type of the specied interface. Syntax ipcong.ifType(index) Parameters index Species the index of the interface. The index of the interfaces starts with 0 Returns String.
419
Description Retrieves the IP address of the specied interface. Syntax ipcong.ifIP(index) Parameters index Species the index of the interface. The index of the interfaces starts with 0 Returns Returns a string array.
2.44.2.3
ifIPMask
Description Retrieves the subnet mask associated with the IP address of the specied interface. Syntax ipcong.ifIPMask(index) Parameters index Species the index of the interface. The index of the interfaces starts with 0 Returns Returns a string array.
Description Retrieves the default gateway of the specied interface. Syntax ipcong.ifDefaultGateway(index) Parameters index Species the index of the interface. The index of the interfaces starts with 0 Returns String.
2.44.2.5
ifMac
Description Retrieves the MAC address of the specied interface. Syntax ipcong.ifMac(index) Parameters index Species the index of the interface. The index of the interfaces starts with 0 Returns String.
421
Description Retrieves the description of the specied interface. Syntax ipcong.ifDesc(index) Parameters index Species the index of the interface. The index of the interfaces starts with 0 Returns String.
2.45
SysInfo Object
Description Retrieves system information. available: SWFKit, SWFKit Pro Syntax SysInfo.property or method The SysInfo object needs no constructors. All of its properties and methods are static.
2.45.1
2.45.1.1
Properties
computerName
Description String. Gets or sets the computer name of the local system. Readonly Syntax SysInfo.computerName
Description String. Retrieves the current user name of the local system. Readonly. Syntax SysInfo.userName
2.45.1.3
version
2.45.1.4
workarea
workareaTop workareaLeft workareaRight workareaBottom Description Integer. Retrieves the position of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars. The four properties represent the top, left, right, and bottom of the work area respectively. Read-only. Syntax SysInfo.workareaTop SysInfo.workareaLeft SysInfo.workareaRight SysInfo.workareaBottom
423
Description Integer. Retrieves the total number of bytes of physical memory. Read-only. Syntax SysInfo.totalPhysMemory
2.45.1.6
availPhysMemory
Description Integer. Retrieves the number of bytes of physical memory available. Read-only. Syntax SysInfo.availPhysMemory
2.45.1.7
cpuSpeed
2.45.1.8
screenSaver
Description String. Gets or sets the default screen saver of the system Syntax SysInfo.screenSaver
Description Boolean. Gets or sets the state of the screen saver. Syntax SysInfo.screenSaverActive Example //Deactivate the screen saver SysInfo.screenSaverActive = false;
2.45.1.10
screenSaverTimeout
Description Integer. Gets or Sets the screen saver time-out value Syntax SysInfo.screenSaverTimeout
2.45.1.11
displaySetting
Description Object. Gets or sets the current display setting. Syntax SysInfo.displaySetting Remarks The property returns an object contains following properties: pelsWidth Pixel width pelsHeight Pixel height bitsPerPel Bits per pixel displayFrequency Species the frequency, in hertz (cycles per second), of the display device in a particular mode
2.45 SysInfo Object If you want to test if the display setting can be set, just add a test property to the object and set it to true. Tips: Use the getDisplaySettings method to list all of the display settings. After you set the property, you can check the test property to see what has happened: 0 The settings change was successful. 1 The computer must be restarted in order for the graphics mode to work. -1 The display driver failed the specied graphics mode. -2 The graphics mode is not supported. Example //get the current display setting var ds = SysInfo.displaySetting; trace(ds. pelsWidth); trace(ds. pelsHeight); trace(ds. bitsPerPel); trace(ds. displayFrequency); //change the current display setting; ds.pelsWidth = 800; ds.pelsHeight = 600; ds.test = true; SysInfo.displaySetting = ds;
425
2.45.2
2.45.2.1
Methods
powerO
Description Shuts down the system and turns o the power. The system must support the power-o feature. Syntax SysInfo.powerO() Parameters None Returns Nothing.
Description Logs the current user o. Syntax SysInfo.logO() Parameters None Returns Nothing.
2.45.2.3
reboot
Description Shuts down the system and then restarts the system. Syntax SysInfo.reboot() Parameters None Returns Nothing.
2.45.2.4
shutdown
Description Shuts down the system to a point at which it is safe to turn o the power. Syntax SysInfo.shutdown() Parameters None Returns Nothing.
427
Description Lists all of the current display devices graphics mode. Syntax SysInfo.getDisplaySettings() Parameters None Returns Array. See also: displaySetting
2.46
Folder
Description Provides access to all the properties of a folder. available: SWFKit, SWFKit Pro Syntax new Folder(folder); Parameter folder Species the full path of the folder. If the specied folder does not exist, the constructor will try to create it. Returns Returns a new instance of the Folder object. If failed, returns null.
428
2.46.1
2.46.1.1
Properties
attributes
Description Sets or returns the attributes of les or folders. Syntax folder.attributes Remarks The attributes property can have any of the following values or any logical combination of the following values: Value 1 2 4 16 64 128 256 512 1024 2048 4096 Description The le or directory is read-only. The le or directory is hidden. The le or directory is part of, or is used exclusively by, the operating system. Folder or directory. The le or directory is encrypted. The le or directory has no other attributes set. This attribute is valid only if used alone. The le is being used for temporary storage. The le is a sparse le. The le has an associated reparse point. The le or directory is compressed. The data of the le is not immediately available.
2.46.1.2
dateCreated
Description Integer. Returns or sets the date and time that the specied le or folder was created. Syntax folder.dateCreated Example f = new Folder("c:\\demo"); d = new Date(f.dateCreated); trace(d.toLocaleString());
429
Description Integer. Returns or sets the date and time that the specied le or folder was last accessed. Syntax folder.dateLastAccessed Example f = new Folder("c:\\demo"); d = new Date(f. dateLastAccessed); trace(d.toLocaleString());
2.46.1.4
dateLastModied
Description Integer. Returns or sets the date and time that the specied le or folder was last modied. Syntax folder.dateLastModied Example f = new Folder("c:\\demo"); d = new Date(f.dateLastModified); trace(d.toLocaleString());
2.46.1.5
drive
Description String. Returns the drive letter of the drive on which the specied le or folder resides. Read-only. Syntax folder.drive Example f = new Folder("c:\\demo"); trace(f.drive); //output: c:
Description Boolean. Returns true if the specied folder is the root folder; false if it is not. Read-only. Syntax folder.isRootFolder Example f = new Folder("c:\\demo"); trace(f.isRootFolder); //output: false
2.46.1.7
name
Description String. Sets or returns the name of a specied le or folder. Syntax folder.name Example f = new Folder("c:\\demo"); trace(f.name); //output: demo
2.46.1.8
parentPath
Description String. Returns the folder object for the parent of the specied le or folder. Read-only. Syntax folder.parentPath Example f = new Folder("c:\\demo"); trace(f.parentPath); //output: c:
431
Description String. Returns the path for a specied le, folder. Read-only. Syntax folder.path Example f = new Folder("c:\\demo"); trace(f.path); //output: c:\demo
2.46.1.10
shortName
Description String. Returns the short name used by programs that require the earlier 8.3 naming convention. Read-only. Syntax folder.shortName Example f = new Folder("c:\\program files"); trace(f.shortName); //output: PROGRA~1
2.46.1.11
shortPath
Description String. Returns the short path used by programs that require the earlier 8.3 le naming convention. Read-only. Syntax folder.shortPath Example f = new Folder("c:\\program files"); trace(f.shortPath); //output: c:\PROGRA~1
Description Integer. Returns the size, in bytes, of all les and subfolders contained in the folder. Read-only. Syntax folder.size Example f = new Folder("c:\\program files"); trace(f.size); //output: 847435821
2.46.1.13
subFolders
Description Returns a string array contains all subfolder paths of the folder. Read-only. Syntax folder.subFolders
2.46.1.14
les
Description Returns a string array contains all le pathnames in the folder. Read-only. Syntax folder.les
2.46 Folder
433
2.46.2
2.46.2.1
Methods
copy
Description Copies a specied le or folder from one location to another. CAUTION: the method overwrites the existing les silently. Syntax folder.copy(dest) Parameters dest Species the destination to copy Returns Boolean. Returns true for success, false for failure.
2.46.2.2
remove
Description Deletes a specied le or folder. The method can only remove empty folders. If you want to remove all les and subfolders, use a recursive function like this: function remove_all(path) { var folder = new Folder(path); var files = folder.files; var folders = folder.subFolders; var i; for (i = 0; i < files.length; i++) { (new File(files[i])).remove(); } for (i = 0; i < folders.length; i++) ] remove_all(folders[i]); folder.remove(); } CAUTION: The function wont put the deleted folders into the recycle bin. You cannot recovery them anymore.
2.46.2.3
move
Description Moves a specied le or folder from one location to another. The method does not move folder where the destination is on a dierent volume. You can write your own function to do this. Syntax folder.move(dest) Parameters dest Species the destination to move. Returns Boolean. Returns true for success, false for failure.
2.46.2.4
les
Description Returns an array contains the name of the specied les. Syntax folder.les([name]) Parameters name Species the name of the le(dont include the path name). Supports wild characters * and ?. If the parameter is not specied, act just like the les property.
2.47 File Object Returns Array. Example var f = new Folder("c:\\windows"); trace(f.files("*.exe;*.dll;*.scr"));
435
2.46.2.5
exists
Description Determines whether the specied folder or le exists. Static Syntax Folder.exists(name) Parameters name Species full path and name of the folder or le. Returns Boolean. Returns true for success, false for failure.
2.47
File Object
Description Provides access to all the properties of a le. available: SWFKit, SWFKit Pro Syntax new File(le); Parameter le Species the full path and name of a existing le. Returns Returns a new instance of the File object. If failed, returns null.
436
2.47.1
2.47.1.1
Properties
attributes
Description Sets or returns the attributes of les or folders. Syntax le.attributes Remarks The attributes property can have any of the following values or any logical combination of the following values: Value 1 2 4 16 64 128 256 512 1024 2048 4096 Description The le or directory is read-only. The le or directory is hidden. The le or directory is part of, or is used exclusively by, the operating system. Folder or directory. The le or directory is encrypted. The le or directory has no other attributes set. This attribute is valid only if used alone. The le is being used for temporary storage. The le is a sparse le. The le has an associated reparse point. The le or directory is compressed. The data of the le is not immediately available.
2.47.1.2
dateCreated
Description Integer. Returns or sets the date and time that the specied le or folder was created. Syntax le.dateCreated Example f = new File("c:\\demo\\1.txt"); d = new Date(f.dateCreated); trace(d.toLocaleString()); //output: Fri Aug 16 16:46:45 GMT+800 () 2002
437
Description Integer. Returns or sets the date and time that the specied le or folder was last accessed. Syntax le.dateLastAccessed Example f = new File("c:\\demo\\1.txt"); d = new Date(f.dateLastAccessed); trace(d.toLocaleString());
2.47.1.4
dateLastModied
Description Integer. Returns or sets the date and time that the specied le or folder was last modied. Syntax le.dateLastModied Example f = new File("c:\\demo\\1.txt"); d = new Date(f.dateLastModified); trace(d.toLocaleString());
2.47.1.5
drive
Description String. Returns the drive letter of the drive on which the specied le or folder resides. Read-only. Syntax le.drive Example f = new File("c:\\demo\\1.txt"); trace(f.drive); //output: c:
Description String. Sets or returns the name of a specied le or folder. Syntax le.name Example f = new File("c:\\demo\\1.txt"); trace(f.name); //output: 1.txt
2.47.1.7
parentPath
Description String. Returns the folder object for the parent of the specied le or folder. Read-only. Syntax le.parentPath Example f = new File("c:\\demo\\1.txt"); trace(f.parentPath); //output: c:\demo
2.47.1.8
path
Description String. Returns the path for a specied le, folder. Read-only. Syntax le.path Example f = new File("c:\\demo\\1.txt"); trace(f.path); //output: c:\demo\1.txt
439
Description String. Returns the short name used by programs that require the earlier 8.3 naming convention. Read-only. Syntax le.shortName Example f = new File("c:\\demo\\ A demo file.txt"); trace(f.shortName); //output: ADEMOF~2.TXT
2.47.1.10
shortPath
Description String. Returns the short path used by programs that require the earlier 8.3 le naming convention. Read-only. Syntax le.shortPath Example f = new File("c:\\demo\\ A demo file.txt"); trace(f.shortPath); //output: c:\demo\ADEMOF~2.TXT
2.47.1.11
size
Description Integer. Returns the size of the le. Read-only. Syntax le.size Example f = new File("c:\\demo\\A demo file.txt"); trace(f.size); //output: 7
2.47.2
2.47.2.1
Methods
copy
Description Copies a specied le or folder from one location to another. CAUTION: the method overwrites the existing les silently. Syntax le.copy(dest) Parameters dest Species the destination to copy Returns Boolean. Returns true for success, false for failure.
2.47.2.2
remove
Description Deletes the specied le. Syntax le.remove() Parameters None Returns Boolean. Returns true for success, false for failure.
441
Description Moves a specied le from one location to another. Syntax le.move(dest) Parameters dest Species the destination to move. Returns Boolean. Returns true for success, false for failure.
2.47.2.4
exists
Description Determines whether the specied folder or le exists. Static Syntax File. exists (name) Parameters name Species full path and name of the folder or le. Returns Boolean. Returns true if exists, otherwise returns false.
2.48
Drive Object
Description Provides access to the properties of a particular disk drive. available: SWFKit, SWFKit Pro Syntax new Drive(drive);
2.48.1
2.48.1.1
Properties
availableSpace
Description Integer. Returns the amount of space available to a user on the specied drive. Read-only. Syntax drive.availableSpace Example d = new Drive("c:\\program files"); trace(d.availableSpace); //output: 748310528
2.48.1.2
driveLetter
Description String. Returns the drive letter of a physical local drive. Read-only. Syntax drive.driveLetter Example d = new Drive("c:\\program files"); trace(d.driveLetter); //output: C
443
Description String. Returns the type of a specied drive. Read-only. It can be one of the following values: Value unknown no root dir removable xed network cdrom ram disk Syntax drive.driveType Example d = new Drive("e:"); trace(d.driveType); //output: cdrom Meaning The drive type cannot be determined. The root directory does not exist. The disk can be removed from the drive. The disk cannot be removed from the drive. The drive is a remote (network) drive. The drive is a CD-ROM drive. The drive is a RAM disk.
2.48.1.4
leSystem
Description String. Returns the type of le system in use for the specied drive. Read-only. Available return types include FAT, NTFS, and CDFS Syntax drive.leSystem Example d = new Drive("c:\\program files"); trace(d.fileSystem); //output: FAT32
Description Integer. Returns the amount of free space available to a user on the specied drive. Read-only. Syntax drive.freeSpace Remarks The value returned by the freeSpace property is typically the same as that returned by the availableSpace property. Dierences may occur between the two for computer systems that support quotas. Example d = new Drive("c:\\program files"); trace(d.freeSpace);
2.48.1.6
isReady
Description Boolean. Returns true if the specied drive is ready; false if it is not. Read-only. Syntax drive.isReady Example d = new Drive("a:\\"); trace(d.isReady); //output: false
445
Description String. Returns the path for a specied drive. Read-only. Syntax drive.path Example d = new Drive("c:\\program files"); trace(d.path); //output: c:\
2.48.1.8
rootFolder
Description String. Returns a string representing the root folder of a specied drive. Read-only. Syntax drive.rootFolder Example d = new Drive("c:\\program files"); trace(d.rootFolder); //output: c:\
2.48.1.9
serialNumber
Description String. Returns the decimal serial number used to uniquely identify a disk volume. Read-only. Syntax drive.serialNumber Example d = new Drive("c:\\program files"); trace(d.serialNumber);
Description Float. Returns the total space, in bytes, of a drive. Read-only. Syntax drive.totalSize Example d = new Drive("c:\\program files"); trace(d.totalSize);
2.48.1.11
volumeName
Description String. Sets or returns the volume name of the specied drive. Syntax drive.volumeName Example d = new Drive("c:\\program files"); trace(d.volumeName);
2.48.1.12
drives
Description An array contains drive objects. Gets all drives in the system. Static. Read-only. Syntax drive.drives Example
2.49 StringStream Object var d = Drive.drives; for (i = 0; i < d.length; i++) { trace(d[i].driveLetter, ":\t", d[i].driveType); trace("\t", d[i].fileSystem); trace("\t", d[i].isReady); trace("\t", d[i].rootFolder); trace("\t", d[i].serialNumber); trace("\t", d[i].totalSize); trace("\t", d[i].volumeName); }
447
2.49
StringStream Object
Description Represents a binary stream in memory.. available: SWFKit, SWFKit Pro Syntax new StringStream([mode]); Parameters mode Optional. Integer. Type of access permitted. Default $STREAM IN | $STREAM OUT Returns Returns a new instance of the StringStream object. If failed, returns null.
2.49.1
2.49.1.1
Properties
length
Description Integer. Gets of sets the length of the le stream. If you set a value smaller than the origin length of the le stream, it will be truncated. Syntax stream.length
Description Integer. Gets of sets the current position of the reading pointer. Syntax stream.getPos
2.49.1.3
putPos
Description Integer. Gets of sets the current position of the writing pointer. Syntax stream.putPos
2.49.1.4
eof
Description Boolean. Tests for end-of-le on a stream. Read-only. After a failed reading operation at the end of the stream, it is set to true Syntax stream.eof
2.49.1.5
crc
Description Integer. Calculates the CRC code of the stream. Syntax stream.crc
449
2.49.2
2.49.2.1
Methods
get
Description Reads a byte from the le stream Syntax stream.get() Parameters None Returns Integer. If failed returns false.
2.49.2.2
getLong
Description Reads a long integer (four bytes) from the le stream or string stream Syntax stream.getLong() Parameters None Returns Integer.
Description Reads a short integer (two bytes) from the le stream or string stream Syntax stream.getShort() Parameters None Returns Integer.
2.49.2.4
getFloat
Description Reads a 32-bit oating-point number from the le stream or string stream. Syntax stream.getFloat() Parameters None Returns Float number
451
Description Reads a 64-bit oating-point number from the le stream or string stream Syntax stream.getDouble() Parameters None Returns Float number
2.49.2.6
read
Description Reads specied number of bytes from the le stream Syntax stream.read(bytes) Parameters bytes Species the number of bytes to read. Returns Returns a string represents the read bytes.
2.49.2.7
readLine
Description Reads a line from the le stream Syntax stream.readLine() Parameters None Returns Returns a string represents the read line.
Description Writes a character to the le stream Syntax stream.put(c) Parameters c Integer. Species the character to write. Returns Boolean
2.49.2.9
putShort
Description Writes a short integer to the le stream or string stream Syntax stream.putShort(num) Parameters num Number. Represents an integer to write. Returns Nothing
2.49.2.10
putFloat
Description Writes a 32-bit oating-point number to the le stream or string stream Syntax stream.putFloat(num) Parameters num Number. Represents a oat number Returns Nothing
453
Description Writes the specied values to the le stream or string stream Syntax stream. write (v0 , v1 , . . . , vN ) Parameters v0 , v1 , . . . , vN Species the values to write. The value can be an integer, oat, string or StringStream object. Returns Nothing
2.49.2.12
writeLine
Description Writes a line to the le stream Syntax stream.writeLine(v0 , v1 , . . . , vN ) Parameters v0 , v1 , . . . , vN Species the values to write. The value can be an integer, oat, string or StringStream object. Returns Nothing
2.49.2.13
unget
Description Pushes a character back onto the le stream. Syntax stream.unget(c) Parameters c Species the character to unget. Returns Boolean
2.49.2.15
close
2.49.2.16
readString
Description Reads a null terminated ANSI string (8-bit character) from the le stream or string stream. Syntax stream.readString() Parameters None Returns String
455
Description Reads a null terminated UNICODE string (16-bit character) from the le stream or string stream. Syntax stream.readUnicodeString() Parameters None Returns String
2.49.2.18
writeUnicodeString
Description Writes a string to the le stream or string stream include a null terminator. Syntax stream.writeUnicodeString(str) Parameters str String. Represents the string to write. Returns Nothing
2.49.2.19
compress
Description Compresses the string stream. Syntax stream.compress() Parameters None Returns A StringStream object represents the compressed data
Description Uncompress the string stream. Syntax stream.uncompress() Parameters None Returns A StringStream object represents the uncompressed data. Returns null if the format of the source stream is invalid.
2.49.2.21
readFromFile
Description Reads an entire le into a string stream. Static. Syntax stream.readFromFile(name) Parameters name Species the full pathname of the le to read. Returns A StringStream object.
2.49.2.22
saveToFile
Description Write the entire string stream to a le Syntax stream.saveToFile(name) Parameters name Species the full pathname of the output le. If the le exists, its contents are destroyed. Returns Nothing
457
2.50
FileStream(Stream) Object
Description Facilitates sequential access to le. available: SWFKit, SWFKit Pro Syntax new FileStream([lename[, mode]]); Parameter lename Optional. String. Species the full path and name of the le. mode Optional. String. Type of access permitted. Default r+ Values Description r Opens for reading. If the le does not exist or cannot be found, returns null. w Opens an empty le for writing. If the given le exists, its contents are destroyed. a Opens for writing at the end of the le (appending) without removing the EOF marker before writing new data to the le; creates the le rst if it doesnt exist. r+ Opens for both reading and writing. (The le must exist.) w+ Opens an empty le for both reading and writing. If the given le exists, its contents are destroyed. a+ Opens for reading and appending; the appending operation includes the removal of the EOF marker before new data is written to the le and the EOF marker is restored after writing is complete; creates the le rst if it doesnt exist. If neither of the parameters is specied, the method creates a temporary le for both reading and writing. After a calling of the close method, the temporary le is automatically deleted. The les are always opened in binary mode. Returns Returns a new instance of the FileStream object. If failed, returns null. properties
458
2.50.1
2.50.1.1
Properties
length
Description Integer. Gets of sets the length of the le stream. If you set a value smaller than the origin length of the le stream, it will be truncated. Syntax stream.length
2.50.1.2
pos
Description Integer. Gets of sets the current position of the le pointer. Syntax stream.pos
2.50.1.3
eof
Description Boolean. Tests for end-of-le on a stream. Read-only. After a failed reading operation at the end of the stream, it is set to true Syntax stream.eof
2.50.2
2.50.2.1
Methods
get
2.50 FileStream(Stream) Object Parameters None Returns Integer. If failed returns false.
459
2.50.2.2
getLong
Description Reads a long integer (four bytes) from the le stream or string stream Syntax stream.getLong() Parameters None Returns Integer.
2.50.2.3
getShort
Description Reads a short integer (two bytes) from the le stream or string stream Syntax stream.getShort() Parameters None Returns Integer.
Description Reads a 32-bit oating-point number from the le stream or string stream. Syntax stream.getFloat() Parameters None Returns Float number
2.50.2.5
getDouble
Description Reads a 64-bit oating-point number from the le stream or string stream Syntax stream.getDouble() Parameters None Returns Float number
2.50.2.6
read
Description Reads specied number of bytes from the le stream Syntax stream.read(bytes) Parameters bytes Species the number of bytes to read. Returns Returns a string represents the read bytes.
461
Description Reads a line from the le stream Syntax stream.readLine() Parameters None Returns Returns a string represents the read line.
2.50.2.8
put
Description Writes a character to the le stream Syntax stream.put(c) Parameters c Integer. Species the character to write. Returns Boolean
2.50.2.9
putShort
Description Writes a short integer to the le stream or string stream Syntax stream.putShort(num) Parameters num Number. Represents an integer to write. Returns Nothing
Description Writes a 32-bit oating-point number to the le stream or string stream Syntax stream.putFloat(num) Parameters num Number. Represents a oat number Returns Nothing
2.50.2.11
write
Description Writes the specied values to the le stream or string stream Syntax stream. write (v0 , v1 , . . . , vN ) Parameters v0 , v1 , . . . , vN Species the values to write. The value can be an integer, oat, string or StringStream object. Returns Nothing
463
Description Writes a line to the le stream Syntax stream.writeLine(v0 , v1 , . . . , vN ) Parameters v0 , v1 , . . . , vN Species the values to write. The value can be an integer, oat, string or StringStream object. Returns Nothing
2.50.2.13
unget
Description Pushes a character back onto the le stream. Syntax stream.unget(c) Parameters c Species the character to unget. Returns Boolean
2.50.2.14
ush
2.50.2.16
readString
Description Reads a null terminated ANSI string (8-bit character) from the le stream or string stream. Syntax stream.readString() Parameters None Returns String
2.50.2.17
readUnicodeString
Description Reads a null terminated UNICODE string (16-bit character) from the le stream or string stream. Syntax stream.readUnicodeString() Parameters None Returns String
465
Description Writes a string to the le stream or string stream include a null terminator. Syntax stream.writeUnicodeString(str) Parameters str String. Represents the string to write. Returns Nothing
2.51
Socket Object
Description Represents a Windows Socket. available: SWFKit, SWFKit Pro Syntax new Socket Parameters None Returns Returns a new instance of the Socket object.
466
2.51.1
2.51.1.1
Properties
error
Description Gets the error status for the last operation that failed. Static. Readonly Syntax socket.error Remarks The following is a list of possible error codes:
467
468
continued from the previous page Value 10043 10041 10058 10044 10060 10109 10035 11001 11004 11003 11002 10094 Description Protocol not supported.
Protocol wrong type for socket. Cannot send after socket shutdown. Socket type not supported. Connection timed out. Class type not found. Resource temporarily unavailable. Host not found. Valid name, no data record of requested type. This is a non-recoverable error. Non-authoritative host not found. Graceful shutdown in progress.
2.51.2
2.51.2.1
Methods
accept
Description Accepts a connection on the socket Syntax socket.accept() Parameters None Returns A Socket object available for connection
469
Description Requests event notication for the socket Syntax socket.asyncSelect(event) Parameters event Integer. Species a combination of network events. Value Description $FD READ Want to receive notication of readiness for reading. $FD WRITE Want to receive notication when data is available to be read. $FD OOB Want to receive notication of the arrival of out-of-band data. $FD ACCEPT Want to receive notication of incoming connections. $FD CONNECT Want to receive notication of connection results. $FD CLOSE Want to receive notication when a socket has been closed by a peer. Returns Boolean. If succeed, returns true. Otherwise returns false.
2.51.2.3
bind
Description Associates a local address with the socket Syntax socket.bind(port[, address]) Parameters port Integer. Species the port to bind. address Optional. String. Species the network address (a dotted number such as 219.138.64.12) to bind. Returns Boolean.
Description Closes the socket. Syntax socket.close() Parameters None Returns Nothing.
2.51.2.5
connect
Description Establishes a connection to a socket. Syntax socket.connect(address, port) Parameters address String. Species the network address of the socket to which this object is connected. Such as www.swfkit.com, ftp.microsoft.com, or 218.5.79.162. port Integer. Species the port to connect. Returns Boolean.
471
Description Creates the Windows socket and bind it to the specied address Syntax socket.create([port[, type[, event[, address]]]]) Parameters port Optional. Integer. Species a port to be used with the socket. The default value is 0 (Windows Sockets will select a port for the socket if the value is set to 0). type Optional. Integer. Species the socket type. Default $SOCK STREAM. Value Description $SOCK STREAM Provides sequenced, reliable, two-way, connection-based byte streams with an out-of-band data transmission mechanism. Uses TCP for the Internet address family. $SOCK DGRAM Supports datagrams, which are connectionless, unreliable buers of a xed (typically small) maximum length. Uses UDP for the Internet address family. event Optional. Integer. Species a combination of network events. Default $FD READ | $FD WRITE | $FD OOB | $FD ACCEPT | $FD CONNECT | $FD CLOSE Value Description $FD READ Want to receive notication of readiness for reading. $FD WRITE Want to receive notication when data is available to be read. $FD OOB Want to receive notication of the arrival of out-of-band data. $FD ACCEPT Want to receive notication of incoming connections. $FD CONNECT Want to receive notication of connection results. $FD CLOSE Want to receive notication when a socket has been closed by a peer. address Optional. String. Species the network address (a dotted number such as 219.138.64.12.) to bind.
2.51.2.7
getPeerName
Description Gets the address of the peer socket to which the socket is connected. Syntax socket.getPeerName() Parameters None Returns Object. The object has two properties: address String A dotted number IP address. port Integer If failed, returns null.
2.51.2.8
getSockName
Description Gets the local name for the socket Syntax socket.getSockName() Parameters None Returns Object. The object has two properties: address String. A dotted number IP address. port Integer If failed, returns null.
473
Description Retrieves the socket option. Syntax socket.getSockOpt(name, level) Parameters name Integer. Species the socket option for which the value is to be retrieved level Integer. Species the level at which the option is dened
Level 0xFFFF Name 0x0002 0x0020 Return Type Boolean Boolean Description Whether the socket is listening. Whether the socket is congured for the transmission of broadcast messages. Whether the debugging is enabled. Whether the SO LINGER(0x0080) option is disabled. Whether the routing is disabled. Retrieve error status and clear. Keep-alives are being sent Returns the current linger options. Whether the out-of-band data is being received in the normal data stream. Buer size for receives. Whether the socket can be bound to an address which is already in use. Buer size for sends. The type of the socket (for example, $SOCK STREAM). continued on next page
474
2.51.2.10
setSockOpt
Description Sets the socket option. Syntax socket.setSockOpt(name, value, level) Parameters name Integer. Species the socket option for which the value is to be retrieved value Integer. Species the new option value level Integer. Species the level at which the option is dened
Level 0xFFFF Name 0x0002 0x0020 Return Type Boolean Boolean Description Whether the socket is listening. Whether the socket is congured for the transmission of broadcast messages. Whether the debugging is enabled. Whether the SO LINGER(0x0080) option is disabled. Whether the routing is disabled. Retrieve error status and clear. Keep-alives are being sent continued on next page
475
Returns the current linger options. Whether the out-of-band data is being received in the normal data stream. Buer size for receives. Whether the socket can be bound to an address which is already in use. Buer size for sends. The type of the socket (for example, $SOCK STREAM). Whether the Nagle algorithm is disabled for send coalescing.
Returns Boolean.
2.51.2.11
ioctl
Parameters cmd Integer. Species the command to perform on the socket value Optional. Depends on the command to be performed.
FFish Script Objects Reference Return Type Description Enable or disable nonblocking mode on the socket. Determine the maximum number of bytes that can be read with one receive call from this socket. Checks if we are at the out-of-band marker in the stream
0x4004667F
Integer
0x80047307
Boolean
2.51.2.12
listen
Description Listens for incoming connection requests. Syntax socket.listen([value]) Parameters value Optional. Integer. Species the maximum length to which the queue of pending connections can grow. Valid range is from 1 to 5. The default value is 5. Returns Boolean
2.51.2.13
receive
2.51 Socket Object socket.receive(stream, len[, ag]) Parameters stream A StringStream object for the incoming data. len Integer. Species the number of bytes to retrieve. ag Optional. Integer. Species the way in which the call is made. It can be a combination of the following data Flag Description 0x02 Peek at the incoming data. The data is copied into the StringStream but is not removed from the input queue. 0x01 Process out-of-band data Returns Integer. The number of bytes received.
477
2.51.2.14
receiveFrom
Description Receives a datagram and stores the source address Syntax socket.receiveFrom(stream, len[, ag]) Parameters stream A StringStream object for the incoming data. len Integer. Species the number of bytes to retrieve. ag Optional. Integer. Species the way in which the call is made. It can be a combination of the following data: Flag Description 0x02 Peek at the incoming data. The data is copied into the StringStream but is not removed from the input queue. 0x01 Process out-of-band data Returns An object contains following properties: address String. A dotted number IP address of the source port Integer. The port of the source length Integer. The number of bytes received.
Description Sends data on a connected socket. Syntax socket.send(stream, len[, ag]) Parameters stream A StringStream object containing the output data. len Species the number of bytes to send. ag Optional. Integer. Species the way in which the call is made. It can be a combination of the following data: Flag Description 0x04 Species that the data should not be subject to routing. 0x01 Process out-of-band data Returns Integer. The number of bytes sent.
2.51.2.16
sendTo
Description Sends data to a specic destination. Syntax socket.sendTo(stream, len, port[, address[, ag]]) Parameters stream A StringStream object containing the output data. len Species the number of bytes to send. port Integer. The port of the destination. address Optional. String. Species the network address of the destination. If this parameter is not specied, the socket sends a broadcast.
2.51 Socket Object ag Optional. Integer. Species the way in which the call is made. It can be a combination of the following data: Flag Description 0x04 Species that the data should not be subject to routing. 0x01 Process out-of-band data Returns Integer. The number of bytes sent.
479
2.51.2.17
shutDown
Description Disables sends or receives on the socket. Syntax socket.shutDown([how]) Parameters how Optional. Integer. Describes what types of operation will no longer be allowed, using the following values: 0 receives 1 sends 2 both The default value is 1. Returns Boolean
2.51.2.18
htonl
Description Converts a 32-bit integer from host to TCP/IP network byte order. Static Syntax socket.htonl(hostlong)
480 Parameters
hostlong Integer. Represents a 32-bit number in host byte order. Returns Integer
2.51.2.19
htons
Description Converts a 16-bit integer from host to TCP/IP network byte order. Static. Syntax socket.htons(hostshort) Parameters hostshort Integer. Represents a 16-bit number in host byte order. Returns Integer
2.51.2.20
ntohl
Description Converts a 32-bit integer from TCP/IP network byte order to host byte order. Static. Syntax socket.ntohl(netlong) Parameters netlong Integer. Represents a 32-bit number in TCP/IP network byte order. Returns Integer
481
Description Converts a 16-bit integer from TCP/IP network byte order to host byte order. Static. Syntax socket.ntohs(netshort) Parameters netshort Integer. Represents a 16-bit number in TCP/IP network byte order. Returns Integer
2.51.3
2.51.3.1
Events
onAccept
Description Fires when a listening socket can accept pending connection requests by calling the accept method. Syntax socket.onAccept = function () { body }
2.51.3.2
onClose
Description Fires when the connected socket is closed. Syntax socket. onClose = function () { body }
Description Fires when the connection attempt of the connecting socket is completed. Syntax socket. onConnect = function () { body }
2.51.3.4
onOOBData
Description Noties the receiving socket that the sending socket has out-of-band data to send. Syntax socket.onOOBData = function () { body }
2.51.3.5
onReceive
Description Fires when there is data in the buer that can be retrieved by the socket. Syntax socket.onReceive = function () { body }
483
Description Fires when the socket can send data. Syntax socket.onSend = function () { body }
2.52
SplashWnd
Description Creates and displays a splash window. Not available for screen savers. available: SWFKit Pro Syntax new SplashWnd(width, height) Parameters width Integer. Species the width of the splash window. height Integer. Species the height of the splash window. Remarks SWFKit Pro 2 can only maintain one splash window at the same time. That is to say, if you want to create another splash window, you must rstly close the created one. Or the expression new Splash(width, height) will always return a reference to the created one.
484
2.52.1
2.52.1.1
Properties
timeout
Description Integer. Species the time-out interval, in milliseconds. The splash window closes and the onTimeout event res if the interval elapses. Syntax splashwnd.timeout
2.52.1.2
window
Description A window object represents the splash window. The object is invalid after the after the splash window has been closed. Syntax splashwnd.window
2.52.2
2.52.2.1
Methods
loadSWF
Description Loads a swf movie into the splash window. Syntax splashwnd.loadSWF(movie) Parameters movie String. Species the full path name of the SWF movie.
2.53 Splash2
485
2.52.3
2.52.3.1
Events
onFSCommand
Description Fires when the playing movie in the splash window calls a FSCommand Syntax splashwnd.onFSCommand = function (cmd, args) { trace(cmd); trace(args); } Parameters cmd String. Represents the FSCommand. args String. Represents the parameter of the FSCommand.
2.52.3.2
onTimeout
Description Fires when the time-out interval elapses. Syntax splashwnd.onTimeout = function () { } Parameters None
2.53
Splash2
Description
486
FFish Script Objects Reference Creates and displays a splash window. Not available for screen savers. Unlike the SplashWnd object, this splash window object will run in a new thread; that is to say, even if the main program has been blocked by a time costing operation. For example, if the output executable le of swfkit has a lot of resource les packed in it, the getAdditionalFile method in the initialize script will take to long time to extract the resource les. Before all the resource les have been extracted, the main program will be blocked. If you use the SplashWnd object to create a splash window before the getAdditionalFile method, the splash window will also be blocked; however, if you use Splash2 object instead, the splash window will not be blocked. available: SWFKit Pro
Syntax new Splash2(movie, timeout) Parameters movie String. Species the swf movie to be played in the splash window timeout Integer. Life span of the splash window in milliseconds. You get also set this parameter to a rather big value, and close the splash window later manually by using the close method.
2.53.1
2.53.1.1
Methods
close
2.54 Printer
487
2.54
Printer
Description The Printer object provides methods to enumerate printers in system, print images or text on a printer. It also supports print preview. Not available for screen savers. available: SWFKit Pro How to use the Printer object 1. Lists all printers in system for (i = 0; i < Printer.printers.length; i++) { trace(Printer.printers[i]); } 2. Sets the title of the document to print Printer.title = "my doc"; 3. Selects a printer to use Printer.printerIndex = 0; 4. Does print or print preview Printer.print(); //or Printer.printPreview(); During printing or print preview, 5 events will be red. You can change the printer properties and dene the print jobs in these event handlers. The event handlers are uniform for both printing and print preview, so you can get the same result in both printing and print preview. The following pseudo code shows how will these event handlers be called. function print_or_print_preview() { onPreparePrinting() onBeginPrinting() for (i = 0; i < pages; i++) { onNewPage(i); onPrint(i); }
488 onEndPrinting(); }
5. Handles the onPreparePrinting event In the onPreparePrinting event handler, you should set the total count of pages you want to print. You can also change the printer used to print or set the title of the document in it. If you dont want to launch a print dialog, set the silent property to true. Remember to use the this pointer to access the properties or methods of the Printer object. For the this pointer contains the printer context used to dierentiate between printing and print preview. Printer.onPreparePrinting = function () { this.pageCount = 3; this.silent = true; } 6. Handles the onBeginPrinting event In the onBeginPrinting event handler, you can set several properties of the printer such as orientation, paper size or copies of the document to print. The properties may have been set in the print dialog before this event after the onPreparePrinting event, but you still can change them in this event handler. Printer.onBeginPrinting = function () { this.orientation = true; this.paperSize = 1; this.copies = 3; } 7. Handles the onNewPage event The onNewPage will be red before rendering a new page. In this event you can abort printing by set the continuePrinting property to false; Printer.onNewPage = function (page) { if (page >= 2) { this.continuePrinting = false; } } 8. Handles the onPrint event This event handler is used to render the page. The Printer provides properties and methods to draw text, images, lines, etc.
2.54 Printer The following code shows how to print the screen. //capture screen image = Image.captureScreen(); Printer.onPrint(page) { // only render the first page if (page > 0) return; // get the image size(not its actual size, //but its size should be on paper) var size = this.getImageSize(image); // put the image on the center of the paper var width = this.pageWidth; var height = this.pageHeight; var left = (width - size.width) / 2; var top = (height - size.height) / 2; this.printImage(image, left, top, size.width, size.height); } You can also draw text, lines or shapes on the paper. . Draw text. You must set the font, bkColor, textColor, bkMode properties before drawing text. If the bkMode is set to opaque, the character cells will be lled with the bkColor. Otherwise the background will remain untouched. . Draw lines. You must set the pen property before drawing a line. . Draw shapes. You must set the pen and the brush properties before drawing a shape. The pen is used to draw the frame of the shape, the brush is used to ll the shape. If you only want to draw the frame of the shape, set brush to hollow.
489
2.54.1
2.54.1.1
Properties
printers
2.54.1.2
printerIndex
Description Integer. Species a printer in the printer list returned by the printers property used to print. Syntax Printer.printers Example trace(Printer.printers[Printer.printerIndex]); Printer.printerIndex = 0;
2.54.1.3
title
2.54.1.4
pageCount
Description Integer. Species the total number of pages of the document. You must set it in the onPreparePrinting event handler. Syntax Printer.pageCount
491
Description Boolean. You can set it to true in the onPreparePrinting event handler to prevent the print method from displaying the print dialog. Syntax Printer.silent
2.54.1.6
orientation
Description Boolean. Selects the orientation of the paper. You can set it in the onBeginPrinting event handler. true landscape false portrait Syntax Printer.orientation
2.54.1.7
paperSize
Description Boolean. Selects the size of the paper to print on. You can set it in the onBeginPrinting event handler. It can be one of the following values:
Value 1 2 3 4 5 Description Letter 8 1/2 x 11 in Letter Small 8 1/2 x 11 in Tabloid 11 x 17 in Ledger 17 x 11 in Legal 8 1/2 x 14 in continued on next page
492
continued from the previous page Value 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 Description Statement 5 1/2 x 8 1/2 in
Executive 7 1/4 x 10 1/2 in A3 297 x 420 mm A4 210 x 297 mm A4 Small 210 x 297 mm A5 148 x 210 mm B4 (JIS) 250 x 354 B5 (JIS) 182 x 257 mm Folio 8 1/2 x 13 in Quarto 215 x 275 mm 10x14 in 11x17 in 8 1/2 x 11 in Envelope #9 3 7/8 x 8 7/8 Envelope #10 4 1/8 x 9 1/2 Envelope #11 4 1/2 x 10 3/8 Envelope #12 4 3/4 x 11 Envelope #14 5 x 11 1/2 C size sheet D size sheet E size sheet Envelope DL 110 x 220mm Envelope C5 162 x 229 mm Envelope C3 324 x 458 mm Envelope C4 229 x 324 mm Envelope C6 114 x 162 mm Envelope C65 114 x 229 mm Envelope B4 250 x 353 mm Envelope B5 176 x 250 mm continued on next page
2.54 Printer
continued from the previous page Value 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 275 x 12 in 51 275 x 15 in 52 53 54 275 x 11 in 55 56 275 x 12 in 57 58 59 SuperA/SuperA/A4 227 x 356 mm SuperB/SuperB/A3 305 x 487 mm Letter Plus 8.5 x 12.69 in continued on next page A4 Transverse 210 x 297 mm Letter Extra Transverse 9 Tabloid Extra 11.69 x 18 in A4 Extra 9.27 x 12.69 in Letter Transverse 8 Legal Extra 9 Description Envelope B6 176 x 125 mm Envelope 110 x 230 mm Envelope Monarch 3.875 x 7.5 in 6 3/4 Envelope 3 5/8 x 6 1/2 in US Std Fanfold 14 7/8 x 11 in German Std Fanfold 8 1/2 x 12 in German Legal Fanfold 8 1/2 x 13 in B4 (ISO) 250 x 353 mm Japanese Postcard 100 x 148 mm 9 x 11 in 10 x 11 in 15 x 11 in Envelope Invite 220 x 220 mm RESERVEDDO NOT USE RESERVEDDO NOT USE Letter Extra 9
493
494
continued from the previous page Value 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 Description A4 Plus 210 x 330 mm
A5 Transverse 148 x 210 mm B5 (JIS) Transverse 182 x 257 mm A3 Extra 322 x 445 mm A5 Extra 174 x 235 mm B5 (ISO) Extra 201 x 276 mm A2 420 x 594 mm A3 Transverse 297 x 420 mm A3 Extra Transverse 322 x 445 mm Japanese Double Postcard 200 x 148 mm A6 105 x 148 mm Japanese Envelope Kaku #2 Japanese Envelope Kaku #3 Japanese Envelope Chou #3 Japanese Envelope Chou #4 Letter Rotated 11 x 8 1/2 11 in A3 Rotated 420 x 297 mm A4 Rotated 297 x 210 mm A5 Rotated 210 x 148 mm B4 (JIS) Rotated 364 x 257 mm B5 (JIS) Rotated 257 x 182 mm Japanese Postcard Rotated 148 x 100 mm Double Japanese Postcard Rotated 148 x 200 mm A6 Rotated 148 x 105 mm Japanese Envelope Kaku #2 Rotated Japanese Envelope Kaku #3 Rotated Japanese Envelope Chou #3 Rotated Japanese Envelope Chou #4 Rotated B6 (JIS) 128 x 182 mm continued on next page
2.54 Printer
continued from the previous page Value 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 Description B6 (JIS) Rotated 182 x 128 mm 12 x 11 in Japanese Envelope You #4 Japanese Envelope You #4 Rotated PRC 16K 146 x 215 mm PRC 32K 97 x 151 mm PRC 32K(Big) 97 x 151 mm PRC Envelope #1 102 x 165 mm PRC Envelope #2 102 x 176 mm PRC Envelope #3 125 x 176 mm PRC Envelope #4 110 x 208 mm PRC Envelope #5 110 x 220 mm PRC Envelope #6 120 x 230 mm PRC Envelope #7 160 x 230 mm PRC Envelope #8 120 x 309 mm PRC Envelope #9 229 x 324 mm PRC Envelope #10 324 x 458 mm PRC 16K Rotated PRC 32K Rotated PRC 32K(Big) Rotated PRC Envelope #1 Rotated 165 x 102 mm PRC Envelope #2 Rotated 176 x 102 mm PRC Envelope #3 Rotated 176 x 125 mm PRC Envelope #4 Rotated 208 x 110 mm PRC Envelope #5 Rotated 220 x 110 mm PRC Envelope #6 Rotated 230 x 120 mm PRC Envelope #7 Rotated 230 x 160 mm PRC Envelope #8 Rotated 309 x 120 mm PRC Envelope #9 Rotated 324 x 229 mm continued on next page
495
496
continued from the previous page Value 118 Description
Syntax Printer.paperSize
2.54.1.8
copies
Description Integer. Selects the number of copies printed. You can set it in the onBeginPrinting event handler. Syntax Printer.copies
2.54.1.9
continuePrinting
Description Boolean. It can be used in the onNewPage event handler. Set it to false to abort the printing. Syntax Printer.continuePrinting
2.54.1.10
pageHeight
Description Integer. Returns the height of the page. It can be used in the onPrint event handler. Syntax Printer.pageHeight
497
Description Integer. Returns the width of the page. It can be used in the onPrint event handler. Syntax Printer.pageWidth
2.54.1.12
font
Description FontObject object. Selects the current font to draw text. It can be used in the onPrint event handler. Write only. Syntax Printer.font Example var font = new FontObject; font.name = "Arial"; font.size = 11; Printer.font = font;
2.54.1.13
brush
Description Object. Selects the current brush to ll shapes. It can be used in the onPrint event handler. Write only. The properties must be assigned by an object contains the following properties style Integer. Species the brush style. It can be the following values: 0 Solid brush 1 Hollow brush 2 Hatched brush color Integer. Species the brush color. hatch Integer. Species a hatch style(for a hatched brush). It can be one of the following values:
FFish Script Objects Reference Horizontal hatch Vertical hatch A 45-degree downward, left-to-right hatch A 45-degree upward, left-to-right hatch Horizontal and vertical cross-hatch 45-degree crosshatch
function brush(style, color, hatch) { this.style = style; this.color = color; this.hatch = hatch; } Printer.onPrint = function (page) { this.brush = new brush(0, 0xFFFFFF, 0); }
2.54.1.14
pen
Description Object. Selects the current pen to draw lines or frames. It can be used in the onPrint event handler. Write only. The properties must be assigned by an object contains the following properties style Integer. Species the pen style. It can be the following values: 0 1 2 3 4 5 The The The The The The pen pen pen pen pen pen is solid. is dashed. is dotted. has alternating dashes and dots has dashes and double dots. is invisible.
color Integer. Species the pen color. width Integer. Species the width of the pen.
2.54 Printer Syntax Printer.pen Example function pen(style, width, color) { this.style = style; this.width = width; this.color = color; } Printer.onPrint = function (page) { this.brush = new pen(0, 1, 0); }
499
2.54.1.15
bkColor
Description Integer. Sets the background color to draw text. It can be used in the onPrint event handler. Write only. Syntax Printer.bkColor
2.54.1.16
textColor
Description Integer. Sets the text color to draw text. It can be used in the onPrint event handler. Write only. Note: the FontObject also has a color property, but it can not change the color to draw text. Syntax Printer.textColor
Description Integer. Sets the background mode to draw text. It can be used in the onPrint event handler. Write only. It can be one of the following values: 1 Transparent. The background remains untouched. 2 Opaque. The background will be lled with the bkColor. Syntax Printer.bkMode
2.54.2
2.54.2.1
Methods
print
Description Prints the document. Syntax Printer.print() Parameters None Returns Nothing
2.54.2.2
printPreview
Description Does print preview Syntax Printer.printPreview() Parameters None Returns Nothing
501
Description Draws formatted text on the page. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. This method is provided only for compatibility with the old version of swfkit pro. New applications should use the printText2 method Syntax Printer.printText(text, left, top, width, height, ag) Parameters text String. Represents the text to draw. left, top, width, height Integer. Represents a rectangle to draw the text in. ag Integer. Species how to format the text. It can be one or more of the following value. 0 Justies the text to the top of the rectangle or Aligns text to the left 1 Centers text horizontally in the rectangle 2 Aligns text to the right 4 Centers text vertically. This value is used only when you draw text on a single line 8 Justies the text to the bottom of the rectangle. This value is used only when you draw text on a single line 16 Breaks words. Lines are automatically broken between words if a word would extend past the edge of the rectangle. A carriage return-line feed sequence also breaks the line. 32 Displays text on a single line only. Carriage returns and line feeds do not break the line. 64 Expands tab characters. The default number of characters per tab is eight. 128 Sets tab stops. Bits 15C8 (high-order byte of the loworder word) of the ag parameter specify the number of characters for each tab. The default number of characters per tab is eight. 256 Draws without clipping. 512 Includes the font external leading in line height. Normally, external leading is not included in the height of a line of text.
502
Returns Nothing
2.54.2.4
printText2
Description Draws text on the page. It can be and can only be called in the onPrint event handler with the this object, for only the this object contains the printing context. Syntax this.printText2(text, left, top, width, height[, tabstop[, wrap]]) Parameters text String. Represents the text to draw. left, top, width, height Integer. Represents a rectangle to draw the text in. tabstop Integer. Optional. Species the width of each tab stop. The default value is 32, which means eight times of the average character width (based on uppercase and lowercase alphabetic characters only) of the font used at the time of printing. wrap Boolean. Optional. Wraps the text in the rectangle or not. The default value is true, which means the text will be wrapped. Returns String. If the text is too long to print in the rectangle, the method will return the remain words.
2.54.2.5
getWrappedTextExtent
Description Gets the height of the specied text which would be print in a column. It can be and can only be called in the onPrint event handler with the this object, for only the this object contains the printing context.
2.54 Printer Syntax this.getWrappedTextExtent(text, columnwidth[, tabstop]) Parameters text String. Represents the text to calculate the height. columnwidth Integer. Species the width of the column in which the text would be print. tabstop Integer. Optional.Species the with of each tab stop. The default value is 32, which means eight times of the average character width (based on uppercase and lowercase alphabetic characters only) of the font used at the time of printing. Returns Integer. The height of the text.
503
2.54.2.6
getTabbedTextExtent
Description Gets the width and height of the specied single line text. It can be and can only be called in the onPrint event handler with the this object, for only the this object contains the printing context. Syntax this.getTabbedTextExtent(text[, tabstop]) Parameters text String. Represents the text to calculate the width and height. tabstop Integer. Optional.Species the with of each tab stop. The default value is 32, which means eight times of the average character width (based on uppercase and lowercase alphabetic characters only) of the font used at the time of printing. Returns Object. The object contains two Integer properties, width and height.
Description Gets the height of the specied text. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the printing context. This method is provided only for compatibility with the old version of swfkit pro. New applications should use the getWrappedTextExtent method Syntax Printer.getTextHeight(text, left, top, width, height, wrap) Parameters text String. Represents the text to draw. left, top, width, height Integer. Represents a rectangle to draw the text in wrap Boolean. If its true, the text will be wrapped in the rectangle, and the method returns the total height of the text on multi lines; otherwise, the method returns the height of a single line. Returns Integer. The height of the text.
2.54.2.8
getTextExtent
Description Computes the width and height of a line of text. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. Syntax Printer.getTextExtent(text) Parameters text String. Represents a string text. Returns Object. Contains two properties. width Integer. The width of the text height Integer. The height of the text
505
Description Draws an image. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. Syntax Printer.printImage(image, left, top, width, height) Parameters Image Image object. Represents the image to draw. left, top, width, height Integer. Represents a rectangle to draw the image in Returns Nothing
2.54.2.10
getImageSize
Description Gets the size of an image. The Image object provides methods to get the dimension of an image. But thats its real size. This method returns the size of the image should be on paper. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. Syntax Printer.getImageSize(image) Parameters Image Image object. Represents an image Returns Object. Contains two properties. width Integer. The width of the image height Integer. The height of the image
Description Draws a line. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. Syntax Printer.line(x0, y0, x1, y1) Parameters x0 y0 x1 y1 Returns Nothing Integer. Integer. Integer. Integer. Species Species Species Species the the the the x-coordinate y-coordinate x-coordinate y-coordinate of of of of the the the the lines lines lines lines starting point. starting point. ending point. ending point.
2.54.2.12
rectangle
Description Draws a rectangle. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. Syntax Printer.rectangle(left, top, width, height) Parameters left Integer. Species the x-coordinate of the upper-left corner of the rectangle top Integer. Species the y-coordinate of the upper-left corner of the rectangle width Integer. Species the width of the rectangle. height Integer. Species the height of the rectangle. Returns Nothing
507
Description Draws a round rectangle. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. Syntax Printer.roundRect(left, top, width, height, ellipseWidth, ellipseHeight) Parameters left Integer. Species the x-coordinate of the upper-left corner of the rectangle top Integer. Species the y-coordinate of the upper-left corner of the rectangle width Integer. Species the width of the rectangle. height Integer. Species the height of the rectangle. ellipseWidth Integer. Species the width of the ellipse. ellipseHeight Integer. Species the height of the ellipse. Returns Nothing
2.54.2.14
ellipse
Description Draws an ellipse. You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. Syntax Printer.ellipse(left, top, width, height) Parameters left Integer. Species the x-coordinate of the upper-left corner of the bounding rectangle top Integer. Species the y-coordinate of the upper-left corner of the bounding rectangle
508
width Integer. Species the width of the rectangle. height Integer. Species the height of the rectangle. Returns Nothing
2.54.2.15
llRect
Description Fills a rectangle(without drawing the frame and you dont need to set the pen and brush properties). You can use it in the onPrint event handler, and remember to call it by using the this object in the event handler. For the this object contains the print context. Syntax Printer.llRect(left, top, width, height, brush) Printer.llRect(left, top, width, height, color) Parameters left Integer. Species the x-coordinate of the upper-left corner of the rectangle top Integer. Species the y-coordinate of the upper-left corner of the rectangle width Integer. Species the width of the rectangle. height Integer. Species the height of the rectangle. brush Object. Species the brush used to ll the rectangle. See the brush property. color Integer. Species the color to ll the rectangle. Returns Nothing
2.54 Printer
509
2.54.3
2.54.3.1
Events
onPreparePrinting
Description Fires when its preparing to print Syntax Printer.onPreparePrinting = function () { } Parameters None
2.54.3.2
onBeginPrinting
Description Fires when its beginning to print Syntax Printer.onBeginPrinting = function () { } Parameters None
2.54.3.3
onNewPage
Description Fires when its beginning to print on a new page Syntax Printer.onNewPage = function (page) { } Parameters page Integer. The page number. The number of the rst page is 0.
Description Fires when its printing. You should handle this event to render the page. Syntax Printer.onPrint = function (page) { } Parameters page Integer. The page number. The number of the rst page is 0.
2.54.3.5
onEndPrinting
Description Fires when the printing job has been done. Syntax Printer.onEndPrinting = function () { } Parameters None
2.55
Image
Description available: SWFKit Pro Manipulates images. Before you can manipulate an image, load it by the load method or capture an image by the captureScreen method or the captureMovie method. You can also get an image from clipboard by the Application.clipboard.pasteBitmap method. All these methods return an instance of the Image object. The Image object also provides methods to access the TWAIN interface. The TWAIN interface feature is not available for Screen Savers. The supported image formats are:
2.55 Image bmp wmf emf jpg jpeg ico pcx ti tif tga gif png read, write read read, write read read read read read read, write
511
Remarks The Image object supports the TWAIN interface, you can use it to scan images using a scanner: 1. Initializes the TWAIN driver Image.twainInit(); 2. Selects a source Image.twainSelectSource(); 3. Acquires images When an image is transferred to the application, the onCopyImage event will be red. You should save the transferred image by handling the event var imgs = []; Image.twainAcquire(); Image.onCopyImage = function (image) { imgs.push(image); image.loadImage(1); }
2.55.1
2.55.1.1
Properties
width
Description Integer. Returns the width of the image. Read-only. Syntax image.width
Description Integer. Returns the height of the image. Read-only. Syntax image.height
2.55.1.3
bitCount
Description Integer. Returns the number of bits-per-pixel of the image. Readonly. Syntax image.bitCount
2.55.1.4
twainReady
Description Boolean. If its ready to use the TWAIN interface. You must call the twainInit method rstly, or it returns false. Syntax image.twainReady
2.55.1.5
twainSourceSelected
Description Boolean. If a source is selected. You must select a source before you can acquire images. Syntax image.twainSourceSelected
2.55 Image
513
2.55.2
2.55.2.1
Methods
load
Description Loads an image. Syntax image.load(name[, bkcolor, width, height, index]) Parameters name String. Species the full path name of the image to load. bkcolor Integer. Optional. Species the background color of the image. Images support transparent background such as icons, png les need the parameter. The default value is white. width, height Integer. Species the width and height of the image to load. Only needed for loading icons. An icon le may contains a serial of images with dierent size. index Integer. Species the index of the image to load. Gif les and tif les may contain more than one image, use this parameter to specify the image you want to load in the image le. The index of the rst image is 0. Returns An image object. If fails, return null. Example var image = Image.load("c:\\test.bmp"); trace(image.width); trace(image.height);
2.55.2.2
save
514
name String. Species the full path name of the image to save. compresslevel Integer. Optional. For saving png les, it can be from 0 to 9. 0 means no compression, 9 means maximum compression. The default value is 5. For saving jpg les, the default value is 100. Returns Boolean. Example var image = Image.load("c:\\test.bmp"); trace(image.width); trace(image.height); image.save("c:\\test.jpg");
2.55.2.3
mirror
Description Converts to mirror image. Syntax image.mirror() Parameters None Returns Boolean
2.55.2.4
ip
Description Flips the image. Syntax image.ip() Parameters None Returns Boolean
515
Description Rotates the image 90 degree. Syntax image.rotate90() Parameters None Returns Boolean
2.55.2.6
rotate270
Description Rotates the image 270 degree. Syntax image.rotate270() Parameters None Returns Boolean
2.55.2.7
zoom
Description Zooms the image with the specied factor. Syntax image.zoom(factor) Parameters factor Number. Species the zoom factor. Returns Boolean
Description Modies the intensities of red, green and blue in the color of each pixel in the image by adding the specied values. Syntax image.adjustRGB(r, g, b) Parameters r Integer. Species the value to add to the intensity of red. g Integer. Species the value to add to the intensity of green. b Integer. Species the value to add to the intensity of blue. Returns Boolean
2.55.2.9
adjustBrightness
Description Adjusts the brightness of the image. Syntax image.adjustBrightness(value) image.adjustBrightness(rate) Parameters value Integer. Species the value to adjust. rate oat. Species the rate to adjust. Returns Boolean
517
Description Adjusts the contrast of the image. Syntax image.adjustContrast(percent) Parameters percent Integer. Species the percent to adjust. From 0 to 100. Returns Boolean
2.55.2.11
adjustHS
Description Adjusts the hue and saturation of the image. Syntax image.adjustHS(hpercent, spercent) Parameters hpercent Integer. Species the percent of the hue to adjust. From 0 to 100. spercent Integer. Species the percent of the saturation to adjust. From 0 to 100. Returns Boolean
Description Inverts the image. Syntax image.invert() Parameters None Returns Boolean
2.55.2.13
blur
Description Blurs the image. Syntax image.blur() Parameters None Returns Boolean
2.55.2.14
blurGauss
Description Blurs the image. Syntax image.blurGauss() Parameters None Returns Boolean
519
Description Sharpens the image. Syntax image.sharpen() Parameters None Returns Boolean
2.55.2.16
emboss
Description Embosses the image. Syntax image.emboss([step]) Parameters step Integer. Species the emboss step. The default value is 2. Returns Boolean
2.55.2.17
to24Bits
Description Converts the image to a 24 bits color image. Syntax image.to24Bit() Parameters None Returns Boolean
Description Converts the mode of the image to gray scale. Syntax image.toGray() Parameters None Returns Boolean
2.55.2.19
crop
Description Crops the image. Syntax image.crop(left, top, right, bottom) Parameters left, top, width, height Integer. Represents a rectangle to crop. Returns Boolean
2.55.2.20
getCount
Description Gets the image count in a image le. For bmp, jpg, png, wmf and ico les, the method always returns 1. Syntax Image.getCount(name) Parameters name String. Species the full path name of the image le. Returns Integer
521
Description Captures screen and returns an image object. Syntax Image.captureScreen([left, top, width, height]) Parameters left, top, right, bottom Optional. Integer. Species the coordinates of the upper-left and lower-right corners of a rectangle. The rectangle denes the area of screen to capture. If you call the method without parameters, it will capture the entire screen. Returns An image object. If fails, return null.
2.55.2.22
captureMovie
Description Captures the playing movie and returns an image object. Syntax Image.captureMovie([left, top, width, height]) Parameters left, top, right, bottom Optional. Integer. Species the coordinates of the upper-left and lower-right corners of a rectangle. The rectangle denes the area of the playing movie to capture. If you call the method without parameters, it will capture the entire movie. Returns An image object. If fails, return null.
Description Loads the image into the specied level of the movie. Syntax image.loadImage(level) Parameters level Integer. Species the level of the movie to load. Returns Boolean
2.55.2.24
twainInit
Description Initializes the TWAIN driver. Syntax Image.twainInit() Parameters None Returns Nothing
2.55.2.25
twainSelectSource
Description Displays a dialog box to select a source. Syntax Image.twainSelectSource() Parameters None Returns Nothing
523
2.55.3
2.55.3.1
Events
onCopyImage
Description Fires when an image is transferred from the TWAIN driver to the application. Syntax Image.onCopyImage = function (image) { } The image parameter is an Image object represents the transferred image.
2.56
DirectX
Description Uses DirectX to change the screen resolution and enumerates joysticks. You can make your full screen sized applications run faster using the DirectX object to set a lower screen resolution. available: SWFKit Express, SWFKit, SWFKit Pro
524
2.56.1
2.56.1.1
Properties
joysticks
Description Array. Returns all attached joysticks in the system. Read-only. Each item in the returned array is an object contains two properties name String. The name of the joystick guid String. The unique identier of the joystick. You can use the value to create a Joystick object. Syntax DirectX.joysticks Example var x = DirectX.joysticks; for (i = 0; i < x.length; i++) { trace(x[i].name); trace(x[i].guid); }
2.56.2
2.56.2.1
Methods
setDisplayMode
Description Sets the display mode. Syntax DirectX.setDisplayMode(width, height, colordepth) Parameters width Integer. Species the width of the screen. height Integer. Species the height of the screen. colordepth Integer. Species the color depth. Returns Boolean. If DirectX has not been installed or the specied display mode is not supported, returns false. The method requires at least DirectX 3. You can list all supported display modes using the SysInfo.getDisplayMode method.
525
Description Resets the mode of the display device hardware to what it was before the setDisplayMode method was called Syntax DirectX.restore() Parameters None Returns Boolean.
2.57
Joystick
Description Accesses a joystick. Requires DirectX 5 or higher. available: SWFKit Pro Syntax new Joystick(guid)
2.57.1
2.57.1.1
Properties
buttons
Description Array. Returns names of all the buttons of the joystick Syntax joystick.buttons
526 2.57.1.2 x
Description Integer. X-axis, usually the left-right movement of a stick. Readonly. Syntax joystick.x
2.57.1.3
Description Integer. Y-axis, usually the forward-backward movement of a stick. Read-only. Syntax joystick.y
2.57.1.4
Description Integer. Z-axis, often the throttle control. Read-only. Syntax joystick.z
2.57.1.5
rx
527
2.57.1.7
rz
Description Integer. Z-axis rotation (often called the rudder). Read-only. Syntax joystick.rz
2.57.1.8
uaxis
2.57.1.9
vaxis
Description Integer. Direction controllers, such as point-of-view hats. Read-only. Syntax 1. joystick.pov0 2. joystick.pov1 3. joystick.pov2 4. joystick.pov3
2.57.1.11
range
Description Object. Returns the range of the axes. Read-only. Contains two properties xMin Integer. Lower limit of the range. xMax Integer. Upper limit of the range. Syntax joystick.range
2.57.1.12
deadzone
Description Integer. Returns the dead zone of the axes. Read-only. Syntax joystick.deadzone
2.57 Joystick
529
2.57.2
2.57.2.1
Methods
read
Description Reads input of the joystick and res events. Syntax joystick.read() Parameters None Returns Nothing Example var x = DirectX.joysticks; for (i = 0; i < x.length; i++) { trace(x[i].name); trace(x[i].guid); } joy = []; joy[0] = new Joystick(x[0].guid); joy[1] = new Joystick(x[1].guid); trace(joy[0].buttons); joy[0].onLeft = function () { trace("left"); } joy[0].onUp = function () { trace("up"); } joy[0].onRight = function () { trace("right"); }
530
joy[0].onDown = function () { trace("down"); } joy[0].onPress = joy[1].onPress = function (n) { trace(n); } function readJoystick() { joy[0].read(); joy[1].read(); } Application.setInterval(readJoystick, 50);
2.57.2.2
buttonState
Description Gets the state of the specied button. You should call the read method before get the state of a button. Syntax joystick.buttonState(index) Parameters index Integer. Species the index of the button. The index of the rst button is 0. Returns Boolean. If the button is pressed, returns true. Example function readJoystick() { joy[0].read();
531
2.57.3
2.57.3.1
Events
onLeft
2.57.3.2
onRight
2.57.3.3
onUp
2.57.3.5
onPress
Description Fires when a button is pressed Syntax joystick.onPress = function (index) { } Parameters index Integer. The index of the pressed button.
2.58
Dll
Description availability: SWFKit Pro 2.0 Calling dynamic-link libraries (.dll les) in FFish Scripting language. With the Dll object, you can call functions developed by C/C++, Pascal, Basic, etc to extend the power of Flash. SWFKit Pro 3 supports two methods of importing an external function in a dll. The rst one is to call the registerFunction method of the Dll object, and the second one is to use the dllimport keyword. The latter method is recommended. You can read the manual page of the registerFunction method to learn how to use it. At here we will only introduce the dllimport keyword as follows. The dllimport keyword is used to import an external function so that you can call the function in sh script as if it is a built-in function. The dllimport clause has the form
2.58 Dll dllimport libraryName callType returnType functionName(arg0, arg1, ..., argN) [as alias]; Where libraryName is the path name of the dll that contains the function to import. It can be either a string constant or a string variable. callType species the calling convention of the function to import, which can be either stdcall or cdecl. The fastcall calling convention is not supported in SWFKit Pro 3.0 yet. returnType species the return type of the function. functionName is the name of the function exported by the dll. arg0, arg1, ... argN declare the parameters of the function, which dene the type of the each parameter, with or without the name of each parameter. alias is optional, which species the alias of the function. If you specify an alias for the function, you must call the function by using the alias in sh script; otherwise, you must use the functionName to call it. For instance:
533
dllimport "user32.dll" stdcall long GetWindowLong(pointer, int) as user32_getWindowLong; var GWL_STYLE = -16; var styles = user32_getWindowLong(getMainWnd().handle, GWL_STYLE); trace(styles); SWFKit supports the following types of the return values and parameters: void For returns only, you cannot declare a parameter to be of this type. This type means that the function has no return. char The return value or a parameter is a character. When a function returns a value of char type, the value will be converted to a Number object in sh script that contains the ASCII value of the character. String objects and Number objects can be passed as a parameter of char type. Only the rst character of a String object will be used to set the value of the parameter; if a Number object is used, SWFKit will convert its value to a character and then pass the character to the function. unsigned char The return value or a parameter is an unsigned character. This type is similar to the char type. char* The return value or a parameter is a pointer to a char value or a ansi string. When a functions return is of char* type, SWFKit will simply convert it to a Number object that represents the address of the pointer, not the value it points to. In fact SWFKit will always do in this way when a function returns a pointer. The address of the pointer should be retained because the pointer may point to an allocated memory
534
FFish Script Objects Reference and may be used to free the memory later. You can use the getPointerXXXValue methods of the Dll object such as getPointerStringValue, getPointerWideStringValue, etc to get the value it points to. When a parameter is of char* type, you can use A String object or A Number object to pass parameter. SWFKit will convert a String object to a c-style string (a null terminated string) before pass it to the function if the parameter is of char* type. For a Number object, SWFKit will rst convert it to a char value and then allocate a pointer to pass to the function, which points to the converted char value. Similar to the char* type. The return value or a parameter is a short integer (A short integer is 16 bits). When a function returns a value of short type, the value will be converted to a Number object. String objects and Number objects can be passed as a parameter of short type. Only the rst character of a String object will be used to set the value of the parameter; if a Number object is used, SWFKit will convert it to a short integer and then pass the value to the function. Similar to the short type. The return value or a parameter is a pointer to a short integer or a wide string. When a function returns a value of short* type, SWFKit will simply convert it to a Number object that represents the address of the pointer. When a functions parameter is of short* type, you can use a String object or a Number object to pass parameter. SWFKit will convert a String object to a wide string (null terminated) before pass it to the function. For a Number object, SWFKit will rst convert it to a short integer and then allocate a pointer to pass to the function, which points to the converted short integer. Similar to the short* type. The return value or a parameter is a 32-bit long value. When a function returns a value of this type, the value will be converted to a Number object. String objects, Number objects and Boolean objects can be passed as parameters of long type. Only the rst character of a String object will be used to set the value of the parameter; if a Number object or a Boolean object is used, SWFKit will convert it to a long value and then pass the value to the function. Similar to the long type. The return value or a parameter is a pointer to a long value. When a function returns a value of long* type, SWFKit will simply convert it to a Number object that represents the address of the pointer. When a functions parameter is of long*
2.58 Dll type, you would have to use a Number object or a Boolean object to pass value to it. In this case, SWFKit will convert the Number object or the Boolean object to a long value, and then allocate a pointer to pass to the function, which points to the converted long value. Similar to the long* type. Same as the long type. Same as the unsigned long type. Same as the long* type. Same as the unsigned long* type. The return value or a parameter is a 64-bit long integer. When a function returns a value of this type, the value will be converted to a Number object. String objects and Number objects can be passed as parameters of int64 type. Only the rst character of a String object will be used to set the value of the parameter; if a Number object is used, SWFKit will convert it to a 64-bit long integer value and then pass the value to the function. The return value or a parameter is a pointer to a 64-bit signed integer. When a function returns a value of int64* type, SWFKit will simply convert it to a Number object that represents the address of the pointer. When a functions parameter is of int64* type, you would have to use a Number object to pass value to it. In this case, SWFKit will convert the Number object to a 64-bit long integer, and then allocate a pointer to pass to the function, which points to the converted 64-bit integer. Similar to the int64 type. Similar to the int64* type. The return value or a parameter is a 4-byte oating-point number. When a function returns a value of this type, the value will be converted to a Number object. String objects and Number objects can be passed as parameters of this type. Only the rst character of a String object will be used to set the value of the parameter; if a Number object is used, SWFKit will convert it to a oating-point number and then pass the value to the function. Similar to the oat type. The dierence between the oat type and the double type is that the double type is 8 bytes long. The return value or a parameter is a pointer to a 4-byte oatingpoint number. When a function returns a value of oat* type, SWFKit will simply convert it to a Number object that represents the value of the pointer. When a functions parameter
535
int64*
double
oat*
536
FFish Script Objects Reference is of oat* type, you would have to use a Number object to pass value to it. In this case, SWFKit will convert the Number object to a 4-byte oating-point number, and then allocate a pointer to pass to the function, which points to the converted 4-byte oating-point number.
double* Similar to the double type. pointer The return value or a parameter is a pointer to an unspecied type. When a function returns a value of pointer type, SWFKit will simply convert it to a Number object that represents the address of the pointer. Similarly, you can pass a Number object as a parameter of pointer type to a function. In this case, SWFKit does not allocate a pointer to pass to the function. Instead, the value of the Number object is converted to a pointer and passed to the function, that is, the Number object must represent address of a pointer. A Struct object or a StringStream object can also be used to pass as a pointer type parameter. In this case, SWFKit will allocate a pointer to pass to the function, which points to the binary data hold by the Struct object or the StringStream object. String Same as the char* type. Boolean Same as the long type. Boolean* Same as the long* type. StructName The StructName must be a pre-declared structure type. The details of structure type will be introduced later in this manual page. If the return value of a function is of structure type, SWFKit will convert the return value to a Struct object. If a parameter of a function is of structure type, you can use a Struct object or a StringStream object that has the same data size as that of the pre-declared structure type to pass value to the function. StructName* The return value or a parameter is a pointer to a pre-declared structure type StructName. If the return value of a function is of this type, SWFKit will simply convert it to a Number object that represents the address of the pointer. If a parameter of a function is of this type, you can use a Struct object or a StringStream object to pass value to the function. In this case, a pointer is allocated and passed to the function, which points to the binary data hold by the Struct object or the StringStream object. Note: the above types can only be used to declare dll functions in FFish Script. You cannot use them to declare a FFish Script
2.58 Dll variable. Pointer to pointer type is also not supported, e.g. char ** is not supported, you would have to use the pointer type instead. The structure type For convenience of calling dll functions in FFish Script, we introduces a new element into the FFish Scripting language - the structure type. A structure type is declared by the struct keyword, and the declaration of a structure type is similar to that in the c/c++ languages. The declaration of a structure type has the following form: struct { type0 itemName0; type1 itemName1; ... typeN itemNameN; } StructName; where typeN is the type of the Nth member of the structure. itemNameN is the name of the Nth member. StructName is the name of the structure type. The valid types of a structure member are the same as those of a function parameter. Moreover, SWFKit Pro 3 supports embedded structure members and array members. E.g. struct { int value[4]; } myStruct; struct { myStruct myItem; struct { int iValue; float fValue; } myEmbeddedStructItem; } myStruct2; The struct keyword only declares a structure type. To create an instance of the declared structure type, you should create a Struct object by using the new operator. E.g. var struct1 = new Struct(myStruct); var struct2 = new Struct(myStruct2); struct1.value[0] = 0; struct2.myEmbeddedStructItem.iValue = 100;
537
538
FFish Script Objects Reference Pass values to parameters by referenceGenerally, SWFKit Pro pass parameters to functions by value. However, many dll functions have out parameters, that is, these parameters will be used for output so that they must be passed by reference. The sh scripting language does not support to pass parameters by reference directly, so an alternative calling method is introduced into the sh scripting language to support this feature. The method is to use Object objects to pass parameters to functions. The objects used to do this must have a value property, which is the actual variable to pass to the functions. After calling the functions, the value property of the objects will contain the new value output by the functions.
2.58.1
2.58.1.1
Methods
registerFunction
Description Registers a dll function. After the function has been registered, you can call it like a global function. Syntax Dll.registerFunction(libName, funcName[, aliasName[, callType[, [retType, [argType, ...]]]]]) Parameters libName String. Species the dll le name funcName String. Species the function name to register. aliasName String. Species the alias name of the function. Its used to call the registered function. callType String. Species the call type. cdecl or stdcall retType String. Species the return type. supported types are: void void* char char* or string byte byte* short short* widestring Species the function doesnt return a value A pointer. A character A string A byte A byte pointer A short integer A short integer pointer A wide string(Each character in the string is 16 bits).
2.58 Dll ushort ushort* long long* ulong ulong* longlong oat oat* double double* A A A A A A A A A unsigned short integer unsigned short integer pointer long integer long integer pointer unsigned long integer unsigned long integer pointer 64 bits integer oat oat pointer
539
You can also dene a new type using the DllParam object. //Providing a structure defined in C is //typedef struct tagMyStruct //{ // DWORD dwSize; // DWORD dwFlag; //} MyStruct, *PMyStruct; //to define the struct in FFish script, //you can do like this //The first parameter 8 indicates //the size of the structure is 8 //The second parameter 0 indicates //the type is not a pointer var MyStructType = new DllParam(8, 0); //The second parameter 1 indicates //the type is a pointer var PMyStructType = new DllParam(8, 1); If the function returns a pointer type, in FFish script, you get a integer represents the pointer after calling it. You can use the getPointerValue method to get its content. If the function returns a customized type, in FFish script, you get a StringStream object after calling it. Otherwise, FFish script converts the return value to integer or oat. argType String. Species the argument type of the function. See the retType. Returns Boolean
540 Example
Dll.registerFunction("kernel32.dll", "GetSystemDirectoryA", "winDir", "stdcall", "long", "char*", "long*"); function StringBuffer(length) { this.value = new StringStream; for (var i = 0; i < length; i++) this.value.put(0); } function LongBuffer(value) { this.value = value; } var buf = new StringBuffer(260); var length = new LongBuffer(260); trace(winDir(buf, length)); trace(buf.value);
2.58.1.2
unregisterFunction
Description Un-registers a function. Syntax Dll.unregisterFunction(name) Parameters name String. Species the alias name of the function. Returns Nothing
541
Description Gets the value represented by a pointer. Syntax Dll.getPointerValue(pointer, length) Parameters pointer Integer. Represents the pointer to get value. length Integer. Species the length of the value. Returns A StringStream object contains the value.
2.58.1.4
getPointerStringValue
Description Gets the null terminated string represented by the specied pointer. Syntax Dll.getPointerStringValue(pointer) Parameters pointer Integer. Represents the pointer to get value. Returns String.
542 2.58.1.5
Description Gets the null terminated wide-string represented by the specied pointer. Syntax Dll.getPointerWideStringValue(pointer) Parameters pointer Integer. Represents the pointer to get value. Returns String.
2.59
Struct
Description Constructs an instance of a pre-declared structure type. See Dll object. available: SWFKit Pro Syntax new Struct(StructName) Parameters StructName: a structure type declared by the struct keyword.
2.59.1
2.59.1.1
Properties
align
Description Integer. Gets or sets the alignment of the structure items. Its value can be 1, 2, 4, 8, 16, 32, etc which means that the structure is aligned at 1, 2, 4, 8, 16, 32, etc bytes. This property will aect the data size of all structure objects. The default value of this property is 8. Syntax Struct.align
543
Description Integer. Returns the data size of the structure object. Note: the data size of a structure object may change if you change the value of the align property. Syntax myStruct.structSize
2.60
Sound
Description Uses the audio mixer to change the volume of wave, CD, microphone, etc. available: SWFKit Pro
2.60.1
2.60.1.1
Properties
mixerName
Description String. Returns the name of the audio mixer. Read-only Syntax Sound.mixerName
2.60.1.2
Sound.playback.masterMute
Description Boolean. Set it to true to mute all lines for playback. Syntax Sound.playback.masterMute
544 2.60.1.3
Description An array has two integer items. Gets or sets the master volume for playback. Item 0 for the left channel, item 1 for the right channel. Syntax Sound.playback.masterVolume
2.60.1.4
Sound.playback.waveMute
Description Boolean. Set it to true to mute the wave line for playback. Syntax Sound.playback.waveMute
2.60.1.5
Sound.playback.waveVolume
Description An array has two integer items. Gets or sets the wave volume for playback. Item 0 for the left channel, item 1 for the right channel. Syntax Sound.playback.waveVolume
2.60.1.6
Sound.playback.midiMute
Description Boolean. Set it to true to mute the midi line for playback. Syntax Sound.playback.midiMute
545
Description An array has two integer items. Gets or sets the midi volume for playback. Item 0 for the left channel, item 1 for the right channel. Syntax Sound.playback.midiVolume
2.60.1.8
Sound.playback.CDMute
Description Boolean. Set it to true to mute the CD line for playback. Syntax Sound.playback.CDMute
2.60.1.9
Sound.playback.CDVolume
Description An array has two integer items. Gets or sets the CD volume for playback. Item 0 for the left channel, item 1 for the right channel. Syntax Sound.playback.CDVolume
2.60.1.10
Sound.playback.lineInMute
Description Boolean. Set it to true to mute the line in line for playback. Syntax Sound.playback.lineInMute
546 2.60.1.11
Description An array has two integer items. Gets or sets the line in volume for playback. Item 0 for the left channel, item 1 for the right channel. Syntax Sound.playback.lineInVolume
2.60.1.12
Sound.playback.microphoneMute
Description Boolean. Set it to true to mute the microphone line for playback. Syntax Sound.playback.microphoneMute
2.60.1.13
Sound.playback.microphoneVolume
Description Integer. Gets or sets the microphone volume for playback. Syntax Sound.playback.microphoneVolume
2.60.1.14
Sound.recording.lineInSelect
Description Boolean. If the line in line is selected for recording, returns true. Syntax Sound.recording.lineInSelect
547
Description An array has two integer items. Gets or sets the line in volume for recording. Item 0 for the left channel, item 1 for the right channel. Syntax Sound.recording.lineInVolume
2.60.1.16
Sound.recording.microphoneSelect
Description Boolean. If the microphone line is selected for recording, returns true. Syntax Sound.recording.microphoneSelect
2.60.1.17
Sound.recording.microphoneVolume
Description Integer. Gets or sets the microphone volume for recording. Syntax Sound.recording.microphoneVolume
2.60.2
2.60.2.1
Events
Sound.playback.onMasterMute
Description Fires when mutes all lines for playback. Syntax Sound.playback.onMasterMute = function() { }
548 2.60.2.2
Description Fires when the volume of all lines for playback changed. Syntax Sound.playback.onMasterVolumeChange = function() { }
2.60.2.3
Sound.playback.onWaveMute
Description Fires when mutes the wave line for playback. Syntax Sound.playback.onWaveMute = function() { }
2.60.2.4
Sound.playback.onWaveVolumeChange
Description Fires when the volume of the wave lines for playback changed. Syntax Sound.playback.onWaveVolumeChange = function() { }
2.60.2.5
Sound.playback.onMidiMute
Description Fires when mutes the midi line for playback. Syntax Sound.playback.onMidiMute = function() { }
549
Description Fires when the volume of the midi lines for playback changed. Syntax Sound.playback.onMidiVolumeChange = function() { }
2.60.2.7
Sound.playback.onCDMute
Description Fires when mutes the CD line for playback. Syntax Sound.playback.onCDMute = function() { }
2.60.2.8
Sound.playback.onCDVolumeChange
Description Fires when the volume of the CD lines for playback changed. Syntax Sound.playback.onCDVolumeChange = function() { }
2.60.2.9
Sound.playback.onLineInMute
Description Fires when mutes the line in line for playback. Syntax Sound.playback.onLineInMute = function() { }
550 2.60.2.10
Description Fires when the volume of the line in lines for playback changed. Syntax Sound.playback.onLineInVolumeChange = function() { }
2.60.2.11
Sound.playback.onMicrophoneMute
Description Fires when mutes the microphone line for playback. Syntax Sound.playback.onMicrophoneMute = function() { }
2.60.2.12
Sound.playback.onMicrophoneVolumeChange
Description Fires when the volume of the microphone lines for playback changed. Syntax Sound.playback.onMicrophoneVolumeChange = function() { }
2.60.2.13
Sound.recording.lineInSelect
Description Fires when selects the line in line for recording. Syntax Sound.recording.lineInSelect = function() { }
551
Description Fires when the volume of the line in lines for recording changed. Syntax Sound.recording.onLineInVolumeChange = function() { }
2.60.2.15
Sound.recording.onMicrophoneSelect
Description Fires when selects the microphone line for recording. Syntax Sound.recording.onMicrophoneSelect = function() { }
2.60.2.16
Sound.recording.onMicrophoneVolumeChange
Description Fires when the volume of the microphone lines for recording changed. Syntax Sound.recording.onMicrophoneVolumeChange = function() { }
2.61
PConn Object
Description Supports the interprocess communication. The server applications use the PConn object to listen for incoming connections, the client applications use the PConn object to connect to the server. available: SWFKit Pro
1. Listen with an unique server name The server must listen with an unique server name, the clients use the unique server name to connect to the server. var conn = new PConn(); conn.listen("This is a demo server"); 2. provide a function to process the connection The clients needs to call a function dened in the server function HandleData(p1, p2) { return p1 + " " + p2; } The client side needs only to connect to the server var conn = new PConn(); var result = conn.send("This is a demo server", "HandleData", "hello,world"); //the result is "hello world"
2.61.1
2.61.1.1
Methods
listen
Description Creates a server and listen to the incoming connections. Syntax pconn.listen(server) Parameters server String. Species an unique server name. Returns Nothing
553
Description Connects to a PConn server and call the specied function on the server. The result of this method is the result of the function called on the server. Syntax pconn.send(server, function, parameters) Parameters server String. Species unique name of a server to connect. function String. Species name of a function to call by this connection. parameters String. Species the parameters to pass to the function on the server. More than one parameters can be separated by ,. Returns String. The result of the function on the server.
2.62
Form Object
Description available: SWFKit Pro The Form object enable you to create applications with multiple forms. It can represent a modal or a modeless form. A form is a modal or modeless window contains a playing Flash movie(SWF le). The Form object provides methods to create a form and get data from a form. Each form has a return string. When the form is closed, you can test the return string of the form to see what action that has been done by the form. The return string can be returned by the sh ret command(see below) or the close method. If the form is closed by the x button, the return string will be empty. The playing ash movie in the form can call all the fscommands such as sh run, sh eval which are supported by swfkit. The form object support one more fscommand than the main movie: the sh ret command fscommand(sh ret, the ret value); When the movie calls the fscommand, the form will be closed and return a string the ret value.
1. Dene a form The form is a ash window, so rstly we must specify the movie to play in it. var form = new Form; form.movie = getMovies()[1]; form.showCaption = true; form.canDrag = true; form.caption = "A test"; 2. Initialize the variables in the movie form.initVars = "from=100&to=200&dir=c:\\"; 3. Dene the onExit event handler to get data from the movie in the form form.onExit = function (ret) { trace("The return value is: " + ret); trace(this.getVariable("_root.from")); trace(this.getVariable("_root.to")); trace(this.getVariable("_root.dir")); } 4. Display the form if (form.show() == ok) { ... }
2.62.1
2.62.1.1
Methods
show
Description
2.62 Form Object Displays the form. The method creates and shows the modal or modeless window. Be sure to set the movie property to a valid value, or the window cannot be created and nothing will be displayed on the screen otherwise. If the method displays a modeless window, the method will return immediately. If the method displays a modal window, the method wont return until the window has been closed. Syntax form.show([modal]) Parameters
555
modal Boolean. Species the form mode, modal(true) or modeless(false). The default value is true. Returns For modeless form, it will always return null. For modal form, it will return a string. The string can be returned by the sh ret command or the close method. If the window is closed by the x button on the top right corner of the form, it will return a empty string.
2.62.1.2
close
Description Closes the form. Syntax form.close(value) Parameters value String. Species the return value of the form. The value is the result of the show method for a modal window, or the parameter of the onExit event handler for both modal or modeless windows. Returns Nothing.
Description Gets the value of the specied variable in the playing movie in the form. This method is only meaningful in the life cycle of the window. Before the window is displayed or after the window is closed, this method always returns undened. This method can be called in the onExit event handler of the form. Syntax form.getVariable(variable) Parameters variable String. Species the name of the variable in the movie to get its value. Returns String.
2.62.1.4
setVariable
Description Sets the value of the specied variable in the playing movie in the form. This method is only meaningful in the life cycle of the window. Before the window is displayed or after the window is closed, this method does nothing. Syntax form.setVariable(variable, value) Parameters variable String. Species the name of the variable in the movie to set its value. value String. The value of the variable to be set. Returns Nothing.
557
Description Goes to the specied frame. This method is only meaningful in the life cycle of the window. Before the window is displayed or after the window is closed, this method does nothing. Syntax form.targetGotoFrame(target, frame) Parameters target String. Species the target. e.g. root frame Integer. Species the frame to go to. Returns Nothing.
2.62.1.6
targetGotoLabel
Description Goes to the specied label. This method is only meaningful in the life cycle of the window. Before the window is displayed or after the window is closed, this method does nothing. Syntax form.targetGotoLabel(target, label) Parameters target String. Species the target. e.g. root label String. Species the label to go to. Returns Nothing.
Description Calls the actions in the specied frame. This method is only meaningful in the life cycle of the window. Before the window is displayed or after the window is closed, this method does nothing. Syntax form.targetCallFrame(target, frame) Parameters target String. Species the target. e.g. root label Integer. Species the frame to call. Returns Nothing.
2.62.1.8
targetCallLabel
Description Calls the actions in the specied label. This method is only meaningful in the life cycle of the window. Before the window is displayed or after the window is closed, this method does nothing. Syntax form.targetCallLabel(target, label) Parameters target String. Species the target. e.g. root label String. Species the label to call. Returns Nothing.
559
Description Sets the base of the playing movie in the form. This method is only meaningful in the life cycle of the window. Before the window is displayed or after the window is closed, this method does nothing. Syntax form.setBase(path) Parameters path String. Species the base path (a full path name on disk) of the movie. Returns Nothing.
2.62.1.10
loadMovie
Description Loads a movie into the specied layer in the playing movie in the form. This method is only meaningful in the life cycle of the window. Before the window is displayed or after the window is closed, this method does nothing. Syntax form.loadMovie(layer, movie) Parameters layer Integer. Species the layer of the movie to load movie Integer. Species the full path name of the movie to load Returns Nothing.
Description Creates and displays an ActiveX control on the form. This method is similar to the global method createControl. The only dierence between these two methods is that the global method createControl will display the created ActiveX controls on the main window, whereas this method display ActiveX controls on form. Syntax form.createControl(progid, left, top, right, bottom[, param[, licensekey]) Parameters progid A string species the ProgID of the ActiveX to be created. left, top, right, bottom Integer. Species the controls size and position on the form. param Optional. String. Initializes the properties of the ActiveX control. It contains several name=value pairs conjoined by character & licensekey Optional. String. Species the license key of the ActiveX control. Returns An object contains two properties 1. The window property The window property is a Window object that represents the window of the created ActiveX control. You can use this property to set the placement of the ActiveX control, show or hide it, ect. 2. The activex property The activex property is an ActiveXObject object. You can use this property to access the properties, methods and events of the ActiveX control.
2.62.2
2.62.2.1
Properties
movie
Description String. The full path name of the movie to be played in the form. This property must be set properly before displaying the form. Syntax form.movie
561
Description Boolean. Species if the form has caption. Change this property has no eects after the form window is displayed on the screen. Syntax form.showCaption
2.62.2.3
canDrag
Description Boolean. Species if the form can be dragged. Change this property has no eects after the form window is displayed on the screen. Syntax form.canDrag
2.62.2.4
clipRegion
Description String. Species the name of a pre-dened clip region used to create a customize windowed form. Change this property has no eects after the form window is displayed on the screen. Syntax form.clipRegion
2.62.2.5
caption
Description String. Species the caption of the form window. Change this property has no eects after the form window is displayed on the screen. Syntax form.caption
Description String. Species the initial values of the variables in the form movie. The form of the initial values is name0=value0&name1=value1...&namen=valuen Change this property has no eects after the form window is displayed on the screen. Syntax form.initVars
2.62.2.7
window
Description Returns a Window object that represents the form window. Readonly. Syntax form.window
2.62.3
2.62.3.1
Events
onExit
Description This event is triggered when the form window is about to close. form.onExit = function (ret) { } The parameter ret is a string returned by the form (returned by the sh ret fscommand or the close method). If the form window is closed by the x button or alt+f4, the parameter is an empty string. The movie hasnt been closed yet, so the getVariable method still can work in this event handler.
563
2.63
ScriptHost Object
Description available: SWFKit Pro ScriptHost object enables the FFish Scripting language to call other Active scripting languages such as jscript, vbscript, perlscript, pythonscript, rubyscript, etc, that is, you now have much more choices to develop your Flash EXE programs. To use a scripting language other than FFish, you must rst create an instance of the ScriptHost object, and then open the script engine. For instance, create a ScriptHost object to run jscript: var sh = new ScriptHost(); sh.open("jscript"); After creating a ScriptHost object and opening the script engine, now you can call scripts by using either the runScript method or the runScriptFile method. The former one is used to run script code, and the latter one is used to run a script le. Finally, when a script nishes running, you may want to get the value of a variable in the script, or call a function in the script. This can be done by the getScriptObject method, which is an ActiveX object. Every global variable in the script is a property of the returned ActiveX object, and every global function in the script is a method of it. For instance, a jscript script, c: test.js, is function _add(a, b) { return a + b; } x = _add("hello", " world"); To call it in SWFKit: var scriptHost = new ScriptHost; scriptHost.open("jscript"); scriptHost.runScriptFile("c:\\test.js"); var so = scriptHost.getScriptObject(); // so is an ActiveX object trace(so); // get the value of the "x" variable var t = so.x; trace(t); // the result is "hello world"
564
FFish Script Objects Reference // call the _add function t = so._add(1, 2); trace(t); // the result is "3" The methods of ScriptHost object works not only in jscript, but in vbscript, perlscript, pythonscript, rubyscript, etc. For the scripts to be called, the ScriptHost object also provides a useful Scripter object. With this object, the scripts can output messages to the trace window of SWFKit, and access the variables and methods in the current Flash movie. The Scripter object contains the following properties and method: FlashPlayer an ActiveX object represents the current ash player in which the current swf movie is playing. Trace a method to output messages to the SWFKit trace window. The Trace method takes only one string parameter, so please be sure to use method like toString to convert variables to strings. For example, Scripter.Trace(x.toString()); HostCreateObject a method to create ActiveX objects. For instance, still in the c: test.js, we can send the result of the variable x to a text eld in the current ash movie function _add(a, b) { return a + b; } x = _add("hello", " world"); // send the value of "x" to flash movie var fp = Scripter.FlashPlayer; fp.SetVariable("_root.xvalue", x.toString()); Scripter.Trace(fp.GetVariable("_root.xvalue")); // The HostCreateObject is used to create an ActiveX object // The following code creates another flash player object, // however, it is different from the one returned by // "Scripter.FlashPlayer", that is, you cannot use it to // access the current playing flash movie. var fp2 = Scripter.HostCreateObject("ShockwaveFlash.ShockwaveFlash"); Scripter.Trace(fp2.FlashVersion().toString()); Another example of calling a perl script. The following code is from c: test.pl $WshShell = $Scripter->HostCreateObject("WScript.Shell"); $numFolders = $WshShell->SpecialFolders->{Count};
2.63 ScriptHost Object $title = "PerlScript & WSH Example"; $style = 1; for($i=0; $i<$numFolders; $i++) { $ok_or_cancel = $WshShell->Popup( $WshShell->SpecialFolders($i), undef, $title, $style); exit if ($ok_or_cancel == 2); } Calling c: test.pl in SWFKit var scriptHost = new ScriptHost; scriptHost.open("perlscript"); scriptHost.runScriptFile("c:\\test.pl"); Syntax new ScriptHost();
565
2.63.1
2.63.1.1
Methods
open
Description Opens a script engine so that you can run the corresponding scripts. Syntax scripthost.open(engineName); Parameters engineName String. Species the name of the Active Scripting language such as jscript, vbscript, perlscript, pythonscript, rubyscript, etc. Returns Boolean. Returns true if successful; otherwise returns false;
Description Closes an opened script engine. After a script engine is closed, you can on longer run corresponding scripts, nor access the variables or functions in an running script. Syntax scripthost.close() Parameters None Returns Boolean. Returns true if successful; otherwise returns false;
2.63.1.3
runScript
Description Runs script code. The corresponding script engine must already been opened by using the open method Syntax scripthost.runScript(code); Parameters code String. The script code to run. For example, a piece of jscript code is function add(x, y) return x+ y; Returns Boolean. Returns true if successful; otherwise returns false;
567
Description Runs a script le. The corresponding script engine must already been opened by using the open method. Syntax scripthost.runScriptFile(leName); Parameters leName String. Species the script le to run. Returns Boolean. Returns true if successful; otherwise returns false;
2.63.1.5
getScriptObject
Description Returns an ActiveX object that represents the global variables and functions in the running script. Syntax scripthost.getScriptObject(); Parameters None Returns An ActiveX object. Returns null if failed.
568
Chapter 3
FSCommands
3.1 FSCommands FFish Eval
Evaluates FFish Script expressions. Syntax FSCommand(FFish Eval, expression) Parameters expression An expression to be evaluated. Example FSCommand("FFish_Eval", "trace(x)");
Description
3.2
Description
570
FSCommands
scriptname A string species the name of the script to be executed. Remarks If the FFish Script needs to call the processMsg method, its better to use the command FFish AsynRun instead. For the proceeMsg method can enable the Flash Player to handle user inputs while the FSCommand is still running. The Flash Player may call the FSCommand again while the FSCommand is still running. That will make the FSCommand to be called twice or more times. The FFish AsynRun command can avoid the problem. Example FSCommand("FFish_Run", "Connect");
3.3
FSCommands Quit
Description Exits the projectors or screen savers. Syntax FSCommand(Quit, ) Parameters None Example FSCommand("Quit", "")
571
3.4
FSCommands FullScreen
Maximizes or restores the projectors.
Description
Syntax FSCommand(FullScreen, true or false) Parameters true or false A true string to maximize the projector and a false string to restore the projector. Example FSCommand("FullScreen", "true");
3.5
FSCommands exec
Launches an executable le.
Description
3.6
Description
FSCommands