Upload
joejunkis
View
310
Download
11
Embed Size (px)
Citation preview
SWFKit Series 3 Manual
August 29, 2007
2
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
Contents
1 Tutorials 291.1 Converting your flash movies to an executable program . . . . . 291.2 Add more functions to your application . . . . . . . . . . . . . . 331.3 Using FFish script objects synchronously in ActionScript 2/3 . . 36
1.3.1 Setting the class path for ActionScript 2/3 . . . . . . . . 361.3.2 Defining hot keys for SWFKit plug-in commands . . . . . 371.3.3 Installing the plug-in and commands manually . . . . . . 371.3.4 Attaching to a SWFKit project . . . . . . . . . . . . . . . 381.3.5 Adding functions, preview, and testing . . . . . . . . . . . 381.3.6 About the trace method of SWFKit . . . . . . . . . . . . 401.3.7 Handling events of the FFish script objects . . . . . . . . 411.3.8 How does the synchronous calls work . . . . . . . . . . . . 411.3.9 Wrapping ActiveX components . . . . . . . . . . . . . . . 461.3.10 Differences between wrapper classes for actionscript 2 and actionscript 3 481.3.11 Calling methods written in ffish script from within actionscript 2 or 3 491.3.12 Calling actionscript methods from within ffish script . . . 491.3.13 Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
1.4 Data exchanging between Action Script and FFish Script . . . . 511.4.1 The setVariable method and the getVariable method . . . 511.4.2 The updateData method . . . . . . . . . . . . . . . . . . . 511.4.3 getArray, putArray, getObject, putObject . . . . . . . . . 52
1.5 Protecting your applications . . . . . . . . . . . . . . . . . . . . . 521.5.1 Bypassing the default handler . . . . . . . . . . . . . . . . 531.5.2 Check if it is expired . . . . . . . . . . . . . . . . . . . . . 531.5.3 Registration . . . . . . . . . . . . . . . . . . . . . . . . . . 53
1.6 Protecting your resource files . . . . . . . . . . . . . . . . . . . . 541.7 Using menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
1.7.1 The main menu . . . . . . . . . . . . . . . . . . . . . . . . 551.7.2 The context menu . . . . . . . . . . . . . . . . . . . . . . 56
1.8 Using ActiveX Objects . . . . . . . . . . . . . . . . . . . . . . . . 561.8.1 Registering ActiveX objects manually . . . . . . . . . . . 561.8.2 Registering ActiveX objects on end users’ systems I - using the ”register” method 571.8.3 Registering ActiveX objects on end users’ systems II - let the setup programs do it 581.8.4 Using ActiveX dlls without registration . . . . . . . . . . 60
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
4 CONTENTS
1.9 Stand alone programs and the Flash Player . . . . . . . . . . . . 601.10 The “trace” method . . . . . . . . . . . . . . . . . . . . . . . . . 601.11 The variable scope in FFish Script . . . . . . . . . . . . . . . . . 611.12 Using SWFKit Pro to call functions in dynamic-linked libraries(dlls) 61
1.12.1 Declaring the dll functions . . . . . . . . . . . . . . . . . . 611.12.2 Calling dll functions and get results . . . . . . . . . . . . 63
1.13 Building windowless projectors . . . . . . . . . . . . . . . . . . . 691.14 Accessing disk files . . . . . . . . . . . . . . . . . . . . . . . . . . 691.15 Launching external applications . . . . . . . . . . . . . . . . . . . 701.16 Opening system dialog boxes . . . . . . . . . . . . . . . . . . . . 711.17 Accessing databases . . . . . . . . . . . . . . . . . . . . . . . . . 721.18 Programming the tray icons . . . . . . . . . . . . . . . . . . . . . 741.19 Downloading and uploading files . . . . . . . . . . . . . . . . . . 751.20 Sending and receiving emails . . . . . . . . . . . . . . . . . . . . 771.21 Creating multiple forms . . . . . . . . . . . . . . . . . . . . . . . 781.22 Changing screen resolutions . . . . . . . . . . . . . . . . . . . . . 791.23 Screen capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . 801.24 Reusing the web browser control . . . . . . . . . . . . . . . . . . 801.25 Playing avi, rm, mov, wmv, etc movies . . . . . . . . . . . . . . . 821.26 Opening pdf files . . . . . . . . . . . . . . . . . . . . . . . . . . . 831.27 Calling Active scripting languages . . . . . . . . . . . . . . . . . 851.28 Using shared objects in packed movies . . . . . . . . . . . . . . . 861.29 Using autoupdate . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
2 FFish Script Objects Reference 892.1 Global Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
2.1.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 892.1.1.1 NaN . . . . . . . . . . . . . . . . . . . . . . . . . 892.1.1.2 Infinity . . . . . . . . . . . . . . . . . . . . . . . 90
2.1.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 902.1.2.1 parseFloat . . . . . . . . . . . . . . . . . . . . . 902.1.2.2 parseInt . . . . . . . . . . . . . . . . . . . . . . . 912.1.2.3 escape . . . . . . . . . . . . . . . . . . . . . . . . 912.1.2.4 unescape . . . . . . . . . . . . . . . . . . . . . . 922.1.2.5 eval . . . . . . . . . . . . . . . . . . . . . . . . . 932.1.2.6 isNAN . . . . . . . . . . . . . . . . . . . . . . . 932.1.2.7 isFinit . . . . . . . . . . . . . . . . . . . . . . . . 942.1.2.8 trace . . . . . . . . . . . . . . . . . . . . . . . . 942.1.2.9 createControl . . . . . . . . . . . . . . . . . . . . 952.1.2.10 getMainWnd . . . . . . . . . . . . . . . . . . . . 972.1.2.11 getAppDir . . . . . . . . . . . . . . . . . . . . . 972.1.2.12 getMovies . . . . . . . . . . . . . . . . . . . . . . 982.1.2.13 setWindowless . . . . . . . . . . . . . . . . . . . 982.1.2.14 readProfile . . . . . . . . . . . . . . . . . . . . . 992.1.2.15 writeProfile . . . . . . . . . . . . . . . . . . . . . 992.1.2.16 processMsg . . . . . . . . . . . . . . . . . . . . . 100
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 5
2.1.2.17 getAdditionalFile . . . . . . . . . . . . . . . . . 1002.1.2.18 getExeName . . . . . . . . . . . . . . . . . . . . 1012.1.2.19 invoke . . . . . . . . . . . . . . . . . . . . . . . . 1022.1.2.20 evals . . . . . . . . . . . . . . . . . . . . . . . . . 1022.1.2.21 decodeURI . . . . . . . . . . . . . . . . . . . . . 1022.1.2.22 encodeURI . . . . . . . . . . . . . . . . . . . . . 1032.1.2.23 decodeURIComponent . . . . . . . . . . . . . . . 1032.1.2.24 encodeURIComponent . . . . . . . . . . . . . . . 103
2.2 Boolean object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1042.3 Number object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
2.3.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 1052.3.1.1 MAX VALUE . . . . . . . . . . . . . . . . . . . 1052.3.1.2 MIN VALUE . . . . . . . . . . . . . . . . . . . . 1052.3.1.3 NaN . . . . . . . . . . . . . . . . . . . . . . . . . 1052.3.1.4 NEGATIVE INFINITY . . . . . . . . . . . . . . 1062.3.1.5 POSITIVE INFINITY . . . . . . . . . . . . . . 106
2.3.2 methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1062.3.2.1 format . . . . . . . . . . . . . . . . . . . . . . . 106
2.4 String object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1072.4.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
2.4.1.1 length . . . . . . . . . . . . . . . . . . . . . . . . 1082.4.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
2.4.2.1 charAt . . . . . . . . . . . . . . . . . . . . . . . 1082.4.2.2 charCodeAt . . . . . . . . . . . . . . . . . . . . . 1092.4.2.3 concat . . . . . . . . . . . . . . . . . . . . . . . . 1092.4.2.4 fromCharCode . . . . . . . . . . . . . . . . . . . 1102.4.2.5 indexOf . . . . . . . . . . . . . . . . . . . . . . . 1112.4.2.6 lastIndexOf . . . . . . . . . . . . . . . . . . . . . 1112.4.2.7 slice . . . . . . . . . . . . . . . . . . . . . . . . . 1122.4.2.8 split . . . . . . . . . . . . . . . . . . . . . . . . . 1132.4.2.9 substr . . . . . . . . . . . . . . . . . . . . . . . . 1142.4.2.10 substring . . . . . . . . . . . . . . . . . . . . . . 1142.4.2.11 toLowerCase . . . . . . . . . . . . . . . . . . . . 1152.4.2.12 toUpperCase . . . . . . . . . . . . . . . . . . . . 1162.4.2.13 match . . . . . . . . . . . . . . . . . . . . . . . . 1172.4.2.14 replace . . . . . . . . . . . . . . . . . . . . . . . 1172.4.2.15 search . . . . . . . . . . . . . . . . . . . . . . . . 1182.4.2.16 anchor . . . . . . . . . . . . . . . . . . . . . . . 1192.4.2.17 big . . . . . . . . . . . . . . . . . . . . . . . . . . 1192.4.2.18 blink . . . . . . . . . . . . . . . . . . . . . . . . 1202.4.2.19 bold . . . . . . . . . . . . . . . . . . . . . . . . . 1202.4.2.20 fixed . . . . . . . . . . . . . . . . . . . . . . . . . 1212.4.2.21 fontColor . . . . . . . . . . . . . . . . . . . . . . 1222.4.2.22 fontSize . . . . . . . . . . . . . . . . . . . . . . . 1222.4.2.23 italics . . . . . . . . . . . . . . . . . . . . . . . . 1232.4.2.24 link . . . . . . . . . . . . . . . . . . . . . . . . . 124
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
6 CONTENTS
2.4.2.25 small . . . . . . . . . . . . . . . . . . . . . . . . 1242.4.2.26 strike . . . . . . . . . . . . . . . . . . . . . . . . 1252.4.2.27 sub . . . . . . . . . . . . . . . . . . . . . . . . . 1252.4.2.28 sup . . . . . . . . . . . . . . . . . . . . . . . . . 126
2.5 Function Object . . . . . . . . . . . . . . . . . . . . . . . . . . . 1262.5.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
2.5.1.1 arguments . . . . . . . . . . . . . . . . . . . . . 1282.6 Array Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
2.6.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 1302.6.1.1 length . . . . . . . . . . . . . . . . . . . . . . . . 130
2.6.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1302.6.2.1 concat . . . . . . . . . . . . . . . . . . . . . . . . 1302.6.2.2 join . . . . . . . . . . . . . . . . . . . . . . . . . 1312.6.2.3 pop . . . . . . . . . . . . . . . . . . . . . . . . . 1322.6.2.4 push . . . . . . . . . . . . . . . . . . . . . . . . . 1322.6.2.5 reverse . . . . . . . . . . . . . . . . . . . . . . . 1332.6.2.6 shift . . . . . . . . . . . . . . . . . . . . . . . . . 1332.6.2.7 slice . . . . . . . . . . . . . . . . . . . . . . . . . 1342.6.2.8 sort . . . . . . . . . . . . . . . . . . . . . . . . . 1352.6.2.9 splice . . . . . . . . . . . . . . . . . . . . . . . . 1352.6.2.10 unshift . . . . . . . . . . . . . . . . . . . . . . . 136
2.7 Date Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1372.7.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
2.7.1.1 getDate . . . . . . . . . . . . . . . . . . . . . . . 1382.7.1.2 getDay . . . . . . . . . . . . . . . . . . . . . . . 1382.7.1.3 getFullYear . . . . . . . . . . . . . . . . . . . . . 1392.7.1.4 getHours . . . . . . . . . . . . . . . . . . . . . . 1402.7.1.5 getMilliseconds . . . . . . . . . . . . . . . . . . . 1402.7.1.6 getMinutes . . . . . . . . . . . . . . . . . . . . . 1412.7.1.7 getMonth . . . . . . . . . . . . . . . . . . . . . . 1412.7.1.8 getSeconds . . . . . . . . . . . . . . . . . . . . . 1422.7.1.9 getTime . . . . . . . . . . . . . . . . . . . . . . . 1422.7.1.10 getTimezoneOffset . . . . . . . . . . . . . . . . . 1432.7.1.11 getUTCDate . . . . . . . . . . . . . . . . . . . . 1432.7.1.12 getUTCDay . . . . . . . . . . . . . . . . . . . . 1442.7.1.13 getUTCFullYear . . . . . . . . . . . . . . . . . . 1442.7.1.14 getUTCHours . . . . . . . . . . . . . . . . . . . 1452.7.1.15 getUTCMilliseconds . . . . . . . . . . . . . . . . 1452.7.1.16 getMinutes . . . . . . . . . . . . . . . . . . . . . 1462.7.1.17 getUTCMonth . . . . . . . . . . . . . . . . . . . 1462.7.1.18 getUTCSeconds . . . . . . . . . . . . . . . . . . 1472.7.1.19 getYear . . . . . . . . . . . . . . . . . . . . . . . 1472.7.1.20 setDate . . . . . . . . . . . . . . . . . . . . . . . 1482.7.1.21 setFullYear . . . . . . . . . . . . . . . . . . . . . 1482.7.1.22 setHours . . . . . . . . . . . . . . . . . . . . . . 1492.7.1.23 setMilliseconds . . . . . . . . . . . . . . . . . . . 149
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 7
2.7.1.24 setMinutes . . . . . . . . . . . . . . . . . . . . . 1502.7.1.25 setMonth . . . . . . . . . . . . . . . . . . . . . . 1502.7.1.26 setSeconds . . . . . . . . . . . . . . . . . . . . . 1512.7.1.27 setTime . . . . . . . . . . . . . . . . . . . . . . . 1512.7.1.28 setUTCDate . . . . . . . . . . . . . . . . . . . . 1522.7.1.29 setUTCFullYear . . . . . . . . . . . . . . . . . . 1522.7.1.30 setUTCHours . . . . . . . . . . . . . . . . . . . 1532.7.1.31 setUTCMilliseconds . . . . . . . . . . . . . . . . 1532.7.1.32 setUTCMinutes . . . . . . . . . . . . . . . . . . 1542.7.1.33 setUTCMonth . . . . . . . . . . . . . . . . . . . 1542.7.1.34 setUTCSeconds . . . . . . . . . . . . . . . . . . 1552.7.1.35 setYear . . . . . . . . . . . . . . . . . . . . . . . 1552.7.1.36 UTC . . . . . . . . . . . . . . . . . . . . . . . . 1562.7.1.37 parse . . . . . . . . . . . . . . . . . . . . . . . . 1562.7.1.38 toGMTString . . . . . . . . . . . . . . . . . . . . 1572.7.1.39 toLocaleString . . . . . . . . . . . . . . . . . . . 158
2.8 Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1582.8.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
2.8.1.1 E . . . . . . . . . . . . . . . . . . . . . . . . . . 1582.8.1.2 LN2 . . . . . . . . . . . . . . . . . . . . . . . . . 1592.8.1.3 LOG2E . . . . . . . . . . . . . . . . . . . . . . . 1592.8.1.4 LN10 . . . . . . . . . . . . . . . . . . . . . . . . 1592.8.1.5 LOG10E . . . . . . . . . . . . . . . . . . . . . . 1602.8.1.6 PI . . . . . . . . . . . . . . . . . . . . . . . . . . 1602.8.1.7 SQRT1 2 . . . . . . . . . . . . . . . . . . . . . . 1602.8.1.8 SQRT2 . . . . . . . . . . . . . . . . . . . . . . . 160
2.8.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1612.8.2.1 abs . . . . . . . . . . . . . . . . . . . . . . . . . 1612.8.2.2 acos . . . . . . . . . . . . . . . . . . . . . . . . . 1612.8.2.3 asin . . . . . . . . . . . . . . . . . . . . . . . . . 1622.8.2.4 atan . . . . . . . . . . . . . . . . . . . . . . . . . 1622.8.2.5 atan2 . . . . . . . . . . . . . . . . . . . . . . . . 1632.8.2.6 ceil . . . . . . . . . . . . . . . . . . . . . . . . . 1632.8.2.7 cos . . . . . . . . . . . . . . . . . . . . . . . . . . 1642.8.2.8 exp . . . . . . . . . . . . . . . . . . . . . . . . . 1642.8.2.9 floor . . . . . . . . . . . . . . . . . . . . . . . . . 1652.8.2.10 log . . . . . . . . . . . . . . . . . . . . . . . . . . 1652.8.2.11 max . . . . . . . . . . . . . . . . . . . . . . . . . 1662.8.2.12 min . . . . . . . . . . . . . . . . . . . . . . . . . 1662.8.2.13 pow . . . . . . . . . . . . . . . . . . . . . . . . . 1662.8.2.14 random . . . . . . . . . . . . . . . . . . . . . . . 1672.8.2.15 round . . . . . . . . . . . . . . . . . . . . . . . . 1672.8.2.16 sin . . . . . . . . . . . . . . . . . . . . . . . . . . 1672.8.2.17 sqrt . . . . . . . . . . . . . . . . . . . . . . . . . 1682.8.2.18 tan . . . . . . . . . . . . . . . . . . . . . . . . . 169
2.9 Dialogs Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
8 CONTENTS
2.9.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1702.9.1.1 msgBox . . . . . . . . . . . . . . . . . . . . . . . 1702.9.1.2 fileOpen . . . . . . . . . . . . . . . . . . . . . . . 1712.9.1.3 fileSave . . . . . . . . . . . . . . . . . . . . . . . 1722.9.1.4 chooseColor . . . . . . . . . . . . . . . . . . . . . 1732.9.1.5 chooseFont . . . . . . . . . . . . . . . . . . . . . 1732.9.1.6 browse . . . . . . . . . . . . . . . . . . . . . . . 174
2.10 Shell Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1752.10.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
2.10.1.1 run . . . . . . . . . . . . . . . . . . . . . . . . . 1752.10.1.2 runConsole . . . . . . . . . . . . . . . . . . . . . 1762.10.1.3 runAndWait . . . . . . . . . . . . . . . . . . . . 1772.10.1.4 open . . . . . . . . . . . . . . . . . . . . . . . . . 1782.10.1.5 print . . . . . . . . . . . . . . . . . . . . . . . . 1792.10.1.6 explore . . . . . . . . . . . . . . . . . . . . . . . 1802.10.1.7 findExecutable . . . . . . . . . . . . . . . . . . . 1812.10.1.8 getSpecialFolder . . . . . . . . . . . . . . . . . . 1822.10.1.9 addToRecentDocs . . . . . . . . . . . . . . . . . 1842.10.1.10 clearRecentDocs . . . . . . . . . . . . . . . . . . 1852.10.1.11 emptyRecycleBin . . . . . . . . . . . . . . . . . 1852.10.1.12 getEnvironmentStrings . . . . . . . . . . . . . . 1862.10.1.13 getEnvironmentVariable . . . . . . . . . . . . . . 1862.10.1.14 setEnvironmentVariable . . . . . . . . . . . . . . 1872.10.1.15 delEnvironmentVariable . . . . . . . . . . . . . . 1872.10.1.16 expandEnvironmentStrings . . . . . . . . . . . . 1882.10.1.17 setDesktopWallpaper . . . . . . . . . . . . . . . 1882.10.1.18 getFileVersionInfo . . . . . . . . . . . . . . . . . 189
2.11 MCI Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1902.11.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
2.11.1.1 alias . . . . . . . . . . . . . . . . . . . . . . . . . 1942.11.1.2 canEject . . . . . . . . . . . . . . . . . . . . . . 1942.11.1.3 canPlay . . . . . . . . . . . . . . . . . . . . . . . 1952.11.1.4 canRecord . . . . . . . . . . . . . . . . . . . . . 1952.11.1.5 canStep . . . . . . . . . . . . . . . . . . . . . . . 1962.11.1.6 deviceID . . . . . . . . . . . . . . . . . . . . . . 1962.11.1.7 deviceType . . . . . . . . . . . . . . . . . . . . . 1962.11.1.8 fileName . . . . . . . . . . . . . . . . . . . . . . 1962.11.1.9 frames . . . . . . . . . . . . . . . . . . . . . . . . 1972.11.1.10 from . . . . . . . . . . . . . . . . . . . . . . . . . 1972.11.1.11 length . . . . . . . . . . . . . . . . . . . . . . . . 1982.11.1.12 mode . . . . . . . . . . . . . . . . . . . . . . . . 1982.11.1.13 notify . . . . . . . . . . . . . . . . . . . . . . . . 1992.11.1.14 position . . . . . . . . . . . . . . . . . . . . . . . 1992.11.1.15 recordMode . . . . . . . . . . . . . . . . . . . . . 1992.11.1.16 sharable . . . . . . . . . . . . . . . . . . . . . . . 2002.11.1.17 channel . . . . . . . . . . . . . . . . . . . . . . . 201
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 9
2.11.1.18 start . . . . . . . . . . . . . . . . . . . . . . . . . 2012.11.1.19 timeFormat . . . . . . . . . . . . . . . . . . . . . 2022.11.1.20 to . . . . . . . . . . . . . . . . . . . . . . . . . . 2022.11.1.21 track . . . . . . . . . . . . . . . . . . . . . . . . 2032.11.1.22 trackLength . . . . . . . . . . . . . . . . . . . . 2042.11.1.23 trackPosition . . . . . . . . . . . . . . . . . . . . 2042.11.1.24 wait . . . . . . . . . . . . . . . . . . . . . . . . . 2042.11.1.25 playerWindow . . . . . . . . . . . . . . . . . . . 2052.11.1.26 error . . . . . . . . . . . . . . . . . . . . . . . . . 2052.11.1.27 errorMsg . . . . . . . . . . . . . . . . . . . . . . 2052.11.1.28 command . . . . . . . . . . . . . . . . . . . . . . 2052.11.1.29 left . . . . . . . . . . . . . . . . . . . . . . . . . 2072.11.1.30 top . . . . . . . . . . . . . . . . . . . . . . . . . 2072.11.1.31 width . . . . . . . . . . . . . . . . . . . . . . . . 2082.11.1.32 height . . . . . . . . . . . . . . . . . . . . . . . . 208
2.11.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2082.11.2.1 sendCmdString . . . . . . . . . . . . . . . . . . . 2082.11.2.2 getDevices . . . . . . . . . . . . . . . . . . . . . 2092.11.2.3 hmsHour . . . . . . . . . . . . . . . . . . . . . . 2092.11.2.4 hmsMinute . . . . . . . . . . . . . . . . . . . . . 2102.11.2.5 hmsSecond . . . . . . . . . . . . . . . . . . . . . 2102.11.2.6 makeHMS . . . . . . . . . . . . . . . . . . . . . 2112.11.2.7 makeMSF . . . . . . . . . . . . . . . . . . . . . . 2112.11.2.8 makeTMSF . . . . . . . . . . . . . . . . . . . . . 2122.11.2.9 msfFrame . . . . . . . . . . . . . . . . . . . . . . 2122.11.2.10 msfMinute . . . . . . . . . . . . . . . . . . . . . 2132.11.2.11 msfSecond . . . . . . . . . . . . . . . . . . . . . 2132.11.2.12 tmsfMinute . . . . . . . . . . . . . . . . . . . . . 2142.11.2.13 tmsfFrame . . . . . . . . . . . . . . . . . . . . . 2142.11.2.14 tmsfSecond . . . . . . . . . . . . . . . . . . . . . 2152.11.2.15 tmsfTrack . . . . . . . . . . . . . . . . . . . . . . 215
2.11.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2162.11.3.1 onNotify . . . . . . . . . . . . . . . . . . . . . . 216
2.12 Application Object . . . . . . . . . . . . . . . . . . . . . . . . . . 2162.12.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
2.12.1.1 Appearance . . . . . . . . . . . . . . . . . . . . . 2172.12.1.2 SizeAndPos . . . . . . . . . . . . . . . . . . . . . 2172.12.1.3 Interaction . . . . . . . . . . . . . . . . . . . . . 2172.12.1.4 Behaviour . . . . . . . . . . . . . . . . . . . . . . 2182.12.1.5 SysTray . . . . . . . . . . . . . . . . . . . . . . . 2182.12.1.6 Preferences . . . . . . . . . . . . . . . . . . . . . 2182.12.1.7 Expiry . . . . . . . . . . . . . . . . . . . . . . . 2192.12.1.8 dragdrop . . . . . . . . . . . . . . . . . . . . . . 2192.12.1.9 clipboard . . . . . . . . . . . . . . . . . . . . . . 2192.12.1.10 StatusBar . . . . . . . . . . . . . . . . . . . . . . 2192.12.1.11 cmdLine . . . . . . . . . . . . . . . . . . . . . . 219
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
10 CONTENTS
2.12.1.12 cmdItems . . . . . . . . . . . . . . . . . . . . . . 2202.12.1.13 cursor . . . . . . . . . . . . . . . . . . . . . . . . 2202.12.1.14 isScr . . . . . . . . . . . . . . . . . . . . . . . . . 2212.12.1.15 traceWnd . . . . . . . . . . . . . . . . . . . . . . 2212.12.1.16 captureMouse . . . . . . . . . . . . . . . . . . . 2212.12.1.17 setFocus . . . . . . . . . . . . . . . . . . . . . . 221
2.12.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2222.12.2.1 getBasePath . . . . . . . . . . . . . . . . . . . . 2222.12.2.2 setBasePath . . . . . . . . . . . . . . . . . . . . 2222.12.2.3 associate . . . . . . . . . . . . . . . . . . . . . . 2242.12.2.4 setInterval . . . . . . . . . . . . . . . . . . . . . 2252.12.2.5 clearInterval . . . . . . . . . . . . . . . . . . . . 2262.12.2.6 traceToFile . . . . . . . . . . . . . . . . . . . . . 2262.12.2.7 about . . . . . . . . . . . . . . . . . . . . . . . . 2272.12.2.8 setDragRegion . . . . . . . . . . . . . . . . . . . 2272.12.2.9 sendMessage . . . . . . . . . . . . . . . . . . . . 2282.12.2.10 registerASMethods . . . . . . . . . . . . . . . . . 228
2.12.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2292.12.3.1 onGetMovie . . . . . . . . . . . . . . . . . . . . 2292.12.3.2 onMovieLoaded . . . . . . . . . . . . . . . . . . 230
2.13 Application.Appearance . . . . . . . . . . . . . . . . . . . . . . . 2302.13.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
2.13.1.1 windowShape . . . . . . . . . . . . . . . . . . . . 2302.13.1.2 borderStyle . . . . . . . . . . . . . . . . . . . . . 2312.13.1.3 borderIcons . . . . . . . . . . . . . . . . . . . . . 2312.13.1.4 scaleMode . . . . . . . . . . . . . . . . . . . . . 2322.13.1.5 caption . . . . . . . . . . . . . . . . . . . . . . . 2322.13.1.6 icon . . . . . . . . . . . . . . . . . . . . . . . . . 233
2.14 Application.SizeAndPos . . . . . . . . . . . . . . . . . . . . . . . 2332.14.1 properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
2.14.1.1 windowSize . . . . . . . . . . . . . . . . . . . . . 2332.14.1.2 pos . . . . . . . . . . . . . . . . . . . . . . . . . 2342.14.1.3 bKeepRatio . . . . . . . . . . . . . . . . . . . . . 235
2.14.2 methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2352.14.2.1 setCustomPos . . . . . . . . . . . . . . . . . . . 2352.14.2.2 setCustomSize . . . . . . . . . . . . . . . . . . . 2352.14.2.3 setCustomSizeAndPos . . . . . . . . . . . . . . . 236
2.15 Application.Interaction . . . . . . . . . . . . . . . . . . . . . . . . 2362.15.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
2.15.1.1 lBtnClk . . . . . . . . . . . . . . . . . . . . . . . 2362.15.1.2 rBtnClk . . . . . . . . . . . . . . . . . . . . . . . 2372.15.1.3 keyPress . . . . . . . . . . . . . . . . . . . . . . 2372.15.1.4 exitKeys . . . . . . . . . . . . . . . . . . . . . . 2382.15.1.5 hotKey . . . . . . . . . . . . . . . . . . . . . . . 2382.15.1.6 bDisableAltTab . . . . . . . . . . . . . . . . . . 2382.15.1.7 bDisableCursor . . . . . . . . . . . . . . . . . . . 239
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 11
2.15.1.8 bDisableScr . . . . . . . . . . . . . . . . . . . . . 2392.16 Application.Behaviour . . . . . . . . . . . . . . . . . . . . . . . . 239
2.16.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 2392.16.1.1 bAllowExtendContextMenu . . . . . . . . . . . . 2392.16.1.2 extendContextMenu . . . . . . . . . . . . . . . . 2402.16.1.3 bAutoPlay . . . . . . . . . . . . . . . . . . . . . 2402.16.1.4 bStartMinimized . . . . . . . . . . . . . . . . . . 2402.16.1.5 bAlwaysOnTop . . . . . . . . . . . . . . . . . . . 2412.16.1.6 bShowInSystemTray . . . . . . . . . . . . . . . . 241
2.17 Application.Expiry . . . . . . . . . . . . . . . . . . . . . . . . . . 2412.17.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
2.17.1.1 bEnable . . . . . . . . . . . . . . . . . . . . . . . 2412.17.1.2 expireOn . . . . . . . . . . . . . . . . . . . . . . 2422.17.1.3 leftDays . . . . . . . . . . . . . . . . . . . . . . . 2422.17.1.4 bEnableUnlock . . . . . . . . . . . . . . . . . . . 2422.17.1.5 isExpired . . . . . . . . . . . . . . . . . . . . . . 2432.17.1.6 isRegistered . . . . . . . . . . . . . . . . . . . . 2432.17.1.7 expiryMsg . . . . . . . . . . . . . . . . . . . . . 2432.17.1.8 rbCustomized . . . . . . . . . . . . . . . . . . . 2432.17.1.9 rbCaption . . . . . . . . . . . . . . . . . . . . . . 2442.17.1.10 rbInfo . . . . . . . . . . . . . . . . . . . . . . . . 2442.17.1.11 rbShow3rdBtn . . . . . . . . . . . . . . . . . . . 2442.17.1.12 rb3rdBtnCaption . . . . . . . . . . . . . . . . . . 2442.17.1.13 rb3rdBtnLink . . . . . . . . . . . . . . . . . . . 2452.17.1.14 username . . . . . . . . . . . . . . . . . . . . . . 2452.17.1.15 serialNumber . . . . . . . . . . . . . . . . . . . . 245
2.17.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2452.17.2.1 showRegisterDlg . . . . . . . . . . . . . . . . . . 2452.17.2.2 register . . . . . . . . . . . . . . . . . . . . . . . 246
2.17.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2472.17.3.1 onExpiry . . . . . . . . . . . . . . . . . . . . . . 247
2.18 Application.SysTray . . . . . . . . . . . . . . . . . . . . . . . . . 2482.18.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
2.18.1.1 tip . . . . . . . . . . . . . . . . . . . . . . . . . . 2492.18.1.2 icon . . . . . . . . . . . . . . . . . . . . . . . . . 2492.18.1.3 balloonTip . . . . . . . . . . . . . . . . . . . . . 2492.18.1.4 balloonTitle . . . . . . . . . . . . . . . . . . . . 2492.18.1.5 balloonTimeout . . . . . . . . . . . . . . . . . . 2502.18.1.6 balloonIcon . . . . . . . . . . . . . . . . . . . . . 2502.18.1.7 useDefaultHandler . . . . . . . . . . . . . . . . . 250
2.18.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2512.18.2.1 add . . . . . . . . . . . . . . . . . . . . . . . . . 2512.18.2.2 modify . . . . . . . . . . . . . . . . . . . . . . . 2522.18.2.3 remove . . . . . . . . . . . . . . . . . . . . . . . 2532.18.2.4 showBalloonTip . . . . . . . . . . . . . . . . . . 253
2.18.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
12 CONTENTS
2.18.3.1 onMouseMove . . . . . . . . . . . . . . . . . . . 2532.18.3.2 onLClicked . . . . . . . . . . . . . . . . . . . . . 2542.18.3.3 onRClicked . . . . . . . . . . . . . . . . . . . . . 2542.18.3.4 onLDblClicked . . . . . . . . . . . . . . . . . . . 2542.18.3.5 onRDblClicked . . . . . . . . . . . . . . . . . . . 255
2.19 Application.Preferences . . . . . . . . . . . . . . . . . . . . . . . 2552.19.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
2.19.1.1 wakeupMethod . . . . . . . . . . . . . . . . . . . 2552.19.1.2 hotKey . . . . . . . . . . . . . . . . . . . . . . . 2562.19.1.3 disableCursor . . . . . . . . . . . . . . . . . . . . 2562.19.1.4 disableCDAutoRun . . . . . . . . . . . . . . . . 256
2.20 Application.dragdrop . . . . . . . . . . . . . . . . . . . . . . . . . 2562.20.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
2.20.1.1 enable . . . . . . . . . . . . . . . . . . . . . . . . 2572.20.2 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
2.20.2.1 onDragEnter Text . . . . . . . . . . . . . . . . . 2572.20.2.2 onDragEnter Files . . . . . . . . . . . . . . . . . 2582.20.2.3 onDragOver Text . . . . . . . . . . . . . . . . . 2582.20.2.4 onDragOver Files . . . . . . . . . . . . . . . . . 2582.20.2.5 onDragLeave . . . . . . . . . . . . . . . . . . . . 2592.20.2.6 onDropText . . . . . . . . . . . . . . . . . . . . 2592.20.2.7 onDropFiles . . . . . . . . . . . . . . . . . . . . 2592.20.2.8 onDragGetData . . . . . . . . . . . . . . . . . . 260
2.21 Application.clipboard . . . . . . . . . . . . . . . . . . . . . . . . 2602.21.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
2.21.1.1 copyBitmap Screen . . . . . . . . . . . . . . . . 2612.21.1.2 copyBitmap Movie . . . . . . . . . . . . . . . . . 2612.21.1.3 copyText . . . . . . . . . . . . . . . . . . . . . . 2622.21.1.4 paste . . . . . . . . . . . . . . . . . . . . . . . . 2622.21.1.5 pasteBitmap . . . . . . . . . . . . . . . . . . . . 262
2.22 Application.StatusBar . . . . . . . . . . . . . . . . . . . . . . . . 2632.22.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
2.22.1.1 progress . . . . . . . . . . . . . . . . . . . . . . . 2632.22.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
2.22.2.1 init . . . . . . . . . . . . . . . . . . . . . . . . . 2632.22.2.2 setPaneText . . . . . . . . . . . . . . . . . . . . 2642.22.2.3 setPaneIcon . . . . . . . . . . . . . . . . . . . . 2652.22.2.4 setPaneWidth . . . . . . . . . . . . . . . . . . . 2652.22.2.5 disablePane . . . . . . . . . . . . . . . . . . . . . 2662.22.2.6 setPaneBorder . . . . . . . . . . . . . . . . . . . 2662.22.2.7 show . . . . . . . . . . . . . . . . . . . . . . . . 2672.22.2.8 hide . . . . . . . . . . . . . . . . . . . . . . . . . 267
2.23 Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2672.23.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
2.23.1.1 enableAccel . . . . . . . . . . . . . . . . . . . . . 2682.23.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 13
2.23.2.1 load . . . . . . . . . . . . . . . . . . . . . . . . . 2682.23.2.2 setMenu . . . . . . . . . . . . . . . . . . . . . . . 2692.23.2.3 createMenu . . . . . . . . . . . . . . . . . . . . . 2692.23.2.4 createPopupMenu . . . . . . . . . . . . . . . . . 2702.23.2.5 appendItem . . . . . . . . . . . . . . . . . . . . . 2702.23.2.6 insertItem . . . . . . . . . . . . . . . . . . . . . 2712.23.2.7 removeItem . . . . . . . . . . . . . . . . . . . . . 2722.23.2.8 getSubMenu . . . . . . . . . . . . . . . . . . . . 2722.23.2.9 show . . . . . . . . . . . . . . . . . . . . . . . . 273
2.23.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2742.23.3.1 onCommand . . . . . . . . . . . . . . . . . . . . 2742.23.3.2 onUpdateItem . . . . . . . . . . . . . . . . . . . 275
2.24 Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2762.24.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
2.24.1.1 blowfishEncode . . . . . . . . . . . . . . . . . . . 2762.24.1.2 blowfishDecode . . . . . . . . . . . . . . . . . . . 2772.24.1.3 md5 . . . . . . . . . . . . . . . . . . . . . . . . . 2772.24.1.4 md5File . . . . . . . . . . . . . . . . . . . . . . . 2782.24.1.5 desEncode . . . . . . . . . . . . . . . . . . . . . 2782.24.1.6 desDecode . . . . . . . . . . . . . . . . . . . . . 2792.24.1.7 encFile . . . . . . . . . . . . . . . . . . . . . . . 2792.24.1.8 decFile . . . . . . . . . . . . . . . . . . . . . . . 280
2.25 DiskInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2802.25.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
2.25.1.1 modelNumber . . . . . . . . . . . . . . . . . . . 2812.25.1.2 revisionNumber . . . . . . . . . . . . . . . . . . 2812.25.1.3 driveType . . . . . . . . . . . . . . . . . . . . . . 2812.25.1.4 bufferSize . . . . . . . . . . . . . . . . . . . . . . 2822.25.1.5 cylinders . . . . . . . . . . . . . . . . . . . . . . 2822.25.1.6 heads . . . . . . . . . . . . . . . . . . . . . . . . 2822.25.1.7 sectors . . . . . . . . . . . . . . . . . . . . . . . 282
2.26 DataFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2822.26.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
2.26.1.1 load . . . . . . . . . . . . . . . . . . . . . . . . . 2832.26.1.2 loadAndDec . . . . . . . . . . . . . . . . . . . . 2832.26.1.3 save . . . . . . . . . . . . . . . . . . . . . . . . . 2842.26.1.4 saveAndEnc . . . . . . . . . . . . . . . . . . . . 2852.26.1.5 remove . . . . . . . . . . . . . . . . . . . . . . . 285
2.27 DesktopToy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2852.27.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
2.27.1.1 followCursor . . . . . . . . . . . . . . . . . . . . 2862.27.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
2.27.2.1 act . . . . . . . . . . . . . . . . . . . . . . . . . . 2862.27.2.2 stop . . . . . . . . . . . . . . . . . . . . . . . . . 287
2.27.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2872.27.3.1 onStop . . . . . . . . . . . . . . . . . . . . . . . 287
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
14 CONTENTS
2.28 Window Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2882.28.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
2.28.1.1 caption . . . . . . . . . . . . . . . . . . . . . . . 2882.28.1.2 left . . . . . . . . . . . . . . . . . . . . . . . . . 2892.28.1.3 top . . . . . . . . . . . . . . . . . . . . . . . . . 2892.28.1.4 width . . . . . . . . . . . . . . . . . . . . . . . . 2892.28.1.5 height . . . . . . . . . . . . . . . . . . . . . . . . 2902.28.1.6 parent . . . . . . . . . . . . . . . . . . . . . . . . 2902.28.1.7 handle . . . . . . . . . . . . . . . . . . . . . . . . 2902.28.1.8 className . . . . . . . . . . . . . . . . . . . . . 2912.28.1.9 visible . . . . . . . . . . . . . . . . . . . . . . . . 2912.28.1.10 enable . . . . . . . . . . . . . . . . . . . . . . . . 2912.28.1.11 clientRect . . . . . . . . . . . . . . . . . . . . . . 2922.28.1.12 windowState . . . . . . . . . . . . . . . . . . . . 292
2.28.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2922.28.2.1 show . . . . . . . . . . . . . . . . . . . . . . . . 2922.28.2.2 hide . . . . . . . . . . . . . . . . . . . . . . . . . 2932.28.2.3 close . . . . . . . . . . . . . . . . . . . . . . . . . 2942.28.2.4 getChildren . . . . . . . . . . . . . . . . . . . . . 2942.28.2.5 getWindowsByName . . . . . . . . . . . . . . . . 2952.28.2.6 find . . . . . . . . . . . . . . . . . . . . . . . . . 2962.28.2.7 bringToTop . . . . . . . . . . . . . . . . . . . . . 2962.28.2.8 modifyStyle . . . . . . . . . . . . . . . . . . . . . 2972.28.2.9 modifyStyleEx . . . . . . . . . . . . . . . . . . . 2972.28.2.10 move . . . . . . . . . . . . . . . . . . . . . . . . 2982.28.2.11 update . . . . . . . . . . . . . . . . . . . . . . . 2992.28.2.12 animate . . . . . . . . . . . . . . . . . . . . . . . 2992.28.2.13 fly . . . . . . . . . . . . . . . . . . . . . . . . . . 3002.28.2.14 fly2 . . . . . . . . . . . . . . . . . . . . . . . . . 3012.28.2.15 center . . . . . . . . . . . . . . . . . . . . . . . . 302
2.28.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3022.28.3.1 onClose . . . . . . . . . . . . . . . . . . . . . . . 3022.28.3.2 onQueryClose . . . . . . . . . . . . . . . . . . . 3022.28.3.3 onEnter . . . . . . . . . . . . . . . . . . . . . . . 3032.28.3.4 onLeave . . . . . . . . . . . . . . . . . . . . . . . 3042.28.3.5 onHover . . . . . . . . . . . . . . . . . . . . . . . 3042.28.3.6 onSize . . . . . . . . . . . . . . . . . . . . . . . . 3052.28.3.7 onMessage . . . . . . . . . . . . . . . . . . . . . 305
2.29 FlashPlayer Object . . . . . . . . . . . . . . . . . . . . . . . . . . 3062.29.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
2.29.1.1 totalFrames . . . . . . . . . . . . . . . . . . . . . 3072.29.1.2 playing . . . . . . . . . . . . . . . . . . . . . . . 3082.29.1.3 quality . . . . . . . . . . . . . . . . . . . . . . . 3082.29.1.4 scaleMode . . . . . . . . . . . . . . . . . . . . . 3082.29.1.5 alignMode . . . . . . . . . . . . . . . . . . . . . 3092.29.1.6 backgroundColor . . . . . . . . . . . . . . . . . . 309
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 15
2.29.1.7 loop . . . . . . . . . . . . . . . . . . . . . . . . . 3092.29.1.8 movie . . . . . . . . . . . . . . . . . . . . . . . . 3092.29.1.9 frameNum . . . . . . . . . . . . . . . . . . . . . 3102.29.1.10 wmode . . . . . . . . . . . . . . . . . . . . . . . 3102.29.1.11 salign . . . . . . . . . . . . . . . . . . . . . . . . 3102.29.1.12 base . . . . . . . . . . . . . . . . . . . . . . . . . 3102.29.1.13 scale . . . . . . . . . . . . . . . . . . . . . . . . . 3112.29.1.14 bgColor . . . . . . . . . . . . . . . . . . . . . . . 3112.29.1.15 showPrintDlg . . . . . . . . . . . . . . . . . . . . 3112.29.1.16 printerProperties . . . . . . . . . . . . . . . . . . 311
2.29.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3122.29.2.1 bindData . . . . . . . . . . . . . . . . . . . . . . 3122.29.2.2 unbindData . . . . . . . . . . . . . . . . . . . . . 3122.29.2.3 unbindAll . . . . . . . . . . . . . . . . . . . . . . 3132.29.2.4 updateData . . . . . . . . . . . . . . . . . . . . . 3132.29.2.5 getArray . . . . . . . . . . . . . . . . . . . . . . 3142.29.2.6 putArray . . . . . . . . . . . . . . . . . . . . . . 3142.29.2.7 getObject . . . . . . . . . . . . . . . . . . . . . . 3152.29.2.8 putObject . . . . . . . . . . . . . . . . . . . . . 3152.29.2.9 setZoomRect . . . . . . . . . . . . . . . . . . . . 3162.29.2.10 zoom . . . . . . . . . . . . . . . . . . . . . . . . 3162.29.2.11 pan . . . . . . . . . . . . . . . . . . . . . . . . . 3172.29.2.12 play . . . . . . . . . . . . . . . . . . . . . . . . . 3172.29.2.13 stop . . . . . . . . . . . . . . . . . . . . . . . . . 3182.29.2.14 back . . . . . . . . . . . . . . . . . . . . . . . . . 3182.29.2.15 forward . . . . . . . . . . . . . . . . . . . . . . . 3182.29.2.16 rewind . . . . . . . . . . . . . . . . . . . . . . . 3192.29.2.17 gotoFrame . . . . . . . . . . . . . . . . . . . . . 3192.29.2.18 currentFrame . . . . . . . . . . . . . . . . . . . . 3202.29.2.19 isPlaying . . . . . . . . . . . . . . . . . . . . . . 3202.29.2.20 percentLoaded . . . . . . . . . . . . . . . . . . . 3202.29.2.21 flashVersion . . . . . . . . . . . . . . . . . . . . 3212.29.2.22 loadMovie . . . . . . . . . . . . . . . . . . . . . 3212.29.2.23 setVariable . . . . . . . . . . . . . . . . . . . . . 3222.29.2.24 getVariable . . . . . . . . . . . . . . . . . . . . . 3222.29.2.25 targetGotoFrame . . . . . . . . . . . . . . . . . . 3232.29.2.26 targetGotoLabel . . . . . . . . . . . . . . . . . . 3232.29.2.27 targetCurrentFrame . . . . . . . . . . . . . . . . 3242.29.2.28 targetCurrentLabel . . . . . . . . . . . . . . . . 3242.29.2.29 targetPlay . . . . . . . . . . . . . . . . . . . . . 3242.29.2.30 targetStopPlay . . . . . . . . . . . . . . . . . . . 3252.29.2.31 targetGetProperty . . . . . . . . . . . . . . . . . 3252.29.2.32 targetSetProperty . . . . . . . . . . . . . . . . . 3262.29.2.33 targetCallFrame . . . . . . . . . . . . . . . . . . 3272.29.2.34 targetCallLabel . . . . . . . . . . . . . . . . . . 3272.29.2.35 targetGetPropertyNum . . . . . . . . . . . . . . 328
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
16 CONTENTS
2.29.2.36 targetSetPropertyNum . . . . . . . . . . . . . . 3282.29.2.37 getMovieInfo . . . . . . . . . . . . . . . . . . . . 3292.29.2.38 movieToWindow . . . . . . . . . . . . . . . . . . 329
2.29.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3302.29.3.1 onContextMenu . . . . . . . . . . . . . . . . . . 330
2.30 RegExp Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3312.30.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
2.30.1.1 source . . . . . . . . . . . . . . . . . . . . . . . . 3342.30.1.2 global . . . . . . . . . . . . . . . . . . . . . . . . 3342.30.1.3 ignoreCase . . . . . . . . . . . . . . . . . . . . . 3342.30.1.4 multiline . . . . . . . . . . . . . . . . . . . . . . 3352.30.1.5 lastIndex . . . . . . . . . . . . . . . . . . . . . . 3352.30.1.6 input (or $ ) . . . . . . . . . . . . . . . . . . . . 3352.30.1.7 lastMatch . . . . . . . . . . . . . . . . . . . . . . 3362.30.1.8 leftContext . . . . . . . . . . . . . . . . . . . . . 3362.30.1.9 rightContext . . . . . . . . . . . . . . . . . . . . 3362.30.1.10 $1 . . . $9 . . . . . . . . . . . . . . . . . . . . . . . 3362.30.1.11 lastParen . . . . . . . . . . . . . . . . . . . . . . 337
2.30.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3372.30.2.1 compile . . . . . . . . . . . . . . . . . . . . . . . 3372.30.2.2 exec . . . . . . . . . . . . . . . . . . . . . . . . . 3382.30.2.3 test . . . . . . . . . . . . . . . . . . . . . . . . . 338
2.31 ActiveXObject Object . . . . . . . . . . . . . . . . . . . . . . . . 3382.31.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
2.31.1.1 register . . . . . . . . . . . . . . . . . . . . . . . 3402.31.1.2 unregister . . . . . . . . . . . . . . . . . . . . . . 3402.31.1.3 setProperty . . . . . . . . . . . . . . . . . . . . . 3412.31.1.4 addObjectInfo . . . . . . . . . . . . . . . . . . . 341
2.31.2 ActiveXObject Object Events . . . . . . . . . . . . . . . . 3432.31.2.1 EnablePropertyNotify . . . . . . . . . . . . . . . 3442.31.2.2 OnPropertyChanged . . . . . . . . . . . . . . . . 3442.31.2.3 OnPropertyWillChange . . . . . . . . . . . . . . 3442.31.2.4 onError . . . . . . . . . . . . . . . . . . . . . . . 345
2.32 Enumerator Object . . . . . . . . . . . . . . . . . . . . . . . . . . 3452.32.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
2.32.1.1 atEnd . . . . . . . . . . . . . . . . . . . . . . . . 3462.32.1.2 item . . . . . . . . . . . . . . . . . . . . . . . . . 346
2.32.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3472.32.2.1 moveFirst . . . . . . . . . . . . . . . . . . . . . . 3472.32.2.2 moveEnd . . . . . . . . . . . . . . . . . . . . . . 3472.32.2.3 moveNext . . . . . . . . . . . . . . . . . . . . . . 347
2.33 RegKey Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3482.33.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
2.33.1.1 className . . . . . . . . . . . . . . . . . . . . . 3482.33.1.2 newCreated . . . . . . . . . . . . . . . . . . . . . 3492.33.1.3 lastWriteTime . . . . . . . . . . . . . . . . . . . 349
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 17
2.33.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3502.33.2.1 create . . . . . . . . . . . . . . . . . . . . . . . . 3502.33.2.2 open . . . . . . . . . . . . . . . . . . . . . . . . . 3512.33.2.3 getSubkeyNames . . . . . . . . . . . . . . . . . . 3522.33.2.4 getValues . . . . . . . . . . . . . . . . . . . . . . 3532.33.2.5 getValue . . . . . . . . . . . . . . . . . . . . . . 3532.33.2.6 write . . . . . . . . . . . . . . . . . . . . . . . . 3542.33.2.7 deleteKey . . . . . . . . . . . . . . . . . . . . . . 3552.33.2.8 deleteValue . . . . . . . . . . . . . . . . . . . . . 355
2.34 RegValue Object . . . . . . . . . . . . . . . . . . . . . . . . . . . 3562.34.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
2.34.1.1 name . . . . . . . . . . . . . . . . . . . . . . . . 3572.34.1.2 type . . . . . . . . . . . . . . . . . . . . . . . . . 3572.34.1.3 data . . . . . . . . . . . . . . . . . . . . . . . . . 359
2.35 Ini Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3602.35.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
2.35.1.1 getInt . . . . . . . . . . . . . . . . . . . . . . . . 3612.35.1.2 getSection . . . . . . . . . . . . . . . . . . . . . 3612.35.1.3 getSectionNames . . . . . . . . . . . . . . . . . . 3622.35.1.4 getString . . . . . . . . . . . . . . . . . . . . . . 3622.35.1.5 writeSection . . . . . . . . . . . . . . . . . . . . 3632.35.1.6 writeString . . . . . . . . . . . . . . . . . . . . . 3632.35.1.7 deleteSection . . . . . . . . . . . . . . . . . . . . 3642.35.1.8 deleteKey . . . . . . . . . . . . . . . . . . . . . . 364
2.36 FontObject Object . . . . . . . . . . . . . . . . . . . . . . . . . . 3652.36.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
2.36.1.1 bold . . . . . . . . . . . . . . . . . . . . . . . . . 3652.36.1.2 color . . . . . . . . . . . . . . . . . . . . . . . . . 3652.36.1.3 italic . . . . . . . . . . . . . . . . . . . . . . . . 3652.36.1.4 name . . . . . . . . . . . . . . . . . . . . . . . . 3662.36.1.5 size . . . . . . . . . . . . . . . . . . . . . . . . . 3662.36.1.6 underline . . . . . . . . . . . . . . . . . . . . . . 366
2.36.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3662.36.2.1 getFonts . . . . . . . . . . . . . . . . . . . . . . 366
2.37 Shortcut Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3672.37.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
2.37.1.1 arguments . . . . . . . . . . . . . . . . . . . . . 3682.37.1.2 description . . . . . . . . . . . . . . . . . . . . . 3692.37.1.3 hotKey . . . . . . . . . . . . . . . . . . . . . . . 3692.37.1.4 iconLocation . . . . . . . . . . . . . . . . . . . . 3692.37.1.5 targetPath . . . . . . . . . . . . . . . . . . . . . 3702.37.1.6 windowStyle . . . . . . . . . . . . . . . . . . . . 3702.37.1.7 workingDirectory . . . . . . . . . . . . . . . . . 371
2.37.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3722.37.2.1 save . . . . . . . . . . . . . . . . . . . . . . . . . 372
2.38 URLShortcut Object . . . . . . . . . . . . . . . . . . . . . . . . . 372
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
18 CONTENTS
2.38.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 3732.38.1.1 url . . . . . . . . . . . . . . . . . . . . . . . . . . 373
2.38.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3732.38.2.1 save . . . . . . . . . . . . . . . . . . . . . . . . . 373
2.39 Mail Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3742.39.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
2.39.1.1 from . . . . . . . . . . . . . . . . . . . . . . . . . 3762.39.1.2 replyTo . . . . . . . . . . . . . . . . . . . . . . . 3762.39.1.3 to . . . . . . . . . . . . . . . . . . . . . . . . . . 3772.39.1.4 subject . . . . . . . . . . . . . . . . . . . . . . . 3772.39.1.5 cc . . . . . . . . . . . . . . . . . . . . . . . . . . 3772.39.1.6 bcc . . . . . . . . . . . . . . . . . . . . . . . . . 3772.39.1.7 date . . . . . . . . . . . . . . . . . . . . . . . . . 3782.39.1.8 priority . . . . . . . . . . . . . . . . . . . . . . . 3782.39.1.9 size . . . . . . . . . . . . . . . . . . . . . . . . . 3782.39.1.10 text . . . . . . . . . . . . . . . . . . . . . . . . . 3782.39.1.11 html . . . . . . . . . . . . . . . . . . . . . . . . . 3792.39.1.12 attachmentCount . . . . . . . . . . . . . . . . . 3792.39.1.13 htmlItemCount . . . . . . . . . . . . . . . . . . . 380
2.39.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3802.39.2.1 save . . . . . . . . . . . . . . . . . . . . . . . . . 3802.39.2.2 load . . . . . . . . . . . . . . . . . . . . . . . . . 3802.39.2.3 asText . . . . . . . . . . . . . . . . . . . . . . . . 3812.39.2.4 getAttachmentContentType . . . . . . . . . . . 3822.39.2.5 getAttachmentName . . . . . . . . . . . . . . . . 3822.39.2.6 saveAttachment . . . . . . . . . . . . . . . . . . 3832.39.2.7 addAttachment . . . . . . . . . . . . . . . . . . . 3832.39.2.8 removeAttachment . . . . . . . . . . . . . . . . . 3842.39.2.9 getHtmlItemName . . . . . . . . . . . . . . . . . 3842.39.2.10 getHtmlItemID . . . . . . . . . . . . . . . . . . . 3852.39.2.11 saveHtmlItem . . . . . . . . . . . . . . . . . . . 3852.39.2.12 addHtmlItem . . . . . . . . . . . . . . . . . . . . 386
2.40 SendMail Object . . . . . . . . . . . . . . . . . . . . . . . . . . . 3872.40.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
2.40.1.1 server . . . . . . . . . . . . . . . . . . . . . . . . 3892.40.1.2 port . . . . . . . . . . . . . . . . . . . . . . . . . 3892.40.1.3 username . . . . . . . . . . . . . . . . . . . . . . 3892.40.1.4 password . . . . . . . . . . . . . . . . . . . . . . 390
2.40.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3902.40.2.1 send . . . . . . . . . . . . . . . . . . . . . . . . . 3902.40.2.2 connect . . . . . . . . . . . . . . . . . . . . . . . 3902.40.2.3 command . . . . . . . . . . . . . . . . . . . . . . 3912.40.2.4 write . . . . . . . . . . . . . . . . . . . . . . . . 3912.40.2.5 close . . . . . . . . . . . . . . . . . . . . . . . . . 392
2.40.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3922.40.3.1 onSend . . . . . . . . . . . . . . . . . . . . . . . 392
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 19
2.41 RecvMail Object . . . . . . . . . . . . . . . . . . . . . . . . . . . 3932.41.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
2.41.1.1 server . . . . . . . . . . . . . . . . . . . . . . . . 3942.41.1.2 port . . . . . . . . . . . . . . . . . . . . . . . . . 3942.41.1.3 Username . . . . . . . . . . . . . . . . . . . . . . 3942.41.1.4 password . . . . . . . . . . . . . . . . . . . . . . 395
2.41.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3952.41.2.1 connect . . . . . . . . . . . . . . . . . . . . . . . 3952.41.2.2 close . . . . . . . . . . . . . . . . . . . . . . . . . 3952.41.2.3 dele . . . . . . . . . . . . . . . . . . . . . . . . . 3962.41.2.4 list . . . . . . . . . . . . . . . . . . . . . . . . . . 3962.41.2.5 noop . . . . . . . . . . . . . . . . . . . . . . . . 3972.41.2.6 quit . . . . . . . . . . . . . . . . . . . . . . . . . 3972.41.2.7 retr . . . . . . . . . . . . . . . . . . . . . . . . . 3972.41.2.8 rset . . . . . . . . . . . . . . . . . . . . . . . . . 3982.41.2.9 stat . . . . . . . . . . . . . . . . . . . . . . . . . 3982.41.2.10 top . . . . . . . . . . . . . . . . . . . . . . . . . 3992.41.2.11 uidl . . . . . . . . . . . . . . . . . . . . . . . . . 399
2.41.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4002.41.3.1 onRecv . . . . . . . . . . . . . . . . . . . . . . . 400
2.42 Inet Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4012.42.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
2.42.1.1 ping . . . . . . . . . . . . . . . . . . . . . . . . . 4012.42.1.2 mxfind . . . . . . . . . . . . . . . . . . . . . . . 4022.42.1.3 isInetConnected . . . . . . . . . . . . . . . . . . 4032.42.1.4 getDNS . . . . . . . . . . . . . . . . . . . . . . . 4032.42.1.5 getIPConfig . . . . . . . . . . . . . . . . . . . . . 4042.42.1.6 getUrl . . . . . . . . . . . . . . . . . . . . . . . . 4042.42.1.7 getHttpFileSize . . . . . . . . . . . . . . . . . . 4052.42.1.8 getHttpFileLastModifiedTime . . . . . . . . . . 4062.42.1.9 getHttpFileStatus . . . . . . . . . . . . . . . . . 4062.42.1.10 getHttpFileHeader . . . . . . . . . . . . . . . . . 4072.42.1.11 openFtp . . . . . . . . . . . . . . . . . . . . . . 407
2.42.2 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4082.42.2.1 onPinging . . . . . . . . . . . . . . . . . . . . . . 4082.42.2.2 onGetUrl . . . . . . . . . . . . . . . . . . . . . . 409
2.43 Inet.Ftp Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4102.43.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
2.43.1.1 connect . . . . . . . . . . . . . . . . . . . . . . . 4112.43.1.2 createDir . . . . . . . . . . . . . . . . . . . . . . 4122.43.1.3 removeDir . . . . . . . . . . . . . . . . . . . . . 4122.43.1.4 deleteFile . . . . . . . . . . . . . . . . . . . . . . 4132.43.1.5 rename . . . . . . . . . . . . . . . . . . . . . . . 4132.43.1.6 getFileInfo . . . . . . . . . . . . . . . . . . . . . 4142.43.1.7 list . . . . . . . . . . . . . . . . . . . . . . . . . . 4142.43.1.8 download . . . . . . . . . . . . . . . . . . . . . . 415
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
20 CONTENTS
2.43.1.9 upload . . . . . . . . . . . . . . . . . . . . . . . 4152.43.1.10 close . . . . . . . . . . . . . . . . . . . . . . . . . 416
2.43.2 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 4162.43.2.1 currentDir . . . . . . . . . . . . . . . . . . . . . 416
2.43.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4172.43.3.1 onDownload . . . . . . . . . . . . . . . . . . . . 4172.43.3.2 onUpload . . . . . . . . . . . . . . . . . . . . . . 417
2.44 IPConfig Object . . . . . . . . . . . . . . . . . . . . . . . . . . . 4182.44.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
2.44.1.1 ifNum . . . . . . . . . . . . . . . . . . . . . . . . 4182.44.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
2.44.2.1 ifType . . . . . . . . . . . . . . . . . . . . . . . . 4182.44.2.2 ifIP . . . . . . . . . . . . . . . . . . . . . . . . . 4192.44.2.3 ifIPMask . . . . . . . . . . . . . . . . . . . . . . 4192.44.2.4 ifDefaultGateway . . . . . . . . . . . . . . . . . 4202.44.2.5 ifMac . . . . . . . . . . . . . . . . . . . . . . . . 4202.44.2.6 ifDesc . . . . . . . . . . . . . . . . . . . . . . . . 421
2.45 SysInfo Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4212.45.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
2.45.1.1 computerName . . . . . . . . . . . . . . . . . . . 4212.45.1.2 userName . . . . . . . . . . . . . . . . . . . . . . 4222.45.1.3 version . . . . . . . . . . . . . . . . . . . . . . . 4222.45.1.4 workarea . . . . . . . . . . . . . . . . . . . . . . 4222.45.1.5 totalPhysMemory . . . . . . . . . . . . . . . . . 4232.45.1.6 availPhysMemory . . . . . . . . . . . . . . . . . 4232.45.1.7 cpuSpeed . . . . . . . . . . . . . . . . . . . . . . 4232.45.1.8 screenSaver . . . . . . . . . . . . . . . . . . . . . 4232.45.1.9 screenSaverActive . . . . . . . . . . . . . . . . . 4242.45.1.10 screenSaverTimeout . . . . . . . . . . . . . . . . 4242.45.1.11 displaySetting . . . . . . . . . . . . . . . . . . . 424
2.45.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4252.45.2.1 powerOff . . . . . . . . . . . . . . . . . . . . . . 4252.45.2.2 logOff . . . . . . . . . . . . . . . . . . . . . . . . 4262.45.2.3 reboot . . . . . . . . . . . . . . . . . . . . . . . . 4262.45.2.4 shutdown . . . . . . . . . . . . . . . . . . . . . . 4262.45.2.5 getDisplaySettings . . . . . . . . . . . . . . . . . 427
2.46 Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4272.46.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 428
2.46.1.1 attributes . . . . . . . . . . . . . . . . . . . . . . 4282.46.1.2 dateCreated . . . . . . . . . . . . . . . . . . . . 4282.46.1.3 dateLastAccessed . . . . . . . . . . . . . . . . . 4292.46.1.4 dateLastModified . . . . . . . . . . . . . . . . . 4292.46.1.5 drive . . . . . . . . . . . . . . . . . . . . . . . . 4292.46.1.6 isRootFolder . . . . . . . . . . . . . . . . . . . . 4302.46.1.7 name . . . . . . . . . . . . . . . . . . . . . . . . 4302.46.1.8 parentPath . . . . . . . . . . . . . . . . . . . . . 430
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 21
2.46.1.9 path . . . . . . . . . . . . . . . . . . . . . . . . . 4312.46.1.10 shortName . . . . . . . . . . . . . . . . . . . . . 4312.46.1.11 shortPath . . . . . . . . . . . . . . . . . . . . . . 4312.46.1.12 size . . . . . . . . . . . . . . . . . . . . . . . . . 4322.46.1.13 subFolders . . . . . . . . . . . . . . . . . . . . . 4322.46.1.14 files . . . . . . . . . . . . . . . . . . . . . . . . . 432
2.46.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4332.46.2.1 copy . . . . . . . . . . . . . . . . . . . . . . . . . 4332.46.2.2 remove . . . . . . . . . . . . . . . . . . . . . . . 4332.46.2.3 move . . . . . . . . . . . . . . . . . . . . . . . . 4342.46.2.4 files . . . . . . . . . . . . . . . . . . . . . . . . . 4342.46.2.5 exists . . . . . . . . . . . . . . . . . . . . . . . . 435
2.47 File Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4352.47.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
2.47.1.1 attributes . . . . . . . . . . . . . . . . . . . . . . 4362.47.1.2 dateCreated . . . . . . . . . . . . . . . . . . . . 4362.47.1.3 dateLastAccessed . . . . . . . . . . . . . . . . . 4372.47.1.4 dateLastModified . . . . . . . . . . . . . . . . . 4372.47.1.5 drive . . . . . . . . . . . . . . . . . . . . . . . . 4372.47.1.6 name . . . . . . . . . . . . . . . . . . . . . . . . 4382.47.1.7 parentPath . . . . . . . . . . . . . . . . . . . . . 4382.47.1.8 path . . . . . . . . . . . . . . . . . . . . . . . . . 4382.47.1.9 shortName . . . . . . . . . . . . . . . . . . . . . 4392.47.1.10 shortPath . . . . . . . . . . . . . . . . . . . . . . 4392.47.1.11 size . . . . . . . . . . . . . . . . . . . . . . . . . 4392.47.1.12 type . . . . . . . . . . . . . . . . . . . . . . . . . 440
2.47.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4402.47.2.1 copy . . . . . . . . . . . . . . . . . . . . . . . . . 4402.47.2.2 remove . . . . . . . . . . . . . . . . . . . . . . . 4402.47.2.3 move . . . . . . . . . . . . . . . . . . . . . . . . 4412.47.2.4 exists . . . . . . . . . . . . . . . . . . . . . . . . 441
2.48 Drive Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4412.48.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
2.48.1.1 availableSpace . . . . . . . . . . . . . . . . . . . 4422.48.1.2 driveLetter . . . . . . . . . . . . . . . . . . . . . 4422.48.1.3 driveType . . . . . . . . . . . . . . . . . . . . . . 4432.48.1.4 fileSystem . . . . . . . . . . . . . . . . . . . . . . 4432.48.1.5 freeSpace . . . . . . . . . . . . . . . . . . . . . . 4442.48.1.6 isReady . . . . . . . . . . . . . . . . . . . . . . . 4442.48.1.7 path . . . . . . . . . . . . . . . . . . . . . . . . . 4452.48.1.8 rootFolder . . . . . . . . . . . . . . . . . . . . . 4452.48.1.9 serialNumber . . . . . . . . . . . . . . . . . . . . 4452.48.1.10 totalSize . . . . . . . . . . . . . . . . . . . . . . 4462.48.1.11 volumeName . . . . . . . . . . . . . . . . . . . . 4462.48.1.12 drives . . . . . . . . . . . . . . . . . . . . . . . . 446
2.49 StringStream Object . . . . . . . . . . . . . . . . . . . . . . . . . 447
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
22 CONTENTS
2.49.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 4472.49.1.1 length . . . . . . . . . . . . . . . . . . . . . . . . 4472.49.1.2 getPos . . . . . . . . . . . . . . . . . . . . . . . . 4482.49.1.3 putPos . . . . . . . . . . . . . . . . . . . . . . . 4482.49.1.4 eof . . . . . . . . . . . . . . . . . . . . . . . . . . 4482.49.1.5 crc . . . . . . . . . . . . . . . . . . . . . . . . . . 448
2.49.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4492.49.2.1 get . . . . . . . . . . . . . . . . . . . . . . . . . . 4492.49.2.2 getLong . . . . . . . . . . . . . . . . . . . . . . . 4492.49.2.3 getShort . . . . . . . . . . . . . . . . . . . . . . 4502.49.2.4 getFloat . . . . . . . . . . . . . . . . . . . . . . . 4502.49.2.5 getDouble . . . . . . . . . . . . . . . . . . . . . . 4512.49.2.6 read . . . . . . . . . . . . . . . . . . . . . . . . . 4512.49.2.7 readLine . . . . . . . . . . . . . . . . . . . . . . 4512.49.2.8 put . . . . . . . . . . . . . . . . . . . . . . . . . 4522.49.2.9 putShort . . . . . . . . . . . . . . . . . . . . . . 4522.49.2.10 putFloat . . . . . . . . . . . . . . . . . . . . . . 4522.49.2.11 write . . . . . . . . . . . . . . . . . . . . . . . . 4532.49.2.12 writeLine . . . . . . . . . . . . . . . . . . . . . . 4532.49.2.13 unget . . . . . . . . . . . . . . . . . . . . . . . . 4532.49.2.14 flush . . . . . . . . . . . . . . . . . . . . . . . . . 4542.49.2.15 close . . . . . . . . . . . . . . . . . . . . . . . . . 4542.49.2.16 readString . . . . . . . . . . . . . . . . . . . . . 4542.49.2.17 readUnicodeString . . . . . . . . . . . . . . . . . 4552.49.2.18 writeUnicodeString . . . . . . . . . . . . . . . . 4552.49.2.19 compress . . . . . . . . . . . . . . . . . . . . . . 4552.49.2.20 uncompress . . . . . . . . . . . . . . . . . . . . . 4562.49.2.21 readFromFile . . . . . . . . . . . . . . . . . . . . 4562.49.2.22 saveToFile . . . . . . . . . . . . . . . . . . . . . 456
2.50 FileStream(Stream) Object . . . . . . . . . . . . . . . . . . . . . 4572.50.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 458
2.50.1.1 length . . . . . . . . . . . . . . . . . . . . . . . . 4582.50.1.2 pos . . . . . . . . . . . . . . . . . . . . . . . . . 4582.50.1.3 eof . . . . . . . . . . . . . . . . . . . . . . . . . . 458
2.50.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4582.50.2.1 get . . . . . . . . . . . . . . . . . . . . . . . . . . 4582.50.2.2 getLong . . . . . . . . . . . . . . . . . . . . . . . 4592.50.2.3 getShort . . . . . . . . . . . . . . . . . . . . . . 4592.50.2.4 getFloat . . . . . . . . . . . . . . . . . . . . . . . 4602.50.2.5 getDouble . . . . . . . . . . . . . . . . . . . . . . 4602.50.2.6 read . . . . . . . . . . . . . . . . . . . . . . . . . 4602.50.2.7 readLine . . . . . . . . . . . . . . . . . . . . . . 4612.50.2.8 put . . . . . . . . . . . . . . . . . . . . . . . . . 4612.50.2.9 putShort . . . . . . . . . . . . . . . . . . . . . . 4612.50.2.10 putFloat . . . . . . . . . . . . . . . . . . . . . . 4622.50.2.11 write . . . . . . . . . . . . . . . . . . . . . . . . 462
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 23
2.50.2.12 writeLine . . . . . . . . . . . . . . . . . . . . . . 4632.50.2.13 unget . . . . . . . . . . . . . . . . . . . . . . . . 4632.50.2.14 flush . . . . . . . . . . . . . . . . . . . . . . . . . 4632.50.2.15 close . . . . . . . . . . . . . . . . . . . . . . . . . 4642.50.2.16 readString . . . . . . . . . . . . . . . . . . . . . 4642.50.2.17 readUnicodeString . . . . . . . . . . . . . . . . . 4642.50.2.18 writeUnicodeString . . . . . . . . . . . . . . . . 465
2.51 Socket Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4652.51.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
2.51.1.1 error . . . . . . . . . . . . . . . . . . . . . . . . . 4662.51.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
2.51.2.1 accept . . . . . . . . . . . . . . . . . . . . . . . . 4682.51.2.2 asyncSelect . . . . . . . . . . . . . . . . . . . . . 4692.51.2.3 bind . . . . . . . . . . . . . . . . . . . . . . . . . 4692.51.2.4 close . . . . . . . . . . . . . . . . . . . . . . . . . 4702.51.2.5 connect . . . . . . . . . . . . . . . . . . . . . . . 4702.51.2.6 create . . . . . . . . . . . . . . . . . . . . . . . . 4712.51.2.7 getPeerName . . . . . . . . . . . . . . . . . . . . 4722.51.2.8 getSockName . . . . . . . . . . . . . . . . . . . . 4722.51.2.9 getSockOpt . . . . . . . . . . . . . . . . . . . . . 4732.51.2.10 setSockOpt . . . . . . . . . . . . . . . . . . . . . 4742.51.2.11 ioctl . . . . . . . . . . . . . . . . . . . . . . . . . 4752.51.2.12 listen . . . . . . . . . . . . . . . . . . . . . . . . 4762.51.2.13 receive . . . . . . . . . . . . . . . . . . . . . . . 4762.51.2.14 receiveFrom . . . . . . . . . . . . . . . . . . . . 4772.51.2.15 send . . . . . . . . . . . . . . . . . . . . . . . . . 4782.51.2.16 sendTo . . . . . . . . . . . . . . . . . . . . . . . 4782.51.2.17 shutDown . . . . . . . . . . . . . . . . . . . . . . 4792.51.2.18 htonl . . . . . . . . . . . . . . . . . . . . . . . . 4792.51.2.19 htons . . . . . . . . . . . . . . . . . . . . . . . . 4802.51.2.20 ntohl . . . . . . . . . . . . . . . . . . . . . . . . 4802.51.2.21 ntohs . . . . . . . . . . . . . . . . . . . . . . . . 481
2.51.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4812.51.3.1 onAccept . . . . . . . . . . . . . . . . . . . . . . 4812.51.3.2 onClose . . . . . . . . . . . . . . . . . . . . . . . 4812.51.3.3 onConnect . . . . . . . . . . . . . . . . . . . . . 4822.51.3.4 onOOBData . . . . . . . . . . . . . . . . . . . . 4822.51.3.5 onReceive . . . . . . . . . . . . . . . . . . . . . . 4822.51.3.6 onSend . . . . . . . . . . . . . . . . . . . . . . . 483
2.52 SplashWnd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4832.52.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
2.52.1.1 timeout . . . . . . . . . . . . . . . . . . . . . . . 4842.52.1.2 window . . . . . . . . . . . . . . . . . . . . . . . 484
2.52.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4842.52.2.1 loadSWF . . . . . . . . . . . . . . . . . . . . . . 484
2.52.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
24 CONTENTS
2.52.3.1 onFSCommand . . . . . . . . . . . . . . . . . . . 4852.52.3.2 onTimeout . . . . . . . . . . . . . . . . . . . . . 485
2.53 Splash2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4852.53.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
2.53.1.1 close . . . . . . . . . . . . . . . . . . . . . . . . . 4862.54 Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
2.54.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 4892.54.1.1 printers . . . . . . . . . . . . . . . . . . . . . . . 4892.54.1.2 printerIndex . . . . . . . . . . . . . . . . . . . . 4902.54.1.3 title . . . . . . . . . . . . . . . . . . . . . . . . . 4902.54.1.4 pageCount . . . . . . . . . . . . . . . . . . . . . 4902.54.1.5 silent . . . . . . . . . . . . . . . . . . . . . . . . 4912.54.1.6 orientation . . . . . . . . . . . . . . . . . . . . . 4912.54.1.7 paperSize . . . . . . . . . . . . . . . . . . . . . . 4912.54.1.8 copies . . . . . . . . . . . . . . . . . . . . . . . . 4962.54.1.9 continuePrinting . . . . . . . . . . . . . . . . . . 4962.54.1.10 pageHeight . . . . . . . . . . . . . . . . . . . . . 4962.54.1.11 pageWidth . . . . . . . . . . . . . . . . . . . . . 4972.54.1.12 font . . . . . . . . . . . . . . . . . . . . . . . . . 4972.54.1.13 brush . . . . . . . . . . . . . . . . . . . . . . . . 4972.54.1.14 pen . . . . . . . . . . . . . . . . . . . . . . . . . 4982.54.1.15 bkColor . . . . . . . . . . . . . . . . . . . . . . . 4992.54.1.16 textColor . . . . . . . . . . . . . . . . . . . . . . 4992.54.1.17 bkMode . . . . . . . . . . . . . . . . . . . . . . . 500
2.54.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5002.54.2.1 print . . . . . . . . . . . . . . . . . . . . . . . . 5002.54.2.2 printPreview . . . . . . . . . . . . . . . . . . . . 5002.54.2.3 printText . . . . . . . . . . . . . . . . . . . . . . 5012.54.2.4 printText2 . . . . . . . . . . . . . . . . . . . . . 5022.54.2.5 getWrappedTextExtent . . . . . . . . . . . . . . 5022.54.2.6 getTabbedTextExtent . . . . . . . . . . . . . . . 5032.54.2.7 getTextHeight . . . . . . . . . . . . . . . . . . . 5042.54.2.8 getTextExtent . . . . . . . . . . . . . . . . . . . 5042.54.2.9 printImage . . . . . . . . . . . . . . . . . . . . . 5052.54.2.10 getImageSize . . . . . . . . . . . . . . . . . . . . 5052.54.2.11 line . . . . . . . . . . . . . . . . . . . . . . . . . 5062.54.2.12 rectangle . . . . . . . . . . . . . . . . . . . . . . 5062.54.2.13 roundRect . . . . . . . . . . . . . . . . . . . . . 5072.54.2.14 ellipse . . . . . . . . . . . . . . . . . . . . . . . . 5072.54.2.15 fillRect . . . . . . . . . . . . . . . . . . . . . . . 508
2.54.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5092.54.3.1 onPreparePrinting . . . . . . . . . . . . . . . . . 5092.54.3.2 onBeginPrinting . . . . . . . . . . . . . . . . . . 5092.54.3.3 onNewPage . . . . . . . . . . . . . . . . . . . . . 5092.54.3.4 onPrint . . . . . . . . . . . . . . . . . . . . . . . 5102.54.3.5 onEndPrinting . . . . . . . . . . . . . . . . . . . 510
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 25
2.55 Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5102.55.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
2.55.1.1 width . . . . . . . . . . . . . . . . . . . . . . . . 5112.55.1.2 height . . . . . . . . . . . . . . . . . . . . . . . . 5122.55.1.3 bitCount . . . . . . . . . . . . . . . . . . . . . . 5122.55.1.4 twainReady . . . . . . . . . . . . . . . . . . . . . 5122.55.1.5 twainSourceSelected . . . . . . . . . . . . . . . . 512
2.55.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5132.55.2.1 load . . . . . . . . . . . . . . . . . . . . . . . . . 5132.55.2.2 save . . . . . . . . . . . . . . . . . . . . . . . . . 5132.55.2.3 mirror . . . . . . . . . . . . . . . . . . . . . . . . 5142.55.2.4 flip . . . . . . . . . . . . . . . . . . . . . . . . . 5142.55.2.5 rotate90 . . . . . . . . . . . . . . . . . . . . . . . 5152.55.2.6 rotate270 . . . . . . . . . . . . . . . . . . . . . . 5152.55.2.7 zoom . . . . . . . . . . . . . . . . . . . . . . . . 5152.55.2.8 adjustRGB . . . . . . . . . . . . . . . . . . . . . 5162.55.2.9 adjustBrightness . . . . . . . . . . . . . . . . . . 5162.55.2.10 adjustContrast . . . . . . . . . . . . . . . . . . . 5172.55.2.11 adjustHS . . . . . . . . . . . . . . . . . . . . . . 5172.55.2.12 invert . . . . . . . . . . . . . . . . . . . . . . . . 5182.55.2.13 blur . . . . . . . . . . . . . . . . . . . . . . . . . 5182.55.2.14 blurGauss . . . . . . . . . . . . . . . . . . . . . . 5182.55.2.15 sharpen . . . . . . . . . . . . . . . . . . . . . . . 5192.55.2.16 emboss . . . . . . . . . . . . . . . . . . . . . . . 5192.55.2.17 to24Bits . . . . . . . . . . . . . . . . . . . . . . . 5192.55.2.18 toGray . . . . . . . . . . . . . . . . . . . . . . . 5202.55.2.19 crop . . . . . . . . . . . . . . . . . . . . . . . . . 5202.55.2.20 getCount . . . . . . . . . . . . . . . . . . . . . . 5202.55.2.21 captureScreen . . . . . . . . . . . . . . . . . . . 5212.55.2.22 captureMovie . . . . . . . . . . . . . . . . . . . . 5212.55.2.23 loadImage . . . . . . . . . . . . . . . . . . . . . 5222.55.2.24 twainInit . . . . . . . . . . . . . . . . . . . . . . 5222.55.2.25 twainSelectSource . . . . . . . . . . . . . . . . . 5222.55.2.26 twainAcquire . . . . . . . . . . . . . . . . . . . . 523
2.55.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5232.55.3.1 onCopyImage . . . . . . . . . . . . . . . . . . . . 523
2.56 DirectX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5232.56.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
2.56.1.1 joysticks . . . . . . . . . . . . . . . . . . . . . . 5242.56.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
2.56.2.1 setDisplayMode . . . . . . . . . . . . . . . . . . 5242.56.2.2 restore . . . . . . . . . . . . . . . . . . . . . . . 525
2.57 Joystick . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5252.57.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
2.57.1.1 buttons . . . . . . . . . . . . . . . . . . . . . . . 5252.57.1.2 x . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
26 CONTENTS
2.57.1.3 y . . . . . . . . . . . . . . . . . . . . . . . . . . . 5262.57.1.4 z . . . . . . . . . . . . . . . . . . . . . . . . . . . 5262.57.1.5 rx . . . . . . . . . . . . . . . . . . . . . . . . . . 5262.57.1.6 ry . . . . . . . . . . . . . . . . . . . . . . . . . . 5272.57.1.7 rz . . . . . . . . . . . . . . . . . . . . . . . . . . 5272.57.1.8 uaxis . . . . . . . . . . . . . . . . . . . . . . . . 5272.57.1.9 vaxis . . . . . . . . . . . . . . . . . . . . . . . . 5272.57.1.10 pov0, pov1, pov2, pov3 . . . . . . . . . . . . . . 5282.57.1.11 range . . . . . . . . . . . . . . . . . . . . . . . . 5282.57.1.12 deadzone . . . . . . . . . . . . . . . . . . . . . . 528
2.57.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5292.57.2.1 read . . . . . . . . . . . . . . . . . . . . . . . . . 5292.57.2.2 buttonState . . . . . . . . . . . . . . . . . . . . . 530
2.57.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5312.57.3.1 onLeft . . . . . . . . . . . . . . . . . . . . . . . . 5312.57.3.2 onRight . . . . . . . . . . . . . . . . . . . . . . . 5312.57.3.3 onUp . . . . . . . . . . . . . . . . . . . . . . . . 5312.57.3.4 onDown . . . . . . . . . . . . . . . . . . . . . . . 5322.57.3.5 onPress . . . . . . . . . . . . . . . . . . . . . . . 532
2.58 Dll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5322.58.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538
2.58.1.1 registerFunction . . . . . . . . . . . . . . . . . . 5382.58.1.2 unregisterFunction . . . . . . . . . . . . . . . . . 5402.58.1.3 getPointerValue . . . . . . . . . . . . . . . . . . 5412.58.1.4 getPointerStringValue . . . . . . . . . . . . . . . 5412.58.1.5 getPointerWideStringValue . . . . . . . . . . . . 542
2.59 Struct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5422.59.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
2.59.1.1 align . . . . . . . . . . . . . . . . . . . . . . . . . 5422.59.1.2 structSize . . . . . . . . . . . . . . . . . . . . . . 543
2.60 Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5432.60.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
2.60.1.1 mixerName . . . . . . . . . . . . . . . . . . . . . 5432.60.1.2 Sound.playback.masterMute . . . . . . . . . . . 5432.60.1.3 Sound.playback.masterVolume . . . . . . . . . . 5442.60.1.4 Sound.playback.waveMute . . . . . . . . . . . . 5442.60.1.5 Sound.playback.waveVolume . . . . . . . . . . . 5442.60.1.6 Sound.playback.midiMute . . . . . . . . . . . . . 5442.60.1.7 Sound.playback.midiVolume . . . . . . . . . . . 5452.60.1.8 Sound.playback.CDMute . . . . . . . . . . . . . 5452.60.1.9 Sound.playback.CDVolume . . . . . . . . . . . . 5452.60.1.10 Sound.playback.lineInMute . . . . . . . . . . . . 5452.60.1.11 Sound.playback.lineInVolume . . . . . . . . . . . 5462.60.1.12 Sound.playback.microphoneMute . . . . . . . . . 5462.60.1.13 Sound.playback.microphoneVolume . . . . . . . 5462.60.1.14 Sound.recording.lineInSelect . . . . . . . . . . . 546
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
CONTENTS 27
2.60.1.15 Sound.recording.lineInVolume . . . . . . . . . . 5472.60.1.16 Sound.recording.microphoneSelect . . . . . . . . 5472.60.1.17 Sound.recording.microphoneVolume . . . . . . . 547
2.60.2 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5472.60.2.1 Sound.playback.onMasterMute . . . . . . . . . . 5472.60.2.2 Sound.playback.onMasterVolumeChange . . . . 5482.60.2.3 Sound.playback.onWaveMute . . . . . . . . . . . 5482.60.2.4 Sound.playback.onWaveVolumeChange . . . . . 5482.60.2.5 Sound.playback.onMidiMute . . . . . . . . . . . 5482.60.2.6 Sound.playback.onMidiVolumeChange . . . . . . 5492.60.2.7 Sound.playback.onCDMute . . . . . . . . . . . . 5492.60.2.8 Sound.playback.onCDVolumeChange . . . . . . 5492.60.2.9 Sound.playback.onLineInMute . . . . . . . . . . 5492.60.2.10 Sound.playback.onLineInVolumeChange . . . . . 5502.60.2.11 Sound.playback.onMicrophoneMute . . . . . . . 5502.60.2.12 Sound.playback.onMicrophoneVolumeChange . . 5502.60.2.13 Sound.recording.lineInSelect . . . . . . . . . . . 5502.60.2.14 Sound.recording.onLineInVolumeChange . . . . 5512.60.2.15 Sound.recording.onMicrophoneSelect . . . . . . . 5512.60.2.16 Sound.recording.onMicrophoneVolumeChange . 551
2.61 PConn Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5512.61.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
2.61.1.1 listen . . . . . . . . . . . . . . . . . . . . . . . . 5522.61.1.2 send . . . . . . . . . . . . . . . . . . . . . . . . . 553
2.62 Form Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5532.62.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
2.62.1.1 show . . . . . . . . . . . . . . . . . . . . . . . . 5542.62.1.2 close . . . . . . . . . . . . . . . . . . . . . . . . . 5552.62.1.3 getVariable . . . . . . . . . . . . . . . . . . . . . 5562.62.1.4 setVariable . . . . . . . . . . . . . . . . . . . . . 5562.62.1.5 targetGotoFrame . . . . . . . . . . . . . . . . . . 5572.62.1.6 targetGotoLabel . . . . . . . . . . . . . . . . . . 5572.62.1.7 targetCallFrame . . . . . . . . . . . . . . . . . . 5582.62.1.8 targetCallLabel . . . . . . . . . . . . . . . . . . 5582.62.1.9 setBase . . . . . . . . . . . . . . . . . . . . . . . 5592.62.1.10 loadMovie . . . . . . . . . . . . . . . . . . . . . 5592.62.1.11 createControl . . . . . . . . . . . . . . . . . . . . 560
2.62.2 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . 5602.62.2.1 movie . . . . . . . . . . . . . . . . . . . . . . . . 5602.62.2.2 showCaption . . . . . . . . . . . . . . . . . . . . 5612.62.2.3 canDrag . . . . . . . . . . . . . . . . . . . . . . . 5612.62.2.4 clipRegion . . . . . . . . . . . . . . . . . . . . . 5612.62.2.5 caption . . . . . . . . . . . . . . . . . . . . . . . 5612.62.2.6 initVars . . . . . . . . . . . . . . . . . . . . . . . 5622.62.2.7 window . . . . . . . . . . . . . . . . . . . . . . . 562
2.62.3 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
28 CONTENTS
2.62.3.1 onExit . . . . . . . . . . . . . . . . . . . . . . . 5622.63 ScriptHost Object . . . . . . . . . . . . . . . . . . . . . . . . . . 563
2.63.1 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5652.63.1.1 open . . . . . . . . . . . . . . . . . . . . . . . . . 5652.63.1.2 close . . . . . . . . . . . . . . . . . . . . . . . . . 5662.63.1.3 runScript . . . . . . . . . . . . . . . . . . . . . . 5662.63.1.4 runScriptFile . . . . . . . . . . . . . . . . . . . . 5672.63.1.5 getScriptObject . . . . . . . . . . . . . . . . . . 567
3 FSCommands 5693.1 FSCommands – FFish Eval . . . . . . . . . . . . . . . . . . . . . 5693.2 FSCommands – FFish Run . . . . . . . . . . . . . . . . . . . . . 5693.3 FSCommands – Quit . . . . . . . . . . . . . . . . . . . . . . . . . 5703.4 FSCommands – FullScreen . . . . . . . . . . . . . . . . . . . . . 5713.5 FSCommands – exec . . . . . . . . . . . . . . . . . . . . . . . . . 5713.6 FSCommands – FFish Trace . . . . . . . . . . . . . . . . . . . . 571
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
Chapter 1
Tutorials
The tutorials in this chapter discuss both the topics for the beginners suchas how to start converting flash movies to .exe files, adding more functions toyour SWFKit projects, protecting your resource files, etc, and the topics for theadvanced users such as using the synchronous methods to call FFish Scritinglanguage elements directly from within Action Script, building windowless pro-jectors, opening, reading, writing, moving and deleting files, launching externalapplications, opening system dialog boxes, accessing databases, programmingthe tray icons, downloading and uploading files, sending and receiving emails,creating multiple forms, changing screen resolutions, screen capture, reusing theweb browser control, playing avi, rm, mov, wmv movies, opening pdf files, call-ing Active scripting languages such as jscript, vbscript, perlscript, pythonscript,ect, calling dynamic linked libraries and ActiveX components, etc. Althoughthe tutorials in this chapter cover only the details of how to build executablefiles(.exe files), the methods introduced in these tutorials are also helpful forbuilding screen savers(.scr files).
1.1 Converting your flash movies to an executableprogram
In this tutorial you will learn how to create a simple SWFKit project to convertyour flash movies to an executable program(.exe file). If you have a flash project,say, a flash presentation or a flash game, which may contain more than one flashmovie(.swf file) in several folders, with many other resource files such as XMLfiles, sounds, images, text files, etc, and you would like to convert them all to asingle .exe file, or an .exe file that can launch and play your flash presentationor flash game, you can do as follows.
The first step is to launch SWFKit (either SWFKit Express, SWFKit orSWFKit Pro) and create a new SWFKit project. After saving your new SWFKitproject, you can then set the ”output details” options such as the output direc-tory, what to build, an .exe file or a .scr file(the default setting is to build an
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
30 Tutorials
Figure 1.1: Creating a new SWFKit project
application, that is, to build an .exe file), the icons for the output .exe file or.scr file, etc, as shown in figure 1.1
If you check the ”standalone” option, SWFKit will pack the Flash Playerinto the output .exe file so that it can work on a computer without the mostcurrent version of Flash Player, or without Flash Player at all. The ”CreateAutoRun.inf” enables your project to create an autorun.inf file, that is, yourproject can produce an autorun CD. If the ”pack resources” option is checked,SWFKit will produce a single .exe file, that is, all the resource files are packedinto the output .exe file.
Now you can begin the second step - adding resource files into your SWFKitproject. Going to the resources panel, you will see a tree view on the left side ofthe panel and a list view on the right side of the panel, as shown in the figure1.1.The tree view is used to organize the directory structure of the resource files,and the list view is used to manage the resource files in a folder. Typically yourresource files are added into the ”Application” folder in the tree view, and the”Windows” folder is only used by the installers to copy some special files tothe Windows folder or system folder. The simplest way to add your resourcefiles is to use the ”Import” button. In this way, all files in your flash projectwill be added into the ”Application” folder and the directory structure of your
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.1 Converting your flash movies to an executable program 31
Figure 1.2: Adding resource files
flash project keeps unchanged. You can also add your resource files by creatingfolders and adding files manually. The resource files can be of any file type.After adding the resource files you must specify the main movie, which is theflash movie that the output .exe file will load first. You may notice that beforeeach file in the list view there is a check box. It is used to protect your resourcefiles. You may read the relative tutorials to learn how to use it.
The third step is to go to the ”Application Definition” panel to set theoptions such as appearance, size, position, behavior, etc of your output .exe file.For example, in this panel you can set the caption of the main window of youroutput program, check the ”show in system tray” option to show an icon in thesystem tray, define the exit keys, etc. See figure 1.1
Finally, you would have to insert a line of code into the ”initialize” script asfollows,
//InitializegetAdditionalFile();
return true;
The purpose of calling the ”getAdditionalFile” method in the ”initialize” script
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
32 Tutorials
Figure 1.3: Settings of your SWFKit project
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.2 Add more functions to your application 33
is to extract the resource files if they are packed into the output .exe file, or theoutput .exe file cannot work properly. Now your SWFKit project is ready towork. Before building the output .exe file, you can preview it first by pressingthe hot key ”F9” (for screen savers it is ”CTRL+F9”), and in this case SWFKitdoes not produce any .exe files. When you feel everything is ok, you can buildthe output .exe file by pressing ”F7” and run it by pressing ”F5”. To go to thedirectory that the output .exe file resides in, you can press ”F10”.
From what have been discussed above, you can see that it is very easy toconvert your flash project to an .exe file - just some mouse clicks.
1.2 Add more functions to your application
Besides simply converting a flash project to an .exe file, you may want to addmore functions to your application such as reading and writing disk files, ac-cessing databases, encrypting and decrypting files, etc, which Flash itself doesnot 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, youalso know the ffishscript programming. The FFish scripting language providesmany objects to extend the power of Flash. More details of these objects canbe found in the FFish scripting language manual.
The general way of using the FFish scripting language is to insert scriptsinto SWFKit, add code into the scripts and call the script in Action scripts. Ifyou use Flash 8, however, you can call the FFish script objects directly fromwithin Action script. This way is more clear and convenient. Calling the FFishscript objects directly in Action script will be introduced in another tutorial, athere 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 havefound that for every newly created SWFKit project, there is a predefined ”ini-tialize” script. SWFKit automatically inserts an ”initialize” script for eachSWFKit project, and the ”initialize” script will be called after the produced.exe file or .scr file is launched. It is called just after the main window is createdand about to be visible, but before the main flash movie is loaded. Hence, youcan use the ”initialize” script to do some initialization tasks, for example, load-ing a data file, checking some registry entry, etc. A useful example is to make aprogram has only one instance at a time. The idea of doing this job is to findwhether there is already a window has the same caption as the current programthat is about to run. If such a window is found, we will bring the found windowto top and stop the current program; otherwise, we will continue the currentprogram. The following code shows how to do this:
var wnds = Window.getWindowsByName(your window name);var w = getMainWnd();var has = false;for (i = 0; i < wnds.length; i++)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
34 Tutorials
{if (wnds[i].handle != w.handle){
has = true;break;
}}
if (has){
wnds[i].bringToTop();return false;
}
return true;
What you should notice is that when calling the ”initialize” script the mainmovie is not loaded yet. All Attempts in the ”initialize” script to set the valuesof the variables in the main movie will have no effect.
Second, you can add as many scripts in SWFKit as you can and call themin Action script. At here we only discuss the asynchronous way of calling FFishscripts - using the ”ffish run” fscommand. For example, say you have a scriptnamed ”recordSound” in SWFKit, and you want to call it when you press abutton, 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. Forexample, 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 immediatelyafter the script is called by fscommand, because the value of the variable may bechanged after all the Action script instructions in this frame has been executed.Notice: fscommands are always called synchronously, for example, if you havemore 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 fs-commands will never be reversed. Now we use an example to show how to usethe FFish scripting language to add more functions to your SWFKit project.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.2 Add more functions to your application 35
Providing you are creating a game with flash, which will save and load thescores of players, that is, the game needs read and write a disk file to load andsave data. To implement this feature, we would have to maintain an array tosave the score data for each user, and add functions to add, load and save scoredata. 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 datafile. 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 datascoreRecords = [];var scoreFile = getAppDir() + "\\scores.txt";// loads the dataDataFile.load(scoreFile);
// traces the data to see how many score data is loadedfor (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 newplayer. Generally there should be a button in the main movie; when pressingthe button, we call the FFish script to add the a score record. After creating anew script called ”newplayer” in SWFKit, we add the following code into thescript:
// Get player name and score from flash movievar playerName = FlashPlayer.getVariable("_root.playerName");var score = parseInt(FlashPlayer.getVariable("_root.score"));// Create a new score record and save into the arrayvar scoreRecord = new scoreInfo(playerName, score);scoreRecords.push(scoreRecord);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
36 Tutorials
Calling the ”newplayer” script in Action script:
on (release){
FSCommand("FFish_Run", "newplayer");}
Finally, we would have to add a function to save the score data when thegame 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 whenit is about to exit. This can be done by handling the ”onClose” event of themain window of the game. When the main window of the game is about toclose, this event handler will be called. Hence, we can call the saving score datafunction in this event handler. We put this event handler into the ”initialize”script because the ”initialize” script has already been loaded into memory whenthe game starts. If you put the event handler in another script, you must makesure that the script is loaded, or the game cannot find the event handler.
function saveScores(){
var df = getAppDir() + "\\scores.txt";// remove the old fileDataFile.remove(df);DataFile.save(df, "scoreRecords");
}
var wnd = getMainWnd();wnd.onClose = function(){
saveScores();}
1.3 Using FFish script objects synchronously inActionScript 2/3
SWFKit 3 supports calling FFish script objects synchronously in Action script2 or 3. Moreover, it comes with a plug-in that enables you to preview and testyour SWFKit projects from within Flash 8 or 9. Now we will introduce thisfeature step by step as follows:
1.3.1 Setting the class path for ActionScript 2/3
Most of the FFish script objects have been wrapped in Action script classes. Thewrapper classes reside in the classes subfolder of the SWFKit installed folder,whose typical paths are “c:\program files\swfkit pro 3\classes” (for actionscript2), and “c:\program files\swfkit pro 3\classes 3” (for actionscript 3). To call
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.3 Using FFish script objects synchronously in ActionScript 2/3 37
Figure 1.4: Adding the class path
the classes in Action script, you must add the path into the class path foractionscript 2 or 3. The figure 1.3.1 shows how to set the class path in Flash 8:
1.3.2 Defining hot keys for SWFKit plug-in commands
After SWFKit is installed, five commands are added into the command menu ofFlash 8 or 9. Defining hot keys for these newly added commands will make yourdeveloping works more convenient. In the Edit menu of Flash 8 or 9, choose thekeyboard shortcuts command, duplicate a new shortcut set, e.g. ”New”, andthen assign hot keys for the new commands. Please see the figure1.3.2
1.3.3 Installing the plug-in and commands manually
If the plug-in and the commands are not installed properly, e.g. your Flash8 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 SWFKitinstalled folder, whose typical path is “c:\program files\swfkit pro 3\plug-in”.Second, copy the skp plugin.dll into the “C:\Documents and Settings\{currentuser}\Local Settings\Application Data\Macromedia\Flash 8\{language}\Configuration\ExternalLibraries” folder, and copy the five .jsfl files into the “C:\Documents and Settings\{currentuser}\Local Settings\Application Data\Macromedia\Flash 8\language}\Configuration\Commands”
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
38 Tutorials
Figure 1.5: Defining hot keys
folder. Finally, you would have to follow the above two steps to add class pathand define hot keys. For flash 9, the directories will be “C:\Documents andSettings\{current user}\Local Settings\Application Data\Adobe\Flash CS3\{language}\Configuration\ExternalLibraries” and “C:\Documents and Settings\{current user}\Local Settings\ApplicationData\Adobe\Flash CS3\language}\Configuration\Commands”
1.3.4 Attaching to a SWFKit project
Now we can start working on our SWFKit projects. First, you must create anew SWFKit project as we have introduced in the ”start converting your flashmovies to an executable program” tutorial. Second, we open a flash project inFlash 8 (it will export one of the movies that have been added into the openedSWFKit project), and run the ”swfkit attach” command in the command menu.A dialog box will be launched to attach the current flash movie to a .swf filein an opened SWFKit project, that is, you must keep both the Flash 8 andSWFKit opened.
1.3.5 Adding functions, preview, and testing
After the current flash project is attached to a SWFKit project, you can beginto call FFish script in your flash project. For example, to launch a file opendialog by click a button.
on (click)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.3 Using FFish script objects synchronously in ActionScript 2/3 39
Figure 1.6: Attaching to a SWFKit project
{import SWFKit.*;
var file = Dialog.fileOpen("All files(*.*)|*.*|");if (file){
_root.strace(file);}
Now we can check whether the code could work by running the ”swfkit previewapp”command, which is used to preview an .exe file, whereas the ”swfkit previewscr”command is used to preview a .scr file. After running the command, the pre-view window is displayed and the output messages are displayed in the outputpanel of Flash 8. The ”swfkit previewapp” command will also display a floatinginformation panel. If the preview window is freezing, you can kill it by closingthe information panel. The ”x” button of the information panel will appearabout 30 seconds after the preview window is launched. However, if the pre-view window works well, please do not kill it by closing the information panel,because the preview window would have no chance to remove temporary folderor release memory if it is killed. So normally you should first close the previewwindow and then the information panel will disappear automatically. Similarly,you can run the ”swfkit testapp” command to build the output .exe file, launchand test it. As you can see, most of your developing works can be done directlyin Flash 8.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
40 Tutorials
Figure 1.7: Calling FFish Script directly in Action Script
1.3.6 About the trace method of SWFKit
When you preview a SWFKit project, the trace method of action script cannotwork. 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 functioncalled ”strace” into ” root”:
function strace(value){
SWFKit.Global.trace(value);}
Although this function does nothing in the output .exe file, the flash player willalways pass the ”value” parameter to FFish scripting language. It will do harmto the efficiency of the output .exe file in this case. Hence, we recommend youto modify the strace function to the following form when you are ready to buildthe release version of your .exe file.
/*function strace(value){
SWFKit.Global.trace(value);}*/strace = trace;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.3 Using FFish script objects synchronously in ActionScript 2/3 41
1.3.7 Handling events of the FFish script objects
For example, to handle the onContextMenu event, that is, to do somethingwhen right click the flash movie. First, we would have to create an instance ofthe corresponding FFish script object even if all its methods are static. Second,add an event handler in Action script. Finally, call the setEventHandler to setthe event handler.
import SWFKit.*;
function onContextMenu(){
Dialogs.msgBox("Right click!");}
var fp = new FlashPlayer;fp.setEventHandler("onContextMenu", onContextMenu);
1.3.8 How does the synchronous calls work
The reason that the synchronous calls can work is that the Flash 8 supportsexternal interface, that is, you can use ExternalInterface.call method to calla method provided by the container of the Flash Player. SWFKit support thefollowing methods that can be called by the external interface.
ffish new Creating an instance of a FFish script object. The first parameteris the name of the FFish script object, the other parameters are passed to theconstructor of the FFish script object. E.g.
var identifier = ExternalInterface.call("ffish_new", "ActiveXObject","ShockwaveFlash.ShockwaveFlash");
This function will returns an identifier of the newly created FFish script objectthat can be used to access its properties and methods.
ffish delete Deleting a FFish script object
ExternalInterface.call("ffish_delete", identifier);
ffish call Calling a method of a FFish script. The first parameter is theidentifier of the FFish script object, or the name of the object if the method isstatic, the second parameter is the name of the method, and the other param-eters are passed to the method of the object. If the method accepts an FFishscript object as a parameter, you must also use an identifier of the object.
var devices = ExternalInterface.call("ffish_call", "MCI", "getDevices");
ffish call2 Similar to ffish call. The third parameter of this method is anarray that contains all parameters that will be passed to the method of theFFish script to call.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
42 Tutorials
ffish getprop Get the value of a property of a FFish script object. Thefirst parameter is the identifer of the object, or the name of the object if theproperty is static.
var command = ExternalInterface.call("ffish_getprop", identifier, "command");
ffish setprop Set the value of a property of a FFish script object. The firstparameter is the identifer of the object, or the name of the object if the propertyis static. The second parameter is the value to set to the property of the object.
ExternalInterface.call("ffish_setprop", identifier, "command", "open");
ffish run, ffish eval The ffish run method is used to call a FFish script, andthe ffish eval method is used to execute FFish script code. These two methodsare almost the same as the ffish run and ffish eval fscommands. The onlydifference 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 difference between thismethod and the exec fscommand is that this method is synchronous. Boththis method and the exe fscommand can launch any external applications.
Besides the above methods, the ExternalInterface.call method can also beused to call global methods defined in FFish script. For example, you canwrite a function in the ”initialize” script in SWFkit and call it in Action scriptsynchronously. For example, in SWFKit:
// save a XML filefunction 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 wewrapped most of the FFish script objects in action script classes and you cancall them in action script using almost the same syntax as in ffish script. Forexample, the Form object:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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);}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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,
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 ffish 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 Wrapping ActiveX components
Each ActiveX component has its own property and method set, and Actionscript classes do not support to add methods dynamically, so you would haveto wrap ActiveX components by yourself. We have already created a baseclass - SWFKit.ActiveXObject, although it has methods to access properties ormethods 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;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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;}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
48 Tutorials
}
To wrap an ActiveX component, you would have to inherit this class. Forexample, 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 Differences between wrapper classes for actionscript2 and actionscript 3
The wrapper classes for actionscript 2 are in the “classes” sub folder of the swfkitinstalled folder, while the wrapper classes for actionscript 3 are in the “classes3” sub folder of the swfkit installed folder. The two sets of classes have sameobjects, methods, properties and events. However, there are some differencesbetween them.
First, the ActiveXObject class for actionscript 3 can access any methodor property of the ActiveXObject object it wraps; whereas, the ActiveXObjectclass for actionscript 2 can only access properties of the ActiveXObject it wraps.
Second, except the Global class, the sound.playback class and the sound.recordingclass, all wrapper classes for actionscript 3 have no static methods or properties.That is to say, you will have to first create a new instance of the class before youcan call its methods, even if the methods in ffish script is static. For example,in actionscript, you can show a message box by calling “Dialogs.msgBox(“Helloworld”);”, while in actionscript 3, you will have to create an instance of the“Dialogs” class first. For example
import SWFKit.*;var dlg = new Dialogs;dlg.msgBox("hello world");dlg.Release();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.3 Using FFish script objects synchronously in ActionScript 2/3 49
1.3.11 Calling methods written in ffish script from withinactionscript 2 or 3
From swfkit v3.2, you can use the Global class to call any methods written inffish script. For example, to call a method named “ add” defined in ffish 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 thatyou must construct an instance of the Global class before you can use it to callffish script methods.
1.3.12 Calling actionscript methods from within ffish script
First, you must define the methods in actionscript and export them. For exam-ple, 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 ffish script and call them
// The "registerASMethods" method turns any as2 or as3// callback functions into ffish script global functions. That is to say,
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
50 Tutorials
// you can call the action script functions directly in ffish script// after calling this methodApplication.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 file is a global method of SWFKit, in actionscript you should call it in the following form:
import SWFKit.*;Global.getAdditionalFile("my.file");
To avoid conflicts, the Application.* object in SWFKit such as Applica-tion.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 cancall static methods or properties, the action script supports only to call a staticmethod or property by using the class name. For example, the following codeworks,
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 aninstance of the class and call the ”setEventHandler” method.
Each wrapper class has a ”Release” method that is used to delete the in-stances of the FFish script objects. Although the FFish script objects are cre-ated and accessed from within Action script, the instances of the objects aremaintained in the FFish scripting language. In this case, the FFish scriptinglanguage does not know when you have finished using these instances of theobjects, that is, the instances will be kept in memory unless you delete themexplicitly. Hence, calling the ”Release” method after you have finished usinga FFish script object will save memory, especially if you have created a lot ofFFish script objects in your flash movie. The instances of the objects will bereleased automatically when the output executable file exits even if you do notcall the ”Release” method.
import SWFKit.*;var fs = new FileStream("c:\\demo.txt", "w");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.4 Data exchanging between Action Script and FFish Script 51
...
...fs.close();fs.Release();
Some objects, such as Printer, Dll, PConn, etc, which are not suitable forcalling directly in action script, or do not work by directly calling them in actionscript at all, are not wrapped.
If you have any problem with the wrapper classes, you can look into theirsource code to get help.
1.4 Data exchanging between Action Script andFFish Script
We often need to exchange data between Action Script and FFish Script if weuse asynchronous fscommands to call FFish scripts in Action script. In thesection ”Add more functions to your application” we discussed a sample aboutsaving game scores. The ”score” variable for a player is defined 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 setVariable method and the getVariable method
The most direct way to exchange data between AS and FS is to use these twomethods. In fact, in all other two ways these two methods will be called at lastimplicitly. The methods are provided by the Macromedia Flash Player ActiveXObject 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 The updateData method
See: 2.29Binds the variables
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
52 Tutorials
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);
1.4.3 getArray, putArray, getObject, putObject
These four methods provide an easier way to exchange arrays and objects be-tween 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 byonly one call. However, you must declare the arrays or objects in Action Scriptexplicitly before data exchanging.
However, we recommend you to use synchronous FFish script objects directlyin Action script if you have Flash 8. The synchronous objects will return valuesdirectly to Action script, and you need not transfer any data between FFishscript and Action script.
1.5 Protecting your applications
In the [operation panel]->[Application Definitions]->[Expiry] dialog box, youcan check the ”Enable expiry” option to protect your application.
When the application is expired, a dialog box will appear and tell the usersthe application is expired. If the ”enable unlock” option is checked, the dialogbox will show a ”Register” button. The users can click the button to finish theregistration. The registration codes can be generated by the ”Serial Numbercreator” in SWFKit.
In SWFKit 3, you can do all these things in your own way. A new object”Application.Expiry” is provided.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.5 Protecting your applications 53
1.5.1 Bypassing the default handler
When the application has expired, the onExpiry event will be triggered. Thefollowing 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 byyourself. In frame 1 of the main movie add a FSCommand.
FSCommand("FFish_Run", "CheckExpiry");
Insert the ”CheckExpiry” script in SWFKit, and insert the following codeinto it
if (Application.isExpired && !isRegistered()){
// the application is expiredFlashPlayer.targetGotoLabel("_root", "Expired");
}
1.5.3 Registration
In this sample, if the application is expired, the ”isRegistered” method will becalled. The isRegistered method checks if the application has been registered.
We can save the registration information in the Windows Registry, the ”is-Registered” 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)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
54 Tutorials
return false;
writeProfile("Registration", "userName", userName);writeProfile("Registration", "password", password);
return true;}
Insert the above codes into the ”Initialize” script to make them can beaccessed in the ”CheckExpiry” and the ”doRegister” scripts.
When the application finds that it is expired and not registered, it will jumpto the ”Expired” frame, in the frame, you can let the users to input their usernames and passwords to register the application.
Providing the ”Expired” frame has two input text boxes, associate with twovariables ”userName” and ”password”, and a ”Register” button, the action forthe ”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 Protecting your resource files
From SWFKit 3 it provides a unique feature to protect your resource files,including flash movies(.swf files), XML files, images, mp3 sounds, FLV movies,etc, that is, the flash movies and the resource files that can be loaded into aflash movie can be protected. How does SWFKit protects these resource filesand are they easily be decompiled by some reverse engineering tools? No, the
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.7 Using menus 55
protected resource files are encrypted so that they cannot be decompiled by anyreverse engineering tool, nor be loaded into any flash player or movie player. Ina word, they can only be played in a specific .exe file produced by SWFKit.
Another advantage of this feature is that although the resource files areencrypted, they can be loaded into the flash movies as if they are not changedat all. That is to say, the decryption process is transparent, no decrypted datais written to local disk, and you need not call any function in Action scriptto decrypt the resource files explicitly. Even if you do not pack the protectedresource files into the output .exe file, nobody could play them, import theminto Flash, or decompile them.
To protect your resource files is very simple: before each file added into theresources panel there is a check box; if you want to protect the file, just checkit. And do not forget to set a strong password in the resources panel for yourSWFKit project. SWFKit uses this password to encrypt the resource files.
At this time, the files such as .exe files, HTML files, PDF files, etc cannotbe protected by this feature, because they all need external program to openthem. The default file type that SWFKit will automatically check it to protectit is .swf files. You can change this setting in the [MainMenu]− > [V iew]− >[Options]setting box.
SWFKit also supports to stream an remote encrypted FLV file on Internet,only if the FLV file is encrypted by the same password as the main movie. Inthis case, you can start playing an encrypted FLV file without waiting for it tobe downloaded completely.
1.7 Using menus
From SWFKit 2 it provides a WYSIWYG menu editor, you can use menus inthe SWFKit projects conveniently.
1.7.1 The main menu
The applications built by SWFKit have no main menus. But you can assignone 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” eventfires.
menu = new Menu;menu.load("main");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
56 Tutorials
menu.setMenu();menu.onCommand = function (id){
if (id == "new"){
// do something}
}
SWFKit will pass the identifier of the menu item to the event handler. So youmust assign an unique identifier for each menu item, or you cannot distinguishwhich one is clicked.
The menu items can have shortcuts, you can set the ”enableAccel” propertyof the menu object to true to enable the shortcuts.
1.7.2 The context menu
You can customize the context menu by handling the FlashPlayer.onContextMenuevent.
FlashPlayer.onContextMenu = function (){
var menu = new Menu;menu.load("contextMenu");menu = menu.getSubMenu(0);if (menu.show() == "new"){
//do something}
}
1.8 Using ActiveX Objects
1.8.1 Registering ActiveX objects manually
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 figure1.8.1.When you want to unregister the ActiveX object, say ”swfgen.dll”, you can
use the command ”regsvr32 -u c:myprojectdllswfgen.dll”.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.8 Using ActiveX Objects 57
Figure 1.8: Registers an ActiveX object by typing a command
After the ActiveX object has been registered, you can use it in SWFKitdeveloping environment. But the ActiveX object is only registered onyour computer, you must also ensure that it will be registered on theend users’ computers correctly.
1.8.2 Registering ActiveX objects on end users’ systemsI - using the ”register” method
The ActiveXObject object provides a method ”register” to register an ActiveXobject. If you only want to use the ActiveX objects privately and need to removethem after the application closed, you can use this method.
1. Adding the ActiveX objects into the attachment list. For example, creat-ing a sub folder called ”ActiveX” under the ”Application” folder, addingthe ”SWFGen.dll” into it. As shown in figure 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 methodsand 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 files include the ActiveX object will be removed after theapplication is closed.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
58 Tutorials
Figure 1.9: Adds an ActiveX object
1.8.3 Registering ActiveX objects on end users’ systemsII - 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 beunregistered and removed by the uninstall program.
If you don’t want to build setup programs using SWFKit, you need to followthe instructions of your installer making tool to install ActiveX objects. InSWFKit, you can install ActiveX objects like this
1. Checks the ”Enable the setup program to register ActiveX objects” in”Main Menu”–”View”–”Options”. As shown in figure 1
2. Adds the Activex Objects into the attachment list. Remember to add itunder the ”Windows”–”System” folder. That is to say, the ActiveX ob-ject won’t be packed into the output executable files, but be packed intothe ”setup.exe”. The setup.exe will install the ActiveX objects into thespecified folder, for example, if you’ve added the ActiveX objects into thefolder ”Windows”–”System”–”ActiveX”, the installer will create a ”Ac-tiveX” sub folder in the system folder and copy the ActiveX objects intoit then register them. As shown in figure 2
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.8 Using ActiveX Objects 59
Figure 1.10: Checks the ”Enable the setup program to register ActiveX objects”option
Figure 1.11: Adds an ActiveX object into attachment list
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
60 Tutorials
1.8.4 Using ActiveX dlls without registration
From SWFKit 3.2, you can use activex dlls in ffish script without first regis-tering them in Windows Registry. As you already know, the activex dlls muststore their information in Windows Registry so that the COM functions cancreate instances of the activex objects exposed by the activex dlls. Now swfkitprovides a method “ActiveXObject.addObjectInfo”. By using this method youcan “register” the activex objects only in the ffish script engine, without writ-ing anything into the Windows Registry. For more details, please read the helpdocument for the “ActiveXObject.addObjectInfo” method.
1.9 Stand alone programs and the Flash Player
The .exe files built by SWFKit requires the Flash Player to run. However,the end user’ computers may have no flash player installed. The ”standalone”option in SWFKit resolves this problem. If you check this option, a most currentversion of flash player will be packed into the output .exe files. When such astand alone .exe file is launched and it finds that there is no flash player insystem, or the flash player in system is of the older version, it will use thepacked flash player.
The flash player that will be packed into a stand alone .exe file resides inthe data subfolder of the folder that SWFKit was installed into. E.g. a typicalpath is ”c:\program files\SWFKit Pro 3\data”. The file name of the flashplayer is ”install flash player active x.exe”, whose version is 9.0.16.0. If Adobeupgrades it, SWFKit will download it automatically by using the auto updatefeature. Another important file about the flash player is the flash player.ini,which defines the version and file name of the flash player. If you want to usesome special version of flash player, you can copy it into the folder and modifythe flash player.ini file. SWFKit will read the information of the flash playerto create stand alone .exe files from the flash player.ini file. The flash playershould be an installer of the flash player that can be downloaded from Adobeafter you get a distribution license.
Because we have got a distribution license from Adobe, our distribution ofthe flash player is legal.
1.10 The “trace” method
You can use the ”trace” method to watch the value of the FFish Script variablesduring preview. The ”trace” method does nothing while the output executablefile is running.
But the ”trace” method in FFish script cannot display the value of variablesin Action Script, and the ”trace” method in Action Script does nothing whileyou preview a project in SWFKit.
SWFKit 2 provides a FSCommand ”FFish Trace” to do this. The ”FF-ish Trace” works like the ”trace” method, for it’s called in Action Script, it can
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.11 The variable scope in FFish Script 61
display the value of variables in Action Script. It does nothing while the outputexecutable file is running.
If you want to save the trace messages while the application is running, youcan direct the output to a file by calling the ”traceToFile” method.
1.11 The variable scope in FFish Script
In FFish Scripting language, you can define global variables and local variables.The global variable is declared without the keyword ”var”.
// decares a local variablevar obj = new Object;
// declares a global variablearr = [1, 2, "string"];
After a FFish Script has finished running, all local variables declared insidea block will be cleared, as well as the interim variables. That is to say, they arenot accessible in the followed scripts.
The global variables, local variables that are not inside any blocks and namedfunction can be accessible in the later scripts.
To access a function defined in another script, you must load the script con-tains the function into memory firstly. It can be done by the ”invoke” method.
1.12 Using SWFKit Pro to call functions in dynamic-linked libraries(dlls)
SWFKit Pro has the ability to call functions in dlls, thus providing you withunlimited possibility of extending the power of Adobe Flash. For instance, youmay call any Windows API functions from within Action Script now. Further-more, if you need some feature that both Flash and SWFKit do not include,you can first implement it in a dll using c/c++, Pascal, Basic, etc, and then callthe dll in SWFKit Pro. It is no doubt that you can do anything with SWFKitPro.
In this tutorial, you will learn how to declare dll functions, pass parametersfrom ffish script to dll functions, and get function results.
1.12.1 Declaring the dll functions
The first thing you would have to do before you can call a dll function inSWFKit Pro is to declare the function. The new ”dllimport” keyword and thenew structure type make things easier: the ”dllimport” keyword makes functiondeclarations in FFish Script very distinct just like in c/c++, and the structure
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
62 Tutorials
type gives the FFish Script the power of supporting complex data types. Moredetails about dll function declaration can be found at 2.58. Some dll functiondeclaration examples are as follows:
A function without structure type parameters The GetSystemDirec-tory function is exported by ”kernel32.dll” and is used to retrieve the path ofthe system directory. The declaration of this function in SWFKit Pro shouldbe
dllimport "kernel32.dll" stdcall unsigned intGetSystemDirectoryA(char *lpBuffer, unsigned int uSize) as getSysDir;
where ”kernel32.dll” indicates the library name (name of the dll file that exportsthe function). Since ”kernel32.dll” is a system file that SWFKit Pro can findit, at here we need not use a full path name like ”c:windowssystem32kernel32.dll”. However, for a dll created by yourself, e.g. in the ”Resources” ofSWFKit Pro, you would have to specify the full path name of the dll file:
var myDll = getAdditionalFile("mydll.dll");dllimport myDll stdcall void MyFunc();
”stdcall” indicates the calling convention. SWFKit Pro 3 now supports twokinds of calling convention: stdcall and cdecl. Typically, Windows API func-tions use stdcall calling convention, whereas c/c++ functions use cdecl callingconvention. After ”stdcall” is the return value, function name, and the param-eter list in a pair of brackets You can also omit the parameter names of thefunctions, e.g.
dllimport "kernel32.dll" stdcall unsigned intGetSystemDirectoryA(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 parame-ter 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 FFishScript; otherwise the name of the function will be used.
A function with structure type parameters or returns a structureIn this case, you would have to declare the structure type first. E.g. the Find-FirstFile function:
struct{
unsigned int dwLowDateTime;unsigned int dwHighDateTime;
} FILETIME;
struct
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.12 Using SWFKit Pro to call functions in dynamic-linkedlibraries(dlls) 63
{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 pointerFindFirstFileA(char *, WIN32_FIND_DATA*) as findFirstFile;
1.12.2 Calling dll functions and get results
As you can see, calling a dll function is as easy as calling a native FFish Scriptfunction, because SWFKit Pro hides the details of type conversion betweenFFish Script variables and dll function parameters. You need not know how thedata type conversion works, SWFKit Pro does everything for you. All you needto learn is the following rules of data type conversion:
A Number object in FFish Script can be passed to a dll function asa parameter of character type, integer type or floating-point numbertype, or as a pointer to these data types. For instance, the GetSystem-Metrics function can be used to retrieve various system metrics (widths andheights of display elements) and system configuration settings:
dllimport "user32.dll" stdcall int GetSystemMetrics(int) as getSysMetrics;//get the width and height of the screenvar SM_CXSCREEN = 0;var SM_CYSCREEN = 1;// A Number object can be passed to a function as an integer parametervar 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 parametertrace(asin(1.0));
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
64 Tutorials
A String object in FFish Script can be passed as a parameter ofstring(char*) type or wide string(short*) type. For instance, finding thetask 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 find. The secondparameter of this function is the name of window, which can be NULL. Theresult 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 alwaysreturns the addresses of the pointers.
The unicode version of the FindWindow function (on Windows NT, 2000 orXP):
dllimport "user32.dll" stdcall pointer FindWindowW(short*, short*) as findWindow;// A String object can also be passed as a wide string parametertrace(findWindow("Shell_TrayWnd", null));
As you can see, String objects can be passed as both parameters of string typeand parameters of wide string type.
A Number object can be passed as a pointer to an unspecified type.In this case, the Number object must represent the address the pointer. As wehave just discussed in the above part, SWFKit Pro always converts functionresults of pointer type to Number objects, that is, you can pass these returnedNumber objects to functions that require pointer parameters. For instance, inthe 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 sizeof the window:
struct{
int left;int top;int right;int bottom;
} 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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.12 Using SWFKit Pro to call functions in dynamic-linkedlibraries(dlls) 65
if (getWinRect(handle, obj)){
trace("left: ", obj.value.left);trace("top: ", obj.value.top);trace("right: ", obj.value.right);trace("bottom: ", obj.value.bottom);
}
A StringStream object in FFish Script can be passed as a parame-ter of structure type or as a pointer to any data type. If the data size ofthe StringStream object is smaller than that of the structure type, the remaindata area will be filled with zero. The StringStream object is very useful whenthe dll functions need allocated data buffers. We will discuss this in more detailin the ”passing parameters by reference” part.
A Struct object in FFish Script can be passed as a parameter ofstructure type or as a pointer to structure type. The ”struct” keywordonly declares a structure type, you must use the ”new Struct(structName);”clause to create a Struct object of that structure type. For instance, confinesthe cursor to a rectangular area on the screen:
// first we should declare the structure type for the// "ClipCursor" functionstruct{
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 membersvar 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 astructure object, the rule is similar to that of passing parameters todll functions.
Passing parameters by reference. Generally, SWFKit Pro pass param-eters 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 passedby reference. The ffish scripting language does not support to pass parametersby reference directly, so an alternative calling method is introduced into the
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
66 Tutorials
ffish scripting language to support this feature. The method is to use Objectobjects to pass parameters to functions. The objects used to do this must havea ”value” property, which is the actual variable to pass to the functions. Aftercalling the functions, the ”value” property of the objects will contain the newvalue output by the functions.
For instance, to get the system directory, the GetSystemDirectory functionhas an output parameter to receive the path of the system directory. In orderto get the output value, we must use an Object object to pass parameter byreference:
dllimport "kernel32.dll" stdcall intGetSystemDirectoryA(char*, int) as getSysDir;
// to get the output value, we must pass parameter by referencevar 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 valuetrace(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 enoughbuffer = 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 find that the StringStream is suitable for allocate
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.12 Using SWFKit Pro to call functions in dynamic-linkedlibraries(dlls) 67
buffers. Although you can use a very long string object to provide a buffer, itis not so convenient as using a StringStream object. The ”GetWindowRect”example in another part of this tutorial also shows how to pass a parameter ofstructure type by reference so that we can get the output coordinations of thespecified window.
Sometimes a member of a structure object may be used to receive outputvalue, for instance, the GetOpenFileName function outputs the file name tothe ”lpstrFile” member of the ”OPENFILENAME” structure. In this case, youmust do two things: the first one is to use a StringStream to allocate a bufferto hold the output value, the second one is to use an Object object to pass theparameter 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 BooleanGetOpenFileNameA(OPENFILENAME*) as getOpenFileName;
var ofn = new Struct(OPENFILENAME);ofn.lStructSize = ofn.structSize;trace(ofn.lStructSize);ofn.hwndOwner = getMainWnd().handle;var filter = new StringStream;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
68 Tutorials
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 files 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;
dllimport "kernel32.dll" stdcall pointerFindFirstFileA(char *, WIN32_FIND_DATA*) as findFirstFile;
dllimport "kernel32.dll" stdcall Boolean
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.13 Building windowless projectors 69
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);}
About the return values. If the return values are numbers, they will beconverted to Number objects automatically. However, if the return values arepointers, they will be converted to Number objects, even if they are strings, andyou would have to use the Dll.getPointerStringValue method to get the valueof the string. Finally, if the return values are structures, they will be convertedto structure objects automatically. If some members of the returned structuresare pointers, they are also converted to numbers, and you would have to useDll.getPointerXXXValue method to get the values that the pointers point to.
1.13 Building windowless projectors
SWFKit supports to build windowless projectors. You can do this by sim-ply setting the window shape to transparent in the [application definition]->[appearance] panel. Under Windows 2000 and XP, it also supports alphablending so that you can get dazzling display effects.
1.14 Accessing disk files
SWFKit provides three objects for operating disk files or folders, which are theFile object, the Folder object, and the FileStream object. The File and Folderobjects can be used to get the properties of a file or a folder. For example, youcan use the File object to get the modified time of a file, or get its size, filetype, short name, parent path, etc. Moreover, you can use them to determinewhether a file or folder exists. The following code is used to get properties of afile in FFish script:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
70 Tutorials
var fileName = "c:\\sounds\\demo.mp3";if (File.exists(fileName)){
var f = new File(fileName);trace(f.size);trace(f.shortName);
}
Furthermore, the File object and the Folder object can also be used to copy,move or delete files or folders. For example, copy a file
var file = new File("c:\\sounds\\demo.mp3");file.copy("d:\\demo.mp3");
The FileStream object is used to read data from a file or write data to afile. It can not only read or write strings, but read or write binary data. Forexample, the get method is used to read a byte from a file, while the readLinemethod can read a line of string from a file. The following Action script codefor Flash 8 shows how to write a XML object to a file
import SWFKit.*;
var xml = new XML;// XML operations......
// Save a XML filevar 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 Launching external applications
SWFKit provides two ways to launch an external application. One way is touse the ”exec” command, and the other way is to call the ”Shell” object.
The ”exec” can be used either synchronously or asynchronously. To use itsynchronously in action script:
function runApp(args){
ExternalInterface.call("exec", args);}
runApp("notepad.exe c:\\1.txt");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.16 Opening system dialog boxes 71
To use it asynchronously
fscommand("exec", "notepad c:\\1.txt");
The ”exec” can launch an external application at anywhere on local disk. Ifyou pass the absolute path name of an application to the ”exec” command, itwill launch it directly; if the relative path name of an application is passed toit, it will first search for the application and then launch the application. Itsearches for an application in this way: first, searches in the resource files, iffound, launches the application and returns; second, searches in the same folderof the .exe file, 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 externalapplication or open an external document. The ”run” method can launch anapplication and return a Window object that represents the main window ofthe running application. The ”open” method can open an external document.The ”runAndWait” method can launch an external application and wait for itto exit. The following code shows how to use the Shell object in action scriptin Flash 8
import SWFKit.*;
var window = Shell.run("notepad.exe c:\\1.txt");Dialogs.msgBox(window.caption);
1.16 Opening system dialog boxes
The following code shows how to open the system dialog boxes in action scriptin 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");......
}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
72 Tutorials
var dir = Dialogs.browse("Choose the destination directory", "c:\\");
1.17 Accessing databases
By using ADO, SWFKit and SWFKit Pro can access almost all types of databasessuch as Access, MySql, dBase, Firebird, SQL Server, Oracle, etc, only if you haveOLEDB drivers for the databases. ADO is the popular and high performancedatabase accessing tool of Microsoft. Using ADO in SWFKit is very simple andconvenient, and you can easily copy your database accessing code from ASP toSWFKit. Another advantage of using ADO in SWFKit to access databases isthat you can immigrate from one type of database to another without rewritingall your code, just by changing the connection string. From SWFKit v3, youcan also use ADO directly in action script in Flash 8. However, you would haveto wrap the ADO objects in Action script classes by yourself. At here we willjust discuss how to use ADO in FFish script.
Connect to the database Before a database can be accessed from aSWFKit application, a database connection has to be established. The steps tomake 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 con-nection string contains the provider, db name, etc. For example, to connect toa MS Access DB ”c:mydatasample.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 thisconnect 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 fireswhen the connection is completed.
var conn = new ActiveXObject("ADODB.Connection");conn.connectOK = false;conn.ConnectComplete = function (err, status, cnt)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.17 Accessing databases 73
{if (typeof err != "undefined"){
trace(err.Description);
return;}else{
trace("Connect complete!");conn.connectOK = true;
}
trace("status: ", status.value);}
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 beenmade, 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 specified 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());
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
74 Tutorials
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();
LinksADO Referencehttp : //msdn.microsoft.com/library/default.asp?url = /library/en −
us/ado270/htm/dasdkadooverview.aspADO Tutorialhttp : //www.w3schools.com/ado/default.asp
1.18 Programming the tray icons
If you check the ”Show in the system tray” option in ”Application definitions”panel, the output .exe file will display a tray icon. However, the function of thetray icon is too simple. If you want to fully customized the tray icon for yourapplications, please use the ”Application.SysTray” object. In this tutorial, wewill 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 file is loaded fromthe resources list
SysTray.icon = Global.getAdditionalFile("NET01.ICO");SysTray.tip = ’A test’;SysTray.add();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.19 Downloading and uploading files 75
Finally, add event handler for the tray icon
function onRClicked(){
var menu = new Menu;menu.createPopupMenu();menu.appendItem("id0", "item 0");menu.appendItem("id1", "item 1");menu.appendItem();menu.appendItem("id2", "item 2");menu.appendItem("id3", "item 3");
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 Downloading and uploading files
SWFKit provides the Inet object and the Inet.Ftp object to download andupload files. Downloading a HTTP file is very simple, the following code showshow 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);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
76 Tutorials
inet.getUrl(’http://www.swfkit.com’, ’c:\\1.html’);
To download or upload a ftp file, 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 serverftp.connect();
//3. Change the current directory_root.strace(ftp.currentDir);ftp.currentDir = "songs";
//4. List the files and foldersvar 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 sizevar info = ftp.getFileInfo("test.rar");_root.strace(info.size);
//6. Download or upload filesfunction onDownload(percent){
_root.strace(percent);return true;
}ftp.setEventHandler("onDownload", onDownload);ftp.download("test.rar", "c:\\sample\\test.rar");
function onUpload(percent){
_root.strace(percent);return true;
}ftp.setEventHandler("onUpload", onUpload);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.20 Sending and receiving emails 77
ftp.upload("test.rar", "c:\\sample\\test_new.rar");
1.20 Sending and receiving emails
Before sending an email, you must first create a Mail object to set the subject,text, attachments, etc
import SWFKit.*;
var mail = new Mail;mail.from = "[email protected]";mail.to = "[email protected];[email protected]";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 objectfunction onRecieve(type, msg){
_root.strace(msg);if (!SWFKit.Global.processMsg()) return false;return true;
}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
78 Tutorials
var rm = new RecvMail;rm.server = "myserver";rm.port = 110;rm.username = "myname";rm.password = "mypassword";// Connect to the POP3 serverrm.connect();rm.setEventHandler("onRecv", onRecieve);
// Get email count on the POP3 servervar count = rm.list();_root.strace(count);if (count.length > 0){
// Receive only the first 10 emailsfor (var i = 1; i <= 10; i++){
// Receive the ith email, it returns// a Mail objectvar 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 Creating multiple forms
With SWFKit Pro, you can create modal or modeless forms. The following codeshows how to create a form in action script in Flash 8.
import SWFKit.*;
var form = new Form;form.movie = Global.getAdditionalFile("forform.swf");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.22 Changing screen resolutions 79
form.caption = "Hello, Form!";form.showCaption = true;form.canDrag = true;form.initVars = "formid=" + form.Identifier;form.show(true);
As you can see from the above code, a Form is a child window that displaysanother flash movie. The form object is created in the main movie, how canwe programming the form object in another flash movie? This can be doneby pass the identifier of the form object to the form movie: form.initVars =”formid=” + form.Identifier;. In this case, we can get the form object inthe first frame of the form view. The following code is in the first 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 formvar width = form.window.clientRect.width;var height = form.window.clientRect.height;ax.window.move(0, 0, width, height);
1.22 Changing screen resolutions
The DirectX object can change the screen resolution without restarting thecomputer. When you play a movie in full screen mode, changing the screenresolution to a lower one will improve the performance.
// List all available screen resolutions in system
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
80 Tutorials
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 resolutionDirectX.setDisplayMode(800, 600, 32);
1.23 Screen capture
SWFKit Pro supports to capture screen and copy onto clipboard or save to anImage object. Besides screen capture, it can also capture the current movie.The following code shows how to capture screen or the current movie and getan 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 fileimage.save("c:\\screen.jpg");
1.24 Reusing the web browser control
You can embed the web browser control in the main movie or forms to displayweb sites or web pages. In fact, the createControl method in SWFKit andSWFKit Pro can embed any ActiveX control in the main movie. First, youwould have to call the ”createControl” method to create the ActiveX controlwindow 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 theActiveX control window, and the other is ”activex”, an ActiveXObject objectthat 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 controlvar ax = createControl("Shell.Explorer.2", 0, 0, 200, 200);// Fill the web browser control in the entire client area of the main windowgetMainWnd().onSize = function(type, width, height){
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.24 Reusing the web browser control 81
ax.window.move(0, 0, width, height);}
// handle event of the ActiveX controlax.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 sensitiveax.activex.navigate2("http://www.topcmm.com");
Although you can also write code in action script to embed a web browsercontrol, you would have to wrap the web browser control in an Action scriptclass, because Action script does not allow you to call a dynamic method that isnot defined in a class. A sample wrapper class, ”WebBrowser.as”, which definesonly 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 ...}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
82 Tutorials
The following code shows how to use the web browser in action script in Flash8
import SWFKit.*;import WebBrowser;
// Create the web browser controlvar ax = Global.createControl("Shell.Explorer.2", 0, 0, 200, 200);// Fill the web browser control in the entire client area of the// main windowvar 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 controlfunction NavigateComplete2(control, url){
_root.strace(url);}wb.setEventHandler("NavigateComplete2", NavigateComplete2);
// Browse web sitewb.Navigate2("http://www.topcmm.com");
To learn how to embed an ActiveX control in a form, please read the ”Cre-ating multiple forms” tutorial.
The reference of reusing the web browser can be found athttp : //msdn.microsoft.com/library/default.asp? url = /workshop/browser/webbrowser/WebBrowser.asp
1.25 Playing avi, rm, mov, wmv, etc movies
By embedding the popular movie players in the main window, SWFKit can playalmost all popular movie types. Just like reusing the web browser, embeddinga movie player requires that you first use the ”createControl” method to createthe movie player, then call the methods and properties of the movie player toplay movies. All methods, properties, and events of the ActiveX controls canbe 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();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.26 Opening pdf files 83
To embed the Windows Media Player 6.4
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 athttp : //msdn.microsoft.com/library/default.asp? url = /library/en −
us/wmplay10/mmp sdk/windowsmediaplayer10sdk.aspTo 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 athttp : //service.real.com/help/library/guides/extend/embed.htmTo 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 athttp : //developer.apple.com/documentation/QuickT ime/ Conceptual/QTScripting JavaScript/bQTScripting JavaScri Document/
chapter 1000 section 1.htmlIf 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 Opening pdf files
You can use the ”Shell.open” method or the ”exec” command to open pdf fileswith an external application, which is generally the Adobe Acrobat PDF Reader.However, you still can display a pdf file in the main window or in a form, byembedding 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 arelisted as follows:
dispinterface IAcroAXDocShim {properties:methods:
[id(0x00000001), propget, helpstring("property src")]BSTR src();[id(0x00000001), propput, helpstring("property src")]
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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,
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.27 Calling Active scripting languages 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 detailsabout using ActiveX controls.
1.27 Calling Active scripting languages
By using the ScriptHost object in SWFKit Pro, you can call Active scripting lan-guages such as jscript, vbscript, perlscript, pythonscript, rubyscript, etc. Pleaseread more details about the ScriptHost object from the FFish scripting languagemanual of SWFKit Pro. At here we just show how to use the ScriptHost objectin Action script.
import SWFKit.*;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
86 Tutorials
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();
As you can see from the above code, the ”getScriptObject” method returns anActiveXObject object, which contains the global functions and variables in therunning script.
1.28 Using shared objects in packed movies
Generally, shared objects are relative to the full path name of the movie thatcreates them. However, the path name of a packed movie changes each time theapplication launches. The reason is that the SWFKit applications will extractthe packed movies to a temporary folder, and will remove the temporary folderwhen they are about to exit. Each time the temporary folder changes, so thepath names of the unpacked movies change. In this case, shared objects do notwork in packed movies. However, there is still a way to make the shared objectswork 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 meansthat the shared objects will be saved in a root folder that any local flash moviescan access it. In this case, however, it may cause conflicts between two differentflash movies because they might use the same shared object name. Hence, weshould specify a longer shared object name like that in the above example.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
1.29 Using autoupdate 87
1.29 Using autoupdate
The autoupdate feature is implemented in the ”AutoUpdate.dll” that can becalled in SWFKit or SWFKit Pro. In SWFKit Pro you can use the Dll ob-ject to call the functions exported by the ”AutoUpdate.dll”. The first thingyou would have to do is to add the ”AutoUpdate.dll” into the resources list.The ”AutoUpdate.dll” file is in the SWFKit installed folder, typically, it is”c:\program files\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 back-ground. That is to say, it does not display a wizard. The first parameter ofthis function is the url of the ini file created by the UpdateMaker, the secondparameter is the name of your application, and the third parameter is used todetermine whether the function will be called silently. The function is calledsilently means that if there is no update found, it will do nothing. If the pa-rameter is set to false, it will display a message box to say that there is no newupdate. If a new update has been found, it will display a message box even ifit 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 checkthe 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 fornew 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 shouldadd the ”AutoUpdate.dll” into the resources list and register it. The ”AutoUp-date.dll” file is in the SWFKit installed folder, typically, it is ”c:program filesswfkit 3”. The ActiveX components exported by ”AutoUpdate.dll” containsthe following methods and properties:
updateINI The ini file produced by the UpdateMakerappName The name of your applicationCheck(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 nonew update, it will do nothing; otherwise, it will display a message box to saythat there is no new update. If a new update is found, it will display a message
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
88 Tutorials
box even if bSilent is set to true. This function does not display a wizard. Soyou 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 awizard.
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);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
Chapter 2
FFish Script ObjectsReference
2.1 Global Object
Description
An intrinsic object whose purpose is to collect global methods intoone object. available: SWFKit Express, SWFKit, and SWFKitPro
Syntax
The Global object has no syntax. You call its methods directly.
Remarks
The Global object is never used directly, and cannot be created usingthe new operator. It is created when the scripting engine is initial-ized, thus making its methods and properties available immediately.
2.1.1 Properties
2.1.1.1 NaN
Description
The initial value of NaN is NaN.
Syntax
NaN
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
90 FFish Script Objects Reference
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 Infinity
Description
Contains an initial value of number positive infinity
Syntax
Infinity
Remarks
The Infinity property is a member of the Global object, and is madeavailable when the scripting engine is initialized.
2.1.2 Methods
2.1.2.1 parseFloat
Description
Converts strings into floating-point numbers.
Syntax
parseFloat(string)
Parameters
string The string to read and convert to a floating-point number.
Returns
The parseFloat method returns an numerical value equal to thenumber contained in string. If no prefix of string can be success-fully parsed into a floating-point number, NaN (not a number) isreturned.
Example
parseFloat("abc") // Returns NaN.parseFloat("1.2abc") // Returns 1.2.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.1 Global Object 91
2.1.2.2 parseInt
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 ofthe number contained in string. If not supplied, strings with aprefix of ‘0x’ are considered hexidecimal and strings with a pre-fix of ‘0’ are considered octal. All other strings are considereddecimal.
Returns
The parseInt method returns an integer value equal to the numbercontained in string. If no prefix of string can be successfully parsedinto 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 URL-encoded format
Returns
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
92 FFish Script Objects Reference
The escape method returns a new String that contains the contentsof expression. All spaces, punctuation, accented characters, and anyother non-ASCII characters are replaced with %xx encoding, wherexx is equivalent to the hexadecimal number representing the char-acter. For example, a space is returned as ”%20.”
Characters with a value greater than 255 are stored using the %uxxxxformat.
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 con-tents of x. All characters encoded with the %xx hexadecimal formare replaced by their ASCII character set equivalents.
Characters encoded in %uxxxx format (Unicode characters) are re-placed with the Unicode character with hexadecimal encoding xxxx.
Examples
unescape("Hello%7B%5BWorld%5D%7D")//The result is: Hello{[World]}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.1 Global Object 93
2.1.2.5 eval
Description
Evaluates FFish Script code.
Syntax
eval(expression)
Parameters
expression A string containing the name of a variable, property, object, ormovie clip to retrieve.
Returns
The eval function allows dynamic execution of Ffish Script sourcecode 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 num-ber).
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 oth-erwise. You typically use this function to test return values from theparseInt and parseFloat methods. Alternatively, a variable could becompared to itself. If it compares as unequal, it is NaN. This isbecause NaN is the only value that is not equal to itself.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
94 FFish Script Objects Reference
2.1.2.7 isFinit
Description
Determines if a supplied number is finite.
Syntax
isFinite(value)
Parameters
value The value to be tested..
Returns
The isFinite method returns true if number is any value other thanNaN, negative infinity, or positive infinity. In those three cases, itreturns false.
2.1.2.8 trace
Description
Print the value of the parameters in the trace window. This methodworks 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);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.1 Global Object 95
2.1.2.9 createControl
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 specifies the ProgID of the ActiveX to be created.
left, top, right, bottom Integer. Specifies the control’s size and position in the projec-tor.
param Optional. String. Initializes the properties of the ActiveX con-trol. It contains several ”name=value” pairs conjoined by char-acter ‘&’
licensekey Optional. String. Specifies the license key of the ActiveX con-trol.
Returns
An object contains two properties
1. The window propertyThe window property is a Window object that represents thewindow of the created ActiveX control. You can use this prop-erty to set the placement of the ActiveX control, show or hideit, ect.
2. The activex propertyThe activex property is an ActiveXObject object. You can usethis property to access the properties, methods and events ofthe ActiveX control.
Remarks
If the method creates a windowless control, the window property ofthe returned object will be undefined. The Windows Media Playercontrol will always be windowless activated, if you want to close it,you cannot use the close method of the window object but shoulddo in this way
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
96 FFish Script Objects Reference
//Embed a Microsoft Media Player in the projector:var mplayer = createControl(
"MediaPlayer.MediaPlayer.1", 0, 0, 200, 200);
...
//destroy itdelete mplayer;mplayer = null;
SWFKit doesn’t support windowless activating for any other con-trols. It doesn’t draw it, so you will get nothing in the main windowif you create a control activated in windowless mode.
//Activate a Flash Player in windowless mode.//For SWFKit doesn’t draw the windowless control//The control won’t be visible in the main window//‘fp.window’ returns undefinedvar 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 filemplayer.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);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.1 Global Object 97
2.1.2.10 getMainWnd
Description
Gets a Window object that represents the main window of the ap-plication or screen saver.
Syntax
getMainWnd()
Parameters
None
Returns
A Window Object.
Example
//Close the projectorvar mw = getMainWnd();mw.Close();
2.1.2.11 getAppDir
Description
Retrieves the pathname of the directory that the application orscreen saver locates in.
Syntax
getAppDir()
Parameters
None
Returns
A String.
Example
var path = getAppDir();trace(path);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
98 FFish Script Objects Reference
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. Won’t work forscreen 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 spec-ifies the transparent mode. If the parameter is a string it spec-ifies a clip region name. The method set the window shapeaccording to the specified clip region. If the clip region speci-fied by the parameter does not exist, the window shape is resetto the regular shape.
If the parameter is a boolean value of true, the method willmake the application transparent. Otherwise, it will make theapplication reset to regular shape.
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.1 Global Object 99
2.1.2.14 readProfile
Description
Retrieves a value from an entry within a specified section of theapplication’s registry or .INI file.
Syntax
readProfile(section, entry)
Parameters
section A string specifies 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 writeProfile
Description
Writes the specified value into the specified section of the applica-tion’s registry or .INI file.
Syntax
writeProfile(section, entry, value)
Parameters
section A string specifies 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");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
100 FFish Script Objects Reference
2.1.2.16 processMsg
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 applicationby clicking the close button, pressing the ”ALT+F4” keys, etc, themethod returns false; otherwise, it returns true.
Remarks
The method is used to avoid the blocking of the application whileexecuting a script takes times. The method peeks messages from themessage queue of the main thread of the application, then translatesthe messages and dispatches them. Users inputs just like key pressesor mouse clicks during the executing of the script will be handledby this method. If the method returns false, you should return fromthe 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
Description
Extracts attached files packed in the executables.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.1 Global Object 101
getAdditionalFile(name)
Parameters
name String. Specifies the name of the file or folder to extract. Thename contains a relative path to the ”Application” folder. Ifthe name specifies a filename, the method extracts the specifiedfile to the temporary folder and returns the pathname of theextracted file. E.g. extract media1.swf”
var m = getAdditionalFile(\\movies\\media1.swf");
If the name specifies a path, the method extracts the specifiedfolder and all its files and subfolders to the temporary folderand returns the pathname of the folder. Invoking the methodwithout parameter or with a empty string extracts all files andfolders. E.g. extract the movies folder:
var movies = getAdditionFile(\\movies");var m = movies + \\" + media1.swf;
Note: This method works only with files and folders under the”Application” folder. SWFKit does not pack any files underthe Windows folder. Only the setup program uses that files.
Returns
String. If the file or folder does not exist, returns null.
2.1.2.18 getExeName
Description
Get the full pathname of the running application.
Syntax
getExeName()
Parameters
None
Returns
String.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
102 FFish Script Objects Reference
2.1.2.19 invoke
Description
Invokes a pre-compiled FFish Script.
Syntax
invoke(name)
Parameters
name Specifies the name of the pre-compiled FFish Script to invoke.
Returns
Nothing.
2.1.2.20 evals
Description
Evaluates a FFish Script file.
Syntax
evals(filename)
Parameters
filename Specifies 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 ResourceIdentifier(URI).
Syntax
decodeURI(str)
Parameters
str String. Represents an encoded URI.
Returns
String.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.1 Global Object 103
2.1.2.22 encodeURI
Description
Encodes a text string as a valid Uniform Resource Identifier (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 Uni-form Resource Identifier (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 ResourceIdentifier (URI).
Syntax
encodeURIComponent(str)
Parameters
str String.
Returns
String
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
104 FFish Script Objects Reference
2.2 Boolean object
Description
Creates a new Boolean value.
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 emptystring, the initial value of the Boolean object is false. Other-wise, the initial value is true.
Remarks
The Boolean object is a wrapper for the Boolean data type. FfishScript implicitly uses the Boolean object whenever a Boolean datatype is converted to a Boolean object.
You rarely call the Boolean object explicitly.
2.3 Number object
Description
An object representation of the number data type and placeholderfor numeric constants.
Syntax
new Number(value)
Parameters
value The numeric value of the Number object being created, or avalue to be converted to a number.
Remarks
FFish Script creates Number objects as required from numericalvalues.
It is rarely necessary to create Number objects explicitly.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.3 Number object 105
2.3.1 Properties
2.3.1.1 MAX VALUE
Description
The largest representable number (double–precision IEEE–754). Thisnumber is approximately 1.79e308.
Syntax
Number.MAX VALUE
Remarks
This property can be accessed without having number object cre-ated.
2.3.1.2 MIN VALUE
Description
The smallest representable number (double-precision IEEE–754).This number is approximately 5e−324.
Syntax
Number.MIN VALUE
Remarks
This property can be accessed without having number object cre-ated.
2.3.1.3 NaN
Description
The IEEE–754 value representing Not A Number (NaN).
Syntax
Number.NAN
Remarks
This property can be accessed without having number object cre-ated.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
106 FFish Script Objects Reference
2.3.1.4 NEGATIVE INFINITY
Description
A value more negative than the largest negative number (−Number.MAX VALUE)representable in Ffish Script.
Syntax
Number.NEGATIVE INFINITY
Remarks
The value of this property behaves mathematically as infinity.
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) rep-resentable in Ffish Script
Syntax
Number.POSITIVE INFINITY
Remarks
The value of this property behaves mathematically as infinity.
This property can be accessed without having number object cre-ated.
2.3.2 methods
2.3.2.1 format
Description
Convert the number to string in the specification format
Syntax
Number.format(fmt)()
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 107
fmt format control string, it is the same as the format parameter ofthe C function ”sprintf”.
returns
String.
Example
Print PI:
trace(Math.PI.format("%.8f"));//output: 3.1415926
2.4 String object
Description
Allows manipulation and formatting of text strings and determina-tion and location of substrings within strings.
Syntax
1. StringObj[.method]2. ”String Literal”[.method]
Remarks
You can call any of the methods of the String object using the con-structor method new String or using a string literal value. You canconvert the value of any object into a string using the String() func-tion. All string indexes are zero-based, the index of the last characterfor 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");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
108 FFish Script Objects Reference
2.4.1 Properties
2.4.1.1 length
Description
The length property contains an integer that indicates the numberof characters in the String object. The last character in the Stringobject 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 Methods
2.4.2.1 charAt
Description
Retrieves the character at the index specified.
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 specified by the parameter in-dex. The index of the first character in a string is 0. If index is nota number from 0 to string.length −1, an empty string is returned.
Example
s = new String("Hello World");s.charAt(2); //returns "l"
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 109
2.4.2.2 charCodeAt
Description
Returns the ascii code of the specified character.
Syntax
1. StringObj.charCodeAt(index)
2. ”String Literal”.charCodeAt(index)
Parameters
index An integer that specifies the position of a character in thestring. The first character is indicated by 0, and the last char-acter is indicated by stringObj.length-1.
returns
Returns an integer represents the character specified by index. Ifindex 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 andreturns the newly formed string; the original value of the Stringobject 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 andreturns the newly formed string; the original value of the Stringobject 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 ASCIIvalues in the parameters
Example
A String object need not be created before calling fromCharCode.This example uses the fromCharCode method to insert an ”” char-acter in the e-mail address.
address = "support" + String.fromCharCode(64) +"swfkit.com";
trace(address);//output: [email protected]
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 111
2.4.2.5 indexOf
Description
Finds the first 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 forwithin stringObj.
startIndex Optional. An integer specifying the starting point in stringObjto search for substring.
Returns
The indexOf method returns an integer value indicating the begin-ning of the substring within the String object. If the substring isnot found, a -1 is returned.
If startindex is negative, startindex is treated as zero. If it is largerthan the greatest character position index, it is treated as the largestpossible 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])
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
112 FFish Script Objects Reference
Parameters
substring An integer or string specifying the substring to be searched forwithin stringObj.
startIndex Optional. An integer specifying the starting point in stringObjto search for substring.
Returns
The lastIndexOf method returns an integer value indicating the be-ginning of the substring within the String object. If the substring isnot found, a -1 is returned.
If startindex is negative, startindex is treated as zero. If it is largerthan the greatest character position index, it is treated as the largestpossible 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 determinedfrom the end of the string, where -1 is the last character.
end Optional. A number specifying the index of the ending point forthe slice. If end is not specified, the slice includes all charactersfrom 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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 113
Returns
The slice method returns a String object containing the specifiedportion of stringObj without modifying the original String object.The returned string includes the start character and all charactersup 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
2.4.2.8 split
Description
Splits a String object into an array of strings by separating the stringinto 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 delim-iter parameter is undefined, the entire string is placed in thefirst 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 eachpoint where delimiter occurred in stingObj. If you use an emptystring (””) as a delimiter, each character in the string is placed asan 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
114 FFish Script Objects Reference
2.4.2.9 substr
Description
Returns a substring beginning at a specified location and having aspecified length.
Syntax
1. StringObj.split(start, [length])
2. ”String Literal”.split(start, [length])
Parameters
start An integer that indicates the position of the first character instringObj to be used to create the substring. If start is a neg-ative number, the starting position is determined from the endof the string, where the -1 is the last character.
length optional. The number of characters in the substring being cre-ated. If length is not specified, the substring includes all of thecharacters from the start to the end of the string.
Returns
If length is zero or negative, an empty string is returned. If notspecified, the substring continues to the end of stringvar. The substrmethod does not change the string specified by stringObj, it returnsa 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 specified location within a String ob-ject.
Syntax
1. StringObj.substring(from, to)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 115
2. ”String Literal”.substring(from, to)
Parameters
from An integer that indicates the position of the first character ofStringObj used to create the substring. Valid values for fromare 0 through string.length - 1. If from is a negative value, 0 isused.
to An integer that is 1+ the index of the last character in StringObjto be extracted. Valid values for to are 1 through string.length.The character indexed by the to parameter is not included inthe extracted string. If this parameter is omitted, string.lengthis used. If this parameter is a negative value, 0 is used.
Returns
The substring method returns a String object containing the sub-string derived from the original object. If from is not an integer, itreturns an empty string. If from is greater than or equal to to, italso returns an empty string.
Example
s = "Hello world";r = s.substring(6, 11);trace(r);//output: world
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
116 FFish Script Objects Reference
This method returns a copy of the String object, with all of theuppercase characters converted to lowercase. The original value isunchanged. The toLowerCase method has no effect on nonalphabeticcharacters.
Example
s = "Hello World";r = s.toLowerCase();trace(r);//output: hello world
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 lowercasecharacters converted to uppercase. The original value is unchanged.It has no effect on nonalphabetic characters.
Example
s = "Hello World";r = s.toUpperCase();trace(r);//output: HELLO WORLD
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 117
2.4.2.13 match
Description
Performs a search on a string using the supplied Regular Expressionobject.
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 containsthe last matched characters. Elements 1...n contain matches to anyparenthesized 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 withother 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 everysuccessful match of rgExp in stringObj.
text String. Specifies the text to search for.
bReplaceAll Optional. Boolean. Determines whether to replace all foundpatterns in the string.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
118 FFish Script Objects Reference
Returns
The result of the replace method is a copy of stringObj after allreplacements 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 searchfor.
text String. Specifies the text to search for.
Returns
The search method indicates if a match is present or not. If a matchis found, the search method returns an integer value that indicatesthe offset 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 methodupdates the contents of the RegExp object.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 119
2.4.2.16 anchor
Description
Places an HTML anchor with a NAME attribute around specifiedtext 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 HTMLanchor.
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 thestringObj.
Example
s = "SWFKit FFish Script Demo";r = s.blink();trace(r);//output: <BLINK>SWFKit FFish Script Demo</BLINK>
2.4.2.19 bold
Description
Places HTML 〈B〉 tags around text in a String object.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 121
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>
2.4.2.20 fixed
Description
Places HTML 〈TT〉 tags around text in a String object.
Syntax
1. StringObj.fixed()
2. ”String Literal”.fixed()
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>
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
122 FFish Script Objects Reference
2.4.2.21 fontColor
Description
Places an HTML 〈FONT〉 tag with the COLOR attribute aroundthe 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 thehexadecimal value for a color, or the predefined name for acolor.
Returns
It returns a string with HTML 〈FONT〉 tags around text in thestringObj.
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 thetext 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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 123
Returns
It returns a string with HTML 〈FONT〉 tags around text in thestringObj.
Example
s = "SWFKit FFish Script Demo";r = s.fontSize(-1);trace(r);//output://<FONT SIZE="-1">SWFKit FFish Script Demo</FONT>
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>
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
124 FFish Script Objects Reference
2.4.2.24 link
Description
Places an HTML anchor with an HREF attribute around the textin 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 ofthe HTML anchor.
Returns
It returns a string with an HREF attribute around the text in thestringObj.
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.4 String object 125
It returns a string with HTML 〈SMALL〉 tags around text in thestringObj.
Example
s = "SWFKit FFish Script Demo";r = s.small();trace(r);//output: <SMALL>SWFKit FFish Script Demo</SMALL>
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>
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
126 FFish Script Objects Reference
2.4.2.28 sup
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
Description
Creates a new function.
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.5 Function Object 127
body A string that contains the block of Ffish Script code to beexecuted when the function is called.
Remarks
Syntax 1 is the standard way to create new functions in Ffish Script.Syntax 2 is an alternative form used to create function objects explic-itly. Ffish script also support nested functions. A nested functionobject is a function placed in another function, it will become amember of the Object object constructed by the outer function. Forexample, 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
Example
For example, to create a function that calculates summation of threenumbers, you can do it in either of two ways:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
128 FFish Script Objects Reference
//Example 1function sum(x, y, z){ return x + y + z;}
//Example 2var 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 Properties
2.5.1.1 arguments
Description
A local object variable containing each argument passed to the cur-rently executing function. It is automatically created by Ffish scriptfor the currently executing function. The variable can be accessedjust like an array. The only difference 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 argumentsfunction 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(){
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.6 Array Object 129
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
2.6 Array Object
Description
Provides support for creation of arrays of any data type.
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 ele-ments will have indexes from zero to size − 1
element0, element1, ..., elementn The elements to place in the array. This creates an array withn + 1 elements.
Remarks
Ffish script only supports one dimension array. To access the ele-ments of an array, use the array access operator ([ ]).
Example
a = new Array();//the length of a is 0a = new Array("e", "f", "g", "h");//the length of a is 4b = [1, 2, 3, 4];//the length of b is 4
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
130 FFish Script Objects Reference
2.6.1 Properties
2.6.1.1 length
Description
Specifies an integer value one higher than the highest element indexdefined in an array.
Syntax
Array.length
Remarks
The elements in an array do not have to be contiguous and thelength 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 lengthproperty, the array is truncated, and any elements with array indexesequal to or greater than the new value of the length property arelost. If a value larger than its previous value is assigned to the lengthproperty, the array is expanded, and any new elements created havethe value undefined.
2.6.2 Methods
2.6.2.1 concat
Description
concatenates the elements specified in the parameters, if any, withthe elements in array1, and creates a new array. If the value param-eters 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 )
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.6 Array Object 131
Parameters
value0, value1, . . . , valueN Numbers, elements, or strings to be concatenated in a newarray.
Returns
An new Array object containing the concatenation of array1 andvalue0, 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 lengthproperty, the array is truncated, and any elements with array indexesequal to or greater than the new value of the length property arelost. If a value larger than its previous value is assigned to the lengthproperty, the array is expanded, and any new elements created havethe value undefined.
2.6.2.2 join
Description
Converts the elements in an array to strings, inserts the specifiedseparator between the elements, concatenates them, and returns theresulting 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 re-turned string. If you omit this parameter, a comma is used asthe default separator.
Returns
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
132 FFish Script Objects Reference
A String object For example:
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 ofthat 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: dtrace(a);//output: a,b,c
2.6.2.4 push
Description
Adds one or more elements to the end of an array and returns thearray’s new length.
Syntax
array1.push(value, . . . )
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.6 Array Object 133
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: 6trace(a);//output: a,b,c,d,e,f
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 first element from an array and returns that element.
Syntax
array1.shift()
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
134 FFish Script Objects Reference
Parameters
None
Returns
The first element in an array. example:
a = new Array("a", "b", "c", "d");trace(a.shift());//output: atrace(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 newarray without modifying the original array. The returned array in-cludes 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 theslice. If start is a negative number, the starting point begins atthe 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 fromthe start to the end of the array. If end is a negative number,the ending point is specified 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.6 Array Object 135
2.6.2.8 sort
Description
Sorts the array in place, without making a copy. If the compare-Function parameter has not been specified, Ffish Script sorts theelements in place using the ”¡” comparison operator.
Syntax
array1.sort([compareFunction])
Parameters
compareFunction An optional comparison function used to determine the sortingorder of elements in an array. It must return one of the followingvalues: A negative value if the first argument passed is less thanthe second argument. Zero if the two arguments are equivalent.A positive value if the first argument is greater than the secondargument.
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 modifies thearray without making a copy. The elements deleted by this methodare put into a new array as the return.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
136 FFish Script Objects Reference
Syntax
array1.splice(start, deleteCount, value0, value1, . . . , valueN )
Parameters
start The index of the element in the array where the insertion ordeletion begins.
deleteCount The number of elements to be deleted. This number includesthe element specified in the start parameter. If no value isspecified for deleteCount, the method deletes all of the valuesfrom the start element to the last element in the array. If thevalue is 0, no elements are deleted.
value0, value1, . . . , valueN Zero or more values to insert into the array at the insertionpoint specified in the start parameter. This parameter is op-tional.
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,data8trace(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 returnsthe array’s new length.
Syntax
array1.unshift(value0, value1, . . . , valueN )
Parameters
value0, value1, . . . , valueN One or more numbers, elements, or variables to be inserted atthe beginning of the array.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 137
Returns
The new length of the array.
Example
a = [3, 4, 5, 6];trace(a.unshift(2, 1, 0));//output: 7trace(a);//output: 0,1,2,3,4,5,6
2.7 Date Object
Description
Enables basic storage and retrieval of dates and times.
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 millisecondsin Universal Coordinated Time between the specified date andmidnight January 1, 1970. If a string, value is parsed accordingto the rules in the parse method.
year The full year, all digits of the year must be specified.e.g.1982and 82 refers to the different year.
month The month as an integer between 0 (January) and 11 (Decem-ber).
date The date as an integer between 1 and 31.
hours An integer from 0 (midnight) to 23 (11pm) that specifies thehour.
minutes An integer from 0 to 59 that specifies the minutes.
seconds An integer from 0 to 59 that specifies the seconds.
ms An integer from 0 to 999 that specifies the milliseconds.
Remarks
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
138 FFish Script Objects Reference
A Date object contains a float value representing the numbers ofmillisecond intervals since Jan 1, 1970. If a date object is contractedwithout parameters, it represents the current time. The range ofdates that can be represented in a Date object is approximately285,616 years on either side of Jan 1, 1970. If you have specified avalue exceed the range, the date is set to Jan 1, 1970. The Dateobject has two static methods that are called without creating aDate object. They are parse and UTC.
2.7.1 Methods
2.7.1.1 getDate
Description
Gets the day of the month (an integer from 1 to 31) of the specifiedDate object according to local time. Local time is determined bythe operating system on which the Ffish 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 specified Date object according to local time. Local time isdetermined by the operating system on which the Ffish Script isrunning.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 139
Syntax
date1.getDay()
Parameters
None
Returns
An integer.
Example
d = new Date(2002, 6, 15);trace(d.getDay());//output: 1
2.7.1.3 getFullYear
Description
Gets the year as an absolute number (For example, 1974) of the spec-ified Date object, according to local time. Local time is determinedby the operating system on which the Ffish Script is running.
Syntax
date1.getFullYear()
Parameters
None
Returns
An integer.
Example
d = new Date(1997, 6, 15);trace(d.getFullYear());//output 1997
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
140 FFish Script Objects Reference
2.7.1.4 getHours
Description
Gets the hour (an integer from 0 to 23) of the specified Date object,according to local time. Local time is determined by the operatingsystem on which the Ffish 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 specifiedDate object, according to local time. Local time is determined bythe operating system on which the Ffish Script is running.
Syntax
date1.getMilliseconds()
Parameters
None
Returns
An integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 141
2.7.1.6 getMinutes
Description
Gets the minutes (an integer from 0 to 59) of the specified Dateobject, according to local time. Local time is determined by theoperating system on which the Ffish 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 thespecified Date object, according to local time. Local time is deter-mined by the operating system on which the Ffish Script is running.
Syntax
date1.getMonth()
Parameters
None
Returns
An integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
142 FFish Script Objects Reference
2.7.1.8 getSeconds
Description
Gets the seconds (an integer from 0 to 59) of the specified Dateobject, according to local time. Local time is determined by theoperating system on which the Ffish 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 specified Date object. You use this methodto 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 143
2.7.1.10 getTimezoneOffset
Description
Gets the difference, in minutes, between the computer’s local timeand universal time
Syntax
date1.getTimezoneOffset()
Parameters
None
Returns
An integer.
Example
d = new Date(1997, 6, 15);trace(d.getTimezoneOffset());//output: -480trace(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 specified Date object, ac-cording to universal time.
Syntax
date1.getUTCDate()
Parameters
None
Returns
An integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
144 FFish Script Objects Reference
2.7.1.12 getUTCDay
Description
Gets the day of the week of the specified Date object, according touniversal time.
Syntax
date1.getUTCDate()
Parameters
None
Returns
An integer.
2.7.1.13 getUTCFullYear
Description
Gets the year as an absolute number of the specified Date object,according to universal time.
Syntax
date1.getUTCFullYear()
Parameters
None
Returns
An integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 145
2.7.1.14 getUTCHours
Description
Gets the hours of the specified Date object, according to universaltime.
Syntax
date1.getUTCHours()
Parameters
None
Returns
An integer.
2.7.1.15 getUTCMilliseconds
Description
Gets the milliseconds of the specified Date object, according to uni-versal time.
Syntax
date1.getUTCMilliseconds()
Parameters
None
Returns
An integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
146 FFish Script Objects Reference
2.7.1.16 getMinutes
Description
Gets the minutes (an integer from 0 to 59) of the specified Dateobject, according to local time. Local time is determined by theoperating system on which the Ffish Script is running.
Syntax
date1.getMinutes()
Parameters
None
Returns
An integer.
2.7.1.17 getUTCMonth
Description
Gets the month of the specified Date object, according to universaltime.
Syntax
date1.getUTCMonth()
Parameters
None
Returns
An integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 147
2.7.1.18 getUTCSeconds
Description
Gets the seconds in the specified Date object, according to universaltime.
Syntax
date1.getUTCSeconds()
Parameters
None
Returns
An integer.
2.7.1.19 getYear
Description
Gets the year of the specified Date object, according to local time.Local time is determined by the operating system on which the FfishScript is running. If the full year is between 1900 and 2000, the resultis the full year minus 1900. For example, the year 2000 is representedas 100.
Syntax
date1.getYear()
Parameters
None
Returns
An integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
148 FFish Script Objects Reference
2.7.1.20 setDate
Description
Sets the day of the month for the specified Date object, accordingto local time, and returns the new time in milliseconds. Local timeis determined by the operating system on which the Ffish Script isrunning.
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: 870364800000trace(d.toLocaleString());//output: Fri Aug 01 00:00:00 GMT+800 () 1997
2.7.1.21 setFullYear
Description
Sets the year of the specified Date object, according to local time,and returns the new time in milliseconds. If the month and dateparameters are specified, they are also set to local time. Local timeis determined by the operating system on which the FFish Script isrunning.
Syntax
date1.setFullYear(year[, month [, date]])
Parameters
year A numeric value equal to the year.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 149
month Optional. An integer from 0 (January) to 11 (December). Thisparameter is optional.
date Optional. A number from 1 to 31. This parameter is optional.
Returns
The new time in milliseconds.
2.7.1.22 setHours
Description
Sets the hours for the specified Date object according to local time,and returns the new time in milliseconds. Local time is determinedby the operating system on which the Ffish 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 specified Date object according to lo-cal time, and returns the new time in milliseconds. Local time isdetermined by the operating system on which the Ffish Script isrunning.
Syntax
date1.setMilliseconds(millisecond)
Parameters
millisecond An integer from 0 to 999.
Returns
An integer
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
150 FFish Script Objects Reference
2.7.1.24 setMinutes
Description
Sets the minutes for a specified Date object according to local time,and returns the new time in milliseconds. Local time is determinedby the operating system on which the Ffish 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 specified Date object in local time, and re-turns the new time in milliseconds. Local time is determined by theoperating system on which the Ffish 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 151
2.7.1.26 setSeconds
Description
Sets the seconds for the specified Date object in local time, andreturns the new time in milliseconds. Local time is determined bythe operating system on which the Ffish 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 specified Date object in milliseconds since mid-night 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
152 FFish Script Objects Reference
2.7.1.28 setUTCDate
Description
Sets the date for the specified Date object in universal time, andreturns 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 specified Date object in universal time, andreturns 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 153
2.7.1.30 setUTCHours
Description
Sets the hour for the specified Date object in universal time, andreturns 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 specified 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
154 FFish Script Objects Reference
2.7.1.32 setUTCMinutes
Description
Sets the minute for the specified Date object in universal time, andreturns 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 specified Date object in universal time, andreturns 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 155
2.7.1.34 setUTCSeconds
Description
Sets the seconds for the specified Date object in universal time, andreturns 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 specified Date object in local time, and re-turns the new time in milliseconds. Local time is determined by theoperating system on which the Ffish 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
156 FFish Script Objects Reference
2.7.1.36 UTC
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[, millisec-ond]]]]])
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 mil-liseconds between that date and midnight, January 1, 1970.
Syntax
Date.parse(value)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.7 Date Object 157
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
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
158 FFish Script Objects Reference
2.7.1.39 toLocaleString
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
Description
The Math object can be accessed without using a constructor. Be-sides the root method which returns an integer value, all methodsof Math Object return a float number.
2.8.1 Properties
2.8.1.1 E
Description
Represents a mathematical constant for the base of natural loga-rithms, expressed as e. The approximate value of e is 2.71828.
Syntax
Math.E
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.8 Math 159
Example
trace(Math.E.format("%.16f"));//output: 2.7182818284590451
2.8.1.2 LN2
Description
Represents a mathematical constant for the natural logarithm of 2,expressed as loge2, 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 theconstant e (Math.E), expressed as log2e, with an approximate valueof 1.442695040888963387.
Syntax
Math.LOG2E
2.8.1.4 LN10
Description
Represents a mathematical constant for the natural logarithm of 10,expressed as loge10, with an approximate value of 2.3025850929940459011.
Syntax
Math.LN10
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
160 FFish Script Objects Reference
2.8.1.5 LOG10E
Description
Represents a mathematical constant for the base-10 logarithm of theconstant e (Math.E), expressed as log10e, with an approximate valueof 0.43429448190325181667.
Syntax
Math.LOG10E
2.8.1.6 PI
Description
Represents a mathematical constant for the ratio of the circumfer-ence of a circle to its diameter, expressed as π, with a value of3.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√
12 , with an approximate value of 0.707106781186.
Syntax
Math.SQRT1 2
2.8.1.8 SQRT2
Description
Represents a mathematical constant for the square root of 2, withan approximate value of 1.414213562373.
Syntax
Math.SQRT2
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.8 Math 161
2.8.2 Methods
2.8.2.1 abs
Description
Computes and returns an absolute value for the number specified bythe 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 specified in theparameter x, in radians.
Syntax
Math.acos(x)
Parameters
x A number from −1.0 to 1.0.
Returns
A number.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
162 FFish Script Objects Reference
2.8.2.3 asin
Description
Computes and returns the arc sine for the number specified in theparameter 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 specified inthe parameter x. The return value is between π
2 , and −π2 .
Syntax
Math.atan(x)
Parameters
x A number.
Returns
A number.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.8 Math 163
2.8.2.5 atan2
Description
Computes and returns the arc tangent of yx in radians. The return
value represents the angle opposite the opposite angle of a righttriangle, where x is the adjacent side length and y is the oppositeside 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 specified number or expression. The ceilingof a number is the closest integer that is greater than or equal to thenumber.
Syntax
Math.ceil(x)
Parameters
x A number or expression.
Returns
A number.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
164 FFish Script Objects Reference
2.8.2.7 cos
Description
Returns the cosine (a value from −1.0 to 1.0) of the angle specifiedby the parameter x. The angle x must be specified 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 func-tions:
//Degree to Radiansfunction D2R(degree){
return Math.PI * degree / 180;}//Radians to Degreefunction 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 thepower of the exponent specified in the parameter x. The constantMath.E can provide the value of e.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.8 Math 165
Math.exp(x)
Parameters
x The exponent; a number or expression.
Returns
A number.
2.8.2.9 floor
Description
Returns the floor of the number or expression specified in the pa-rameter x. The floor is the closest integer that is less than or equalto the specified number or expression.
Syntax
Math.floor(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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
166 FFish Script Objects Reference
2.8.2.11 max
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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.8 Math 167
2.8.2.14 random
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 nearestinteger 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 specified angle in radians.
Syntax
Math.sin(x)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
168 FFish Script Objects Reference
Parameters
x An angle measured in radians.
Returns
A number.
Remarks
To convert between radians values and degree values, use these func-tions:
//Degree to Radiansfunction D2R(degree){
return Math.PI * degree / 180;}//Radians to Degreefunction R2D(radians){
return radians / Math.PI * 180;}
2.8.2.17 sqrt
Description
Computes and returns the square root of the specified number.
Syntax
Math.sqrt(x)
Parameters
x A number or expression greater than or equal to 0.
Returns
A number.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.9 Dialogs Object 169
2.8.2.18 tan
Description
Computes and returns the tangent of the specified angle. The anglex must be specified 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, file open di-alogs, file 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 newinstance.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
170 FFish Script Objects Reference
2.9.1 Methods
2.9.1.1 msgBox
Description
Creates, displays, and operates a message box.
Syntax
Dialogs. msgBox(text[, caption[, type]])
Parameters
text Specifies the message to be displayedcaption Optional. Specifies the string used for the dialog box title
type Optional. Specifies a set of bit flags that determine the con-tents and behavior of the dialog box . This parameter can bea combination of a button type value and a icon type valueshown in the following table.
Button TypeValue Description0 Show [OK] button1 Show [OK] and [Cancel] buttons2 Show [Abort], [Retry] and [Ignore] buttons3 Show [Yes], [No] and [Cancel] buttons4 Show [Yes] and [No] buttons5 Show [Retry] and [Cancel] buttons
Icon TypeValue Description16 Show Stop Mark icon32 Show Question Mark icon48 Show Exclamation Mark icon64 Show Information Mark icon
Returns
An integer indicates which button of the message box has beenclicked.
Value Description1 [OK] button2 [Cancel] button3 [Abort] button4 [Retry] button5 [Ignore] button6 [Yes] button7 [No] button
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.9 Dialogs Object 171
Example
Dialogs.msgBox("This is a test", "Test", 17);
2.9.1.2 fileOpen
Description
Creates, displays and operates a file open dialog box.
Syntax
Dialogs.fileOpen([filter[, default ext[, filename[, multiselect]]]])
Parameters
filter Optional. A series of string pairs that specify filters you canapply to the file. If you specify file filters, only selected files willappear in the Files list box. The first string in the string pair ofthe filter describes the filter; the second string indicates the fileextension to use. Multiple extensions may be specified using ‘;’as the delimiter. The strings and the string pairs are delimitedby the character ‘|’. The filter must end with a character ‘|’.E.g. Zip files(*.zip; *.gz)|*.zip; *.gz|Text files(*.txt)|*.txt|Allfiles(*.*)|*.*|
default ext Optional. The default filename extension. If the user does notinclude an extension in the Filename edit box of the file opendialog, the extension specified by this parameter is automati-cally appended to the filename.
filename Optional. The initial filename that appears in the filename editbox of the file open dialog.
multiselect Optional. To allow users to select multiple files, set this pa-rameter to true.
Returns
If succeed, returns a string represents the selected file name. If pa-rameter multiselect is set to true, the result is an array that containsthe path to the current directory followed by the filenames of the se-lected files. If failed, returns false.
Example
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 fileSave
Description
Creates, displays and operates a file save dialog box.
Syntax
Dialogs. fileSave ([filter[, default ext[, filename]]])
Parameters
filter filter Optional. A series of string pairs that specify filters youcan apply to the file. If you specify file filters, only selectedfiles will appear in the Files list box. The first string in thestring pair of the filter describes the filter; the second stringindicates the file extension to use. Multiple extensions may bespecified using ‘’;’ as the delimiter. The strings and the stringpairs are delimited by the character ‘|’. The filter must endwith a character ‘|’. E.g. Zip files(*.zip; *.gz)|*.zip; *.gz|Textfiles(*.txt)|*.txt|All files(*.*)|*.*|
default ext Optional. The default filename extension. If the user does notinclude an extension in the Filename edit box of the file save di-alog, the extension specified by this parameter is automaticallyappended to the filename.
filename Optional. The initial filename that appears in the filename editbox of the file save dialog.
Returns
If succeed, returns a string represents the selected file name. If failed,returns false.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.9 Dialogs Object 173
Example
var f = "Zip files(*.zip; *.gz)|*.zip;*.gz|Text files(*.txt)|*.txt|All files(*.*)|*.*|";
var res = Dialogs.fileSave(f, "", "");trace(res);
2.9.1.4 chooseColor
Description
Creates, displays and operates a color dialog box.
Syntax
Dialogs.chooseColor([color])
Parameters
color Optional. Specifies the color initially selected when the dialogbox 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])
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
174 FFish Script Objects Reference
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. Specifies a string that is displayed above the treeview control in the dialog box.
path Optional. Specifies the folder selected initially when the dialogbox is created.
browsecomputer Optional. If this parameter is set to true, users can select com-puters name only.
Returns
If succeed, returns the selected folder name. If failed, returns false.
Example
var f = Dialogs.browse("Test", "c:\\");trace(f);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.10 Shell Object 175
2.10 Shell Object
Description
Provides ability to invoke Windows shell functions just like executeapplications, get environment variables, get special foldersetc.
available: SWFKit Express, SWFKit, SWFKit Pro
In SWFKit Express, only the ”run”, ”open”, ”explore”, ”print” andthe ”getSpecialFolder” folder methods are available.
Syntax
Shell.a method()
Remarks
The Dialogs object can be accessed directly without construct a newinstance.
2.10.1 Methods
2.10.1.1 run
Description
Executes an application.
Syntax
Shell.run(app[, show flags[, x, y[, dx, dy]]]);
Parameters
app Specifies the application name to execute.
show flags Optional. Specifies the show state of the application main win-dow. It can be one of the following values.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
176 FFish Script Objects Reference
Values Description0 Hides the window1 Activates and displays a window. If the win-
dow is minimized or maximized, the systemrestores it to its original size and position
2 Activates the window and displays it as a min-imized window
3 Activates the window and displays it as amaximized window
4 Displays a window in its most recent size andposition. The active window remains active
5 Activates the window and displays it in itscurrent size and position
6 Minimizes the specified window and activatesthe 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. Theactive window remains active
9 Activates and displays the window. If thewindow is minimized or maximized, the sys-tem restores it to its original size and position.An application should specify this flag whenrestoring a minimized window
11 Minimizes a window. For windows 2000, xp
x, y Optional. Specifies the position of the application window.
dx, dy Optional. Specifies the size of the application window.
Returns
If succeed, returns a Window Object represents the main window ofthe application. Otherwise, returns null.
Example
Shell.run("Notepad.exe");
2.10.1.2 runConsole
Description
Executes a command and returns the output.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.10 Shell Object 177
Syntax
Shell.runConsole(command);
Parameters
command Specifies the command to execute.
Returns
String. Returns the output of the command.
Example
trace(Shell.runConsole("ping 192.168.100.58"));
2.10.1.3 runAndWait
Description
Executes an application. This method does not return until theapplication is ended.
Syntax
Shell.runAndWait(app[, show flags[, x, y[, dx, dy]]]);
Parameters
app Specifies the application name to execute.
show flags Optional. Specifies the show state of the application main win-dow. It can be one of the following values.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
178 FFish Script Objects Reference
Values Description0 Hides the window1 Activates and displays a window. If the win-
dow is minimized or maximized, the systemrestores it to its original size and position
2 Activates the window and displays it as a min-imized window
3 Activates the window and displays it as amaximized window
4 Displays a window in its most recent size andposition. The active window remains active
5 Activates the window and displays it in itscurrent size and position
6 Minimizes the specified window and activatesthe 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. Theactive window remains active
9 Activates and displays the window. If thewindow is minimized or maximized, the sys-tem restores it to its original size and position.An application should specify this flag whenrestoring a minimized window
11 Minimizes a window. For windows 2000, xp
x, y Optional. Specifies the position of the application window.
dx, dy Optional. Specifies the size of the application window.
Returns
Nothing
Example
Shell.runAndWait("Notepad.exe");
2.10.1.4 open
Description
Opens a specified file.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.10 Shell Object 179
Syntax
Shell.open(app[, param])
Parameters
app Specifies the file to open.
param Specifies the command line arguments.
Returns
Nothing
Remarks
To determine whether there is an application can open the specifiedfile, use the method findExecutable.
Example
Shell.open("c:\\test.doc");
2.10.1.5 print
Description
Prints a specified file.
Syntax
Shell.print(app)
Parameters
app Specifies file to print.
Returns
Nothing
Remarks
To determine whether there is an application can print the specifiedfile, check the registry key: ”HKEY CLASSES ROOT\〈file type〉\shell\print\command”.The 〈file ext〉 is stored in the registry key: ”HKEY CLASSES ROOT\〈file ext〉”.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
180 FFish Script Objects Reference
function getPrintApp(file){
//get the ext of the filevar i = file.indexOf(‘.’);var ext = file.substring(i);
//get the file typevar rk = new RegKey("HKCR\\" + ext);if (rk == null) return null;
//get the default valuevar rv = rk.getValue();if (rv == null) return null;
var filetype = rv.data;
//get the applicationrk = 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
Description
Explores a specified folder.
Syntax
Shell.explore(path)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.10 Shell Object 181
Parameters
path Specifies the folder to explore.
Returns
Nothing
Example
Shell.explore("c:\\");
2.10.1.7 findExecutable
Description
Retrieves the name of the application associated with the specifiedfile name.
Syntax
Shell.findExecutable(filename)
Parameters
filename Specifies the file name.
Returns
A string represents the application name associated with the speci-fied file name if successful, or returns false otherwise.
Example
r = Shell.findExecutable("c:\\test.doc");trace(r);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
182 FFish Script Objects Reference
2.10.1.8 getSpecialFolder
Description
Retrieves the full path of the special folders.
Syntax
Shell.getSpecialFolder(name)
Parameters
name Specifies the special folder name. It can be one of the followingvalue:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.10 Shell Object 183
Values Description”appdata” File system directory that serves as a common
repository for application-specific data”cookies” File system directory that serves as a common
repository for Internet cookies”desktop” File system directory used to physically store file
objects on the desktop”desktop all” File system directory that contains files and fold-
ers that appear on the desktop for all users”favorites” File system directory that serves as a common
repository for the user’s favorite items”fonts” Virtual folder containing fonts”history” File system directory that serves as a common
repository for Internet history items”internet cache” File system directory that serves as a common
repository for temporary Internet files”my documents” File system directory that serves as a common
repository for documents”nethood” File system directory containing objects that ap-
pear in the network neighborhood”printers” File system directory that serves as a common
repository for printer links”program files” The propgram files folder”programs” File system directory that contains the user’s pro-
gram groups”programs all” File system directory that contains the directo-
ries for the common program groups that appearon the Start menu for all users
”recent” File system directory that contains the user’smost recently used documents
”sendto” File system directory that contains Send To menuitems
”startmenu” File system directory containing Start menuitems
”startmenu all” File system directory that contains the programsand folders that appear on the Start menu for allusers
”startup” File system directory that corresponds to theuser’s Startup program group
”startup all” File system directory that contains the programsthat appear in the Startup folder for all users
”system” The system folder”temp” The temporaty folder”templates” File system directory that serves as a common
repository for document templates”windows” The windows folder
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
184 FFish Script Objects Reference
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 shell’s list of recently used documents.
Syntax
Shell. addToRecentDocs(filename)
Parameters
filename Specifies the document name to add.
Returns
Nothing
Example
Shell.addToRecentDocs("c:\\1.zip");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.10 Shell Object 185
2.10.1.10 clearRecentDocs
Description
Clears all documents from the shell’s 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();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
186 FFish Script Objects Reference
2.10.1.12 getEnvironmentStrings
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 specified variable.
Syntax
Shell.getEnvironmentVariable(name)
Parameters
name Specifies 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]));
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.10 Shell Object 187
2.10.1.14 setEnvironmentVariable
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");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
188 FFish Script Objects Reference
2.10.1.16 expandEnvironmentStrings
Description
Expands environment-variable strings and replaces them with theirdefined values.
Syntax
Shell.expandEnvironmentStrings(str)
Parameters
str Specifies a string that might contain references to environment-variable 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. Specifies the filename of the bitmap to set as the desk-top wallpaper.
update Boolean. Optional. Specifies whether the user profile is to beupdated. The default value is true.
notify Boolean. Optional. Specifies whether the WM SETTINGCHANGEmessage is to be broadcast to all top-level windows to notifythem of the change. The default value is true.
Returns
Boolean.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.10 Shell Object 189
2.10.1.18 getFileVersionInfo
Description
Gets the version information of the specified file.
Syntax
Shell.getFileVersionInfo(filename)
Parameters
filename String. Specifies the full pathname of the file.
Returns
Returns an object contains following properties if successful:
Name Descriptioncomments Contains any additional information about
the filecompanyName Identifies the company that produced the
filefileDescription Describes the filefileVersionNum Integer. Identifies the version of this filefileVersion Identifies the version of this fileinternalName Identifies the file’s internal namelegalCopyright Describes all copyright notices, trademarks,
and registered trademarks that apply to thefile
legalTrademarks Describes all trademarks and registeredtrademarks that apply to the file
originalFilename Identifies the original name of the file, notincluding a path
privateBuild Describes by whom, where, and why thisprivate version of the file was built
productName Identifies the name of the product withwhich this file is distributed
productVersionNum Integer. Identifies the version of the productwith which this file is distributed
productVersion Identifies the version of the product withwhich this file is distributed
specialBuild Describes how this version of the file differsfrom the normal version. If failed, returnsnull.
Example
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 pro-vides standard commands for playing multimedia devices and record-ing multimedia resource files.
available: SWFKit Express, SWFKit, SWFKit Pro
Syntax
new MCI();
Remarks
MCI provides two ways to play multimedia devices. The first is thesendCmdString method, which represents the command-string in-terface 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");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 191
The second is the command property, which represents the command-message interface of MCI. The MCI object provides some other prop-erties to work with the command property. The following examplesdemonstrating how to use these properties:
1. Opens a deviceYou can open a device by specifying the deviceType and thefilename.
//Example 1. Opens a cdaudiovar m = new MCI;//specifies the device typem.deviceType = "cdaudio";//open the cdaudio devicem.command = "open";
//Example 2. Opens a waveform-audio filevar m = new MCI;//specifies the device typem.deviceType = "waveaudio";//specifies the file namem.fileName = "test.wav";//open the cdaudio devicem.command = "open";
2. Handling MCI ErrorsYou should check the error property for errors. If it indicatesan error, use the errorMsg property to get a textual descriptionof 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 theuser immediately, even if it takes several minutes to completethe action initiated by the command. You can set the waitproperty to true to direct the device to wait until the requestedaction is completed before returning control to the FFish script.E.g.
var m = new MCI;m.wait = true;m.deviceType = "cdaudio";m.command = "open";
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
192 FFish Script Objects Reference
//The continuous scripts won’t//run until the CDAudio is opened...
4. Using the notify property MCI object fires the onNotify eventsif the notify property is set to true. The events are fired afteran action is completed. You can handle this event by specifyinga handler function. E.g.
//Example.//Closes the device after playing the wavefunction 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 CDfunction on\_notify(flag){
m.notify = false;m.command = "close";
}
m = new MCI;m.deviceType = "cdaudio";m.command = "open";//set the time format to TMSFm.timeFormat = 10;
//plays track 12m.from = MCI.makeTMSF(12, 0, 0, 0);m.to = MCI.makeTMSF(13, 0, 0, 0);m.notify = true;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 193
m.onNotify = on\_notify;m.command = "play";
6. Playing a movie Before open a video device you must set thelocation of the playing movie.
//Example: playing a moviem = new MCI;m.deviceType = "avivideo";m.fileName = "D:\\1.avi";
//set the loaction of the playing windowm.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 cur-rent position of the device.
//Example: use command "seek" to//change the current position of the CDvar m = new MCI;m.deviceType = "cdaudio";m.command = "open";m.timeFormat = 10;m.to = MCI.makeTMSF(10, 1, 0, 0);m.command = "seek";m.to = MCI.makeTMSF(11, 0, 0, 0);m.command = "play";
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 millisecondsm.timeFormat = 0;//Set the record length to 10 secondsm.to = 10000;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
194 FFish Script Objects Reference
m.command = "record";
//save the recording to filem.fileName = "d:\\1.wav";m.command = "save";m.command = "close";
2.11.1 Properties
2.11.1.1 alias
Description
String. Represents the alias of the device. You can send commandsto 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 195
m = new MCI;m.deviceType = "cdaudio";m.command = "open";if (m.canEject) m.command = "eject";m.command = "close";
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";
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
196 FFish Script Objects Reference
2.11.1.5 canStep
Description
Boolean. Determines if the device support stepping. Read-only
Syntax
mci.canStep
2.11.1.6 deviceID
Description
Integer. Represents the ID of the device. Read-only
Syntax
mci.deviceID
2.11.1.7 deviceType
Description
String. Represents the device type. The method getDevices can getall device types supported in the system.
Syntax
mci.deviceType
2.11.1.8 fileName
Description
String. Specifies the multimedia file to play.
Syntax
mci.fileName
Example
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 197
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:";
2.11.1.9 frames
Description
Integer. Specifies the number of frames to step or back.
Syntax
mci.frames
2.11.1.10 from
Description
Integer. Specifies the starting location to play or record. If thisproperty is negative, the starting location defaults to the currentposition. When a device is opened, the property is reset to -1.
Syntax
mci.from
Example
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
198 FFish Script Objects Reference
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 Meaning524 MCI MODE NOT READY525 MCI MODE STOP526 MCI MODE PLAY527 MCI MODE RECORD528 MCI MODE SEEK529 MCI MODE PAUSE530 MCI MODE OPEN
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 199
2.11.1.13 notify
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
200 FFish Script Objects Reference
Boolean. Represents the record mode of the device. The followingtable describes the meaning of this property.
Value Descriptiontrue Overwrite mode. Data should overwrite existing
data.false 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. Specifies if the device or file 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 devicethat has already been opened as sharable.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 201
2.11.1.17 channel
Description
Integer. Specifies the audio channel of the device. The followingtable describes the meaning of the property.
Value Description0 All audio channels1 Left channel2 Right channel
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";
2.11.1.18 start
Description
Integer. Obtains the starting position of the media. Read-only
Value Description0 All audio channels1 Left channel2 Right channel
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
202 FFish Script Objects Reference
Syntax
mci.start
2.11.1.19 timeFormat
Description
Integer. Specifies the time format of the device. This property canbe one of the following values:
Values Description0 MCI FORMAT MILLISECONDS. Specifies
the time in milliseconds.1 MCI FORMAT HMS. Specifies time in HMS
(hours/minutes/seconds) format.2 MCI FORMAT MSF. Specifies the time in
MSF (minutes/seconds/frames) format.3 MCI FORMAT FRAMES. Specifies the time
in frames.4 MCI FORMAT SMPTE 24. Specifies the
time in 24 frame SMPTE format.5 MCI FORMAT SMPTE 25. Specifies the
time in 25 frame SMPTE format.6 MCI FORMAT SMPTE 30. Specifies the
time in 30 frame SMPTE format.7 MCI FORMAT SMPTE 30DROP. Specifies
the time in 30 drop-frame SMPTE format.8 MCI FORMAT BYTES. Specifies the time
member in bytes within a PCM (Pulse Code Mod-ulation) data format.
9 MCI FORMAT SAMPLES. Specifies thetime in samples for input or output.
10 MCI FORMAT TMSF. Changes the time for-mat to tracks, minutes, seconds, and frames.
Syntax
mci.timeFormat
2.11.1.20 to
Description
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 203
Integer. Specifies the ending location to play or record. If the prop-erty is negative, the ending location defaults to the end of the con-tent. 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";
2.11.1.21 track
Description
Integer. Use with the property trackPosition and trackLength tospecify the track number.
Syntax
mci.track
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
204 FFish Script Objects Reference
2.11.1.22 trackLength
Description
Integer. Gets the length of the specified 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 specified track. Read-only.
Syntax
mci.trackPosition
2.11.1.24 wait
Description
Boolean. Specifies whether to direct the device to wait until therequested action is completed before returning control to the scripts.
Syntax
mci.wait
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 205
2.11.1.25 playerWindow
Description
A Window object. Represents the window for playing videos. Read-only
Syntax
mci.playerWindow
2.11.1.26 error
Description
Boolean. Represents if there is an error after an action is accom-plished. The value true indicates there is an error. Read-only.
Syntax
mci.error
2.11.1.27 errorMsg
Description
String. Gets the error message. Read-only.
Syntax
mci.errorMsg
2.11.1.28 command
Description
String. Sets the action to perform.
Syntax
mci.command = action;
Remarks
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
206 FFish Script Objects Reference
FFish Script supports the following actions:
open Opens a device. Specifies the deviceType and the fileNameproperty before using this action. If you want the device to be share-able, set the sharable property to true. If the device needs a playingwindow, you must set the left, top, width and height property to de-fine 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 finished using it.
close Closes an device. E.g.
m.command = "close";
play Plays the specified media. Specifies the from and the to prop-erty before using this action.pause Pauses the specified media.
stop Stops the device.
back Steps back. The frames property specifies the back frames. Ifthis action is successfully finished, the from property is reset to C1.
step Steps forward. The frames property specifies the frame num-ber to step. If this action is successfully finished, the from propertyis reset to C1.
prev Seeks to the begin of the track. If this action is successfullyfinished, the from property is reset to C1.
next Seeks to the end of the next track. If this action is successfullyfinished, the from property is reset to C1.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 207
seek Seeks to the position specified by the to property. If this actionis successfully finished, the from property is reset to C1.
record Records. Specifies the from and the to property before usingthis action. The recordMode property specifies the record mode.
eject Ejects the media.
resume Resumes the device.
save Saves the opened file.
update Updates the playing window. where Obtains the clippingrectangle for the video device. If the action finished successfully,the width property contains the width of the video and the heightproperty contains the height of the video.All of the action strings are case-insensitive.
2.11.1.29 left
Description
Integer. Sets the x-coordinate of the upper-left corner of the playingwindow for video devices. The playing window is embedded in theprojector.
Syntax
mci.left
2.11.1.30 top
Description
Integer. Sets the y-coordinate of the upper-left corner of the playingwindow for video devices. The playing window is embedded in theprojector.
Syntax
mci.top
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
208 FFish Script Objects Reference
2.11.1.31 width
Description
Integer. Sets the width of the playing window for video devices. Theplaying 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 Methods
2.11.2.1 sendCmdString
Description
Sends a command to the MCI interface. static.
Syntax
MCI.sendCmdString(cmd)
Parameters
cmd Specifies the command string to send.
Returns
A string represents result information or error message
Example
MCI.sendCmdString("open c:\\test.rmitype sequencer alias test");
MCI.sendCmdString("play test wait");MCI.sendCmdString("close test");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 209
2.11.2.2 getDevices
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 packedhours/minutes/seconds (HMS) information. Static
Syntax
MCI.hmsHour(value)
Parameters
value Specifies time in HMS format.
Returns
Integer. Returns the hours component of the specified HMS infor-mation
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
210 FFish Script Objects Reference
2.11.2.4 hmsMinute
Description
Retrieves the minutes component from a parameter containing packedhours/minutes/seconds (HMS) information. Static
Syntax
MCI.hmsMinute(value)
Parameters
value Specifies time in HMS format.
Returns
Integer. Returns the minutes component of the specified HMS in-formation
2.11.2.5 hmsSecond
Description
Retrieves the seconds component from a parameter containing packedhours/minutes/seconds (HMS) information. Static
Syntax
MCI.hmsSecond(value)
Parameters
value Specifies time in HMS format.
Returns
Integer. Returns the seconds component of the specified HMS infor-mation
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 211
2.11.2.6 makeHMS
Description
Creates a time value in packed hours/minutes/seconds (HMS) for-mat from the given hours, minutes, and seconds values. Static
Syntax
MCI.makeHMS(h, m, s)
Parameters
h Specifies the number of hours.
m Specifies the number of minutes.
s Specifies 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) for-mat from the given minutes, seconds, and frame values. Static
Syntax
MCI.makeMSF(m, s, f)
Parameters
m Specifies the number of minutes.
s Specifies the number of seconds.
f Specifies the number of frames.
Returns
Integer. Returns the time in packed MSF format.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
212 FFish Script Objects Reference
2.11.2.8 makeTMSF
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 Specifies the number of tracks.
m Specifies the number of minutes.
s Specifies the number of seconds.
f Specifies 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 packedminutes/seconds/frames (MSF) information. Static
Syntax
MCI.msfFrame(value)
Parameters
value Specifies time in MSF format.
Returns
Integer. Returns the frames component of the specified MSF infor-mation.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 213
2.11.2.10 msfMinute
Description
Retrieves the minutes component from a parameter containing packedminutes/seconds/frames (MSF) information. Static
Syntax
MCI.msfMinute(value)
Parameters
value Specifies time in MSF format.
Returns
Integer. Returns the minutes component of the specified MSF infor-mation.
2.11.2.11 msfSecond
Description
Retrieves the seconds component from a parameter containing packedminutes/seconds/frames (MSF) information. Static
Syntax
MCI.msfSecond(value)
Parameters
value Specifies time in MSF format.
Returns
Integer. Returns the minutes component of the specified MSF infor-mation.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
214 FFish Script Objects Reference
2.11.2.12 tmsfMinute
Description
Retrieves the minutes component from a parameter containing packedtracks/minutes/seconds/frames (TMSF) information. Static
Syntax
MCI.tmsfMinute(value)
Parameters
value Specifies time in TMSF format.
Returns
Integer. Returns the minutes component of the specified TMSFinformation.
2.11.2.13 tmsfFrame
Description
Retrieves the frames component from a parameter containing packedtracks/minutes/seconds/frames (TMSF) information. Static
Syntax
MCI.tmsfFrame(value)
Parameters
value Specifies time in TMSF format.
Returns
Integer. Returns the frames component of the specified TMSF in-formation.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.11 MCI Object 215
2.11.2.14 tmsfSecond
Description
Retrieves the seconds component from a parameter containing packedtracks/minutes/seconds/frames (TMSF) information. Static
Syntax
MCI.tmsfSecond(value)
Parameters
value Specifies time in TMSF format.
Returns
Integer. Returns the seconds component of the specified TMSF in-formation.
2.11.2.15 tmsfTrack
Description
Retrieves the tracks component from a parameter containing packedtracks/minutes/seconds/frames (TMSF) information. Static
Syntax
MCI.tmsfTrack(value)
Parameters
value Specifies time in TMSF format.
Returns
Integer. Returns the tracks component of the specified TMSF infor-mation.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
216 FFish Script Objects Reference
2.11.3 Events
2.11.3.1 onNotify
Description
If the notify property is set to true before an action, the onNotifyevent will be triggered after the action is completed. The eventhandler is:
mci.onNotify = function (flag){
body}
The flag will be one of the following values:Value Description1 The device has completed the command2 The current notification conditions have been su-
perseded by a new command.4 The device has received a command that prevents
it from meeting the notification conditions.8 A device error occurred while the device was exe-
cuting the command.
Syntax
mci.onNotify = handler-func;
2.12 Application Object
Description
Provides a series of objects, properties and methods, which offer theability to change the appearance, behavior and many other optionsof the applications or screen savers at runtime.
Syntax
Application.method or properties
Availability
1. SWFKit Express 2+2. SWFKit 2+3. SWFKit Pro 2+
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.12 Application Object 217
2.12.1 Properties
2.12.1.1 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
218 FFish Script Objects Reference
2.12.1.4 Behaviour
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.12 Application Object 219
2.12.1.7 Expiry
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
220 FFish Script Objects Reference
2.12.1.12 cmdItems
Description
Array. Returns the parsed command line items. Read-only
Syntax
Application.cmdItems
Remarks
The Application.cmdLine property will include the path name of theapplication, but this property won’t.
// 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 usethe default cursor. You can specify a full path name of a cursor fileon disk or path name of a cursor in the attachment list.To hide the cursor, set the property to string ”hide”. Any othervalues will show the cursor.
// Hide the cursorApplication.cursor = "hide";
Examples
// Uses a cursor on attachments listApplication.cursor = "1.cur";// Uses a cursor on diskApplication.cursor = "c:\\1.cur";// Restores to the default cursorApplication.cursor = null;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.12 Application Object 221
2.12.1.14 isScr
Description
Returns true if the output file 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 worksunder preview mode.
Syntax
Application.traceWnd
2.12.1.16 captureMouse
Description
Boolean. Captures the mouse. If it’s set to true, the application willreceive mouse events even if the cursor is out of the main window.
Syntax
Application.captureMouse
2.12.1.17 setFocus
Description
Boolean. Sets focus in the application.
Syntax
Application.setFocus
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
222 FFish Script Objects Reference
2.12.2 Methods
2.12.2.1 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 pathis base to find your movies specified 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:/myprojects/movies/test.swf”. It’s very useful when you are workingwith attachments. For example, providing you have added a movie”demo.swf” to the attachments list under folder ”myswfs” You canload 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 foldername like this:loadMovieNum(”demo.swf”, 1);in FFish Script, you need to set the base directory to the folderthat the demo.swf has been put in:
var name = getAddtionalFile("myswfs\\demo.swf");Application.setBasePath((new File(name)).parentPath);
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.12 Application Object 223
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 basedirectory.
1. If the parameter is not set, the base directory will be setto the directory contains the applications or screen savers.
2. If the parameter is set to ”movies”, the base directory willbe set to the directory contains the movies. If the movieswere packed into the executable file, they will be extractedto a temporary folder before the main window appears onscreen, then the base directory is set to the temporaryfolder. Otherwise, it’s the same directory as the executablefile’s.
3. If the parameter is set to ”attachments”, the base directorywill be set to the temporary folder that the attachmentswere extracted into (If the ”Pack attachments” option ischecked).
Returns
Nothing
Remarks
Generally, you use a relative path name to load another moviein 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 ”mas-ter.swf” to the movie list and build a output executable file, provid-ing it is ”master.exe”. At last you can copy the the ”slave.swf” andthe ”master.exe” to a same folder and run the ”master.exe”. But itmay not work.
The reason is that SWFKit supports packing movies into the output
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
224 FFish Script Objects Reference
executable files. When the executable file is beginning to run, thepacked movie will be extracted to a temporary folder. That is to say,the ”slave.swf” and the extracted ”master.swf” can be in differentfolders.
In SWFKit 1, you have to uncheck the ”pack movies” option (makesthe ”master.swf” and the ”slave.swf” are in the same folder) or passthe full path name of ”slave.swf” to the ”loadMovie” method to re-solve the problem.
From SWFKit 2, it provides a better solution. Just call ”Applica-tion.setBasePath()” before loading the ”slave.swf”, the base direc-tory is set to the folder contains ”master.exe”, and the Flash Playercan find the ”slave.swf” now. You don’t need to uncheck the ”packmovies” option or modify the parameter of the ”loadMovie” methodin Action Script.
2.12.2.3 associate
Description
Associates a file type with the application.
Syntax
Application.associate(extension, identifier);
Parameters
extension String. The extension of the files to be associated with.
identifier String. The identifier of the file type
Returns
Nothing
Example
Application.associate(".ccc", "Demo.type");var cmdItems = Application.cmdItems;if (cmdItems.length > 0){
//cmdItems[0] is the name of the fileDialogs.msgBox(cmdItems[0]);
}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.12 Application Object 225
Run the executable file for the first time and close it. Double-click a.ccc file in the Windows Explorer, the executable file will be launchedagain and a message box will popup and display the path name ofthe .ccc file.
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 functionor method.
param1, param2, ..., paramN Optional. The parameters passed to the function or method
Returns
Integer. An interval identifier that you can pass to clearIntervalmethod to cancel the interval.
Examples
function DoTrace(str){
trace(str);}
timer = Application.setInterval(DoTrace,100, (new Date).toString());
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
226 FFish Script Objects Reference
2.12.2.5 clearInterval
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 file. Won’t work in preview mode.
Syntax
Application.traceToFile(filename);
Parameters
filename String. The name of the file to write the trace messages.
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.12 Application Object 227
2.12.2.7 about
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 applica-tion (doesn’t available for screen savers). The drag region is an areaof the main window in which the main window can be dragged byholding the left mouse button down.
Syntax
• Application.setDragRegion();
• Application.setDragRegion(region);
• Application.setDragRegion(left, top, width, height);
Parameters
region string. specifies the name of a pre-created clip region. The dragregion will be changed to the pre-created clip region.
left, top, width, height interger. The four parameters represents a rectangle region inthe client of the main window. The drag region will be changedto the rectangle region.
Returns
Nothing.
Remarks
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
228 FFish Script Objects Reference
If the method is called without a parameter it will reset the dragregion to the whole client area of the main window.
To drag the applications by holding the left mouse button down inthe drag region, the option [operation panel]->[application definition]->[interaction]->[left mouse button click]->[drag window] must hasbeen set.
The option can also be set by the ffish 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 specified window
Syntax
Application.sendMessage(handle, msg, wparam, lparam);
Parameters
handle The handle of the window to send a message. You can useWindow.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 inffish script.
Syntax
Application.registerASMethods(method0, method1, ..., methodN);
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.12 Application Object 229
method0, method1, ..., methodN String. Names of the methods in actionscript 2/3. The methodsmust have be exported by calling the “ExternalInterface.addCallback”method.
Returns
Nothing
2.12.3 Events
2.12.3.1 onGetMovie
Description
SWFKit triggers the event while it’s about to load the main movie.
Syntax
Application.onGetMovie = function (movie)
Parameters
movie An object which has a ”value” property. You can specify thepath name of your movie to this property.
Remarks
Generally, SWFKit loads the first movie in the movie list. But ifthis event handler returns true and ”movie.value” is assigned witha movie name, SWFKit will load it instead.
Example
Tells SWFKit to load the ”test.swf” in attachment list as the mainmovie
Application.onGetMovie = function (movie){
movie.value = getAdditionalFile("test.swf");return true;
}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
230 FFish Script Objects Reference
2.12.3.2 onMovieLoaded
Description
SWFKit triggers the event while the Flash Player has just loaded amovie.
Syntax
Application.onMovieLoaded = function (movie)
Parameters
movie String. Specifies 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. Theappearance options are predefined in the option box ”Operationpanel”->”Application Definition”->”Appearance” of SWFKit UI
available: SWFKit Express, SWFKit, SWFKit Pro
2.13.1 Properties
2.13.1.1 windowShape
Description
Sets or gets the window shape option of the main window. This prop-erty corresponds to the ”Window Shape” group box in the optionbox ”Operation panel”->”Application Definition”->”Appearance”of SWFKit UI
Syntax
Application.Appearance.windowShape
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.13 Application.Appearance 231
Remarks
If the window shape is rectangle or transparent, the property willreturn 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
2.13.1.2 borderStyle
Description
Sets or gets the border style of the main window of the applica-tion. Integer. This property corresponds to the ”Border style” groupbox in the dialog box ”Operation panel”–”Application Definition”–”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 ofthe caption bar) of the main window. Integer. This property corre-sponds to the ”Border Icons” group box in the dialog box ”Operationpanel”–”Application Definition”–”Appearance” of SWFKit UI
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
232 FFish Script Objects Reference
Syntax
Application.Appearance.borderIcons
Remarks
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 propertycorresponds to the ”Scale Mode” group box in the dialog box ”Op-eration panel”–”Application Definition”–”Appearance” of SWFKitUI
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.14 Application.SizeAndPos 233
2.13.1.6 icon
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. Ifthe icon is in the attachment list, you need to get its path name byusing method ”getAdditionalFile”.
2.14 Application.SizeAndPos
Description
Sets or gets the size and position options of the main window. Thesize and position options are predefined in the dialog box ”Operationpanel”–”Application Definition”–”Size and Position” of SWFKit UI
available: SWFKit Express, SWFKit, SWFKit Pro
2.14.1 properties
2.14.1.1 windowSize
Description
Sets or gets the size option of the main window. Integer. This prop-erty corresponds to the ”Window Size” group box in the dialog box”Operation panel”–”Application Definition”–”Size and position” ofSWFKit UI
Syntax
Application.SizeAndPos.windowSize
Remarks
It can be one of the following values:
1. $SSDEFAULT
2. $SSFULLSCREEN
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
234 FFish Script Objects Reference
3. $SSMAXIMIZED
4. $SSCUSTOMIZED
5. $SSPERCENT
Note: You cannot set window size with customized width and heightby this property, use the setCustomSize method instead. The Ap-plication.SizeAndPos object doesn’t offer any method to set windowsize to some percents of the desktop.
2.14.1.2 pos
Description
Sets or gets the position option of the main window. Integer. Thisproperty corresponds to the ”Position” group box in the dialog box”Operation panel”–”Application Definition”–”Size and position” ofSWFKit 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 topvalue by this property, use the setCustomPos method instead.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.14 Application.SizeAndPos 235
2.14.1.3 bKeepRatio
Description
Keeps the aspect ratio of the main window while resizing if set totrue. Boolean.
Syntax
Application.SizeAndPos.bKeepRatio
2.14.2 methods
2.14.2.1 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 specified width and height.
Syntax
Application.SizeAndPos.setCustomSize(width, height)
Parameters
width Integer. Specifies the new width of the main windowheight Integer. Specifies the new height of the main window
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
236 FFish Script Objects Reference
2.14.2.3 setCustomSizeAndPos
Description
Combination of the setCustomSize method and the setCustomPosmethod.
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. Theinteraction options are predefined in the dialog box ”Operation panel”–”Application Definition”–”Interaction” of SWFKit UI
available: SWFKit Express, SWFKit, SWFKit Pro
2.15.1 Properties
2.15.1.1 lBtnClk
Description
Sets or gets the action of the left mouse clicks. This property cor-responds to the ”Left mouse button click” group box in the dia-log box ”Operation panel”–”Application Definition”–”Interaction”of SWFKit UI
Syntax
Application.Interaction.lBtnClk
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.15 Application.Interaction 237
Remarks
It can be one of the following values:
1. $LBSEND2. $LBDRAG3. $LBIGNORE
2.15.1.2 rBtnClk
Description
Sets or gets the action of the right mouse clicks. This propertycorresponds to the ”Right mouse button click” group box in the di-alog box ”Operation panel”–”Application Definition”–”Interaction”of SWFKit UI
Syntax
Application.Interaction.rBtnClk
Remarks
It can be one of the following values:
1. $RBSEND2. $RBCONTEXTMENU3. $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 di-alog box ”Operation panel”–”Application Definition”–”Interaction”of SWFKit UI
Syntax
Application.Interaction.keyPress
Remarks
It can be one of the following values:
1. $KPSEND2. $KPIGNORE
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
238 FFish Script Objects Reference
2.15.1.4 exitKeys
Description
Sets or gets the way to exit the application. This property corre-sponds to the ”Exit Keys” group box in the dialog box ”Operationpanel”–”Application Definition”–”Interaction” 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 ALT–TAB or ALT–CTRL–DELETE when the application is running. Only works under Win9x
Syntax
Application.Interaction.bDisableAltTab
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.16 Application.Behaviour 239
2.15.1.7 bDisableCursor
Description
Boolean. Hides the cursor.
Syntax
Application.Interaction.bDisableCursor
2.15.1.8 bDisableScr
Description
Boolean. Prevents the screen savers from running when the appli-cation is running
Syntax
Application.Interaction.bDisableScr
2.16 Application.Behaviour
Description
Changes the behavior options of the applications at runtime. The be-havior options are pre-defined in the dialog box ”Operation panel”–”Application Definition”–”Behaviour” of SWFKit UI
available: SWFKit Express, SWFKit, SWFKit Pro
2.16.1 Properties
2.16.1.1 bAllowExtendContextMenu
Description
Boolean. If the property is set to false, the context menu of theapplication is not allowed to be extended.
Syntax
Application.Behaviour.bAllowExtendContextMenu
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
240 FFish Script Objects Reference
2.16.1.2 extendContextMenu
Description
Integer. Sets or gets the items to be inserted into the context menu.This property corresponds to the ”Add to context menu” groupbox in the dialog box ”Operation panel”–”Application Definition”–”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 toplay the movies automatically.
Syntax
Application.Behaviour.bAutoPlay
2.16.1.4 bStartMinimized
Description
Boolean. If the property is set to true, the application is minimizedafter starting.
Syntax
Application.Behaviour.bStartMinimized
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.17 Application.Expiry 241
2.16.1.5 bAlwaysOnTop
Description
Boolean. If the property is set to true, the main window of theapplication 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 willbe placed in the system tray. When you click the icon in the systemtray, it will popup a menu. If you want to change the behavior of thesystem tray icon, you should set the ”useDefaultHandler” propertyof the Application.SysTray object to false and handle the mouseevents. You still can add an icon into the system tray by using theApplication.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-defined in the dialog box ”Operationpanel”–”Application Definition”–”Expiry” of SWFKit UI
available: SWFKit Express, SWFKit, SWFKit Pro
2.17.1 Properties
2.17.1.1 bEnable
Description
Boolean. if the ”Expiry” option is enabled in the ”Expiry” settingdialog, this property will return true. Read-only.
Syntax
Application.Expiry.bEnable
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
242 FFish Script Objects Reference
2.17.1.2 expireOn
Description
Integer. Returns the date when the program will expire. Read-only.only valid when the ”Application.Expiry.bEnable” property returnstrue.
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” prop-erty 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” settingdialog, this property will return true. Read-only.
If this option hasn’t been checked, and Application.Expiry.onExpiredevent hasn’t been handled either, when the program is expired itwon’t run anymore.
However, even if this option hasn’t been checked, you still can letthe end users to register your applications by handling the Applica-tion.Expiry.onExpired event. The registration can be done by theApplication.Expiry.register method. To verify if the application hasbeen registered, check the Application.Expiry.isRegistered property.
Syntax
Application.Expiry.bEnableUnlock
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.17 Application.Expiry 243
2.17.1.5 isExpired
Description
Boolean. returns true when the program is expired.
Syntax
Application.Expiry.isExpired
2.17.1.6 isRegistered
Description
returns true when the program is registered.
Syntax
Application.Expiry.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. Specifies if the registration box can be customized by theproperties such as rbCaption, rbInfo, rbShow3rdBtn, and so on.
Set it to true if you want to customize the registration box.
Syntax
Application.Expiry.rbCustomized
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
244 FFish Script Objects Reference
2.17.1.9 rbCaption
Description
String. This property is used to customize the caption of the reg-istration box. Only works if the rbCustomized property is set totrue.
Syntax
Application.Expiry.rbCaption
2.17.1.10 rbInfo
Description
String. This property is used to customize the registration infor-mation in the registration box. Only works if the rbCustomizedproperty 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 it’s set to false,the button will be hidden. Only works if the rbCustomized propertyis set to true.
Syntax
Application.Expiry.rbShow3rdBtn
2.17.1.12 rb3rdBtnCaption
Description
String. Specifies the caption of the third button(the ‘Help’ button).Only works if the rbCustomized and the rbShow3rdBtn propertiesare set to true.
Syntax
Application.Expiry.rb3rdBtnCaption
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.17 Application.Expiry 245
2.17.1.13 rb3rdBtnLink
Description
String. Specifies the link to be opened when users click the thirdbutton. Only works if the rbCustomized and the rbShow3rdBtnproperties 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 appli-cation. If the application has not been registered, returns undefined.
Syntax
Application.Expiry.username
2.17.1.15 serialNumber
Description
String. Read-only. Returns the serial number used to register theapplication. If the application has not been registered, returns un-defined.
Syntax
Application.Expiry.serialNumber
2.17.2 Methods
2.17.2.1 showRegisterDlg
Description
Shows the register dialog.
Syntax
Application.Expiry.showRegisterDlg()
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
246 FFish Script Objects Reference
Parameters
None
Returns
Boolean. returns true if successful, or false otherwise.
2.17.2.2 register
Description
Register the application or screen saver. You can create serial num-bers by using the serial number creator.
Syntax
Application.Expiry.register(username, sn, password)
Parameters
username String. Specifies the user name
sn String. Specifies the serial number
password String. Specifies 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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.17 Application.Expiry 247
2.17.3 Events
2.17.3.1 onExpiry
Description
If the application or screen saver is expired, this event will be trig-gered and will be only triggered for one time just after the mainwindow 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 issucceeded, the application will continue to run, otherwise it will ter-minate.
You can change the default action by handling this event. if thedonot call the default handler.value is set to true, the SWFKit won’tdo the default action. You can display your own message box andregistration box later. But you must do something to prevent theusers from continuing using the application without registration inthis case, or the lock system is passed by the event handler andcannot 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;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
248 FFish Script Objects Reference
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 won’t 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.18 Application.SysTray 249
2.18.1 Properties
2.18.1.1 tip
Description
String. Sets or gets the text of the tooltip appears when the cursoris 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 mustbe the full path name of an icon on the disk. If the icon is in theattachments list, you should get its pathname by using the ”getAd-ditionalFile” method.
Syntax
Application.SysTray.icon
2.18.1.3 balloonTip
Description
String. Sets or gets the text for the balloon tooltip that can beshowed 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 beshowed by the showBalloonTip method.
Syntax
Application.SysTray.balloonTitle
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
250 FFish Script Objects Reference
2.18.1.5 balloonTimeout
Description
Integer. Sets or gets the timeout value, in milliseconds, for theballoon 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 willshow a right click menu as SWFKit 1.
Syntax
Application.SysTray.useDefaultHandler
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.18 Application.SysTray 251
2.18.2 Methods
2.18.2.1 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 = function (){
var menu = new Menu;menu.createPopupMenu();menu.appendItem("id0", "item 0", "525flop1.ico");menu.appendItem("id1", "item 1", "audio.ico");menu.appendItem();menu.appendItem("id2", "item 2", "cddrive.ico");menu.appendItem("id3", "item 3", "clsdfold.ico");
getMainWnd().bringToTop();trace(menu.show());
}
Application.SysTray.onLClicked = function (){
this.balloonTip = "Happy New Year!";this.balloonTitle = "Hello";this.balloonIcon = "warning";
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
252 FFish Script Objects Reference
this.showBalloonTip();}
Notice: before showing a popup menu for the notificationicon, remember to call the ”bringToTop” method for themain window. Otherwise the menu won’t disappear whenthe user click outside the menu.
2.18.2.2 modify
Description
Modifies 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);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.18 Application.SysTray 253
2.18.2.3 remove
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 Events
2.18.3.1 onMouseMove
Description
This even is triggered when the cursor moves over the icon
Syntax
Application.SysTray.onMouseMove = function (){
// do something}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
254 FFish Script Objects Reference
2.18.3.2 onLClicked
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 mousebutton on the icon
Syntax
Application.SysTray.onLDblClicked = function (){
// do something}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.19 Application.Preferences 255
2.18.3.5 onRDblClicked
Description
This event is triggered when the user double-clicks the right mousebutton on the icon
Syntax
Application.SysTray.onRDblClicked = function (){
// do something}
2.19 Application.Preferences
Description
Changes the preferences options of Screen Savers at runtime. Thepreferences options are pre-defined in the dialog box ”Operationpanel”–”Screen Saver Definition”–”Preferences” of SWFKit UI
available: SWFKit Express, SWFKit, SWFKit Pro
2.19.1 Properties
2.19.1.1 wakeupMethod
Description
Sets or gets the method to exit the screen saver. This property corre-sponds to the ”Wake up on” group box in the dialog box ”Operationpanel”–”Screen Saver Definition”–”Preferences” of SWFKit UI
Syntax
Application.Preferences.wakeupMethod
Remarks
The property can be one or more of the following values:
1. $WULEFTBUTTON2. $WURIGHTBUTTON3. $WUMOUSEMOVE4. $WUKEYSTROKE5. $WUESC6. $WUHOTKEY
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
256 FFish Script Objects Reference
2.19.1.2 hotKey
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 files or text transferredby dragging and dropping. Not available for screen savers.
available: SWFKit Pro
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.20 Application.dragdrop 257
2.20.1 Properties
2.20.1.1 enable
Description
Boolean. Set the property to true to accept file or text dropping.
Syntax
Application.dragdrop.enable
Example
To accept a file or text transferred by dropping it into the mainwindow,
1. turn the enable property on
Application.dargdrop.enable = true;
2. write event handlers to accept the files or text
Application.dragdrop.onDropText= function (str)
{trace(str);
}
Application.dragdrop.onDropFiles =function (files)
{trace(files);
}
2.20.2 Events
2.20.2.1 onDragEnter Text
Description
This event is triggered when a text string have just been draggedinto the main window.
Syntax
Application.dragdrop.onDragEnter_Text =function ()
{}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
258 FFish Script Objects Reference
2.20.2.2 onDragEnter Files
Description
This event is triggered when files have just been dragged into themain 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 mainwindow.
Syntax
Application.dragdrop.onDragOver_Text =function ()
{}
2.20.2.4 onDragOver Files
Description
This event is triggered when files are dragging over the main window.
Syntax
Application.dragdrop.onDragOver_Files =function ()
{}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.20 Application.dragdrop 259
2.20.2.5 onDragLeave
Description
This event is triggered when the files or a text string have just beendragged 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 intothe 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 files have just been dropped into themain window.
Syntax
Application.dragdrop.onDropFiles =function (files)
{trace(files);
}
Parameters
files Array. Contains the name of the files being dragged and dropped
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
260 FFish Script Objects Reference
2.20.2.8 onDragGetData
Description
This event is triggered when a drag and drop operation is takingplace (drag data to another application). The data to be draggedto another application can and can only be provided in this eventhandler.
The event handler can return a string object or an image objectwhich 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 WordApplication.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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.21 Application.clipboard 261
2.21.1 Methods
2.21.1.1 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. Specifies the coordinates of the upper-leftand lower-right corners of a rectangle. The rectangle definesthe area of screen to copy. If you call the method withoutparameters, 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. Specifies the coordinates of the upper-leftand lower-right corners of a rectangle. The rectangle definesthe area of the movie to copy. If you call the method withoutparameters, it will copy the entire movie onto the clipboard.
Returns
Boolean. Returns true if successful, or false otherwise.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
262 FFish Script Objects Reference
2.21.1.3 copyText
Description
Copies text onto the clipboard.
Syntax
Application.clipboard.copyText(str)
Parameters
str Optional. String. Specifies 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 doesn’t contain text, this method will returnnull.
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 doesn’t contain a bitmap, thismethod will return null.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 Properties
2.22.1.1 progress
Description
Integer. If it is set to a value between 0 to 100, a progress bar controlwill appear on the first pane of the status bar and the position ofthe 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 Methods
2.22.2.1 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 toArray.length + 1, The text of the indicator 1 to Array.lengthwill be set to the corresponding string in the array. The widthof indicator 1 to Array.legnth will be set to fit its text. Thetext of indicator 0 will be set to ”Ready” and will be stretchedto fill the unused space.
Remarks
Retains text for the indicators.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
264 FFish Script Objects Reference
CAPS If an indicator’s text is set to this, it will display the statusof the ”Caps Lock” key. If the key is toggled, it’s enabled.Otherwise, it’s disabled.
NUM If an indicator’s text is set to this, it will display the statusof the ”Num Lock” key. If the key is toggled, it’s enabled.Otherwise, it’s disabled.
SCRL If an indicator’s text is set to this, it will display the statusof the ”Scroll Lock” key. If the key is toggled, it’s enabled.Otherwise, it’s disabled.
OVR If an indicator’s text is set to this, it will display the status ofthe ”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 specified indicator.
Syntax
Application.StatusBar.setPaneText(index, text)
Parameters
index Integer. Specifies the index of the indicator. The index of thefirst indicator is 0.
text String. Represents the text to set.
Remarks
Retains text for the indicators.
CAPS If an indicator’s text is set to this, it will display the statusof the ”Caps Lock” key. If the key is toggled, it’s enabled.Otherwise, it’s disabled.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.22 Application.StatusBar 265
NUM If an indicator’s text is set to this, it will display the statusof the ”Num Lock” key. If the key is toggled, it’s enabled.Otherwise, it’s disabled.
SCRL If an indicator’s text is set to this, it will display the statusof the ”Scroll Lock” key. If the key is toggled, it’s enabled.Otherwise, it’s disabled.
OVR If an indicator’s text is set to this, it will display the status ofthe ”Insert” key.
Returns
Boolean. If succeeds, returns true.
2.22.2.3 setPaneIcon
Description
Sets the icon of the specified indicator.
Syntax
Application.StatusBar.setPaneIcon(index, icon)
Parameters
index Integer. Specifies the index of the indicator. The index of thefirst 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 specified indicator.
Syntax
Application.StatusBar.setPaneWidth(index, width);
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
266 FFish Script Objects Reference
index Integer. Specifies the index of the indicator. The index of thefirst indicator is 0.
width Integer. Represents the new width of the indicator.The method does nothing when index is set to 0, for the first panewill always fill the unused space.
Returns
Boolean. If succeeds, returns true.
2.22.2.5 disablePane
Description
Disables or enables the specified indicator.
Syntax
Application.StatusBar.disablePane(index, disable);
Parameters
index Integer. Specifies the index of the indicator. The index of thefirst indicator is 0.
disable Boolean. Set it to true to disable the pane, or false to enableit. If the pane is disabled, its text won’t be drawn.
Returns
Boolean. If succeeds, returns true.
2.22.2.6 setPaneBorder
Description
Shows or hides the 3-D border around the specified indicator.
Syntax
Application.StatusBar.setPaneBorder(index, show)
Parameters
index Integer. Specifies the index of the indicator. The index of thefirst indicator is 0.
show Boolean. Set it to true to show the 3-D border around thespecified indicator.
Returns
Boolean. If succeeds, returns true.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.23 Menu 267
2.22.2.7 show
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
268 FFish Script Objects Reference
2.23.1 Properties
2.23.1.1 enableAccel
Description
Boolean. You must set this property to true to enable the shortcutsof the menu items.
Syntax
Menu.enableAccel
Remarks
A menu item can have a shortcut key (does not have to) associatedwith it. Text that identifies the shortcut key is added to the menu-item text string. The shortcut text appears to the right of the menuitem name, after a backslash and tab character (Ä). For example,
\&Close\\tAlt+F4
represents a Close command with the ALT+F4 key combination asits shortcut key.
When the property is set to true, SWFKit will enable all shortcutkeys of the sub items of the menu at once. Otherwise, it will disableall of the shortcut keys.
2.23.2 Methods
2.23.2.1 load
add
Loads a pre-created menu
Syntax
Menu.load(name)
Parameters
name String. Specifies the name of the menu to load. The menu musthave been created by the Menu Creator.
Returns
Boolean. returns true if the menu has been loaded successfully.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.23 Menu 269
Examples
var m = new Menu;m.load("test");m.setMenu();m.enableAccel = true;
2.23.2.2 setMenu
Description
Sets the menu as the main menu. The menu must have been createdby 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 filledwith menu items by using the appendItem and insertItem methods
Syntax
Menu.createMenu()
Parameters
None
Returns
Boolean.
Examples
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 canbe filled with menu items by using the appendItem and insertItemmethods. You can display the popup menu by using the showmethod.
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(identifier, name[, icon]); // Appends a menuitem with identifier and caption
3. Menu.appendItem(); // Appends a separator
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.23 Menu 271
Parameters
submenu A menu object. Represents a pop up menu to be appended.name String. Specifies the caption of the menu item.
Eg. &New\tAlt+N
identifier String. Specifies the unique identifier of the menu item.icon String. Optional. Specifies the icon name of the menu item. It
can be the full path name of an icon on the disk, or a relativepath of an icon in the attachment list.
If the method takes no parameters, a separator will be appended.
Returns
Boolean.
2.23.2.6 insertItem
Description
Inserts a new menu item to the specified position of the menu.
Syntax
1. Menu.insertItem(pos, submenu, name);// Inserts a popup menu2. Menu.insertItem(pos, identifier, name[, icon]); // Inserts a menu
item with identifier and caption3. Menu.insertItem(pos); // Inserts a separator
Parameters
pos Integer. Starts from 0. Specifies the position of the insertionto take place.
submenu A menu object. Represents a pop up menu to be inserted.name String. Specifies the caption of the menu item.
Eg. &New\tAlt+N
identifier String. Specifies the unique identifier of the menu item.icon String. Optional. Specifies the icon name of the menu item. It
can be the full path name of an icon on the disk, or a relativepath of an icon in the attachment list.
Returns
Boolean.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
272 FFish Script Objects Reference
2.23.2.7 removeItem
Description
Removes a menu item at the specified position of the menu.
Syntax
Menu.removeItem(pos);
Parameters
pos Integer. Starts from 0. Specifies the position of menu item tobe removed.
Returns
Boolean.
2.23.2.8 getSubMenu
Description
Gets the drop-down or popup menu activated by the menu item atthe specified position
Syntax
Menu.getSubMenu(pos);
Parameters
pos Integer. Starts from 0. Specifies the position of menu item thatactivates the drop-down menu or popup menu to be retrieved.
Remarks
When the parent of the sub menu is destroyed, the sub menu re-turned by this method will be invalid. For example,
var menu = new Menu;menu.load("main");menu = menu.getSubMenu(0);FlashPlayer.onContextMenu = function (){
menu.show();}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.23 Menu 273
The code won’t work, for the ”menu” variable represents the submenu, when the script is finished, 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.
2.23.2.9 show
Description
Displays a popup menu
Syntax
Menu.show([x, y]);
Parameters
x, y Integer. Optional. Specifies the position to show the popupmenu.
If the method takes no parameters, the menu will be displayed atthe position of the cursor.
Returns
String. The identifier of the menu item that has been chosen. Iffailed, returns null. The method won’t return until a menu itemhas been clicked or user clicked outside the menu. If the users clickoutside the menu, it also returns null.
Examples
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
274 FFish Script Objects Reference
var menu = new Menu;menu.createPopupMenu();menu.appendItem("id0", "item 0", "525flop1.ico");menu.appendItem("id1", "item 1", "audio.ico");menu.appendItem();menu.appendItem("id2", "item 2", "cddrive.ico");menu.appendItem("id3", "item 3", "clsdfold.ico");
switch (menu.show()){case "id0":
trace("item 0!");break;
}
2.23.3 Events
2.23.3.1 onCommand
Description
Fires when a menu item has been clicked or a shortcut key of themenu item has been pressed(if the shortcut keys are enabled)
Syntax
Menu.onCommand = function (identifier){
// do something}
SWFKit transfers the identifier 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 0", "525flop1.ico");menu.appendItem("id1", "item 1", "audio.ico");menu.appendItem();menu.appendItem("id2", "item 2", "cddrive.ico");menu.appendItem("id3", "item 3", "clsdfold.ico");
mainMenu.appendItem(menu, "Test");mainMenu.setMenu();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 thisevent to change the state of the menu item. Not available for Screensavers.
Syntax
Menu.onUpdateItem = function (identifier, state){
// do something}
SWFKit transfers the identifier of the menu item to the event handler. Thestate 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 bedisabled.
check Boolean. If you set it to true in the event handler, the menu item will bechecked.
caption String. You can change the caption of the menu item by setting thisproperty.
Examples
Menu.onUpdateItem = function (id, state){
switch (id){case "id0":
// disable the menu item
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
276 FFish Script Objects Reference
state.enable = false;break;
}}
2.24 Encryption
Description
An object can do encrypt and decrypt.
available: SWFKit Express, SWFKit, SWFKit Pro
2.24.1 Methods
2.24.1.1 blowfishEncode
Description
Do blowfish encode.
Syntax
Encryption.blowfishEncode(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 blowfishDe-code method with the same key and the returned string value.
Examples
trace(Encryption.blowfishEncode("test","message"));
trace(Encryption.blowfishDecode("test","2KRNdy7o/90="));
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.24 Encryption 277
2.24.1.2 blowfishDecode
Description
Do blowfish decode.
Syntax
Encryption.blowfishDecode(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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
278 FFish Script Objects Reference
2.24.1.4 md5File
Description
Calculates MD5 message digest of a file
Syntax
Encryption.md5File(file);
Parameters
file String. Specifies the input file 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 desDecodemethod with the same key and the returned string value.
Examples
trace(Encryption.desEncode("test","message"));
trace(Encryption.desDecode("test","QrfRWpfYc9Q="));
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.24 Encryption 279
2.24.1.6 desDecode
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 file. A file encrypted by this method can be de-crypted by the method decFile. Static
Syntax
Encryption.encFile(key, inputFile, outputFile);
Parameters
key String. An unique key used to encrypt files
inputFile String. Specifies a disk file to encrypt
outputFile String. Specifies a disk file to save the encrypted data
Returns
Boolean. Returns true if successful; otherwise returns false;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
280 FFish Script Objects Reference
2.24.1.8 decFile
Description
Decrypts a disk file that is encrypted by the encFile method. Static
Syntax
Encryption.decFile(key, inputFile, outputFile);
Parameters
key String. An unique key used to encrypt files
inputFile String. Specifies a disk file to decrypt
outputFile String. Specifies a disk file to save the decrypted data
Returns
Boolean. Returns true if successful; otherwise returns false;
2.25 DiskInfo
Description
Retrieves the information of the specified hard disk
available: SWFKit Express, SWFKit, SWFKit Pro
Syntax
new DiskInfo(index)
Parameters
index Integer. It can be 0, 1, 2, 3.
0 The master disk of the primary controller1 The slave disk of the primary controller2 The master disk of the secondary controller3 The slave disk of the secondary controller
Examples
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.25 DiskInfo 281
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);
}}
2.25.1 Properties
2.25.1.1 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
282 FFish Script Objects Reference
2.25.1.4 bufferSize
Description
Integer. Returns the buffer size of the hdd. Read-only.
Syntax
di.bufferSize
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 file or save to file.
available: SWFKit Express, SWFKit, SWFKit Pro
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.26 DataFile 283
2.26.1 Methods
2.26.1.1 load
Description
Loads all variables from a data file. The variables are saved in thefile by using the save method.
Syntax
DataFile.load(file)
Parameters
file String. Specifies the data file 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 file, decrypts its content and read values of the variablesin the data file. The data file must be saved by the ”saveAndEnc”method.
Syntax
DataFile.loadAndDec(file)
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
284 FFish Script Objects Reference
file String. Specifies the data file name
Returns
Boolean. Returns false if failed.
2.26.1.3 save
Description
Saves variables into a data file. If the data file exists, new variableswill be appended to the end of the file.
Syntax
DataFile.save(file, var0[, var1, ..., varn])
Parameters
file String. Specifies the data file name
var0, var1, ..., varn String. Specifies the names of the variables to be saved. Onlythe global variables can be saved, and supported data typesare: Integer, Float, String, Array, Object, Boolean. The arrayto be saved cannot contain any item with unsupported types.So does the objects.
Returns
Boolean. Returns false if failed.
Examples
var x = [1, [0.5, "string", 3], "sdf"];var y = 9;var z = new Object;var m = false;z.x = [1, 2, 3];z.y = "string";z.z = 1.23;
DataFile.save("c:\\1.txt", "x", "y", "z", "m");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.27 DesktopToy 285
2.26.1.4 saveAndEnc
Description
Saves variables into a data file and encrypts the data file. Whetherthe data file exists or not, it will be overwrite by this method.
Syntax
DataFile.saveAndEnc(file, var0[, var1, ..., varn])
Parameters
file String. Specifies the data file namevar0, var1, ..., varn String. Specifies the names of the variables to be saved. Only
the global variables can be saved, and supported data typesare: Integer, Float, String, Array, Object, Boolean. The arrayto 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 file from disk.
Syntax
DataFile.remove(file)
Parameters
file String. Specifies the data file name
Returns
Nothing
2.27 DesktopToy
Description
Controls a desktop toy.
available: SWFKit Express, SWFKit, SWFKit Pro
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
286 FFish Script Objects Reference
2.27.1 Properties
2.27.1.1 followCursor
Description
Boolean. If set to true, the desktop toy will move and follow thecursor.
Syntax
DesktopToy.followCursor
2.27.2 Methods
2.27.2.1 act
Description
Makes the desktop toy to moving on the screen.
Syntax
DesktopToy.act(v, vangle, a, aangle, attenuation, bouncing)
Parameters
v Integer. Specifies the initial velocity. 2.1
vangle Integer. Specifies the angle of the initial velocity.
a Integer. Specifies the initial acceleration
aangle Integer. Specifies the angle of the initial acceleration 2.1
attenuation Integer. Specifies the bouncing attenuation.
bouncing Boolean. Set it to true to support bouncing when it reachesthe bounds of the screen. Otherwise it stops while reaches thebounds of the screen.
Returns
Nothing.
Examples
//do throwingDesktopToy.act(100, 315, 100, 90, 30, true);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.27 DesktopToy 287
Figure 2.1: The angle of velocity or acceleration
2.27.2.2 stop
Description
Stops the action started by the act method.
Syntax
DesktopToy.stop()
Parameters
Nothing
Returns
Nothing
2.27.3 Events
2.27.3.1 onStop
Description
Fires when the moving desktop toy stops. This event can be firedby the stop method, or the desktop toy reaches the bounds of thescreen while the parameter ”bouncing” is set to false.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
288 FFish Script Objects Reference
dt.onStop = function(left, top){
// Do something}
SWFKit will pass the left and top position of the desktop toy windowto 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. Specifies the handle of the window.
2.28.1 Properties
2.28.1.1 caption
Description
String. Gets or sets the caption of the specified window.
Syntax
wnd.caption
Example
var wnd = getMainWnd();wnd.caption = "This is a demo";
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 289
2.28.1.2 left
Description
Integer. Gets or sets the position of the left side of the specifiedwindow.
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 specified 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 specified window.
Syntax
wnd.width
Example
var wnd = getMainWnd();trace(wnd.width);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
290 FFish Script Objects Reference
2.28.1.5 height
Description
Integer. Gets or sets the height of the specified 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 specifiedwindow.
Syntax
wnd.parent
Example
var wnd = getMainWnd();w.parent = wnd;
2.28.1.7 handle
Description
Integer. Gets the handle of the specified window. Read-only.
Syntax
wnd.handle
Example
var wnd = getMainWnd();trace(wnd.handle);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 291
2.28.1.8 className
Description
String. Retrieves the name of the class to which the specified windowbelongs. Read-only.
Syntax
wnd.className
Example
var wnd = getMainWnd();trace(wnd.className);
2.28.1.9 visible
Description
Boolean. Gets the visibility of the specified window. Read-only.
Syntax
wnd.visible
Example
var wnd = getMainWnd();trace(wnd.visible);
2.28.1.10 enable
Description
Boolean. Enables or disables the specified window.
Syntax
wnd.enable
Example
var wnd = getMainWnd();wnd.enable = false;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
292 FFish Script Objects Reference
2.28.1.11 clientRect
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 specified window. It can be oneof the following values:
Value Descriptionnormal The window is in normal statemaximized The window is maximizedminimized The window is minimize
Syntax
wnd.windowState
Example
var wnd = getMainWnd();trace(wnd.windowState);
2.28.2 Methods
2.28.2.1 show
Description
Shows the specified window.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 293
Syntax
wnd.show()
Parameters
None
Returns
Nothing.
2.28.2.2 hide
Description
Hides the specified window.
Syntax
wnd.hide()
Parameters
None
Returns
Nothing.
Example
//Hides the taskbar
var tb = Window.find("Shell_TrayWnd");if (tb != null) tb.hide();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
294 FFish Script Objects Reference
2.28.2.3 close
Description
Closes the specified 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 specified window.
Syntax
wnd.getChildren()
Parameters
None
Returns
An array contains all child windows of the specified window.
Example
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 295
//Get the Flash player windowfunction 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;
}
2.28.2.5 getWindowsByName
Description
Gets top-level windows with the specified 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 specified name. Ifyou have not specified a name, the method will return all windowson the desktop.
Example
//Hides the taskbar
var ws = Window.getWindowsByName();for (i = 0; i < ws.length; i++)
trace(ws[i].caption);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
296 FFish Script Objects Reference
2.28.2.6 find
Description
Retrieves a window to the top-level window whose class name andwindow name match the specified strings. Static
Syntax
wnd.find([classname[, windowname]])
Parameters
classname Optional. Specifies the class name
windowname Optional. Specifies the window name
Returns
A window Object.
Example
//finds the taskbar
//finds the windows task barvar tb = Window.find("Shell_TrayWnd");
2.28.2.7 bringToTop
Description
Puts the specified window into the foreground and activates thewindow.
Syntax
wnd.bringToTop()
Parameters
None
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 297
2.28.2.8 modifyStyle
Description
Modifies the style of the specified window.
Syntax
wnd.modifyStyle(remove[, add])
Parameters
remove Specifies the style to remove.
add Specifies the style to add.The windows style can be combine of the following values:
WS_OVERLAPPED = 0x00000000WS_POPUP = 0x80000000WS_CHILD = 0x40000000WS_MINIMIZE = 0x20000000WS_VISIBLE = 0x10000000WS_DISABLED = 0x08000000WS_CLIPSIBLINGS = 0x04000000WS_CLIPCHILDREN = 0x02000000WS_MAXIMIZE = 0x01000000WS_CAPTION = 0x00C00000WS_BORDER = 0x00800000WS_DLGFRAME = 0x00400000WS_VSCROLL = 0x00200000WS_HSCROLL = 0x00100000WS_SYSMENU = 0x00080000WS_THICKFRAME = 0x00040000WS_GROUP = 0x00020000WS_TABSTOP = 0x00010000WS_MINIMIZEBOX = 0x00020000WS_MAXIMIZEBOX = 0x00010000
Returns
Nothing
2.28.2.9 modifyStyleEx
Description
Modifies the extended style of the specified window.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
298 FFish Script Objects Reference
Syntax
wnd.modifyStyleEx(remove[, add])
Parameters
remove Specifies the extended style to remove.
add Optional. Specifies the extended style to add.The windows extended style can be combine of the followingvalues:
WS_EX_DLGMODALFRAME = 0x00000001WS_EX_NOPARENTNOTIFY = 0x00000004WS_EX_TOPMOST = 0x00000008WS_EX_ACCEPTFILES = 0x00000010WS_EX_TRANSPARENT = 0x00000020WS_EX_MDICHILD = 0x00000040WS_EX_TOOLWINDOW = 0x00000080WS_EX_WINDOWEDGE = 0x00000100WS_EX_CLIENTEDGE = 0x00000200WS_EX_CONTEXTHELP = 0x00000400WS_EX_RIGHT = 0x00001000WS_EX_LEFT = 0x00000000WS_EX_RTLREADING = 0x00002000WS_EX_LTRREADING = 0x00000000WS_EX_LEFTSCROLLBAR = 0x00004000WS_EX_RIGHTSCROLLBAR = 0x00000000WS_EX_CONTROLPARENT = 0x00010000WS_EX_STATICEDGE = 0x00020000WS_EX_APPWINDOW = 0x00040000
Returns
Nothing
2.28.2.10 move
Description
Changes the position of the specified window.
Syntax
wnd.move(left[, top[, right[, bottom]]])
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 299
left Specifies the new position of the left side of the window
top Specifies the new position of the top of the window
right Specifies the new position of the right side of the window
bottom Specifies the new position of the bottom of the window
Returns
Nothing
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 effects when showing or hiding win-dows. There are three types of animation: roll, slide, and alpha-blended fade
Syntax
wnd.animate(time, flag)
Parameters
time Specifies how long it takes to play the animation, in millisec-onds. Typically, an animation takes 200 milliseconds to play.
flag Specifies the type of animation. This parameter can be one ormore of the following values
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
300 FFish Script Objects Reference
Value Name Description
0x00040000 AW SLIDE Uses slide animation. By default, roll ani-mation is used. This flag is ignored whenused with AW CENTER.
0x00020000 AW ACTIVATE Activates the window. Do not use thisvalue with AW HIDE.
0x00080000 AW BLEND Uses a fade effect. This flag can be usedonly if it is a top-level window.
0x00010000 AW HIDE Hides the window. By default, the windowis shown.
0x00000010 AW CENTER Makes the window appear to collapse in-ward if AW HIDE is used or expand out-ward if the AW HIDE is not used.
0x00000001 AW HOR POSITIVE Animates the window from left to right.This flag can be used with roll or slideanimation. It is ignored when used withAW CENTER or AW BLEND.
0x00000002 AW HOR NEGATIVE Animates the window from right to left.This flag can be used with roll or slideanimation. It is ignored when used withAW CENTER or AW BLEND.
0x00000004 AW VER POSITIVE Animates the window from top to bottom.This flag can be used with roll or slideanimation. It is ignored when used withAW CENTER or AW BLEND.
0x00000008 AW VER NEGATIVE Animates the window from bottom to top.This flag can be used with roll or slideanimation. It is ignored when used withAW CENTER or AW BLEND.
Returns
Boolean
2.28.2.13 fly
Description
Makes the window fly at the corner of the screen.
Syntax
wnd.fly(corner, direction, in[, time])
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 301
Parameters
corner Integer. Specifies the corner of the screen.
0 – lower-right1 – upper-right2 – upper-left3 – lower-left
direction Integer. Specifies the direction
0 – horizon1 – vertical2 – 45-degree
in Boolean. If true, the window will fly in, otherwise fly out.
time Integer. Specifies the flying speed in millisecond.
Returns
Nothing
2.28.2.14 fly2
Description
Makes the window fly.
Syntax
wnd.fly2(x0, y0, x1, y1[, time])
Parameters
x0, y0 Integer. Specifies the start position.
x1, y1 Integer. Specifies the end position.
time Integer. Specifies the flying speed in millisecond.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
302 FFish Script Objects Reference
2.28.2.15 center
Description
Places the window at the center of the screen.
Syntax
wnd.center()
Parameters
None
Returns
Nothing
2.28.3 Events
2.28.3.1 onClose
Description
Fires when the specified window is about to close. This event is firedafter the onQueryClose event.
Syntax
wnd.onClose = function (){
body}
2.28.3.2 onQueryClose
Description
Fires when the specified window is about to close. The event givesa chance to determine if the window is allowed to close.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 303
wnd.onQueryClose = function (){
body}
The handler function must return a Boolean value. The value oftrue indicates that the window is allowed to close. While a returnvalue 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;
}
2.28.3.3 onEnter
Description
Fires when the mouse has just entered the client area of the specifiedwindow.
Syntax
wnd.onEnter = function (){
body}
Remarks
If you want to handle the onEnter event in a projector, define ahandler function for the Flash Player window like this.
var fp = FlashPlayer.window();fp.onEnter = function (){
trace("mouse enter");};
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
304 FFish Script Objects Reference
2.28.3.4 onLeave
Description
Fires when the mouse has just left the client area of the specifiedwindow.
Syntax
wnd.onLeave = function (){
body}
Remarks
If you want to handle the onLeave event in a projector, define ahandler 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 specifiedwindow.
Syntax
wnd.onHover = function (){
body}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.28 Window Object 305
2.28.3.6 onSize
Description
Fires when the size of the window is changed.
Syntax
wnd.onSize = function(type, width, height){
body}
Parameters
type Integer. Specifies the type of resizing requested0 The window has been resized, neither maximized nor
minimized1 The window has been minimized.2 The window has been maximized.
width Integer. Specifies the new width of the client area ofthe window.
height Integer. Specifies the new height of the client area ofthe window.
2.28.3.7 onMessage
Description
This event will be fired 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
306 FFish Script Objects Reference
.
Figure 2.2: Data exchanging
2.29 FlashPlayer Object
Description
Provides access to the Macromedia Flash Player. This object encap-sulates all methods of the Macromedia Flash Player ActiveX object.Furthermore, This object provides a way to exchange data betweenthe 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 objectthat can be used without construction.
Remarks
The object provides an easy way to exchange data between the FFishScript and the Macromedia Flash Action Script. The picture 2.2describes the mechanism of the Data Exchanging.
First, the bindData method binds the Action Script variables to theFlashPlayer object. The FlashPlayer Object maintains a propertylist, which contains properties with the same names as the bound Ac-tion Script variables. The FlashPlayer object transfers data betweenthe bound Action Script variables and the corresponding properties.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 307
Second, the updateData method performs the exchanging. A call tothe updateData method with a true argument transfers data fromAction script to the FlashPlayer object. While a call to the update-Data method with a false argument transfers data from the Flash-Player object to Action Script. The updateData method transfersdata all at once.
The unbindData method unbinds Action Script variables. The un-bindAll method unbinds all bound Action Script variables. The twomethods make the FlashPlayer object to remove the correspondingproperties.
The FlashPlayer object only binds numbers, Booleans or strings.The bindData method only accepts variables specified in the dot syn-tax. Furthermore, remember to specify the full path of the variables.With the data exchange mechanism, you can access an Action scriptvariable as if it is a property of the FlashPlayer object. The Flash-Player object automatically converts the data types. The propertyname is exactly the same as the variable name you bind. For exam-ple, if you bind a variable named ” root.x”, you must access it withexpression ”FlashPlayer. root.x”. The expression ”FlashPlayer.x”does not work, though ” root.x” and ”x” specifies the same variablein 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);
2.29.1 Properties
2.29.1.1 totalFrames
Description
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
308 FFish Script Objects Reference
Integer. Returns the total number of frames in the movie. Read-only.
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 309
2.29.1.5 alignMode
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");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
310 FFish Script Objects Reference
2.29.1.9 frameNum
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 311
2.29.1.13 scale
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 flash player will launchthe print dialog when it is about to process a print something. Gen-erally when you call a print method in Action script, the Flash Playerwill 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, andthe 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 thisproperty to set the printer properties such as orientation and paper-Size. This property is effective only if the showPrintDlg propertyis set to false. When “FlashPlayer.printerProperties.orientation” isset to 1, the orientation of the paper will be portrait; if it is set to2, the orientation will be landscape. The meaning of the “Flash-Player.printerProperties.paperSize” property is the same as that ofthe “Printer.paperSize”, the only difference is that the former prop-erty is used to control the printer used by the flash player, while thelatter is to control the printer used by swfkit.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
312 FFish Script Objects Reference
Syntax
FlashPlayer.printerProperties
2.29.2 Methods
2.29.2.1 bindData
Description
Binds Action Script variables to the FlashPlayer Object
Syntax
FlashPlayer.bindData(var0, var1, . . . , varn)
Parameters
var0, var1, . . . , varn Specifies 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 Specifies the names of the Action Script variables to unbind.
Returns
Nothing
Example
FlashPlayer. unbindData("text", "movieClip1.x");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 313
2.29.2.3 unbindAll
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 Flash-Player properties.
Syntax
FlashPlayer.updateData(get)
Parameters
get Boolean. If true, data transfer from the bound Action Scriptvariables to the corresponding FlashPlayer properties. Other-wise, transfer from the FlashPlayer variables to the correspond-ing 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");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
314 FFish Script Objects Reference
2.29.2.5 getArray
Description
Gets an array from Action Script.
Syntax
FlashPlayer.getArray(name)
Parameters
name Specifies 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 Specifies 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 defined as an array inAction Script explicitly.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 315
2.29.2.7 getObject
Description
Gets an object from Action Script.
Syntax
FlashPlayer.getObject(name, prop0[, prop1, ..., propn])
Parameters
name Specifies the name of the object to retrieve.prop0...propn Specifies 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 Specifies 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 defined as an object inAction Script explicitly.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
316 FFish Script Objects Reference
2.29.2.9 setZoomRect
Description
Zooms in on a rectangular area of the movie.
Syntax
FlashPlayer.setZoomRect(left, top, right, bottom)
Parameters
left, top, right, bootom Specifies the coordinates of the rectangle. The units of thecoordinates 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 specified by percent.
Syntax
FlashPlayer.zoom(percent)
Parameters
percent Specifies the scale factor.
Returns
Nothing
Example
FlashPlayer.zoom(200);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 317
2.29.2.11 pan
Description
Pans a zoomed-in movie. specified by x and y. Use mode to specifywhether 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, thecoordinates are percent of the window. Pan does not pan beyondthe boundaries of the zoomed-in movie.
Syntax
FlashPlayer.pan(x, y, mode)
Parameters
x, y Specifies the coordinates to pan.
mode Specifies whether the values for x and y are pixels or a percentof 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
318 FFish Script Objects Reference
2.29.2.13 stop
Description
Stops playing the movie.
Syntax
FlashPlayer.stop()
Parameters
None
Returns
Nothing
2.29.2.14 back
Description
Goes back.
Syntax
FlashPlayer.back()
Parameters
None
Returns
Nothing
2.29.2.15 forward
Description
Goes forward.
Syntax
FlashPlayer.forward()
Parameters
None
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 319
2.29.2.16 rewind
Description
Goes to the first frame.
Syntax
FlashPlayer.rewind()
Parameters
None
Returns
Nothing
2.29.2.17 gotoFrame
Description
Goes to the specified frame.
Syntax
FlashPlayer.gotoFrame(frame)
Parameters
frame Specifies the frame number.
Example
FlashPlayer.gotoFrame(24);
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
320 FFish Script Objects Reference
2.29.2.18 currentFrame
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 playerso far; possible values are from 0 to 100.
Syntax
FlashPlayer.percentLoaded()
Parameters
None
Returns
Integer
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 321
2.29.2.21 flashVersion
Description
Returns the version of the Flash Player.
Syntax
FlashPlayer.flashVersion()
Parameters
None
Returns
Integer
2.29.2.22 loadMovie
Description
Loads the specified movie.
Syntax
FlashPlayer.loadMovie(layerNumber, movie)
Parameters
layerNumber Specifies the layer number
movie Specifies the movie to load.
Example
FlashPlayer.loadMovie(1, "c:\\test.swf");
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
322 FFish Script Objects Reference
2.29.2.23 setVariable
Description
Sets the value of the specified variable.
Syntax
FlashPlayer.setVariable(name, value)
Parameters
name Specifies the name of the variable
value Specifies the value to set.
Example
FlashPlayer.setVariable("_root.var0", "myvalue");
Returns
Nothing
2.29.2.24 getVariable
Description
Gets the value of the specified variable.
Syntax
FlashPlayer.getVariable(name)
Parameters
name Specifies the name of the variable
Example
trace(FlashPlayer.getVariable("_root.var0"));
Returns
String
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 323
2.29.2.25 targetGotoFrame
Description
For the timeline of the specified target, goes to the specified frame.
Syntax
FlashPlayer.targetGotoFrame(target, framenumber)
Parameters
target Specifies the target
framenumber Specifies the frame number to go.
Example
FlashPlayer.targetGotoFrame("_root", 24);
Returns
Nothing
2.29.2.26 targetGotoLabel
Description
For the timeline of the specified target, goes to the specified label.
Syntax
FlashPlayer.targetGotoLabel(target, label)
Parameters
target Specifies the target
label Specifies the label to go.
Example
FlashPlayer.targetGotoLabel("_root", "label");
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
324 FFish Script Objects Reference
2.29.2.27 targetCurrentFrame
Description
Gets the current frame number of the specified target.
Syntax
FlashPlayer.targetCurrentFrame(target)
Parameters
target Specifies the target
Returns
Integer
2.29.2.28 targetCurrentLabel
Description
Gets the current frame label of the specified target.
Syntax
FlashPlayer.targetCurrentLabel(target)
Parameters
target Specifies the target
Returns
String
2.29.2.29 targetPlay
Description
Starts playing the specified target.
Syntax
FlashPlayer.targetPlay(target)
Parameters
target Specifies the target
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 325
2.29.2.30 targetStopPlay
Description
Stops playing the specified target.
Syntax
FlashPlayer.targetStopPlay(target)
Parameters
target Specifies the target
Returns
Nothing
2.29.2.31 targetGetProperty
Description
For the timeline of the specified target, gets the specified property.
Syntax
FlashPlayer.targetGetProperty(target, property)
Parameters
target Specifies the target
property Integer. Specifies 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
326 FFish Script Objects Reference
8 WIDTH9 HEIGHT
10 ROTATION11 TARGET12 FRAMESLOADED13 NAME14 DROPTARGET15 URL( url)
Returns
String
Example
Gets alpha property of level0
FlashPlayer.targetGetProperty("_root", 6);
2.29.2.32 targetSetProperty
Description
For the timeline of the specified target, sets the value of the specifiedproperty. See: targetGetProperty
Syntax
FlashPlayer.targetSetProperty(target, property, value)
Parameters
target Specifies the targetproperty Specifies the property to set.
value String. Specifies the value to set
Returns
Nothing
Example
Sets alpha property of level0 to 50
FlashPlayer.targetSetProperty("_root", 6, "50");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 327
2.29.2.33 targetCallFrame
Description
For the timeline of the specified target, executes the action in thespecified frame.
Syntax
FlashPlayer.targetCallFrame(target, framenumber)
Parameters
target Specifies the target
framenumber Specifies the frame number to call.
Returns
Nothing
2.29.2.34 targetCallLabel
Description
For the timeline of the specified target, executes the action in theframe specified by label.
Syntax
FlashPlayer.targetCallLabel(target, label)
Parameters
target Specifies the target
label Specifies the frame label.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
328 FFish Script Objects Reference
2.29.2.35 targetGetPropertyNum
Description
For the timeline of the specified target, gets the specified property.See: targetGetProperty. This method returns a number.
Syntax
FlashPlayer.targetGetPropertyNum(target, property)
Parameters
target Specifies the target
property Specifies the property to get.
Returns
Number
2.29.2.36 targetSetPropertyNum
Description
For the timeline of the specified target, sets the value of the specifiedproperty. See: targetSetProperty. This method sets the propertywith a float number.
Syntax
FlashPlayer.targetSetPropertyNum(target, property, value)
Parameters
target Specifies the target
property Specifies the property to set.
value Float. Specifies the value to set
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.29 FlashPlayer Object 329
2.29.2.37 getMovieInfo
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 thexMin, 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 win-dows client coordinates system
Syntax
FlashPlayer.movieToWindow(left, right, top, bottom)
Parameters
left A number specifies the x-coordinate of the upper-left corner ofthe rectangle
right A number specifies the x-coordinate of the lower-right cornerof the rectangle.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
330 FFish Script Objects Reference
top A number specifies the y-coordinate of the upper-left corner ofthe rectangle
bottom A number specifies the y-coordinate of the lower-right cornerof 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 Events
2.29.3.1 onContextMenu
Description
Fires when the users right click the movie.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.30 RegExp Object 331
Syntax
FlashPlayer.onContextMenu = function (){}
2.30 RegExp Object
Description
Contains a regular expression pattern used when searching stringsfor 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 ignore caseg global search for all occurrences of pattern
m multilinegi global search, ignore case
Example
r = /ab+/gi;s = "abbdabbcabdaBa";trace(r.exec(s));//output: abbre = 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 regu-lar expression when used for pattern matching:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
332 FFish Script Objects Reference
Subexpression Matched Text
literal character Any source character which is a ReLiteralCharacter.
. Any character except newline.
ˆ Start of string. The matched substring must begin withthe the first character of the string (after the portion ig-nored as specified by lastIndex). This character is onlyspecial when it appears as the first character of the reg-ular expression.
$ End of string. The matched substring must end withthe the last character of the string. This character isonly special when it appears as the last character of theregular expression.
x* Zero or more consecutive matches with subexpression x.The matched substrings need not be identical.
x+ One or more consecutive matches with subexpression x.The matched substrings need not be identical.
x? Zero or one consecutive matches with subexpression x.
X{n} Exactly n consecutive matches with subexpression x.
X{n,} At least n consecutive matches with subexpression x.
X{m,n} At least m and at most n consecutive matches withsubexpression x.
X{n} Exactly n consecutive matches with subexpression x.
(x) The same pattern as subexpression x. The matched sub-string is available for use in a subsequent ”\n” pattern.
xy The subexpression x followed by the subexpression y.
x|y Either of the subexpressions x or y.
[pqr] Any character in pqr, which is a sequence of one or moresource characters and/or subranges of the form s-t. Ifthe Unicode encoding of s is greater than the Unicodeencoding of t, a runtime error is generated. Only thecharacters ˆ, -, ] and need to be escaped when intendedas literal characters. Theˆ character need be escapedonly if it is the first character in pqr. The C characterneed not be escaped if it is the first or last character, or ifit immediately follows a subrange. The escape sequenceshave their usual meanings except for \b which matchesthe backspace character; \B which matches B; and, forsubranges only, \d, \D, \s, \S, \w and\W, which matchd, D, s, S, w and W, respectively.
[p̂qr] Any character not matched by [pqr], including newline ifpqr does not contain newline.
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.30 RegExp Object 333
continued from the previous page
Subexpression Matched Text
\f The formfeed character.
\n The newline character.
\r The carriage return character.
\t The tab character.
\v The vertical tab character.
\s Any whitespace character; equivalent to [\f\n\r\t\v].
\S Any non-whitespace character; equivalent to[ˆ\f\n\r\t\v].
\d Any decimal digit; equivalent to [0-9].
\D Any character except a decimal digit; equivalent to [ˆ0-9].
\w Any character valid in an identifier; equivalent to [a-zA-Z0-9 ].
\W Any character not valid in an identifier; equivalent to[a-zA-Z0-9 ].
\b Word boundary: a zero-length substring which isbounded on one side by a character which matches \wand on the other side by a character which matches \Wor the start of the string or the end of the string.
\B Non-word boundary: a zero-length substring which doesnot match \b.
\cX The character formed by an exclusive OR of the charactercode with 64.
\n Either an OctalEscapeSequence or a backreference equiv-alent to the exact substring most recently matched bythe nth parenthesized subexpression, as determined bythe opening left parenthesis of each such subexpression.If n begins with 0, or if the value of n (when parsedand converted as DecimalDigits) is greater than 9 andalso greater than the number of parenthesized subexpres-sions, then \n is an OctalEscapeSequence; otherwise \nis a backreference. If there is no corresponding paren-thesized subexpression, or if the subexpression does notparticipate in the match (because of the | operator or azero count), \n is treated as the empty string.
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
334 FFish Script Objects Reference
continued from the previous page
Subexpression Matched Text
If the ignoreCase property is true (this property is set by the switchparameter of the constructor) when a pattern match is performed,any letters in the string are matched without considering distinctionsbetween uppercase and lowercase.
An empty pattern matches the start of any string including theempty string.
The match and search method of String object modify the propertiesof RegExp just like the exec method of RegExp Object.
2.30.1 Properties
2.30.1.1 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 specifiedflags 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 specifiedflags contained the character ‘i’. Read-only.
Syntax
rgexp. ignoreCase
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.30 RegExp Object 335
2.30.1.4 multiline
Description
A boolean value indicating whether to perform a newline-sensitivematching
Syntax
rgexp. multiline
2.30.1.5 lastIndex
Description
It is an integer which specifies the string position at which to startthe next match. The lastIndex is modified by the exec or test methodwhen the global property is true. The following rules apply to valuesof lastIndex: If lastIndex is greater than the length of the string, thetest and exec methods fail, and lastIndex is set to zero. If lastIndexis equal to the length of the string, the regular expression matchesif the pattern matches the empty string. Otherwise, the match failsand lastIndex is reset to zero. Otherwise, lastIndex is set to the nextposition following the most recent match.
Syntax
rgexp.lastIndex
2.30.1.6 input (or $ )
Description
Specifies the most recent string against which a regular expressionwas matched. Read-only. Static
Syntax
1. rgexp.input
2. rgexp.$
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
336 FFish Script Objects Reference
2.30.1.7 lastMatch
Description
Specifies the substring matched in the most recent regular expressionmatch. Read-only. Static
Syntax
rgexp.lastMatch
2.30.1.8 leftContext
Description
Specifies the portion of the input string which precedes the matchedsubstring in the most recent regular expression match.. Read-only.Static
Syntax
rgexp. leftContext
2.30.1.9 rightContext
Description
Specifies portion of input string which follows the matched substringin the most recent regular expression match. Read-only. Static
Syntax
rgexp. rightContext
2.30.1.10 $1 . . . $9
Description
Specifies the substrings matched by the corresponding parenthesizedsubexpressions in the most recent regular expression match. Read-only. Static
Syntax
rgexp.$n($1 . . . $9)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.30 RegExp Object 337
Example
re = new RegExp("d(b*)(d)","gi");str = "cdbBdbsbdbdzdd";trace(re.exec(str));//output: dbBd,bB,dtrace(re.$1);//output: bBtrace(re.$2);//output: b
2.30.1.11 lastParen
Description
Specifies the substring matched by the last parenthesized subexpres-sion in the most recent regular expression match. Read-only. Static
Syntax
rgexp. lastParen
2.30.2 Methods
2.30.2.1 compile
Description
Compiles a regular expression. Using this method to change thesearch string dynamicly.
Syntax
rgexp.compile(pattern, [switch])
Parameters
pattern The regular expression pattern to useswitch Optional. Available switches are:
i ignore caseg global search for all occurrences of pattern
m multilinegi global search, ignore case
Returns
A Boolean value, true for success, false for failure
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
338 FFish Script Objects Reference
2.30.2.2 exec
Description
Executes a search for a match in a specified 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 andreturns 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.31 ActiveXObject Object 339
new ActiveXObject(class | clsid | path)
Parameters
class This parameter uses the syntax server.type, the meaning ofeach 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 createpath Full path and name of the file containing the object to retrieve.
Returns
If Succeed, returns a new instance of the ActiveXObject object thatrepresents a reference to the corresponding ActiveX object. You canaccess any properties, methods and evens of the ActiveX object withthe new instance. If failed, return null.
Remarks
You can access properties, methods and evens exposed by the Ac-tiveX object just as invoke a method provides by any FFish ScriptObjects. Don’t worry about the details of COM interfaces, Variabletypes. FFish Script checks and converts variable types automat-ically. FFish Script supports ActiveX object events. Events aremethods defined in the outgoing interfaces of the ActiveX objectsused to notify its client of events. You can define an event handlingfunction and set to the event you care about. FFish Script Enginecalls the function when the ActiveX object fires the event. FFishScript also provides two static methods register and unregister toregister or unregister an ActiveX object.
Examples
//Example1 - create an ActiveXObject by specified a class nameword = 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 filedoc = new ActiveXObject("c:\\test.doc");doc.SaveAs("c:\\test1.doc");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
340 FFish Script Objects Reference
2.31.1 Methods
2.31.1.1 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. Oth-erwise 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");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.31 ActiveXObject Object 341
2.31.1.3 setProperty
Description
Sets value of the specified property. This method is useful when aproperty of the ActiveX object requires parameters. In that case,you can not set value of the property by using syntax like “ac-tivex.property = value;”, as syntax like “activex.property(arg) =value;” is not supported. However, there is no method like “get-Property”, as you can get value of such a property by using “varvalue = 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 canbe accessed by ffish script without registering the ActiveX object inWindows Registry. Generally, an ActiveX object must be registeredin Windows Registry before it can be accessed by any programminglanguage. However, the registration requires administrator privilege;it is inconvenient to use an ActiveX object in an application that willrun 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 infor-mation.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
342 FFish Script Objects Reference
progid The progid of the ActiveX object. An activex server may con-tain more than one activex objects, and every activex objecthas its progid. A progid is used to identify an activex object,so that the command “new ActiveXObject(progid);” will knowwhich activex object to create.
clsid Class identifier (CLSID) of the object. The activex server usesthis class identifier to create the object requested. When youcall “new ActiveXObject(progid);”, the ffish script engine willhave to find out the corresponding class identifier for the progidto create the requested object. If the activex object has beenregistered, the class identifier can be found in Windows Reg-istry; if it is not registered, the ffish script engine will use theclass identifier added by the “addObjectInfo” method. Theffish script engine holds progid-clsid pairs for the activex ob-jects added by the “addObjectInfo” method. For an activexobject that is not registered, the progid can be a unique stringspecified by yourself, not the original one of the activex ob-ject, only if you pass the customized unique progid to the con-structor of the ActiveXObject object, as from the progid-clsidpairs, the ffish script engine can still find out the proper classidentifier. To get the class identifier of an activex object, youcan use the COM/OLE object viewer, which can be found athttp://www.swfkit.com/swfkit/download.html#toolsFirst, use the COM/OLE object viewer to open the ActiveXserver dll by using the menu command “File− >View Type-Lib...”, for example, the flash.ocx. It will open the “ITypeLibviewer”.Then click the coclass item of the activex object in the left typetree, for example “coclass ShockwaveFlash”, and on the top ofright window, the uuid is the class identifier for the activex ob-ject: {D27CDB6E-AE6D-11CF-96B8-444553540000}. As youcan see, an ActiveX server may contains more than one activexobject, and each activex object has its unique class identifier.
typelib Identifier of the type library of the activex object. Just likefinding the class identifier of an ActiveX object, after you haveopened the “ITypeLib viewer”, on top of the right window, youwill find 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 identifier of the type library.
Returns
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.31 ActiveXObject Object 343
Boolean. If the information of the activex object is added success-fully, returns true; otherwise, returns false.
Example
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 ActiveXObject Object Events
Description
FFish Script supports ActiveX Object events. Events are methodsdefined in the outgoing interfaces of the ActiveX Objects used tonotify its client of events. You can define an event handling functionand set to the event you care about. FFish Script Engine calls thefunction when the ActiveX Object fires 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);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
344 FFish Script Objects Reference
conn.Close();//output:Will connect to mydb...Connect to mydb complete!
Remarks
FFish Script also supports ActiveX Object property notifications.The property notifications are sent when the ActiveX Objects changesor are about to change their properties that are marked with [Bin-able] and [RequestEdit] attributes.
The ActiveXObject object provides users with there property tohandle these notifications:
1. EnablePropertyNotify
2. OnPropertyChanged
3. OnPropertyWillChange
2.31.2.1 EnablePropertyNotify
Description
This property represents a Boolean value. If you want to receivethe property notification, set this property to true. Otherwise set tofalse. The default value of this property is false.
2.31.2.2 OnPropertyChanged
Description
This property represents a Boolean value. If you want to receivethe property notification, set this property to true. Otherwise set tofalse. The default value of this property is false.
2.31.2.3 OnPropertyWillChange
Description
This property represents a Boolean value. If you want to receivethe property notification, set this property to true. Otherwise set tofalse. The default value of this property is false.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.32 Enumerator Object 345
2.31.2.4 onError
Description
This event will be triggered when the ffish script engine encountersan 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 ob-ject.
Remarks
You can access collections the members of which are not directlyaccessible. You can also access some collections by using indexes, asif you are working with an array. If you use Enumerator, you canonly move the current item pointer to the first or next element of acollection.
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()){
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
346 FFish Script Objects Reference
var fld = e.item();trace(fld.Name);
}
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 Properties
2.32.1.1 atEnd
Description
Returns a Boolean value indicating if the enumerator is at the endof 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
Description
Returns the current item in the collection.
Syntax
Enum.item()
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.32 Enumerator Object 347
Returns
The item method returns the current item. If the collection is emptyor the current item is undefined, it returns undefined.
2.32.2 Methods
2.32.2.1 moveFirst
Description
Resets the current item in the collection to the first 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
348 FFish Script Objects Reference
2.33 RegKey Object
Description
Access windows registry.
available: SWFKit, SWFKit Pro
Syntax
new RegKey(keyname)
Parameters
keyname Specifies the key name of the registry. This parameter must be-gin with a predefined key name; follow with a series of backslash(‘́) and sub key name groups. The predefined key names are:Name MeaningHKCR HKEY CLASSES ROOTHKCC HKEY CURRENT CONFIGHKCU HKEY CURRENT USERHKLM HKEY LOCAL MACHINEHKU HKEY USERSHKPD HKEY PERFORMANCE DATAHKDD HKEY DYN DATA
Remarks
If the registry key specified by the keyname parameter has beensuccessfully 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 Properties
2.33.1.1 className
Description
Gets the key’s class name. Read-only
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.33 RegKey Object 349
Regkey.className
Returns
A String
2.33.1.2 newCreated
Description
Determines whether the key is new created by method create. Read-only
Syntax
Regkey.newCreated
Returns
If the key is a new created key, returns true. If the key is alreadyexists 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. Win9x 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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
350 FFish Script Objects Reference
2.33.2 Methods
2.33.2.1 create
Description
Create or open a registry key. Static
Syntax
Regkey.create(keyname[, class[, samDesired]])
Parameters
keyname Specifies the key name of the registry. If keyname begins with apredefined key, it defines an absolute key name. The predefinedkey names are:Name MeaningHKCR HKEY CLASSES ROOTHKCC HKEY CURRENT CONFIGHKCU HKEY CURRENT USERHKLM HKEY LOCAL MACHINEHKU HKEY USERSHKPD HKEY PERFORMANCE DATAHKDD HKEY DYN DATA
Otherwise, keyname defines a sub key of Regkey.
class Optional. Specifies the class name of the key.
SamDesired Optional. Specifies an access mask that specifies the desiredsecurity access for the new key. This parameter can be a com-bination of the following values:
Value Name Meaning0 KEY ALL ACCESS Combination of
KEY QUERY VALUE,KEY ENUMERATE SUB KEYS,KEY NOTIFY,KEY CREATE SUB KEY,KEY CREATE LINK, andKEY SET VALUE access
1 KEY CREATE LINK Permission to create a symbolic link2 KEY CREATE SUB KEY Permission to create subkeys3 KEY ENUMERATE SUB KEYS Permission to enumerate subkeys4 KEY EXECUTE Permission for read access5 KEY NOTIFY Permission for change notification6 KEY QUERY VALUE Permission to query subkey data7 KEY READ Combination of
KEY QUERY VALUE,KEY ENUMERATE SUB KEYS,and KEY NOTIFY access
8 KEY SET VALUE Permission to set subkey data9 KEY WRITE Combination of KEY SET VALUE
and KEY CREATE SUB KEY access
Returns
If the key specified by the keyname already exists, it opens the keyand returns a new instance of the RegKey Object. Otherwise itcreates a new key in the registry and returns a new instance of theRegKey Object. If failed, returns null.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.33 RegKey Object 351
Example
r = new RegKey("HKCU\\Software\\Demo1");//create a sub key of rsub = r.create("subkey");//creates "HKCU\Software\Demo1\subkey"//create a key under HKEY_CURRENT_USERsub2 = r.create("HKCU\\Software\\Demo2");sub3 = RegKey.create("HKCU\\Software\\Demo2");sub4 = RegKey.create("subkey");//returns null because there is no root for "subkey"
2.33.2.2 open
Description
Opens a windows registry key. Static
Syntax
Regkey.open(keyname)
Parameters
keyname Specifies the key name of the registry. If keyname begins with apredefined key, it defines an absolute key name. The predefinedkey names are:Name MeaningHKCR HKEY CLASSES ROOTHKCC HKEY CURRENT CONFIGHKCU HKEY CURRENT USERHKLM HKEY LOCAL MACHINEHKU HKEY USERSHKPD HKEY PERFORMANCE DATAHKDD HKEY DYN DATA
Otherwise, keyname defines a sub key of Regkey.
Returns
If the registry key specified by the keyname parameter has beensuccessfully opened, a new instance of the RegKey object is created.Otherwise, returns null.
Example
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 thenputs 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.33 RegKey Object 353
2.33.2.4 getValues
Description
Gets values under the key. This method gets all values under the keythen puts into an array as the result. FFish Script uses RegValueobject 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. Specifies the name of the value to retrieve. Themethod returns the default value if this parameter is not set.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
354 FFish Script Objects Reference
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 towrite. If the name property of value has not been set, Thevalue 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_SZr = RegKey.create("HKCU\\Software\\Demo");r.write(rv);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.33 RegKey Object 355
2.33.2.7 deleteKey
Description
Deletes a registry key. The key to be deleted must not have subkeys. Static
Syntax
Regkey.deleteKey(keyname)
Parameters
keyname Specifies the key name of the registry. If keyname begins with apredefined key, it defines an absolute key name. The predefinedkey names are:Name MeaningHKCR HKEY CLASSES ROOTHKCC HKEY CURRENT CONFIGHKCU HKEY CURRENT USERHKLM HKEY LOCAL MACHINEHKU HKEY USERSHKPD HKEY PERFORMANCE DATAHKDD 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
Description
Deletes a value of the registry key.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
356 FFish Script Objects Reference
Regkey.deleteValue(name)
Parameters
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 valuesinto the registry. It provides three properties that store the valueinformation about name, data and type.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.34 RegValue Object 357
2.34.1 Properties
2.34.1.1 name
Description
Represents the name of the value. If the name is empty string, itspecifies 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
Specifies the type of information to be stored as the value’s data.The default type if REG SZ.
Syntax
Regvalue.type
Remarks
The value types are:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
358 FFish Script Objects Reference
Name Value Description
REG BINARY 3 Binary data in any form.
REG DWORD 4 A 32-bit number
REG DWORD LITTLE ENDIAN 4 A 32-bit number in little-endianformat. This is equivalent toREG DWORD. In little-endian for-mat, a multi-byte value is stored inmemory from the lowest byte (the”little end”) to the highest byte.For example, the value 0x12345678is stored as (0x78 0x56 0x34 0x12)in little-endian format. WindowsNT, Windows 95, and Windows98 are designed to run on little-endian computer architectures. Auser may connect to computers thathave big-endian architectures, suchas some UNIX systems
REG DWORD BIG ENDIAN 5 A 32-bit number in big-endian for-mat. In big-endian format, a multi-byte value is stored in memory fromthe highest byte (the ”big end”) tothe lowest byte. For example, thevalue 0x12345678 is stored as (0x120x34 0x56 0x78) in big-endian for-mat
REG EXPAND SZ 2 A null-terminated string that con-tains unexpanded references to en-vironment variables (for example,”%PATH%”). It will be a Uni-code or ANSI string dependingon whether you use the Uni-code or ANSI functions. To ex-pand the environment variable ref-erences, use the ExpandEnviron-mentStrings function
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.34 RegValue Object 359
continued from the previous page
REG LINK 6 A Unicode symbolic link
REG MULTI SZ 7 An array of null-terminated strings,terminated by two null characters
REG NONE 0 No defined value type
REG RESOURCE LIST 0 A device-driver resource list
REG SZ 1 A null-terminated string. It will bea Unicode or ANSI string depend-ing on whether you use the Uni-code or ANSI functions. Do notuse the REG SZ type to store hard-coded paths to the system root di-rectory or to the drive containingthe system files. Instead, use theREG EXPAND SZ type with envi-ronment variables such as ”%Sys-temRoot%”. This ensures that thepath will be up-to-date even if theuser remaps the system drive to adifferent drive letter
2.34.1.3 data
Description
Represents the data value.
Syntax
Regvalue.data
Remarks
When reads from the registry, FFish Script automatically convertsthe result for you. If the value type is REG BINARY, REG EXPAND SZ,REG SZ, REG RESOURCE LIST or REG LINK, this property re-turns 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, stringsand arrays. If you want to write a DWORD value, store a numberto this property. If you want to store a REG SZ value, assign astring to this property. And If you want to write a value of typeREG MULTI SZ, make an array and set it to this property.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
360 FFish Script Objects Reference
Example
//Writes a DWORD valuerv = new RegValue;rv.name = "number";rv.type = 4;rv.data = 1;r = RegKey.create("HKCU\\Software\\Demo");r.write(rv);
//Writes a String valuerv = new RegValue;rv.name = "string";rv.data = "Hello world";r = RegKey.create("HKCU\\Software\\Demo");r.write(rv);
//Writes a multi string valuea = ["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 files.
available: SWFKit, SWFKit Pro
Syntax
new Ini(pathname)
Parameters
pathname Specifies the full path and name of initialization file.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.35 Ini Object 361
2.35.1 Methods
2.35.1.1 getInt
Description
Retrieves an integer associated with a key in the specified section ofthe initialization file.
Syntax
ini.getInt(section, key)
Parameters
section Specifies the section name of the initialization file.key Specifies the key name whose value is to be retrieved
Returns
Returns an integer if succeed. Otherwise returns undefined.
2.35.1.2 getSection
Description
Retrieves all of the keys and values for the specified section from theinitialization file. The result is an array contains the key and valuepairs.
Syntax
ini.getSection(section)
Parameters
section Specifies the section name of the initialization file.
Returns
Returns an array if succeed. Otherwise returns undefined.
Example
ini = new Ini("win.ini");x = ini.getSection("MCI Extensions");for (i = 0; i < x.length; i++)
trace(x[i]);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
362 FFish Script Objects Reference
2.35.1.3 getSectionNames
Description
Retrieves the names of all sections in the initialization file.
Syntax
ini.getSectionNames()
Parameters
None
Returns
Returns an array of section names if succeed. Otherwise returnsundefined.
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 specified section in the initialization file.
Syntax
ini.getString(section, key)
Parameters
section Specifies the section name of the initialization file.key Specifies the key name whose value is to be retrieved
Returns
Returns a string if succeed. Otherwise returns undefined.
Example
var ini = new Ini("win.ini");var s = ini.getString("Mail", "MAPI");trace(s);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.35 Ini Object 363
2.35.1.5 writeSection
Description
Replaces the keys and values under the specified section in the ini-tialization file.
Syntax
ini.writeSection(section, key value pairs)
Parameters
section Specifies the section name of the initialization file.
key value pairs Contains the new key names and associated values that arewritten to the named section. Must be an array.
Returns
Nothing
Example
//Read all sections from win.ini and write to demo.inivar 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 specified section of the specified initializationfile.
Syntax
ini. writeString (section, key, value)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
364 FFish Script Objects Reference
Parameters
section Specifies the section name of the initialization file.
key Specifies the name of the key to be associated with a string
value Specifies the string to be written to the file
Returns
Nothing
2.35.1.7 deleteSection
Description
Deletes an entire section from the specified initialization file.
Syntax
ini.deleteSection(section)
Parameters
section Specifies the section name to be deleted.
Returns
Nothing
2.35.1.8 deleteKey
Description
Deletes a key in the specified section from the initialization files.
Syntax
ini.deleteKey(section, key)
Parameters
section Specifies the section name.
key Specifies the name of the key to be deleted
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.36 FontObject Object 365
2.36 FontObject Object
Description
Represents the attributes of a font.
Syntax
new FontObject
Parameters
None
2.36.1 Properties
2.36.1.1 bold
Description
Boolean. Specifies a bold font if set to true.
Syntax
font.bold
2.36.1.2 color
Description
Integer. Specifies the font color.
Syntax
font.color
2.36.1.3 italic
Description
Boolean. Specifies an italic font if set to true.
Syntax
font. italic
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
366 FFish Script Objects Reference
2.36.1.4 name
Description
String. Specifies the typeface name of the font.
Syntax
font. name
2.36.1.5 size
Description
Integer. Specifies the point size of the font.
Syntax
font. size
2.36.1.6 underline
Description
Boolean. Specifies an underlined font if set to true.
Syntax
font.underline
2.36.2 Methods
2.36.2.1 getFonts
Description
Gets all font names in the system. Static
Syntax
font.getFonts([charset[, fontname]])
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.37 Shortcut Object 367
charset Optional. If this parameter is set, the method gets only fonts inthe specified character set. It can be set to one of the followingvalues:Charset ValueANSI CHARSET 0DEFAULT CHARSET 1SYMBOL CHARSET 2SHIFTJIS CHARSET 128HANGEUL CHARSET 129HANGUL CHARSET 129GB2312 CHARSET 134CHINESEBIG5 CHARSET 136OEM CHARSET 255JOHAB CHARSET 130HEBREW CHARSET 177ARABIC CHARSET 178GREEK CHARSET 161TURKISH CHARSET 162VIETNAMESE CHARSET 163THAI CHARSET 222EASTEUROPE CHARSET 238RUSSIAN CHARSET 204MAC CHARSET 77BALTIC CHARSET 186
fontname Optional. If this parameter is set, the method gets all fontswith the name specified by fontname.
Returns
If successfully gets the font names, returns an array of strings. Oth-erwise returns null.
Example
var font = new FontObject;var names = font.getFonts(0);trace(names);names = font.getFonts(0, "Arial");trace(names);
2.37 Shortcut Object
Description
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
368 FFish Script Objects Reference
Creates, opens and manipulates a shortcut.
available: SWFKit, SWFKit Pro
Syntax
new Shortcut(name);
Parameters
name Specifies the shortcut file name to open or create.
Returns
Returns a new instance of the Shortcut object represents the speci-fied shortcut. If failed returns null.
Remarks
Use the method save to save any changes to the shortcut. Properties
2.37.1 Properties
2.37.1.1 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();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.37 Shortcut Object 369
2.37.1.2 description
Description
Represents the description of the shortcut object.
Syntax
shortcut.description
Example
shortcut = new Shortcut("c:\\demo.lnk");shortcut.description = "It’s a test";shortcut.save();
2.37.1.3 hotKey
Description
Represents the hot key of the shortcut object. A hot key is a key-board 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 ofthe icon location should be ”Path,index”.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
370 FFish Script Objects Reference
shortcut.iconLocation
Example
shortcut = new Shortcut("c:\\demo.lnk");shortcut.iconLocation =
"D:\\WINNT\\System32\\winmine.exe,0";shortcut.save();
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.37 Shortcut Object 371
The window style of the shortcut object can be one of the followingvalues:Values Description0 Hides the window1 Activates and displays a window. If the window
is minimized or maximized, the system restores itto its original size and position
2 Activates the window and displays it as a mini-mized window
3 Activates the window and displays it as a maxi-mized window
4 Displays a window in its most recent size and po-sition. The active window remains active
5 Activates the window and displays it in its currentsize and position
6 Minimizes the specified window and activates thenext top-level window in the Z order
7 Displays the window as a minimized window. Theactive window remains active
8 Displays the window in its current state. The ac-tive window remains active
9 Activates and displays the window. If the windowis minimized or maximized, the system restoresit to its original size and position. An applica-tion should specify this flag when restoring a min-imized window
11 Minimizes a window. For windows 2000, xp
Example
shortcut = new Shortcut("c:\\demo.lnk");shortcut.windowStyle = 7;shortcut.save();
2.37.1.7 workingDirectory
Description
Represents the working directory of the shortcut object.
Syntax
shortcut.workingDirectory
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
372 FFish Script Objects Reference
Example
shortcut = new Shortcut("c:\\demo.lnk");shortcut.workingDirectory = "d:\\";shortcut.save();
2.37.2 Methods
2.37.2.1 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.38 URLShortcut Object 373
Syntax
new URLShortcut(name);
Parameters
name Specifies the url shortcut file name to open or create.
Returns
Returns a new instance of the URLShortcut object represents thespecified shortcut. If failed returns null.
2.38.1 Properties
2.38.1.1 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 Methods
2.38.2.1 save
Description
Saves the url shortcut object.
Syntax
urlshortcut.save()
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
374 FFish Script Objects Reference
None
Returns
Nothing
Example
shortcut = new URLShortcut("c:\\demo.url");shortcut.url = "http://www.macromedia.com";shortcut.save();
2.39 Mail Object
Description
Handles a mail using the MIME (Multipurpose Internet Mail Exten-sions) 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 viaInternet. An Email can be viewed as having an envelope and con-tents. The envelope contains information about the email such asthe sender, the recipients, the send time, etc. The contents composethe object to deliver to the recipients. The Mail Object supportsmultipart contents such as attachments and HTML contents.
To write a new email, filling the envelope first. The Mail Objectprovides some properties to setup the envelope. The following tabledescribes the properties.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.39 Mail Object 375
Property Descriptionfrom Identifies the sender of the emailreplyTo Specifies the mailbox to which responses are to be
sentto Identifies the primary recipients of the email.subject Specifies the subject of the email.cc Identifies the secondary (informational) recipients
of the emailbcc Identifies the additional recipients of the email.date Specifies the send date.priority Specifies the priority of the email.
Example
mail = new Mail;
mail.from = "[email protected]";mail.replyTo = "[email protected]";mail.to = "[email protected]";mail.subject = "A test";mail.cc = "[email protected]";mail.bcc = "[email protected]";mail.date = Date();mail.priority = 3;
mail.text = "test!";
mail.save("c:\\test.eml");
After filling the envelope, adding contents to the email.
• Adding plain textsUsing the text property.
mail.text = plain\_text\_message;
• Adding attachmentsUsing the addAttachment method.
mail. addAttachment("c:\\attach.zip");
• Adding html contentsUsing the html property and the addHtmlItem method. Usingthe html property to set the text source of the html contents.Other contents such as images can be added by using the ad-dHtmlItem method.
mail.html = "<html><body><img src=\"cid:test\">test</img></body></html>";mail.addHtmlItem("c:\\test.jpg", "test");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
376 FFish Script Objects Reference
Using the save method to store the email to the disk. Using theSendMail 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 Properties
2.39.1.1 from
Description
String. Identifies the sender of the email.
Syntax
mail.from
2.39.1.2 replyTo
Description
String. Specifies the mailbox to which responses are to be sent
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.39 Mail Object 377
Syntax
mail.replyTo
2.39.1.3 to
Description
String. Identifies the primary recipients of the email.
Syntax
mail.to
2.39.1.4 subject
Description
String. Specifies the subject of the email.
Syntax
mail.subject
2.39.1.5 cc
Description
String. Identifies the secondary (informational) recipients of theemail.
Syntax
mail.cc
2.39.1.6 bcc
Description
String. Identifies the additional recipients of the email.
Syntax
mail.bcc
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
378 FFish Script Objects Reference
2.39.1.7 date
Description
String. Specifies the send date.
Syntax
mail.date
2.39.1.8 priority
Description
Integer. Specifies the priority of the email. Valid values:
1 High
3 Normal
5 Low
Syntax
mail.priority
2.39.1.9 size
Description
Integer. Specifies the point size of the font.
Syntax
font.size
2.39.1.10 text
Description
String. Retrieves or specifies the text content of the email.
Syntax
mail.text
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.39 Mail Object 379
2.39.1.11 html
Description
String. Retrieves or specifies 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;//envelopemail.from = ...;mail.replyTo = ...;...//contentsmail.text = "the text content";//get html content from filevar 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
380 FFish Script Objects Reference
2.39.1.13 htmlItemCount
Description
Integer. Gets the count of the HTML items in the email. Read-only.
Syntax
mail.htmlItemCount
2.39.2 Methods
2.39.2.1 save
Description
Saves the email to the disk file.
Syntax
mail.save(filename)
Parameters
filename The full path and name of the file to save.
2.39.2.2 load
Description
Loads an email from disk file.
Syntax
mail.load(filename)
Parameters
filename The full path and name of the file to load.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.39 Mail Object 381
2.39.2.3 asText
Description
Gets the raw text of the email.
Syntax
mail.asText()
Parameters
None
Returns
A String
Example
mail = new Mail;mail.from = "[email protected]";mail.replyTo = "[email protected]";mail.to = "[email protected]";mail.subject = "A test";mail.cc = "[email protected]";mail.bcc = "[email protected]";mail.date = Date();mail.priority = 3;mail.text = "A test";mail.html = "<html><body>A test</body></html>";trace(mail.asText());
//output:From: [email protected]: [email protected]: [email protected]: [email protected]: [email protected]: =?gb2312?B?QSB0ZXN0?=Date: Thu Aug 15 05:36:33 GMT+800 () 2002MIME-Version: 1.0X-Mailer: SWFKit.FFishX-Priority: 3Content-Type: multipart/related;type="multipart/alternative";boundary="====_SWFKIT_MAIL_PART_558.2758077.12DE60_===="This is a multi-part message in MIME format.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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-printableA 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 specified attachment.
Syntax
mail.getAttachmentContentType(index)
Parameters
index Specifies the index of the attachment. The index of the attach-ments starts with 0.
Returns
A String
2.39.2.5 getAttachmentName
Description
Gets the name of the specified attachment.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.39 Mail Object 383
mail.getAttachmentName(index)
Parameters
index Specifies the index of the attachment. The index of the attach-ments starts with 0.
Returns
A String
2.39.2.6 saveAttachment
Description
Saves the specified attachment to disk file.
Syntax
mail.saveAttachment(index, filename)
Parameters
index Specifies the index of the attachment. The index of the attach-ments starts with 0.
filename Specifies the full path and name of the file to save
Returns
Nothing
2.39.2.7 addAttachment
Description
Adds an attachment from disk file.
Syntax
mail.addAttachment(filename)
Parameters
filename Specifies the full path and name of the file to add
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
384 FFish Script Objects Reference
2.39.2.8 removeAttachment
Description
Removes the specified attachment.
Syntax
mail.removeAttachment(index)
Parameters
index Specifies the index of the attachment to remove. The index ofthe attachments starts with 0.
Returns
Nothing
2.39.2.9 getHtmlItemName
Description
Gets name of the specified HTML item.
Syntax
mail.getHtmlItemName(index)
Parameters
index Specifies the index of the HTML item. The index of the HTMLitems starts with 0.
Returns
A string
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.39 Mail Object 385
2.39.2.10 getHtmlItemID
Description
Gets Content-ID of the specified HTML item. The Content-ID is aunique string identifies the HTML item.
Syntax
mail.getHtmlItemID(index)
Parameters
index Specifies the index of the HTML item. The index of the HTMLitems starts with 0.
Returns
A string
2.39.2.11 saveHtmlItem
Description
Saves the specified HTML item to disk file.
Syntax
mial.saveHtmlItem(index, filename)
Parameters
index Specifies the index of the HTML item. The index of the HTMLitems starts with 0.
filename Specifies full path and name of the file to save.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
386 FFish Script Objects Reference
2.39.2.12 addHtmlItem
Description
Adds a HTML item from disk file.
Syntax
mail.addHtmlItem(filename, cid)
Parameters
filename Specifies full path and name of the file to save.
cid Specifies the Content-ID of the HTML item.
Returns
Nothing
Example
//The example embedded a flash movie in an email.//read the html filevar 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 envelopemail.from = "[email protected]";mail.replyTo = "[email protected]";mail.to = "[email protected]";mail.subject = "A test";mail.cc = "[email protected]";mail.bcc = "[email protected]";mail.date = Date();mail.priority = 3;
//make the htmlvar re = new RegExp("clock.swf", "gi");mail.html = str.replace(re, "cid:12345");
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.40 SendMail Object 387
//load the flash moviemail.addHtmlItem("c:\\demo\\clock.swf", "12345");//save the mail. It can be opened in the Microsoft OutlookExpressmail.save("c:\\demo\\demo.eml");
2.40 SendMail Object
Description
Sends an email via Internet using the SMTP (SIMPLE MAIL TRANS-FER 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 familiarwith the SMTP protocol then use the send method, which send anemail all in one step and fires onSend events. Otherwise, you can usethe command method to send an email by hand. Before using thesemethods, remember to set the server, port, username and passwordproperties (username and password is used for SMTP authorization.The SendMail Object supports the login authorization). If you usethe command method to send an email, you must connect to theserver first.
1. Sending an email by using the send method
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
388 FFish Script Objects Reference
//first make an emailvar 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 envelopemail.from = "[email protected]";mail.replyTo = "[email protected]";mail.to = "[email protected] ";mail.subject = "A test";mail.cc = "[email protected]";mail.bcc = "[email protected]";mail.date = Date();mail.priority = 3;//make the htmlvar re = new RegExp("clock.swf", "gi");mail.html = str.replace(re, "cid:12345");//load the flash moviemail.addHtmlItem("c:\\demo\\clock.swf", "12345");//send the mailvar sender = new SendMail;sender.server = "a_smtp_server";//if need authorization, set username and passwordsender.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();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.40 SendMail Object 389
3. Handling an onSend event
sender.onSend = function (type, msg){
trace(msg);}sender.send(mail);
2.40.1 Properties
2.40.1.1 server
Description
String. Specifies the SMTP server that accepts the email. Using themxfind method of the Inet Object to get a SMTP server from anemail address.
Syntax
sendmail.server
2.40.1.2 port
Description
Integer. Specifies the SMTP server port. The default value is 25.
Syntax
sendmail.port
2.40.1.3 username
Description
String. Specifies a user name for authorization.
Syntax
sendmail.username
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
390 FFish Script Objects Reference
2.40.1.4 password
Description
String. Specifies a password for authorization.
Syntax
sendmail.password
2.40.2 Methods
2.40.2.1 send
Description
Sends an email and fires 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. Oth-erwise 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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.40 SendMail Object 391
2.40.2.3 command
Description
Sends a SMTP command to the server. The command must endwith a CRLF pair (”rn”).
Syntax
sendmail.command(cmd)
Parameters
cmd Specifies 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. Thedifference between the command method and the write method isthat the command method receives a reply while the write methoddoes not.
Syntax
sendmail.write(data)
Parameters
data Specifies 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
392 FFish Script Objects Reference
2.40.2.5 close
Description
Closes the connection opened with the connect method.
Syntax
sendmail.close()
Parameters
None
Returns
Nothing
2.40.3 Events
2.40.3.1 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 msg0 Represents a socket error message1 Represents a response of the server2 Represents a command sent by the SendMail ob-
ject3 Represents the bytes sent by the SendMail object
Syntax
sendmail.onSend = handler function;
Remarks
The handler function must return a Boolean value. Returns trueto allow the sending process to continue. Otherwise returns false toterminate the sending process.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.41 RecvMail Object 393
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);
2.41 RecvMail Object
Description
Receives emails using the POP3 (Post Office 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";
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
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 Properties
2.41.1.1 server
Description
String. Specifies the POP3 server that your mailbox resides in.
Syntax
recvmail.server
2.41.1.2 port
Description
Integer. Specifies the POP3 server port. The default value is 110.
Syntax
recvmail. port
2.41.1.3 Username
Description
String. Specifies the user name of the mailbox.
Syntax
recvmail.username
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.41 RecvMail Object 395
2.41.1.4 password
Description
String. Specifies the password of the mailbox.
Syntax
recvmail.password
2.41.2 Methods
2.41.2.1 connect
Description
Connects to the POP3 server and performs an authorization. Youmust call this method first before you can use any other methods.This method needs the server, port, username and password prop-erties 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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
396 FFish Script Objects Reference
2.41.2.3 dele
Description
Deletes the specified email.
Syntax
recvmail.dele(index)
Parameters
index Specifies the email to delete. The index of the emails startswith 1.
returns
Boolean.
2.41.2.4 list
Description
Gets the information of the specified email.
Syntax
recvmail.list([index])
Parameters
index Optional. Specifies the index of the email to list. The index ofthe emails starts with 1. If this parameter is not specified, themethod returns information of all emails.
returns
If the index parameter is specified, returns a string represents thesize of the email. Otherwise returns an array contains strings thatrepresent size of each email in the mailbox. If failed, returns null.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.41 RecvMail Object 397
2.41.2.5 noop
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 havefinished 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 specified email.
Syntax
recvmail.retr(index)
Parameters
index Specifies the email to receive.
returns
Returns a Mail object represents the email. If failed, returns null.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
398 FFish Script Objects Reference
2.41.2.8 rset
Description
Undelete mails. If you have deleted some mails and the transaction isstill open (has not been closed by the quit method yet), this methodcan 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 field repre-sents the total number of the mails in the mailbox. The size fieldrepresents the total size of all mails. If failed, returns null.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.41 RecvMail Object 399
2.41.2.10 top
Description
Gets the top n lines of the specified email.
Syntax
recvmail.top(index, n)
Parameters
index Specifies the index of the mail. The index of the emails startswith 1.
n specifies how many lines to retrieve.
returns
String. If failed, returns null.
2.41.2.11 uidl
Description
Gets the unique id of the specified email.
Syntax
recvmail.uidl([index])
Parameters
index Optional. Specifies the index of the mail. The index of theemails starts with 1.
returns
String. If the index parameter is not specified, returns a string arraycontains the unique ids of each mail in the mailbox. If failed, returnsnull.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
400 FFish Script Objects Reference
2.41.3 Events
2.41.3.1 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 msg0 Represents a socket error message3 Represents the bytes recieved by the retr method
Remarks
The handler function must return a Boolean value. Returns true toallow the recieving process to continue. Otherwise returns false toterminate 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());
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.42 Inet Object 401
size = parseInt(pop.list(1));trace(size);m = pop.retr(1);pop.quit();pop.close();m.save("c:\\test\\3.eml");
2.42 Inet Object
Description
Gets system network configurations, downloads files, checks the In-ternet connection status, etc.
available: SWFKit, SWFKit Pro
Syntax
new Inet
Parameters
None
Returns
Returns a new instance of the Inet object.
2.42.1 Methods
2.42.1.1 ping
Description
Pings the specified host. The method fires the onPinging event.
Syntax
inet.ping(host, count)
Parameters
host Specifies the host to ping.
count Specifies the number of echo requests to send.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
402 FFish Script Objects Reference
Returns
Integer. Returns the echo response number.
Example
Inet.ping("localhost", 10);
2.42.1.2 mxfind
Description
Gets MX (Mail eXchanger) record of the specified domain.
Syntax
inet.mxfind(domain, dns)
Parameters
domain Specifies the domain.
dns Specifies the DNS server to lookup the mx record.
Returns
An array contains objects. Each object has a name and a prefproperty. The name property represents a registered mail serverin the MX record. The pref property represents the preference ofthe 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 10maila.microsoft.com 10mailb.microsoft.com 10
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.42 Inet Object 403
2.42.1.3 isInetConnected
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 re-turns false. This method determines the Internet connection stateby 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]);}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
404 FFish Script Objects Reference
2.42.1.5 getIPConfig
Description
Retrieves TCP/IP network configuration values of the local system.
Syntax
inet.getIPConfig()
Parameters
None
Returns
An IPConfig 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 filesthat specified by the url.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.42 Inet Object 405
Syntax
inet.getUrl(url, localname)
Parameters
url URL(Uniform Resource Locator) , a standardized string used tospecify a resource on the Intenet, such as an HTML document.
localname Specifies full path and name of the local file the Internet re-source saves to.
Returns
Boolean. Returns true for success, false for failure.
Example
inet.getUrl("http://www.swfkit.com", "d:\\1.html")
2.42.1.7 getHttpFileSize
Description
Retrieves the size of a Http file.
Syntax
inet.getHttpFileSize(file)
Parameters
file string. specifies the link of the Http file to get its size.
Returns
Integer. If the file doesn’t exists or the method fails, it will return-1.
Example
var url = "http://www.swfkit.com/download/sp2.exe";var size = Inet.getHttpFileSize(url);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
406 FFish Script Objects Reference
2.42.1.8 getHttpFileLastModifiedTime
Description
Retrieves the last modified time of a Http file.
Syntax
inet.getHttpFileLastModifiedTime(file)
Parameters
file string. specifies the link of the Http file to get its last modifiedtime.
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 forthe http file.
Syntax
inet.getHttpFileStatus(file)
Parameters
file string. specifies the link of the Http file to get the status code.
Returns
Integer.
Example
var url = "http://www.swfkit.com/download/sp2.exe";var status = Inet.getHttpFileStatus(url);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.42 Inet Object 407
2.42.1.10 getHttpFileHeader
Description
Receives the header returned by the server when requests for thehttp file.
Syntax
inet.getHttpFileHeader(file, header)
Parameters
file string. specifies the link of the Http file to get the header.
herader string. specifies the header name. It can be ‘content-type’,‘content-length’, etc.
Returns
String. If the request fails, the result will be undefined.
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 specified parameters.
Syntax
inet.openFtp(server[, port[, username, password[, passive]]])
Parameters
server String. Specifies the address of the FTP server to connect.
port Integer. Specifies the server port. Optional. The default valueis 21.
username String. Specifies the login username. Optional, the default username is anonymous.
password String. Specifies the login password. Optional.
passive Boolean. Specifies if the Inet.Ftp object uses passive mode toconnect to the server. Optional. The default value is false.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
408 FFish Script Objects Reference
Returns
An Inet.Ftp object. Returns null if failed. The method doesn’tconnect to the ftp server. For further operations, please call themethods of the Inet.Ftp object.
Example
var ftp = Inet.openFtp("ftp.microsoft.com");
2.42.2 Events
2.42.2.1 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 bythe ping method. The parameter type represents the message type;it can be one of the following values:
Value Description0 Time out1 The host is unreachable2 Socket error3 Description of the action4 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);}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.42 Inet Object 409
inet.onPinging = on_ping;inet.ping("localhost", 4);//output:Pinging localhost [127.0.0.1]: with 32 bytes of data:Reply from 127.0.0.1: bytes=32 time=0ms TTL=128 icmp_seq=0Reply from 127.0.0.1: bytes=32 time=0ms TTL=128 icmp_seq=1Reply from 127.0.0.1: bytes=32 time=0ms TTL=128 icmp_seq=2Reply from 127.0.0.1: bytes=32 time=0ms TTL=128 icmp_seq=3
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 generatedby the getUrl method. The parameter type represents the messagetype; it can be one of the following values:
Value Description0 An error occurs1 Represents the bytes recieved by the getUrl
method
Remarks
The handler function must return a Boolean value. Returns true toallow the downloading process to continue. Otherwise returns falseto terminate the downloading process.
Syntax
inet.onGetUrl = handler function;
Example
var inet = new Inet;function on_geturl(type, msg){
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
410 FFish Script Objects Reference
trace(msg);return type;
}
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 connecta ftp server, list files and directories on the ftp server, download andupload files, create or remove directories, rename or delete files, etc.
available: SWFKit, SWFKit Pro
Syntax
This object must be returned by the Inet.openFtp method.
Usage
1. Open an Inet.Ftp objectThe 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 files 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 file size
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.43 Inet.Ftp Object 411
var info = ftp.getFileInfo("test.rar");trace(info.size);
6. Download or upload files
ftp.onDownload = function (percent){
trace(percent);return true;
}
ftp.download("test.rar", "c:\\samples\\test.rar");
ftp.onUpload = function (percent){
trace(percent);return true;
}
ftp.upload("test.rar", "c:\\samples\\test_new.rar");
2.43.1 Methods
2.43.1.1 connect
Description
Connects to the ftp server.
Syntax
ftp.connect()
Parameters
None
Returns
Returns true if successful, or false otherwise.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
412 FFish Script Objects Reference
2.43.1.2 createDir
Description
Creates a new directory on the ftp server.
Syntax
ftp.createDir(dir)
Parameters
dir String. Specifies the name of the new directory to create. Itcan be either a fully qualified path or a name relative to thecurrent 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. Specifies the name of the directory to remove. It canbe either a fully qualified path or a name relative to the currentdirectory.
Returns
Returns true if successful, or false otherwise.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.43 Inet.Ftp Object 413
2.43.1.4 deleteFile
Description
Deletes a file on the ftp server.
Syntax
ftp.deleteFile(file)
Parameters
file String. Specifies the name of the file to delete. It can be eithera fully qualified file name or a name relative to the currentdirectory.
Returns
Returns true if successful, or false otherwise.
2.43.1.5 rename
Description
Changes the name of a file on the ftp server.
Syntax
ftp.rename(file)
Parameters
file String. Specifies the name of the file to rename. It can be eithera fully qualified file name or a name relative to the currentdirectory.
Returns
Returns true if successful, or false otherwise.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
414 FFish Script Objects Reference
2.43.1.6 getFileInfo
Description
Gets the size and last modified time of a file on the ftp server.
Syntax
ftp.getFileInfo(file)
Parameters
file String. Specifies the name of the file. It can be either a fullyqualified file name or a name relative to the current directory.
Returns
An object contains two properties ‘size’ and ‘modifiedDate’. The‘size’ property is an Integer represents the size of the file. The ‘mod-ifiedDate’ 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 files and folders in the current directory on the ftp server.
Syntax
ftp.list()
Parameters
None
Returns
An object contains two properties ‘files’ and ‘folders’. The ‘files’property is an array contains names of all files in current directory.The ‘folders’ property is an array contains names of all folders incurrent directory.E.g.
var f = ftp.list();trace(f.files);trace(f.folders);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.43 Inet.Ftp Object 415
2.43.1.8 download
Description
Downloads a file. This method triggers the onDownload event. Thismethod calls the onDownload event handler for many times duringthe file downloading. It passed the downloading percentage to theevent handler. If the event handler returns false, the downloadingprocess will be terminated.
For the downloading may take a long time, this method will blockthe application - the UI of the application cannot be updated. Toresolve the problem, you can call the processMsg method in the eventhandler.
Syntax
ftp.download(file, localfile)
Parameters
file String. Specifies the name of the file to download. It can beeither a fully qualified file name or a name relative to the currentdirectory.
localfile String. Specifies the name of the local file to save the down-loaded data.
Returns
Returns true if successful, or false if failed.
2.43.1.9 upload
Description
Uploads a file. This method triggers the onUpload event. Thismethod calls the onUpload event handler for many times duringthe file uploading. It passed the uploading percentage to the eventhandler. If the event handler returns false, the uploading processwill be terminated.
For the uploading may take a long time, this method will blockthe application - the UI of the application cannot be updated. Toresolve the problem, you can call the processMsg method in the eventhandler.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
416 FFish Script Objects Reference
ftp.upload(file, localfile)
Parameters
file String. Specifies the name of the file on the server to save theuploaded data. It can be either a fully qualified file name or aname relative to the current directory.
localfile String. Specifies the name of the local file 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 Properties
2.43.2.1 currentDir
Description
String. Sets or gets the current directory of the ftp connection.
Syntax
ftp.currentDir
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.43 Inet.Ftp Object 417
2.43.3 Events
2.43.3.1 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 thedownloading. The event handler will be called for many time duringthe downloading.
Remarks
The handler function must return a Boolean value. Returns trueto allow the downloading process to continue, or to terminate thedownloading 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 theuploading. The event handler will be called for many time duringthe uploading.
Remarks
The handler function must return a Boolean value. Returns true toallow the uploading process to continue, or to terminate the upload-ing otherwise.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
418 FFish Script Objects Reference
2.44 IPConfig Object
Description
Represents TCP/IP network configuration values of the local system.This object is returned by the method getIPConfig of the Inet object.
available: SWFKit, SWFKit Pro
Syntax
This object has no syntax.
2.44.1 Properties
2.44.1.1 ifNum
Description
Integer. Represents the number of network interfaces present on thelocal system. Read-only.
Syntax
ipconfig.ifNum
2.44.2 Methods
2.44.2.1 ifType
Description
Retrieves the type of the specified interface.
Syntax
ipconfig.ifType(index)
Parameters
index Specifies the index of the interface. The index of the interfacesstarts with 0
Returns
String.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.44 IPConfig Object 419
2.44.2.2 ifIP
Description
Retrieves the IP address of the specified interface.
Syntax
ipconfig.ifIP(index)
Parameters
index Specifies the index of the interface. The index of the interfacesstarts with 0
Returns
Returns a string array.
2.44.2.3 ifIPMask
Description
Retrieves the subnet mask associated with the IP address of thespecified interface.
Syntax
ipconfig.ifIPMask(index)
Parameters
index Specifies the index of the interface. The index of the interfacesstarts with 0
Returns
Returns a string array.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
420 FFish Script Objects Reference
2.44.2.4 ifDefaultGateway
Description
Retrieves the default gateway of the specified interface.
Syntax
ipconfig.ifDefaultGateway(index)
Parameters
index Specifies the index of the interface. The index of the interfacesstarts with 0
Returns
String.
2.44.2.5 ifMac
Description
Retrieves the MAC address of the specified interface.
Syntax
ipconfig.ifMac(index)
Parameters
index Specifies the index of the interface. The index of the interfacesstarts with 0
Returns
String.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.45 SysInfo Object 421
2.44.2.6 ifDesc
Description
Retrieves the description of the specified interface.
Syntax
ipconfig.ifDesc(index)
Parameters
index Specifies the index of the interface. The index of the interfacesstarts 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 construc-tors. All of its properties and methods are static.
2.45.1 Properties
2.45.1.1 computerName
Description
String. Gets or sets the computer name of the local system. Read-only
Syntax
SysInfo.computerName
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
422 FFish Script Objects Reference
2.45.1.2 userName
Description
String. Retrieves the current user name of the local system. Read-only.
Syntax
SysInfo.userName
2.45.1.3 version
Description
String. Retrieves the Windows version. Read-only.
Syntax
SysInfo.version
2.45.1.4 workarea
workareaTop workareaLeft workareaRight workareaBottomDescription
Integer. Retrieves the position of the work area on the primarydisplay monitor. The work area is the portion of the screen notobscured by the system taskbar or by application desktop toolbars.The four properties represent the top, left, right, and bottom of thework area respectively. Read-only.
Syntax
• SysInfo.workareaTop
• SysInfo.workareaLeft
• SysInfo.workareaRight
• SysInfo.workareaBottom
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.45 SysInfo Object 423
2.45.1.5 totalPhysMemory
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
Description
Float. Retrieves the CPU speed. Read-only.
Syntax
SysInfo.cpuSpeed
2.45.1.8 screenSaver
Description
String. Gets or sets the default screen saver of the system
Syntax
SysInfo.screenSaver
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
424 FFish Script Objects Reference
2.45.1.9 screenSaverActive
Description
Boolean. Gets or sets the state of the screen saver.
Syntax
SysInfo.screenSaverActive
Example
//Deactivate the screen saverSysInfo.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 Specifies the frequency, in hertz (cycles per second), of the dis-play device in a particular mode
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.45 SysInfo Object 425
If you want to test if the display setting can be set, just add a testproperty to the object and set it to true.Tips: Use the getDisplaySettings method to list all of the displaysettings. After you set the property, you can check the test propertyto 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 specified graphics mode.-2 The graphics mode is not supported.
Example
//get the current display settingvar 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;
2.45.2 Methods
2.45.2.1 powerOff
Description
Shuts down the system and turns off the power. The system mustsupport the power-off feature.
Syntax
SysInfo.powerOff()
Parameters
None
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
426 FFish Script Objects Reference
2.45.2.2 logOff
Description
Logs the current user off.
Syntax
SysInfo.logOff()
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 off thepower.
Syntax
SysInfo.shutdown()
Parameters
None
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.46 Folder 427
2.45.2.5 getDisplaySettings
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 Specifies the full path of the folder. If the specified folder doesnot exist, the constructor will try to create it.
Returns
Returns a new instance of the Folder object. If failed, returns null.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
428 FFish Script Objects Reference
2.46.1 Properties
2.46.1.1 attributes
Description
Sets or returns the attributes of files or folders.
Syntax
folder.attributes
Remarks
The attributes property can have any of the following values or anylogical combination of the following values:
Value Description1 The file or directory is read-only.2 The file or directory is hidden.4 The file or directory is part of, or is used exclu-
sively by, the operating system.16 Folder or directory.64 The file or directory is encrypted.128 The file or directory has no other attributes set.
This attribute is valid only if used alone.256 The file is being used for temporary storage.512 The file is a sparse file.1024 The file has an associated reparse point.2048 The file or directory is compressed.4096 The data of the file is not immediately available.
2.46.1.2 dateCreated
Description
Integer. Returns or sets the date and time that the specified file orfolder was created.
Syntax
folder.dateCreated
Example
f = new Folder("c:\\demo");d = new Date(f.dateCreated);trace(d.toLocaleString());
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.46 Folder 429
2.46.1.3 dateLastAccessed
Description
Integer. Returns or sets the date and time that the specified file orfolder was last accessed.
Syntax
folder.dateLastAccessed
Example
f = new Folder("c:\\demo");d = new Date(f. dateLastAccessed);trace(d.toLocaleString());
2.46.1.4 dateLastModified
Description
Integer. Returns or sets the date and time that the specified file orfolder was last modified.
Syntax
folder.dateLastModified
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 specifiedfile or folder resides. Read-only.
Syntax
folder.drive
Example
f = new Folder("c:\\demo");trace(f.drive);//output: c:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
430 FFish Script Objects Reference
2.46.1.6 isRootFolder
Description
Boolean. Returns true if the specified folder is the root folder; falseif 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 specified file 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 specified fileor folder. Read-only.
Syntax
folder.parentPath
Example
f = new Folder("c:\\demo");trace(f.parentPath);//output: c:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.46 Folder 431
2.46.1.9 path
Description
String. Returns the path for a specified file, 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 theearlier 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 theearlier 8.3 file naming convention. Read-only.
Syntax
folder.shortPath
Example
f = new Folder("c:\\program files");trace(f.shortPath);//output: c:\PROGRA~1
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
432 FFish Script Objects Reference
2.46.1.12 size
Description
Integer. Returns the size, in bytes, of all files and subfolders con-tained 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 files
Description
Returns a string array contains all file pathnames in the folder.Read-only.
Syntax
folder.files
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.46 Folder 433
2.46.2 Methods
2.46.2.1 copy
Description
Copies a specified file or folder from one location to another. CAU-TION: the method overwrites the existing files silently.
Syntax
folder.copy(dest)
Parameters
dest Specifies the destination to copy
Returns
Boolean. Returns true for success, false for failure.
2.46.2.2 remove
Description
Deletes a specified file or folder. The method can only remove emptyfolders. If you want to remove all files and subfolders, use a recursivefunction 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 won’t put the deleted folders into the re-cycle bin. You cannot recovery them anymore.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
434 FFish Script Objects Reference
Syntax
folder.remove()
Parameters
None
Returns
Boolean. Returns true for success, false for failure.
2.46.2.3 move
Description
Moves a specified file or folder from one location to another. Themethod does not move folder where the destination is on a differentvolume. You can write your own function to do this.
Syntax
folder.move(dest)
Parameters
dest Specifies the destination to move.
Returns
Boolean. Returns true for success, false for failure.
2.46.2.4 files
Description
Returns an array contains the name of the specified files.
Syntax
folder.files([name])
Parameters
name Specifies the name of the file(don’t include the path name).Supports wild characters ‘*’ and ‘?’. If the parameter is notspecified, act just like the files property.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.47 File Object 435
Returns
Array.
Example
var f = new Folder("c:\\windows");trace(f.files("*.exe;*.dll;*.scr"));
2.46.2.5 exists
Description
Determines whether the specified folder or file exists. Static
Syntax
Folder.exists(name)
Parameters
name Specifies full path and name of the folder or file.
Returns
Boolean. Returns true for success, false for failure.
2.47 File Object
Description
Provides access to all the properties of a file.
available: SWFKit, SWFKit Pro
Syntax
new File(file);
Parameter
file Specifies the full path and name of a existing file.
Returns
Returns a new instance of the File object. If failed, returns null.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
436 FFish Script Objects Reference
2.47.1 Properties
2.47.1.1 attributes
Description
Sets or returns the attributes of files or folders.
Syntax
file.attributes
Remarks
The attributes property can have any of the following values or anylogical combination of the following values:Value Description1 The file or directory is read-only.2 The file or directory is hidden.4 The file or directory is part of, or is used exclu-
sively by, the operating system.16 Folder or directory.64 The file or directory is encrypted.128 The file or directory has no other attributes set.
This attribute is valid only if used alone.256 The file is being used for temporary storage.512 The file is a sparse file.1024 The file has an associated reparse point.2048 The file or directory is compressed.4096 The data of the file is not immediately available.
2.47.1.2 dateCreated
Description
Integer. Returns or sets the date and time that the specified file orfolder was created.
Syntax
file.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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.47 File Object 437
2.47.1.3 dateLastAccessed
Description
Integer. Returns or sets the date and time that the specified file orfolder was last accessed.
Syntax
file.dateLastAccessed
Example
f = new File("c:\\demo\\1.txt");d = new Date(f.dateLastAccessed);trace(d.toLocaleString());
2.47.1.4 dateLastModified
Description
Integer. Returns or sets the date and time that the specified file orfolder was last modified.
Syntax
file.dateLastModified
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 specifiedfile or folder resides. Read-only.
Syntax
file.drive
Example
f = new File("c:\\demo\\1.txt");trace(f.drive);//output: c:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
438 FFish Script Objects Reference
2.47.1.6 name
Description
String. Sets or returns the name of a specified file or folder.
Syntax
file.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 specified fileor folder. Read-only.
Syntax
file.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 specified file, folder. Read-only.
Syntax
file.path
Example
f = new File("c:\\demo\\1.txt");trace(f.path);//output: c:\demo\1.txt
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.47 File Object 439
2.47.1.9 shortName
Description
String. Returns the short name used by programs that require theearlier 8.3 naming convention. Read-only.
Syntax
file.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 theearlier 8.3 file naming convention. Read-only.
Syntax
file.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 file. Read-only.
Syntax
file.size
Example
f = new File("c:\\demo\\A demo file.txt");trace(f.size);//output: 7
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
440 FFish Script Objects Reference
2.47.1.12 type
Description
A return of Integer 0 to indicate its a file object. Read-only.
Syntax
file.type
2.47.2 Methods
2.47.2.1 copy
Description
Copies a specified file or folder from one location to another. CAU-TION: the method overwrites the existing files silently.
Syntax
file.copy(dest)
Parameters
dest Specifies the destination to copy
Returns
Boolean. Returns true for success, false for failure.
2.47.2.2 remove
Description
Deletes the specified file.
Syntax
file.remove()
Parameters
None
Returns
Boolean. Returns true for success, false for failure.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.48 Drive Object 441
2.47.2.3 move
Description
Moves a specified file from one location to another.
Syntax
file.move(dest)
Parameters
dest Specifies the destination to move.
Returns
Boolean. Returns true for success, false for failure.
2.47.2.4 exists
Description
Determines whether the specified folder or file exists. Static
Syntax
File. exists (name)
Parameters
name Specifies full path and name of the folder or file.
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);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
442 FFish Script Objects Reference
Parameter
drive Specifies the path of the drive.
Returns
Returns a new instance of the Drive object. If failed, returns null.
2.48.1 Properties
2.48.1.1 availableSpace
Description
Integer. Returns the amount of space available to a user on thespecified 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.48 Drive Object 443
2.48.1.3 driveType
Description
String. Returns the type of a specified drive. Read-only. It can beone of the following values:
Value Meaningunknown The drive type cannot be determined.no root dir The root directory does not exist.removable The disk can be removed from the drive.fixed The disk cannot be removed from the drive.network The drive is a remote (network) drive.cdrom The drive is a CD-ROM drive.ram disk The drive is a RAM disk.
Syntax
drive.driveType
Example
d = new Drive("e:");trace(d.driveType);//output: cdrom
2.48.1.4 fileSystem
Description
String. Returns the type of file system in use for the specified drive.Read-only. Available return types include FAT, NTFS, and CDFS
Syntax
drive.fileSystem
Example
d = new Drive("c:\\program files");trace(d.fileSystem);//output: FAT32
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
444 FFish Script Objects Reference
2.48.1.5 freeSpace
Description
Integer. Returns the amount of free space available to a user on thespecified drive. Read-only.
Syntax
drive.freeSpace
Remarks
The value returned by the freeSpace property is typically the sameas that returned by the availableSpace property. Differences mayoccur 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 specified drive is ready; false if it isnot. Read-only.
Syntax
drive.isReady
Example
d = new Drive("a:\\");trace(d.isReady);//output: false
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.48 Drive Object 445
2.48.1.7 path
Description
String. Returns the path for a specified 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 specifieddrive. 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 identifya disk volume. Read-only.
Syntax
drive.serialNumber
Example
d = new Drive("c:\\program files");trace(d.serialNumber);
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
446 FFish Script Objects Reference
2.48.1.10 totalSize
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 specified 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.49 StringStream Object 447
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);
}
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, returnsnull.
2.49.1 Properties
2.49.1.1 length
Description
Integer. Gets of sets the length of the file stream. If you set a valuesmaller than the origin length of the file stream, it will be truncated.
Syntax
stream.length
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
448 FFish Script Objects Reference
2.49.1.2 getPos
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-file on a stream. Read-only. After a failedreading 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.49 StringStream Object 449
2.49.2 Methods
2.49.2.1 get
Description
Reads a byte from the file 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 file stream or string stream
Syntax
stream.getLong()
Parameters
None
Returns
Integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
450 FFish Script Objects Reference
2.49.2.3 getShort
Description
Reads a short integer (two bytes) from the file stream or stringstream
Syntax
stream.getShort()
Parameters
None
Returns
Integer.
2.49.2.4 getFloat
Description
Reads a 32-bit floating-point number from the file stream or stringstream.
Syntax
stream.getFloat()
Parameters
None
Returns
Float number
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.49 StringStream Object 451
2.49.2.5 getDouble
Description
Reads a 64-bit floating-point number from the file stream or stringstream
Syntax
stream.getDouble()
Parameters
None
Returns
Float number
2.49.2.6 read
Description
Reads specified number of bytes from the file stream
Syntax
stream.read(bytes)
Parameters
bytes Specifies 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 file stream
Syntax
stream.readLine()
Parameters
None
Returns
Returns a string represents the read line.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
452 FFish Script Objects Reference
2.49.2.8 put
Description
Writes a character to the file stream
Syntax
stream.put(c)
Parameters
c Integer. Specifies the character to write.
Returns
Boolean
2.49.2.9 putShort
Description
Writes a short integer to the file 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 floating-point number to the file stream or stringstream
Syntax
stream.putFloat(num)
Parameters
num Number. Represents a float number
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.49 StringStream Object 453
2.49.2.11 write
Description
Writes the specified values to the file stream or string stream
Syntax
stream. write (v0, v1, . . . , vN )
Parameters
v0, v1, . . . , vN Specifies the values to write. The value can be an integer, float,string or StringStream object.
Returns
Nothing
2.49.2.12 writeLine
Description
Writes a line to the file stream
Syntax
stream.writeLine(v0, v1, . . . , vN )
Parameters
v0, v1, . . . , vN Specifies the values to write. The value can be an integer, float,string or StringStream object.
Returns
Nothing
2.49.2.13 unget
Description
Pushes a character back onto the file stream.
Syntax
stream.unget(c)
Parameters
c Specifies the character to unget.
Returns
Boolean
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
454 FFish Script Objects Reference
2.49.2.14 flush
Description
Flushes a file stream.
Syntax
stream.flush()
Parameters
None
Returns
Boolean
2.49.2.15 close
Description
Closes a file stream.
Syntax
stream.close();
Parameters
None
Returns
Nothing
2.49.2.16 readString
Description
Reads a null terminated ANSI string (8-bit character) from the filestream or string stream.
Syntax
stream.readString()
Parameters
None
Returns
String
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.49 StringStream Object 455
2.49.2.17 readUnicodeString
Description
Reads a null terminated UNICODE string (16-bit character) fromthe file stream or string stream.
Syntax
stream.readUnicodeString()
Parameters
None
Returns
String
2.49.2.18 writeUnicodeString
Description
Writes a string to the file stream or string stream include a nullterminator.
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
456 FFish Script Objects Reference
2.49.2.20 uncompress
Description
Uncompress the string stream.
Syntax
stream.uncompress()
Parameters
None
Returns
A StringStream object represents the uncompressed data. Returnsnull if the format of the source stream is invalid.
2.49.2.21 readFromFile
Description
Reads an entire file into a string stream. Static.
Syntax
stream.readFromFile(name)
Parameters
name Specifies the full pathname of the file to read.
Returns
A StringStream object.
2.49.2.22 saveToFile
Description
Write the entire string stream to a file
Syntax
stream.saveToFile(name)
Parameters
name Specifies the full pathname of the output file. If the file exists,its contents are destroyed.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.50 FileStream(Stream) Object 457
2.50 FileStream(Stream) Object
Description
Facilitates sequential access to file.
available: SWFKit, SWFKit Pro
Syntax
new FileStream([filename[, mode]]);
Parameter
filename Optional. String. Specifies the full path and name of the file.
mode Optional. String. Type of access permitted. Default ”r+”Values Description”r” Opens for reading. If the file does not exist or
cannot be found, returns null.”w” Opens an empty file for writing. If the given
file exists, its contents are destroyed.”a” Opens for writing at the end of the file (ap-
pending) without removing the EOF markerbefore writing new data to the file; creates thefile first if it doesn’t exist.
”r+” Opens for both reading and writing. (The filemust exist.)
”w+” Opens an empty file for both reading and writ-ing. If the given file exists, its contents aredestroyed.
”a+” Opens for reading and appending; the ap-pending operation includes the removal of theEOF marker before new data is written to thefile and the EOF marker is restored after writ-ing is complete; creates the file first if it doesntexist. If neither of the parameters is specified,the method creates a temporary file for bothreading and writing. After a calling of theclose method, the temporary file is automat-ically deleted. The files are always opened inbinary mode.
Returns
Returns a new instance of the FileStream object. If failed, returnsnull. properties
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
458 FFish Script Objects Reference
2.50.1 Properties
2.50.1.1 length
Description
Integer. Gets of sets the length of the file stream. If you set a valuesmaller than the origin length of the file stream, it will be truncated.
Syntax
stream.length
2.50.1.2 pos
Description
Integer. Gets of sets the current position of the file pointer.
Syntax
stream.pos
2.50.1.3 eof
Description
Boolean. Tests for end-of-file on a stream. Read-only. After a failedreading operation at the end of the stream, it is set to true
Syntax
stream.eof
2.50.2 Methods
2.50.2.1 get
Description
Reads a byte from the file stream
Syntax
stream.get()
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.50 FileStream(Stream) Object 459
Parameters
None
Returns
Integer. If failed returns false.
2.50.2.2 getLong
Description
Reads a long integer (four bytes) from the file 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 file stream or stringstream
Syntax
stream.getShort()
Parameters
None
Returns
Integer.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
460 FFish Script Objects Reference
2.50.2.4 getFloat
Description
Reads a 32-bit floating-point number from the file stream or stringstream.
Syntax
stream.getFloat()
Parameters
None
Returns
Float number
2.50.2.5 getDouble
Description
Reads a 64-bit floating-point number from the file stream or stringstream
Syntax
stream.getDouble()
Parameters
None
Returns
Float number
2.50.2.6 read
Description
Reads specified number of bytes from the file stream
Syntax
stream.read(bytes)
Parameters
bytes Specifies the number of bytes to read.
Returns
Returns a string represents the read bytes.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.50 FileStream(Stream) Object 461
2.50.2.7 readLine
Description
Reads a line from the file 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 file stream
Syntax
stream.put(c)
Parameters
c Integer. Specifies the character to write.
Returns
Boolean
2.50.2.9 putShort
Description
Writes a short integer to the file stream or string stream
Syntax
stream.putShort(num)
Parameters
num Number. Represents an integer to write.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
462 FFish Script Objects Reference
2.50.2.10 putFloat
Description
Writes a 32-bit floating-point number to the file stream or stringstream
Syntax
stream.putFloat(num)
Parameters
num Number. Represents a float number
Returns
Nothing
2.50.2.11 write
Description
Writes the specified values to the file stream or string stream
Syntax
stream. write (v0, v1, . . . , vN )
Parameters
v0, v1, . . . , vN Specifies the values to write. The value can be an integer, float,string or StringStream object.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.50 FileStream(Stream) Object 463
2.50.2.12 writeLine
Description
Writes a line to the file stream
Syntax
stream.writeLine(v0, v1, . . . , vN )
Parameters
v0, v1, . . . , vN Specifies the values to write. The value can be an integer, float,string or StringStream object.
Returns
Nothing
2.50.2.13 unget
Description
Pushes a character back onto the file stream.
Syntax
stream.unget(c)
Parameters
c Specifies the character to unget.
Returns
Boolean
2.50.2.14 flush
Description
Flushes a file stream.
Syntax
stream.flush()
Parameters
None
Returns
Boolean
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
464 FFish Script Objects Reference
2.50.2.15 close
Description
Closes a file stream.
Syntax
stream.close();
Parameters
None
Returns
Nothing
2.50.2.16 readString
Description
Reads a null terminated ANSI string (8-bit character) from the filestream 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) fromthe file stream or string stream.
Syntax
stream.readUnicodeString()
Parameters
None
Returns
String
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 465
2.50.2.18 writeUnicodeString
Description
Writes a string to the file stream or string stream include a nullterminator.
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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
466 FFish Script Objects Reference
2.51.1 Properties
2.51.1.1 error
Description
Gets the error status for the last operation that failed. Static. Read-only
Syntax
socket.error
Remarks
The following is a list of possible error codes:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 467
Value Description
10013 Permission denied.
10048 Address already in use.
10049 Cannot assign requested address.
10047 Address family not supported by protocol family.
10037 Operation already in progress.
10053 Software caused connection abort.
10061 Connection refused.
10054 Connection reset by peer.
10039 Destination address required.
10014 Bad address.
10064 Host is down.
10065 No route to host.
10036 Operation now in progress.
10004 Interrupted function call.
10022 Invalid argument.
10056 Socket is already connected.
10024 Too many open files.
10040 Message too long.
10050 Network is down.
10052 Network dropped connection on reset.
10051 Network is unreachable.
10055 No buffer space available.
10042 Bad protocol option.
10057 Socket is not connected.
10038 Socket operation on non-socket.
10045 Operation not supported.
10046 Protocol family not supported.
10067 Too many processes.
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
468 FFish Script Objects Reference
continued from the previous page
Value Description
10043 Protocol not supported.
10041 Protocol wrong type for socket.
10058 Cannot send after socket shutdown.
10044 Socket type not supported.
10060 Connection timed out.
10109 Class type not found.
10035 Resource temporarily unavailable.
11001 Host not found.
11004 Valid name, no data record of requested type.
11003 This is a non-recoverable error.
11002 Non-authoritative host not found.
10094 Graceful shutdown in progress.
2.51.2 Methods
2.51.2.1 accept
Description
Accepts a connection on the socket
Syntax
socket.accept()
Parameters
None
Returns
A Socket object available for connection
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 469
2.51.2.2 asyncSelect
Description
Requests event notification for the socket
Syntax
socket.asyncSelect(event)
Parameters
event Integer. Specifies a combination of network events.Value Description$FD READ Want to receive notification of
readiness for reading.$FD WRITE Want to receive notification when
data is available to be read.$FD OOB Want to receive notification of the
arrival of out-of-band data.$FD ACCEPT Want to receive notification of in-
coming connections.$FD CONNECT Want to receive notification of
connection results.$FD CLOSE Want to receive notification 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. Specifies the port to bind.address Optional. String. Specifies the network address (a dotted num-
ber such as ”219.138.64.12”) to bind.
Returns
Boolean.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
470 FFish Script Objects Reference
2.51.2.4 close
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. Specifies the network address of the socket to whichthis object is connected. Such as www.swfkit.com,
ftp.microsoft.com, or 218.5.79.162”.
port Integer. Specifies the port to connect.
Returns
Boolean.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 471
2.51.2.6 create
Description
Creates the Windows socket and bind it to the specified address
Syntax
socket.create([port[, type[, event[, address]]]])
Parameters
port Optional. Integer. Specifies a port to be used with the socket.The default value is 0 (Windows Sockets will select a port forthe socket if the value is set to 0).
type Optional. Integer. Specifies the socket type. Default $SOCK STREAM.Value Description$SOCK STREAM Provides sequenced, reliable,
two-way, connection-based bytestreams with an out-of-band datatransmission mechanism. UsesTCP for the Internet addressfamily.
$SOCK DGRAM Supports datagrams, which areconnectionless, unreliable buffersof a fixed (typically small) maxi-mum length. Uses UDP for theInternet address family.
event Optional. Integer. Specifies a combination of network events.Default $FD READ | $FD WRITE | $FD OOB | $FD ACCEPT| $FD CONNECT | $FD CLOSEValue Description$FD READ Want to receive notification of
readiness for reading.$FD WRITE Want to receive notification when
data is available to be read.$FD OOB Want to receive notification of the
arrival of out-of-band data.$FD ACCEPT Want to receive notification of in-
coming connections.$FD CONNECT Want to receive notification of
connection results.$FD CLOSE Want to receive notification when
a socket has been closed by a peer.
address Optional. String. Specifies the network address (a dotted num-ber such as 219.138.64.12”.) to bind.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
472 FFish Script Objects Reference
Returns
Boolean.
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.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 473
2.51.2.9 getSockOpt
Description
Retrieves the socket option.
Syntax
socket.getSockOpt(name, level)
Parameters
name Integer. Specifies the socket option for which the value is to beretrieved
level Integer. Specifies the level at which the option is defined
Level Name Return Type Description
0xFFFF 0x0002 Boolean Whether the socket is listening.
0x0020 Boolean Whether the socket is configured forthe transmission of broadcast mes-sages.
0x0001 Boolean Whether the debugging is enabled.
0x0080 Boolean Whether the SO LINGER(0x0080)option is disabled.
0x0010 Boolean Whether the routing is disabled.
0x1007 Integer Retrieve error status and clear.
0x0008 Boolean Keep-alives are being sent
0x0080 Integer Returns the current linger options.
0x0100 Boolean Whether the out-of-band data isbeing received in the normal datastream.
0x1002 Integer Buffer size for receives.
0x0004 Boolean Whether the socket can be bound toan address which is already in use.
0x1001 Integer Buffer size for sends.
0x1008 Integer The type of the socket (for example,$SOCK STREAM).
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
474 FFish Script Objects Reference
continued from the previous page
Level Name Return Type Description
6 0x0001 Boolean Whether the Nagle algorithm is dis-abled for send coalescing.
Returns
Depends on the socket option name.
2.51.2.10 setSockOpt
Description
Sets the socket option.
Syntax
socket.setSockOpt(name, value, level)
Parameters
name Integer. Specifies the socket option for which the value is to beretrieved
value Integer. Specifies the new option value
level Integer. Specifies the level at which the option is defined
Level Name Return Type Description
0xFFFF 0x0002 Boolean Whether the socket is listening.
0x0020 Boolean Whether the socket is configured forthe transmission of broadcast mes-sages.
0x0001 Boolean Whether the debugging is enabled.
0x0080 Boolean Whether the SO LINGER(0x0080)option is disabled.
0x0010 Boolean Whether the routing is disabled.
0x1007 Integer Retrieve error status and clear.
0x0008 Boolean Keep-alives are being sent
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 475
continued from the previous page
Level Name Return Type Description
0x0080 Integer Returns the current linger options.
0x0100 Boolean Whether the out-of-band data isbeing received in the normal datastream.
0x1002 Integer Buffer size for receives.
0x0004 Boolean Whether the socket can be bound toan address which is already in use.
0x1001 Integer Buffer size for sends.
0x1008 Integer The type of the socket (for example,$SOCK STREAM).
6 0x0001 Boolean Whether the Nagle algorithm is dis-abled for send coalescing.
Returns
Boolean.
2.51.2.11 ioctl
Description
Controls the mode of a socket.
Syntax
socket.ioctl(cmd[, value])
Parameters
cmd Integer. Specifies the command to perform on the socket
value Optional. Depends on the command to be performed.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
476 FFish Script Objects Reference
Cmd Value ReturnType
Description
0x8004667E Boolean Enable or disable non-blocking mode on thesocket.
0x4004667F Integer Determine the maxi-mum number of bytesthat can be read withone receive call fromthis socket.
0x80047307 Boolean Checks if we are at the’out-of-band’ marker inthe stream
Returns
Depends on the command to be performed.
2.51.2.12 listen
Description
Listens for incoming connection requests.
Syntax
socket.listen([value])
Parameters
value Optional. Integer. Specifies the maximum length to which thequeue of pending connections can grow. Valid range is from 1to 5. The default value is 5.
Returns
Boolean
2.51.2.13 receive
Description
Receives data from a socket.
Syntax
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 477
socket.receive(stream, len[, flag])
Parameters
stream A StringStream object for the incoming data.len Integer. Specifies the number of bytes to retrieve.flag Optional. Integer. Specifies the way in which the call is made.
It can be a combination of the following dataFlag Description0x02 Peek at the incoming data. The data is copied
into the StringStream but is not removed fromthe input queue.
0x01 Process out-of-band data
Returns
Integer. The number of bytes received.
2.51.2.14 receiveFrom
Description
Receives a datagram and stores the source address
Syntax
socket.receiveFrom(stream, len[, flag])
Parameters
stream A StringStream object for the incoming data.len Integer. Specifies the number of bytes to retrieve.flag Optional. Integer. Specifies the way in which the call is made.
It can be a combination of the following data:Flag Description0x02 Peek at the incoming data. The data is copied
into the StringStream but is not removed fromthe input queue.
0x01 Process out-of-band data
Returns
An object contains following properties:
address String. A dotted number IP address of the sourceport Integer. The port of the source
length Integer. The number of bytes received.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
478 FFish Script Objects Reference
2.51.2.15 send
Description
Sends data on a connected socket.
Syntax
socket.send(stream, len[, flag])
Parameters
stream A StringStream object containing the output data.
len Specifies the number of bytes to send.
flag Optional. Integer. Specifies the way in which the call is made.It can be a combination of the following data:Flag Description0x04 Specifies 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 specific destination.
Syntax
socket.sendTo(stream, len, port[, address[, flag]])
Parameters
stream A StringStream object containing the output data.
len Specifies the number of bytes to send.
port Integer. The port of the destination.
address Optional. String. Specifies the network address of the desti-nation. If this parameter is not specified, the socket sends abroadcast.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 479
flag Optional. Integer. Specifies the way in which the call is made.It can be a combination of the following data:Flag Description0x04 Specifies 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.17 shutDown
Description
Disables sends or receives on the socket.
Syntax
socket.shutDown([how])
Parameters
how Optional. Integer. Describes what types of operation will nolonger be allowed, using the following values:0 receives1 sends2 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)
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
480 FFish Script Objects Reference
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 hostbyte order. Static.
Syntax
socket.ntohl(netlong)
Parameters
netlong Integer. Represents a 32-bit number in TCP/IP network byteorder.
Returns
Integer
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.51 Socket Object 481
2.51.2.21 ntohs
Description
Converts a 16-bit integer from TCP/IP network byte order to hostbyte order. Static.
Syntax
socket.ntohs(netshort)
Parameters
netshort Integer. Represents a 16-bit number in TCP/IP network byteorder.
Returns
Integer
2.51.3 Events
2.51.3.1 onAccept
Description
Fires when a listening socket can accept pending connection requestsby 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}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
482 FFish Script Objects Reference
2.51.3.3 onConnect
Description
Fires when the connection attempt of the connecting socket is com-pleted.
Syntax
socket. onConnect = function (){
body}
2.51.3.4 onOOBData
Description
Notifies the receiving socket that the sending socket has out-of-banddata to send.
Syntax
socket.onOOBData = function (){body}
2.51.3.5 onReceive
Description
Fires when there is data in the buffer that can be retrieved by thesocket.
Syntax
socket.onReceive = function (){
body}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.52 SplashWnd 483
2.51.3.6 onSend
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 screensavers.
available: SWFKit Pro
Syntax
new SplashWnd(width, height)
Parameters
width Integer. Specifies the width of the splash window.
height Integer. Specifies the height of the splash window.
Remarks
SWFKit Pro 2 can only maintain one splash window at the sametime. That is to say, if you want to create another splash win-dow, you must firstly close the created one. Or the expression ”newSplash(width, height)” will always return a reference to the createdone.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
484 FFish Script Objects Reference
2.52.1 Properties
2.52.1.1 timeout
Description
Integer. Specifies the time-out interval, in milliseconds. The splashwindow closes and the onTimeout event fires if the interval elapses.
Syntax
splashwnd.timeout
2.52.1.2 window
Description
A window object represents the splash window. The object is invalidafter the after the splash window has been closed.
Syntax
splashwnd.window
2.52.2 Methods
2.52.2.1 loadSWF
Description
Loads a swf movie into the splash window.
Syntax
splashwnd.loadSWF(movie)
Parameters
movie String. Specifies the full path name of the SWF movie.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.53 Splash2 485
2.52.3 Events
2.52.3.1 onFSCommand
Description
Fires when the playing movie in the splash window calls a FSCom-mand
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
486 FFish Script Objects Reference
Creates and displays a splash window. Not available for screensavers. Unlike the SplashWnd object, this splash window objectwill run in a new thread; that is to say, even if the main programhas been blocked by a time costing operation. For example, if theoutput executable file of swfkit has a lot of resource files packed init, the “getAdditionalFile” method in the “initialize” script will taketo long time to extract the resource files. Before all the resource fileshave been extracted, the main program will be blocked. If you usethe SplashWnd object to create a splash window before the “getAd-ditionalFile” method, the splash window will also be blocked; how-ever, if you use Splash2 object instead, the splash window will notbe blocked.
available: SWFKit Pro
Syntax
new Splash2(movie, timeout)
Parameters
movie String. Specifies the swf movie to be played in the splash win-dow
timeout Integer. Life span of the splash window in milliseconds. Youget also set this parameter to a rather big value, and close thesplash window later manually by using the “close” method.
2.53.1 Methods
2.53.1.1 close
Description
Closes the splash window
Syntax
splash2.close();
Parameters
None
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 487
2.54 Printer
Description
The Printer object provides methods to enumerate printers in sys-tem, 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();//orPrinter.printPreview();
During printing or print preview, 5 events will be fired. Youcan change the printer properties and define the print jobs inthese event handlers. The event handlers are uniform for bothprinting and print preview, so you can get the same result inboth printing and print preview.The following pseudo code shows how will these event handlersbe called.
function print_or_print_preview(){
onPreparePrinting()onBeginPrinting()
for (i = 0; i < pages; i++){
onNewPage(i);onPrint(i);
}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
488 FFish Script Objects Reference
onEndPrinting();}
5. Handles the onPreparePrinting eventIn the onPreparePrinting event handler, you should set the to-tal count of pages you want to print. You can also changethe printer used to print or set the title of the document init. If you don’t want to launch a print dialog, set the silentproperty to true. Remember to use the ”this” pointer to ac-cess the properties or methods of the Printer object. For the”this” pointer contains the printer context used to differentiatebetween printing and print preview.
Printer.onPreparePrinting = function (){
this.pageCount = 3;this.silent = true;
}
6. Handles the onBeginPrinting eventIn the onBeginPrinting event handler, you can set several prop-erties of the printer such as orientation, paper size or copies ofthe document to print. The properties may have been set inthe print dialog before this event after the onPreparePrintingevent, 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 eventThe onNewPage will be fired before rendering a new page. Inthis event you can abort printing by set the continuePrintingproperty to false;
Printer.onNewPage = function (page){
if (page >= 2){
this.continuePrinting = false;}
}
8. Handles the onPrint eventThis event handler is used to render the page. The Printerprovides properties and methods to draw text, images, lines,etc.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 489
The following code shows how to print the screen.
//capture screenimage = Image.captureScreen();
Printer.onPrint(page){
// only render the first pageif (page > 0) return;
// get the image size(not it’s actual size,//but its size should be on paper)var size = this.getImageSize(image);
// put the image on the center of the papervar 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 prop-erties before drawing text. If the bkMode is set to opaque,the character cells will be filled with the bkColor. Other-wise 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 draw-ing a shape. The pen is used to draw the frame of theshape, the brush is used to fill the shape. If you only wantto draw the frame of the shape, set brush to hollow.
2.54.1 Properties
2.54.1.1 printers
Description
Array. Returns all of the names of printers in system.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
490 FFish Script Objects Reference
Syntax
Printer.printers
2.54.1.2 printerIndex
Description
Integer. Specifies a printer in the printer list returned by the ”print-ers” property used to print.
Syntax
Printer.printers
Example
trace(Printer.printers[Printer.printerIndex]);
Printer.printerIndex = 0;
2.54.1.3 title
Description
String. Specifies the title of the document
Syntax
Printer.title
2.54.1.4 pageCount
Description
Integer. Specifies the total number of pages of the document. Youmust set it in the onPreparePrinting event handler.
Syntax
Printer.pageCount
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 491
2.54.1.5 silent
Description
Boolean. You can set it to true in the onPreparePrinting eventhandler 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 theonBeginPrinting 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 inthe onBeginPrinting event handler. It can be one of the followingvalues:
Value Description
1 Letter 8 1/2 x 11 in
2 Letter Small 8 1/2 x 11 in
3 Tabloid 11 x 17 in
4 Ledger 17 x 11 in
5 Legal 8 1/2 x 14 in
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
492 FFish Script Objects Reference
continued from the previous page
Value Description
6 Statement 5 1/2 x 8 1/2 in
7 Executive 7 1/4 x 10 1/2 in
8 A3 297 x 420 mm
9 A4 210 x 297 mm
10 A4 Small 210 x 297 mm
11 A5 148 x 210 mm
12 B4 (JIS) 250 x 354
13 B5 (JIS) 182 x 257 mm
14 Folio 8 1/2 x 13 in
15 Quarto 215 x 275 mm
16 10x14 in
17 11x17 in
18 8 1/2 x 11 in
19 Envelope #9 3 7/8 x 8 7/8
20 Envelope #10 4 1/8 x 9 1/2
21 Envelope #11 4 1/2 x 10 3/8
22 Envelope #12 4 3/4 x 11
23 Envelope #14 5 x 11 1/2
24 C size sheet
25 D size sheet
26 E size sheet
27 Envelope DL 110 x 220mm
28 Envelope C5 162 x 229 mm
29 Envelope C3 324 x 458 mm
30 Envelope C4 229 x 324 mm
31 Envelope C6 114 x 162 mm
32 Envelope C65 114 x 229 mm
33 Envelope B4 250 x 353 mm
34 Envelope B5 176 x 250 mm
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 493
continued from the previous page
Value Description
35 Envelope B6 176 x 125 mm
36 Envelope 110 x 230 mm
37 Envelope Monarch 3.875 x 7.5 in
38 6 3/4 Envelope 3 5/8 x 6 1/2 in
39 US Std Fanfold 14 7/8 x 11 in
40 German Std Fanfold 8 1/2 x 12 in
41 German Legal Fanfold 8 1/2 x 13 in
42 B4 (ISO) 250 x 353 mm
43 Japanese Postcard 100 x 148 mm
44 9 x 11 in
45 10 x 11 in
46 15 x 11 in
47 Envelope Invite 220 x 220 mm
48 RESERVED–DO NOT USE
49 RESERVED–DO NOT USE
50 Letter Extra 9
275 x 12 in
51 Legal Extra 9
275 x 15 in
52 Tabloid Extra 11.69 x 18 in
53 A4 Extra 9.27 x 12.69 in
54 Letter Transverse 8
275 x 11 in
55 A4 Transverse 210 x 297 mm
56 Letter Extra Transverse 9
275 x 12 in
57 SuperA/SuperA/A4 227 x 356 mm
58 SuperB/SuperB/A3 305 x 487 mm
59 Letter Plus 8.5 x 12.69 in
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
494 FFish Script Objects Reference
continued from the previous page
Value Description
60 A4 Plus 210 x 330 mm
61 A5 Transverse 148 x 210 mm
62 B5 (JIS) Transverse 182 x 257 mm
63 A3 Extra 322 x 445 mm
64 A5 Extra 174 x 235 mm
65 B5 (ISO) Extra 201 x 276 mm
66 A2 420 x 594 mm
67 A3 Transverse 297 x 420 mm
68 A3 Extra Transverse 322 x 445 mm
69 Japanese Double Postcard 200 x 148 mm
70 A6 105 x 148 mm
71 Japanese Envelope Kaku #2
72 Japanese Envelope Kaku #3
73 Japanese Envelope Chou #3
74 Japanese Envelope Chou #4
75 Letter Rotated 11 x 8 1/2 11 in
76 A3 Rotated 420 x 297 mm
77 A4 Rotated 297 x 210 mm
78 A5 Rotated 210 x 148 mm
79 B4 (JIS) Rotated 364 x 257 mm
80 B5 (JIS) Rotated 257 x 182 mm
81 Japanese Postcard Rotated 148 x 100 mm
82 Double Japanese Postcard Rotated 148 x 200 mm
83 A6 Rotated 148 x 105 mm
84 Japanese Envelope Kaku #2 Rotated
85 Japanese Envelope Kaku #3 Rotated
86 Japanese Envelope Chou #3 Rotated
87 Japanese Envelope Chou #4 Rotated
88 B6 (JIS) 128 x 182 mm
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 495
continued from the previous page
Value Description
89 B6 (JIS) Rotated 182 x 128 mm
90 12 x 11 in
91 Japanese Envelope You #4
92 Japanese Envelope You #4 Rotated
93 PRC 16K 146 x 215 mm
94 PRC 32K 97 x 151 mm
95 PRC 32K(Big) 97 x 151 mm
96 PRC Envelope #1 102 x 165 mm
97 PRC Envelope #2 102 x 176 mm
98 PRC Envelope #3 125 x 176 mm
99 PRC Envelope #4 110 x 208 mm
100 PRC Envelope #5 110 x 220 mm
101 PRC Envelope #6 120 x 230 mm
102 PRC Envelope #7 160 x 230 mm
103 PRC Envelope #8 120 x 309 mm
104 PRC Envelope #9 229 x 324 mm
105 PRC Envelope #10 324 x 458 mm
106 PRC 16K Rotated
107 PRC 32K Rotated
108 PRC 32K(Big) Rotated
109 PRC Envelope #1 Rotated 165 x 102 mm
110 PRC Envelope #2 Rotated 176 x 102 mm
111 PRC Envelope #3 Rotated 176 x 125 mm
112 PRC Envelope #4 Rotated 208 x 110 mm
113 PRC Envelope #5 Rotated 220 x 110 mm
114 PRC Envelope #6 Rotated 230 x 120 mm
115 PRC Envelope #7 Rotated 230 x 160 mm
116 PRC Envelope #8 Rotated 309 x 120 mm
117 PRC Envelope #9 Rotated 324 x 229 mm
continued on next page
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
496 FFish Script Objects Reference
continued from the previous page
Value Description
118 PRC Envelope #10 Rotated 458 x 324 mm
Syntax
Printer.paperSize
2.54.1.8 copies
Description
Integer. Selects the number of copies printed. You can set it in theonBeginPrinting event handler.
Syntax
Printer.copies
2.54.1.9 continuePrinting
Description
Boolean. It can be used in the onNewPage event handler. Set it tofalse 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 onPrintevent handler.
Syntax
Printer.pageHeight
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 497
2.54.1.11 pageWidth
Description
Integer. Returns the width of the page. It can be used in the onPrintevent handler.
Syntax
Printer.pageWidth
2.54.1.12 font
Description
FontObject object. Selects the current font to draw text. It can beused 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 fill shapes. It can be used inthe onPrint event handler. Write only.The properties must be assigned by an object contains the followingproperties
style Integer. Specifies the brush style. It can be the following values:
0 – Solid brush1 – Hollow brush2 – Hatched brush
color Integer. Specifies the brush color.
hatch Integer. Specifies a hatch style(for a hatched brush). It can beone of the following values:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
498 FFish Script Objects Reference
0 – Horizontal hatch1 – Vertical hatch2 – A 45-degree downward, left-to-right hatch3 – A 45-degree upward, left-to-right hatch4 – Horizontal and vertical cross-hatch5 – 45-degree crosshatch
Syntax
Printer.brush
Example
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 beused in the onPrint event handler. Write only.The properties must be assigned by an object contains the followingproperties
style Integer. Specifies the pen style. It can be the following values:
0 – The pen is solid.1 – The pen is dashed.2 – The pen is dotted.3 – The pen has alternating dashes and dots4 – The pen has dashes and double dots.5 – The pen is invisible.
color Integer. Specifies the pen color.
width Integer. Specifies the width of the pen.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 499
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);}
2.54.1.15 bkColor
Description
Integer. Sets the background color to draw text. It can be used inthe 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 theonPrint event handler. Write only.Note: the FontObject also has a color property, but it can not changethe color to draw text.
Syntax
Printer.textColor
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
500 FFish Script Objects Reference
2.54.1.17 bkMode
Description
Integer. Sets the background mode to draw text. It can be used inthe 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 filled with the bkColor.
Syntax
Printer.bkMode
2.54.2 Methods
2.54.2.1 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 501
2.54.2.3 printText
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 inthe event handler. For the ”this” object contains the print context.
This method is provided only for compatibility with the old versionof swfkit pro. New applications should use the printText2 method
Syntax
Printer.printText(text, left, top, width, height, flag)
Parameters
text String. Represents the text to draw.
left, top, width, height Integer. Represents a rectangle to draw the text in.
flag Integer. Specifies how to format the text. It can be one or moreof the following value.
0 – Justifies the text to the top of the rectangle or Aligns textto the left
1 – Centers text horizontally in the rectangle2 – Aligns text to the right4 – Centers text vertically. This value is used only when you
draw text on a single line8 – Justifies the text to the bottom of the rectangle. This value
is used only when you draw text on a single line16 – Breaks words. Lines are automatically broken between
words if a word would extend past the edge of the rect-angle. A carriage return-line feed sequence also breaks theline.
32 – Displays text on a single line only. Carriage returns andline feeds do not break the line.
64 – Expands tab characters. The default number of charactersper tab is eight.
128 – Sets tab stops. Bits 15C8 (high-order byte of the low-order word) of the flag parameter specify the number ofcharacters for each tab. The default number of charactersper 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 oftext.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
502 FFish Script Objects Reference
2048 – Turns off processing of prefix characters
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 objectcontains 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. Specifies the width of each tab stop. Thedefault value is 32, which means eight times of the averagecharacter width (based on uppercase and lowercase alphabeticcharacters only) of the font used at the time of printing.
wrap Boolean. Optional. Wraps the text in the rectangle or not. Thedefault value is true, which means the text will be wrapped.
Returns
String. If the text is too long to print in the rectangle, the methodwill return the remain words.
2.54.2.5 getWrappedTextExtent
Description
Gets the height of the specified text which would be print in a col-umn.
It can be and can only be called in the ‘onPrint’ event handler withthe ‘this’ object, for only the this object contains the printing con-text.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 503
Syntax
this.getWrappedTextExtent(text, columnwidth[, tabstop])
Parameters
text String. Represents the text to calculate the height.
columnwidth Integer. Specifies the width of the column in which the textwould be print.
tabstop Integer. Optional.Specifies the with of each tab stop. Thedefault value is 32, which means eight times of the averagecharacter width (based on uppercase and lowercase alphabeticcharacters only) of the font used at the time of printing.
Returns
Integer. The height of the text.
2.54.2.6 getTabbedTextExtent
Description
Gets the width and height of the specified single line text.
It can be and can only be called in the ‘onPrint’ event handler withthe ‘this’ object, for only the this object contains the printing con-text.
Syntax
this.getTabbedTextExtent(text[, tabstop])
Parameters
text String. Represents the text to calculate the width and height.
tabstop Integer. Optional.Specifies the with of each tab stop. Thedefault value is 32, which means eight times of the averagecharacter width (based on uppercase and lowercase alphabeticcharacters only) of the font used at the time of printing.
Returns
Object. The object contains two Integer properties, ‘width’ and‘height’.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
504 FFish Script Objects Reference
2.54.2.7 getTextHeight
Description
Gets the height of the specified text. You can use it in the ”onPrint”event handler, and remember to call it by using the ”this” objectin the event handler. For the ”this” object contains the printingcontext.This method is provided only for compatibility with the old versionof swfkit pro. New applications should use the getWrappedTextEx-tent 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 it’s true, the text will be wrapped in the rectangle,and the method returns the total height of the text on multilines; 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 inthe ”onPrint” event handler, and remember to call it by using the”this” object in the event handler. For the ”this” object containsthe print context.
Syntax
Printer.getTextExtent(text)
Parameters
text String. Represents a string text.
Returns
Object. Contains two properties.
width – Integer. The width of the textheight – Integer. The height of the text
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 505
2.54.2.9 printImage
Description
Draws an image. You can use it in the ”onPrint” event handler, andremember 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 toget the dimension of an image. But that’s its real size. This methodreturns the size of the image should be on paper. You can use it inthe ”onPrint” event handler, and remember to call it by using the”this” object in the event handler. For the ”this” object containsthe 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
506 FFish Script Objects Reference
2.54.2.11 line
Description
Draws a line. You can use it in the ”onPrint” event handler, andremember 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 Integer. Specifies the x-coordinate of the line’s starting point.y0 Integer. Specifies the y-coordinate of the line’s starting point.x1 Integer. Specifies the x-coordinate of the line’s ending point.y1 Integer. Specifies the y-coordinate of the line’s ending point.
Returns
Nothing
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 eventhandler. For the ”this” object contains the print context.
Syntax
Printer.rectangle(left, top, width, height)
Parameters
left Integer. Specifies the x-coordinate of the upper-left corner ofthe rectangle
top Integer. Specifies the y-coordinate of the upper-left corner ofthe rectangle
width Integer. Specifies the width of the rectangle.height Integer. Specifies the height of the rectangle.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 507
2.54.2.13 roundRect
Description
Draws a round rectangle. You can use it in the ”onPrint” eventhandler, and remember to call it by using the ”this” object in theevent handler. For the ”this” object contains the print context.
Syntax
Printer.roundRect(left, top, width, height, ellipseWidth, ellipseHeight)
Parameters
left Integer. Specifies the x-coordinate of the upper-left corner ofthe rectangle
top Integer. Specifies the y-coordinate of the upper-left corner ofthe rectangle
width Integer. Specifies the width of the rectangle.
height Integer. Specifies the height of the rectangle.
ellipseWidth Integer. Specifies the width of the ellipse.
ellipseHeight Integer. Specifies 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, andremember 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. Specifies the x-coordinate of the upper-left corner ofthe bounding rectangle
top Integer. Specifies the y-coordinate of the upper-left corner ofthe bounding rectangle
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
508 FFish Script Objects Reference
width Integer. Specifies the width of the rectangle.
height Integer. Specifies the height of the rectangle.
Returns
Nothing
2.54.2.15 fillRect
Description
Fills a rectangle(without drawing the frame and you don’t need toset the pen and brush properties). You can use it in the ”onPrint”event handler, and remember to call it by using the ”this” object inthe event handler. For the ”this” object contains the print context.
Syntax
Printer.fillRect(left, top, width, height, brush) Printer.fillRect(left,top, width, height, color)
Parameters
left Integer. Specifies the x-coordinate of the upper-left corner ofthe rectangle
top Integer. Specifies the y-coordinate of the upper-left corner ofthe rectangle
width Integer. Specifies the width of the rectangle.
height Integer. Specifies the height of the rectangle.
brush Object. Specifies the brush used to fill the rectangle. See thebrush property.
color Integer. Specifies the color to fill the rectangle.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.54 Printer 509
2.54.3 Events
2.54.3.1 onPreparePrinting
Description
Fires when it’s preparing to print
Syntax
Printer.onPreparePrinting = function (){}
Parameters
None
2.54.3.2 onBeginPrinting
Description
Fires when it’s beginning to print
Syntax
Printer.onBeginPrinting = function (){}
Parameters
None
2.54.3.3 onNewPage
Description
Fires when it’s beginning to print on a new page
Syntax
Printer.onNewPage = function (page){}
Parameters
page Integer. The page number. The number of the first page is 0.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
510 FFish Script Objects Reference
2.54.3.4 onPrint
Description
Fires when it’s printing. You should handle this event to render thepage.
Syntax
Printer.onPrint = function (page){}
Parameters
page Integer. The page number. The number of the first 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, loadit by the ”load” method or capture an image by the ”capture-Screen” method or the ”captureMovie” method. You can also get animage 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 in-terface. The TWAIN interface feature is not available for ScreenSavers.
The supported image formats are:
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.55 Image 511
bmp – read, writewmf emf – readjpg jpeg – read, write
ico – readpcx – read
tiff tif – readtga – readgif – read
png – read, write
Remarks
The Image object supports the TWAIN interface, you can use it toscan images using a scanner:
1. Initializes the TWAIN driver
Image.twainInit();
2. Selects a source
Image.twainSelectSource();
3. Acquires imagesWhen an image is transferred to the application, the onCopy-Image event will be fired. You should save the transferred imageby handling the event
var imgs = [];Image.twainAcquire();
Image.onCopyImage = function (image){
imgs.push(image);image.loadImage(1);
}
2.55.1 Properties
2.55.1.1 width
Description
Integer. Returns the width of the image. Read-only.
Syntax
image.width
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
512 FFish Script Objects Reference
2.55.1.2 height
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. Read-only.
Syntax
image.bitCount
2.55.1.4 twainReady
Description
Boolean. If it’s ready to use the TWAIN interface. You must callthe twainInit method firstly, 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 youcan acquire images.
Syntax
image.twainSourceSelected
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.55 Image 513
2.55.2 Methods
2.55.2.1 load
Description
Loads an image.
Syntax
image.load(name[, bkcolor, width, height, index])
Parameters
name String. Specifies the full path name of the image to load.
bkcolor Integer. Optional. Specifies the background color of the image.Images support transparent background such as icons, png filesneed the parameter. The default value is white.
width, height Integer. Specifies the width and height of the image to load.Only needed for loading icons. An icon file may contains aserial of images with different size.
index Integer. Specifies the index of the image to load. Gif files andtif files may contain more than one image, use this parameterto specify the image you want to load in the image file. Theindex of the first 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
Description
Saves an image.
Syntax
image.save(name[, compresslevel])
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
514 FFish Script Objects Reference
name String. Specifies the full path name of the image to save.compresslevel Integer. Optional. For saving png files, it can be from 0 to 9.
0 means no compression, 9 means maximum compression. Thedefault value is 5. For saving jpg files, 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 flip
Description
Flips the image.
Syntax
image.flip()
Parameters
None
Returns
Boolean
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.55 Image 515
2.55.2.5 rotate90
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 specified factor.
Syntax
image.zoom(factor)
Parameters
factor Number. Specifies the zoom factor.
Returns
Boolean
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
516 FFish Script Objects Reference
2.55.2.8 adjustRGB
Description
Modifies the intensities of red, green and blue in the color of eachpixel in the image by adding the specified values.
Syntax
image.adjustRGB(r, g, b)
Parameters
r Integer. Specifies the value to add to the intensity of red.
g Integer. Specifies the value to add to the intensity of green.
b Integer. Specifies 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. Specifies the value to adjust.
rate float. Specifies the rate to adjust.
Returns
Boolean
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.55 Image 517
2.55.2.10 adjustContrast
Description
Adjusts the contrast of the image.
Syntax
image.adjustContrast(percent)
Parameters
percent Integer. Specifies 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. Specifies the percent of the hue to adjust. From 0 to100.
spercent Integer. Specifies the percent of the saturation to adjust. From0 to 100.
Returns
Boolean
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
518 FFish Script Objects Reference
2.55.2.12 invert
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.55 Image 519
2.55.2.15 sharpen
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. Specifies 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
520 FFish Script Objects Reference
2.55.2.18 toGray
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 file. For bmp, jpg, png, wmf andico files, the method always returns 1.
Syntax
Image.getCount(name)
Parameters
name String. Specifies the full path name of the image file.
Returns
Integer
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.55 Image 521
2.55.2.21 captureScreen
Description
Captures screen and returns an image object.
Syntax
Image.captureScreen([left, top, width, height])
Parameters
left, top, right, bottom Optional. Integer. Specifies the coordinates of the upper-leftand lower-right corners of a rectangle. The rectangle definesthe area of screen to capture. If you call the method withoutparameters, 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. Specifies the coordinates of the upper-leftand lower-right corners of a rectangle. The rectangle defines thearea of the playing movie to capture. If you call the methodwithout parameters, it will capture the entire movie.
Returns
An image object. If fails, return null.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
522 FFish Script Objects Reference
2.55.2.23 loadImage
Description
Loads the image into the specified level of the movie.
Syntax
image.loadImage(level)
Parameters
level Integer. Specifies 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.56 DirectX 523
2.55.2.26 twainAcquire
Description
Acquires images.
Syntax
Image.twainAcquire()
Parameters
None
Returns
Nothing
2.55.3 Events
2.55.3.1 onCopyImage
Description
Fires when an image is transferred from the TWAIN driver to theapplication.
Syntax
Image.onCopyImage = function (image){}
The image parameter is an Image object represents the transferredimage.
2.56 DirectX
Description
Uses DirectX to change the screen resolution and enumerates joy-sticks. You can make your full screen sized applications run fasterusing the DirectX object to set a lower screen resolution.
available: SWFKit Express, SWFKit, SWFKit Pro
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
524 FFish Script Objects Reference
2.56.1 Properties
2.56.1.1 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 joystickguid String. The unique identifier 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 Methods
2.56.2.1 setDisplayMode
Description
Sets the display mode.
Syntax
DirectX.setDisplayMode(width, height, colordepth)
Parameters
width Integer. Specifies the width of the screen.height Integer. Specifies the height of the screen.
colordepth Integer. Specifies the color depth.
Returns
Boolean. If DirectX has not been installed or the specified displaymode is not supported, returns false. The method requires at leastDirectX 3. You can list all supported display modes using the ”Sys-Info.getDisplayMode” method.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.57 Joystick 525
2.56.2.2 restore
Description
Resets the mode of the display device hardware to what it was beforethe 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 Properties
2.57.1.1 buttons
Description
Array. Returns names of all the buttons of the joystick
Syntax
joystick.buttons
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
526 FFish Script Objects Reference
2.57.1.2 x
Description
Integer. X-axis, usually the left-right movement of a stick. Read-only.
Syntax
joystick.x
2.57.1.3 y
Description
Integer. Y-axis, usually the forward-backward movement of a stick.Read-only.
Syntax
joystick.y
2.57.1.4 z
Description
Integer. Z-axis, often the throttle control. Read-only.
Syntax
joystick.z
2.57.1.5 rx
Description
Integer. X-axis rotation. Read-only.
Syntax
joystick.rx
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.57 Joystick 527
2.57.1.6 ry
Description
Integer. Y-axis rotation. Read-only.
Syntax
joystick.ry
2.57.1.7 rz
Description
Integer. Z-axis rotation (often called the rudder). Read-only.
Syntax
joystick.rz
2.57.1.8 uaxis
Description
Integer. u-axis. Read-only.
Syntax
joystick.uaxis
2.57.1.9 vaxis
Description
Integer. v-axis. Read-only.
Syntax
joystick.vaxis
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
528 FFish Script Objects Reference
2.57.1.10 pov0, pov1, pov2, pov3
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 twoproperties
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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.57 Joystick 529
2.57.2 Methods
2.57.2.1 read
Description
Reads input of the joystick and fires 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");}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
530 FFish Script Objects Reference
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 specified button. You should call the ”read”method before get the state of a button.
Syntax
joystick.buttonState(index)
Parameters
index Integer. Specifies the index of the button. The index of thefirst button is 0.
Returns
Boolean. If the button is pressed, returns true.
Example
function readJoystick(){
joy[0].read();
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.57 Joystick 531
trace(joy[0].buttonState[0]);}
Application.setInterval(readJoystick, 50);
2.57.3 Events
2.57.3.1 onLeft
Description
Fires when a stick moves left
Syntax
joystick.onLeft = function (){}
2.57.3.2 onRight
Description
Fires when a stick moves right
Syntax
joystick.onRight = function (){}
2.57.3.3 onUp
Description
Fires when a stick moves up
Syntax
joystick.onUp = function (){}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
532 FFish Script Objects Reference
2.57.3.4 onDown
Description
Fires when a stick moves down
Syntax
joystick.onDown = function (){}
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 files) 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 func-tion in a dll. The first one is to call the registerFunction method ofthe Dll object, and the second one is to use the dllimport keyword.The latter method is recommended. You can read the manual pageof the registerFunction method to learn how to use it. At here wewill only introduce the dllimport keyword as follows.
The dllimport keyword is used to import an external function so thatyou can call the function in ffish script as if it is a built-in function.The dllimport clause has the form
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.58 Dll 533
dllimport libraryName callType returnType functionName(arg0, arg1,..., argN) [as alias];
Where libraryName is the path name of the dll that contains thefunction to import. It can be either a string constant or a stringvariable. callType specifies the calling convention of the functionto import, which can be either stdcall or cdecl. The fastcall callingconvention is not supported in SWFKit Pro 3.0 yet. returnTypespecifies the return type of the function. functionName is the nameof the function exported by the dll. arg0, arg1, ... argN declarethe parameters of the function, which define the type of the eachparameter, with or without the name of each parameter. alias isoptional, which specifies the alias of the function. If you specify analias for the function, you must call the function by using the aliasin ffish script; otherwise, you must use the functionName to call it.For instance:
dllimport "user32.dll" stdcall long GetWindowLong(pointer, int) asuser32_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 pa-rameters:
void For returns only, you cannot declare a parameter to be of thistype. This type means that the function has no return.
char The return value or a parameter is a character. When a func-tion returns a value of char type, the value will be converted toa Number object in ffish script that contains the ASCII valueof the character. String objects and Number objects can bepassed as a parameter of char type. Only the first character ofa String object will be used to set the value of the parameter;if a Number object is used, SWFKit will convert its value to acharacter and then pass the character to the function.
unsigned char The return value or a parameter is an unsigned character. Thistype is similar to the char type.
char* The return value or a parameter is a pointer to a char valueor a ansi string. When a function’s return is of char* type,SWFKit will simply convert it to a Number object that rep-resents the address of the pointer, not the value it points to.In fact SWFKit will always do in this way when a functionreturns a pointer. The address of the pointer should be re-tained because the pointer may point to an allocated memory
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
534 FFish Script Objects Reference
and may be used to free the memory later. You can use thegetPointerXXXValue methods of the Dll object such as get-PointerStringValue, getPointerWideStringValue, etc to get thevalue it points to. When a parameter is of char* type, you canuse A String object or A Number object to pass parameter.SWFKit will convert a String object to a c-style string (a nullterminated string) before pass it to the function if the param-eter is of char* type. For a Number object, SWFKit will firstconvert it to a char value and then allocate a pointer to passto the function, which points to the converted char value.
unsigned char* Similar to the char* type.short The return value or a parameter is a short integer (A short
integer is 16 bits). When a function returns a value of shorttype, the value will be converted to a Number object. Stringobjects and Number objects can be passed as a parameter ofshort type. Only the first character of a String object will beused to set the value of the parameter; if a Number object isused, SWFKit will convert it to a short integer and then passthe value to the function.
unsigned short Similar to the short type.short* 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 thatrepresents the address of the pointer. When a function’s param-eter is of short* type, you can use a String object or a Numberobject to pass parameter. SWFKit will convert a String objectto a wide string (null terminated) before pass it to the function.For a Number object, SWFKit will first convert it to a short in-teger and then allocate a pointer to pass to the function, whichpoints to the converted short integer.
unsigned short* Similar to the short* type.long 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 con-verted to a Number object. String objects, Number objectsand Boolean objects can be passed as parameters of long type.Only the first character of a String object will be used to setthe value of the parameter; if a Number object or a Booleanobject is used, SWFKit will convert it to a long value and thenpass the value to the function.
unsigned long Similar to the long type.long* The return value or a parameter is a pointer to a long value.
When a function returns a value of long* type, SWFKit willsimply convert it to a Number object that represents the ad-dress of the pointer. When a function’s parameter is of long*
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.58 Dll 535
type, you would have to use a Number object or a Boolean ob-ject to pass value to it. In this case, SWFKit will convert theNumber object or the Boolean object to a long value, and thenallocate a pointer to pass to the function, which points to theconverted long value.
unsigned long* Similar to the long* type.int Same as the long type.
unsigned int Same as the unsigned long type.int* Same as the long* type.
unsigned int* Same as the unsigned long* type.int64 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 convertedto a Number object. String objects and Number objects can bepassed as parameters of int64 type. Only the first character ofa 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-bitlong integer value and then pass the value to the function.
int64* The return value or a parameter is a pointer to a 64-bit signedinteger. When a function returns a value of int64* type,SWFKit will simply convert it to a Number object that repre-sents the address of the pointer. When a function’s parameteris of int64* type, you would have to use a Number object topass value to it. In this case, SWFKit will convert the Num-ber object to a 64-bit long integer, and then allocate a pointerto pass to the function, which points to the converted 64-bitinteger.
unsigned int64 Similar to the int64 type.unsigned int64* Similar to the int64* type.
float The return value or a parameter is a 4-byte floating-point num-ber. When a function returns a value of this type, the value willbe converted to a Number object. String objects and Numberobjects can be passed as parameters of this type. Only the firstcharacter of a String object will be used to set the value of theparameter; if a Number object is used, SWFKit will convertit to a floating-point number and then pass the value to thefunction.
double Similar to the float type. The difference between the floattype and the double type is that the double type is 8 byteslong.
float* The return value or a parameter is a pointer to a 4-byte floating-point number. When a function returns a value of float* type,SWFKit will simply convert it to a Number object that rep-resents the value of the pointer. When a function’s parameter
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
536 FFish Script Objects Reference
is of float* type, you would have to use a Number object topass value to it. In this case, SWFKit will convert the Numberobject to a 4-byte floating-point number, and then allocate apointer to pass to the function, which points to the converted4-byte floating-point number.
double* Similar to the double type.
pointer The return value or a parameter is a pointer to an unspeci-fied type. When a function returns a value of pointer type,SWFKit will simply convert it to a Number object that rep-resents the address of the pointer. Similarly, you can pass aNumber object as a parameter of pointer type to a function.In this case, SWFKit does not allocate a pointer to pass to thefunction. Instead, the value of the Number object is convertedto a pointer and passed to the function, that is, the Numberobject must represent address of a pointer.A Struct object or a StringStream object can also be used topass as a pointer type parameter. In this case, SWFKit willallocate a pointer to pass to the function, which points to thebinary data hold by the Struct object or the StringStream ob-ject.
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. Thedetails of structure type will be introduced later in this manualpage. If the return value of a function is of structure type,SWFKit will convert the return value to a Struct object. Ifa parameter of a function is of structure type, you can use aStruct object or a StringStream object that has the same datasize as that of the pre-declared structure type to pass value tothe function.
StructName* The return value or a parameter is a pointer to a pre-declaredstructure type ”StructName”. If the return value of a functionis of this type, SWFKit will simply convert it to a Numberobject that represents the address of the pointer. If a parameterof a function is of this type, you can use a Struct object or aStringStream object to pass value to the function. In this case,a pointer is allocated and passed to the function, which pointsto the binary data hold by the Struct object or the StringStreamobject.
Note: the above types can only be used to declare dll functionsin FFish Script. You cannot use them to declare a FFish Script
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.58 Dll 537
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 inFFish Script, we introduces a new element into the FFish Scriptinglanguage - the structure type. A structure type is declared by thestruct keyword, and the declaration of a structure type is similarto that in the c/c++ languages. The declaration of a structure typehas the following form:
struct{
type0 itemName0;type1 itemName1;...typeN itemNameN;
} StructName;
where typeN is the type of the Nth member of the structure. item-NameN is the name of the Nth member. StructName is the name ofthe structure type. The valid types of a structure member are thesame as those of a function parameter. Moreover, SWFKit Pro 3supports 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 aninstance of the declared structure type, you should create a Structobject 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;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
538 FFish Script Objects Reference
Pass values to parameters by referenceGenerally, SWFKit Propass parameters to functions by value. However, many dll functionshave out parameters, that is, these parameters will be used for out-put so that they must be passed by reference. The ffish scriptinglanguage does not support to pass parameters by reference directly,so an alternative calling method is introduced into the ffish script-ing language to support this feature. The method is to use Objectobjects to pass parameters to functions. The objects used to do thismust have a ”value” property, which is the actual variable to passto the functions. After calling the functions, the ”value” propertyof the objects will contain the new value output by the functions.
2.58.1 Methods
2.58.1.1 registerFunction
Description
Registers a dll function. After the function has been registered, youcan call it like a global function.
Syntax
Dll.registerFunction(libName, funcName[, aliasName[, callType[, [ret-Type, [argType, ...]]]]])
Parameters
libName String. Specifies the dll file name
funcName String. Specifies the function name to register.
aliasName String. Specifies the alias name of the function. It’s used tocall the registered function.
callType String. Specifies the call type. ”cdecl” or ”stdcall”
retType String. Specifies the return type. supported types are:
void – Specifies the function doesn’t return a valuevoid* – A pointer.char – A character
char* or string – A stringbyte – A byte
byte* – A byte pointershort – A short integer
short* – A short integer pointerwidestring – A wide string(Each character in the string is 16 bits).
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.58 Dll 539
ushort – A unsigned short integerushort* – A unsigned short integer pointer
long – A long integerlong* – A long integer pointerulong – A unsigned long integer
ulong* – A unsigned long integer pointerlonglong – A 64 bits integer
float – A floatfloat* – A float pointer
double –double* –
You can also define 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 pointervar MyStructType = new DllParam(8, 0);
//The second parameter 1 indicates//the type is a pointervar PMyStructType = new DllParam(8, 1);
If the function returns a pointer type, in FFish script, you geta integer represents the pointer after calling it. You can usethe ”getPointerValue” method to get its content.If the function returns a customized type, in FFish script, youget a StringStream object after calling it. Otherwise, FFishscript converts the return value to integer or float.
argType String. Specifies the argument type of the function. See theretType.
Returns
Boolean
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
540 FFish Script Objects Reference
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. Specifies the alias name of the function.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.58 Dll 541
2.58.1.3 getPointerValue
Description
Gets the value represented by a pointer.
Syntax
Dll.getPointerValue(pointer, length)
Parameters
pointer Integer. Represents the pointer to get value.
length Integer. Specifies 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 specified pointer.
Syntax
Dll.getPointerStringValue(pointer)
Parameters
pointer Integer. Represents the pointer to get value.
Returns
String.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
542 FFish Script Objects Reference
2.58.1.5 getPointerWideStringValue
Description
Gets the null terminated wide-string represented by the specifiedpointer.
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 Dllobject.
available: SWFKit Pro
Syntax
new Struct(StructName)
Parameters
StructName: a structure type declared by the struct keyword.
2.59.1 Properties
2.59.1.1 align
Description
Integer. Gets or sets the alignment of the structure items. Its valuecan be 1, 2, 4, 8, 16, 32, etc which means that the structure is alignedat 1, 2, 4, 8, 16, 32, etc bytes. This property will affect the data sizeof all structure objects. The default value of this property is 8.
Syntax
Struct.align
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.60 Sound 543
2.59.1.2 structSize
Description
Integer. Returns the data size of the structure object. Note: thedata size of a structure object may change if you change the valueof 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 Properties
2.60.1.1 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
544 FFish Script Objects Reference
2.60.1.3 Sound.playback.masterVolume
Description
An array has two integer items. Gets or sets the master volume forplayback. 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 forplayback. 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.60 Sound 545
2.60.1.7 Sound.playback.midiVolume
Description
An array has two integer items. Gets or sets the midi volume forplayback. 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 forplayback. 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
546 FFish Script Objects Reference
2.60.1.11 Sound.playback.lineInVolume
Description
An array has two integer items. Gets or sets the line in volume forplayback. 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.60 Sound 547
2.60.1.15 Sound.recording.lineInVolume
Description
An array has two integer items. Gets or sets the line in volume forrecording. 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, returnstrue.
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 Events
2.60.2.1 Sound.playback.onMasterMute
Description
Fires when mutes all lines for playback.
Syntax
Sound.playback.onMasterMute = function(){}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
548 FFish Script Objects Reference
2.60.2.2 Sound.playback.onMasterVolumeChange
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(){}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.60 Sound 549
2.60.2.6 Sound.playback.onMidiVolumeChange
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(){}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
550 FFish Script Objects Reference
2.60.2.10 Sound.playback.onLineInVolumeChange
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(){}
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.61 PConn Object 551
2.60.2.14 Sound.recording.onLineInVolumeChange
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 applicationsuse the PConn object to listen for incoming connections, the clientapplications use the PConn object to connect to the server.
available: SWFKit Pro
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
552 FFish Script Objects Reference
Syntax
new PConn();
Usage
The server side
1. Listen with an unique server nameThe server must listen with an unique server name, the clientsuse 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 connectionThe clients needs to call a function defined 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 Methods
2.61.1.1 listen
Description
Creates a server and listen to the incoming connections.
Syntax
pconn.listen(server)
Parameters
server String. Specifies an unique server name.
Returns
Nothing
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.62 Form Object 553
2.61.1.2 send
Description
Connects to a PConn server and call the specified function on theserver. The result of this method is the result of the function calledon the server.
Syntax
pconn.send(server, function, parameters)
Parameters
server String. Specifies unique name of a server to connect.function String. Specifies name of a function to call by this connection.
parameters String. Specifies the parameters to pass to the function on theserver. 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 multipleforms. It can represent a modal or a modeless form.
A form is a modal or modeless window contains a playing Flashmovie(SWF file). The Form object provides methods to create aform and get data from a form.
Each form has a return string. When the form is closed, you cantest the return string of the form to see what action that has beendone by the form. The return string can be returned by the ffish retcommand(see below) or the close method. If the form is closed bythe x button, the return string will be empty.
The playing flash movie in the form can call all the fscommands suchas ffish run, ffish eval which are supported by swfkit. The form ob-ject support one more fscommand than the main movie: the ffish retcommand
fscommand(”ffish ret”, ”the ret value”);
When the movie calls the fscommand, the form will be closed andreturn a string ”the ret value”.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
554 FFish Script Objects Reference
Syntax
new Form();
Usage
1. Define a formThe form is a flash window, so firstly we must specify the movieto 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. Define the onExit event handler to get data fromthe 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 Methods
2.62.1.1 show
Description
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.62 Form Object 555
Displays the form. The method creates and shows the modal ormodeless window. Be sure to set the movie property to a valid value,or the window cannot be created and nothing will be displayed onthe screen otherwise.
If the method displays a modeless window, the method will returnimmediately. If the method displays a modal window, the methodwon’t return until the window has been closed.
Syntax
form.show([modal])
Parameters
modal Boolean. Specifies 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 willreturn a string. The string can be returned by the ffish ret commandor the close method. If the window is closed by the x button on thetop 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. Specifies the return value of the form. The value is theresult of the show method for a modal window, or the param-eter of the onExit event handler for both modal or modelesswindows.
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
556 FFish Script Objects Reference
2.62.1.3 getVariable
Description
Gets the value of the specified variable in the playing movie in theform. This method is only meaningful in the life cycle of the window.Before the window is displayed or after the window is closed, thismethod always returns undefined. This method can be called in theonExit event handler of the form.
Syntax
form.getVariable(variable)
Parameters
variable String. Specifies the name of the variable in the movie to getits value.
Returns
String.
2.62.1.4 setVariable
Description
Sets the value of the specified variable in the playing movie in theform. This method is only meaningful in the life cycle of the window.Before the window is displayed or after the window is closed, thismethod does nothing.
Syntax
form.setVariable(variable, value)
Parameters
variable String. Specifies the name of the variable in the movie to setits value.
value String. The value of the variable to be set.
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.62 Form Object 557
2.62.1.5 targetGotoFrame
Description
Goes to the specified frame. This method is only meaningful in thelife cycle of the window. Before the window is displayed or after thewindow is closed, this method does nothing.
Syntax
form.targetGotoFrame(target, frame)
Parameters
target String. Specifies the target. e.g. ‘ root’
frame Integer. Specifies the frame to go to.
Returns
Nothing.
2.62.1.6 targetGotoLabel
Description
Goes to the specified label. This method is only meaningful in thelife cycle of the window. Before the window is displayed or after thewindow is closed, this method does nothing.
Syntax
form.targetGotoLabel(target, label)
Parameters
target String. Specifies the target. e.g. ‘ root’
label String. Specifies the label to go to.
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
558 FFish Script Objects Reference
2.62.1.7 targetCallFrame
Description
Calls the actions in the specified frame. This method is only mean-ingful in the life cycle of the window. Before the window is displayedor after the window is closed, this method does nothing.
Syntax
form.targetCallFrame(target, frame)
Parameters
target String. Specifies the target. e.g. ‘ root’
label Integer. Specifies the frame to call.
Returns
Nothing.
2.62.1.8 targetCallLabel
Description
Calls the actions in the specified label. This method is only mean-ingful in the life cycle of the window. Before the window is displayedor after the window is closed, this method does nothing.
Syntax
form.targetCallLabel(target, label)
Parameters
target String. Specifies the target. e.g. ‘ root’
label String. Specifies the label to call.
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.62 Form Object 559
2.62.1.9 setBase
Description
Sets the base of the playing movie in the form. This method is onlymeaningful in the life cycle of the window. Before the window isdisplayed or after the window is closed, this method does nothing.
Syntax
form.setBase(path)
Parameters
path String. Specifies the base path (a full path name on disk) ofthe movie.
Returns
Nothing.
2.62.1.10 loadMovie
Description
Loads a movie into the specified layer in the playing movie in theform. This method is only meaningful in the life cycle of the window.Before the window is displayed or after the window is closed, thismethod does nothing.
Syntax
form.loadMovie(layer, movie)
Parameters
layer Integer. Specifies the layer of the movie to load
movie Integer. Specifies the full path name of the movie to load
Returns
Nothing.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
560 FFish Script Objects Reference
2.62.1.11 createControl
Description
Creates and displays an ActiveX control on the form. This methodis similar to the global method ”createControl”. The only differencebetween these two methods is that the global method ”createCon-trol” 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 specifies the ProgID of the ActiveX to be created.left, top, right, bottom Integer. Specifies the control’s size and position on the form.
param Optional. String. Initializes the properties of the ActiveX con-trol. It contains several ”name=value” pairs conjoined by char-acter ‘&’
licensekey Optional. String. Specifies the license key of the ActiveX con-trol.
Returns
An object contains two properties
1. The window propertyThe window property is a Window object that represents thewindow of the created ActiveX control. You can use this prop-erty to set the placement of the ActiveX control, show or hideit, ect.
2. The activex propertyThe activex property is an ActiveXObject object. You can usethis property to access the properties, methods and events ofthe ActiveX control.
2.62.2 Properties
2.62.2.1 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
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.62 Form Object 561
2.62.2.2 showCaption
Description
Boolean. Specifies if the form has caption. Change this propertyhas no effects after the form window is displayed on the screen.
Syntax
form.showCaption
2.62.2.3 canDrag
Description
Boolean. Specifies if the form can be dragged. Change this propertyhas no effects after the form window is displayed on the screen.
Syntax
form.canDrag
2.62.2.4 clipRegion
Description
String. Specifies the name of a pre-defined clip region used to createa customize windowed form. Change this property has no effectsafter the form window is displayed on the screen.
Syntax
form.clipRegion
2.62.2.5 caption
Description
String. Specifies the caption of the form window. Change this prop-erty has no effects after the form window is displayed on the screen.
Syntax
form.caption
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
562 FFish Script Objects Reference
2.62.2.6 initVars
Description
String. Specifies 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 effects after the form window is dis-played on the screen.
Syntax
form.initVars
2.62.2.7 window
Description
Returns a Window object that represents the form window. Read-only.
Syntax
form.window
2.62.3 Events
2.62.3.1 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 theffish ret fscommand or the close method). If the form window isclosed by the x button or alt+f4, the parameter is an empty string.
The movie hasn’t been closed yet, so the getVariable method stillcan work in this event handler.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.63 ScriptHost Object 563
2.63 ScriptHost Object
Description
available: SWFKit Pro
ScriptHost object enables the FFish Scripting language to call otherActive scripting languages such as jscript, vbscript, perlscript, python-script, rubyscript, etc, that is, you now have much more choicesto develop your Flash EXE programs. To use a scripting languageother than FFish, you must first create an instance of the ScriptHostobject, and then open the script engine. For instance, create aScriptHost 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 orthe ”runScriptFile” method. The former one is used to run scriptcode, and the latter one is used to run a script file.
Finally, when a script finishes running, you may want to get thevalue of a variable in the script, or call a function in the script.This can be done by the ”getScriptObject” method, which is anActiveX object. Every global variable in the script is a property ofthe returned ActiveX object, and every global function in the scriptis 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 objecttrace(so);// get the value of the "x" variablevar t = so.x;trace(t); // the result is "hello world"
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
564 FFish Script Objects Reference
// call the _add functiont = so._add(1, 2);trace(t); // the result is "3"
The methods of ScriptHost object works not only in jscript, but invbscript, perlscript, pythonscript, rubyscript, etc.
For the scripts to be called, the ScriptHost object also provides auseful ”Scripter” object. With this object, the scripts can outputmessages to the trace window of SWFKit, and access the variablesand methods in the current Flash movie. The ”Scripter” objectcontains the following properties and method: FlashPlayer an Ac-tiveX object represents the current flash player in which the currentswf movie is playing. Trace a method to output messages to theSWFKit trace window. The Trace method takes only one stringparameter, so please be sure to use method like ”toString” to con-vert 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 field inthe current flash movie
function _add(a, b){
return a + b;}
x = _add("hello", " world");// send the value of "x" to flash movievar 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 fromc:test.pl
$WshShell = $Scripter->HostCreateObject("WScript.Shell");$numFolders = $WshShell->SpecialFolders->{Count};
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.63 ScriptHost Object 565
$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();
2.63.1 Methods
2.63.1.1 open
Description
Opens a script engine so that you can run the corresponding scripts.
Syntax
scripthost.open(engineName);
Parameters
engineName String. Specifies the name of the Active Scripting languagesuch as jscript, vbscript, perlscript, pythonscript, rubyscript,etc.
Returns
Boolean. Returns true if successful; otherwise returns false;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
566 FFish Script Objects Reference
2.63.1.2 close
Description
Closes an opened script engine. After a script engine is closed, youcan on longer run corresponding scripts, nor access the variables orfunctions 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 alreadybeen opened by using the open method
Syntax
scripthost.runScript(code);
Parameters
code String. The script code to run. For example, a piece of jscriptcode is ”function add(x, y) return x+ y;”
Returns
Boolean. Returns true if successful; otherwise returns false;
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
2.63 ScriptHost Object 567
2.63.1.4 runScriptFile
Description
Runs a script file. The corresponding script engine must alreadybeen opened by using the open method.
Syntax
scripthost.runScriptFile(fileName);
Parameters
fileName String. Specifies the script file 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 andfunctions in the running script.
Syntax
scripthost.getScriptObject();
Parameters
None
Returns
An ActiveX object. Returns null if failed.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
568 FFish Script Objects Reference
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
Chapter 3
FSCommands
3.1 FSCommands – FFish Eval
Description
Evaluates FFish Script expressions.
Syntax
FSCommand(”FFish Eval”, expression)
Parameters
expression An expression to be evaluated.
Example
FSCommand("FFish_Eval", "trace(x)");
3.2 FSCommands – FFish Run
Description
Excutes pre-compiled FFish Scripts.
Syntax
FSCommand(”FFish Run”, scriptname)
Parameters
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
570 FSCommands
scriptname A string specifies the name of the script to be executed.
Remarks
If the FFish Script needs to call the ”processMsg” method, it’s bet-ter to use the command ”FFish AsynRun” instead. For the ”pro-ceeMsg” method can enable the Flash Player to handle user inputswhile the FSCommand is still running. The Flash Player may callthe FSCommand again while the FSCommand is still running. Thatwill make the FSCommand to be called twice or more times. TheFFish 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", "")
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
3.4 FSCommands – FullScreen 571
3.4 FSCommands – FullScreen
Description
Maximizes or restores the projectors.
Syntax
FSCommand(”FullScreen”, true or false)
Parameters
true or false A ”true” string to maximize the projector and a ”false” stringto restore the projector.
Example
FSCommand("FullScreen", "true");
3.5 FSCommands – exec
Description
Launches an executable file.
Syntax
FSCommand(”exc”, ”an executable file name”)
Example
FSCommand("exec", "c:\\test.exe");
3.6 FSCommands – FFish Trace
Description
Prints a string in the trace window. Only works in Preview Mode.Requires SWFKit 2.
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.
572 FSCommands
Syntax
FSCommand(”FFish Trace”, ”a message”)
Example
FSCommand("FFish_Trace", myvar.toString());
Copyright c©2000-2006 Shanghai TopCMM Software Technologies.All Rights Reserved.