MACROMEDIA FLASHLITE2 ACTIONSCRIPT-LANGUAGE, Flash Lite 2 Reference

Flash Lite 2.x ActionScript Language Reference
Trademarks
1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flash Video Endocer, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are either registered trademarks or trademarks of Macromedia, Inc. and may be registered in the United States or in other jurisdictions including internationally. Other product names, logos, designs, titles, words, or phrases mentioned within this publication may be trademarks, service marks, or trade names of Macromedia, Inc. or other entities and may be registered in certain jurisdictions including internationally.
Third-Party Information
This guide contains links to third-party websites that are not under the control of Macromedia, and Macromedia is not responsible for the content on any linked site. If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
Sorenson™ Spark™ video compression and decompression technology licensed from Sorenson Media, Inc.
Fraunhofer-IIS/Thomson Multimedia: MPEG Layer-3 audio compression technology licensed by Fraunhofer IIS and Thomson Multimedia (http://www.iis.fhg.de/amm/)
Independent JPEG Group: This software is based in part on the work of the Independent JPEG Group.
Nellymoser, Inc.: Speech compression and decompression technology licensed by Nellymoser, Inc. (http:www.nellymoser.com).
Opera ® browser Copyright © 1995-2002 Opera Software ASA and its suppliers. All rights reserved.
Macromedia Flash 8 video is powered by On2 TrueMotion video technology. © 1992-2005 On2 Technologies, Inc. All Rights Reserved. http://www.on2.com.
Visual SourceSafe is a registered trademark or trademark of Microsoft Corporation in the United States and/or other countries.
Copyright © 2006 Macromedia, Inc. All rights reserved. This manual may not be copied, photocopied, reproduced, translated, or converted to any electronic or machine-readable form in whole or in part without written approval from Macromedia, Inc. Notwithstanding the foregoing, the owner or authorized user of a valid copy of the software with which this manual was provided may print out one copy of this manual from an electronic version of this manual for the sole purpose of such owner or authorized user learning to use such software, provided that no part of this manual may be printed out, reproduced, distributed, resold, or transmitted for any other purposes, including, without limitation, commercial purposes, such as selling copies of this documentation or providing paid-for support services.
Acknowledgments
Project Management: Mary Leigh Burke
Writing: Denise Green
Managing Editor: Rosana Francescato
Editing: Linda Adler, Evelyn Eldridge, Mark Nigara, Lisa Stanziano, Anne Szabla, Jessie Wood
Production Management: Adam Barnett, Kristin Conradi
Media Design and Production: Yuriko Ando, Aaron Begley, Paul Benkman. John Francis, Geeta Karmarkar, Masayo Noda, Paul Rangel, Arena Reed, Mario Reynoso
Special thanks to Lisa Friendly, Luciano Arruda, Erick Vera, the beta testers, and the entire Flash Lite engineering and QA teams.
First Edition: January 2006
Macromedia, Inc. 601 Townsend St. San Francisco, CA 94103
Contents
Chapter 1: ActionScript language elements. . . . . . . . . . . . . . . . . 23
Compiler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
#endinitclip directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
#include directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
#initclip directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
false constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Infinity constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
-Infinity constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
NaN constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
newline constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
null constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
true constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
undefined constant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Global Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Array function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Boolean function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
call function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
chr function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
clearInterval function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
duplicateMovieClip function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
escape function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
eval function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
fscommand function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
fscommand2 function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
getProperty function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
getTimer function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
getURL function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
getVersion function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
gotoAndPlay function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
gotoAndStop function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
ifFrameLoaded function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
int function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
isFinite function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
isNaN function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
length function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
loadMovie function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
3
loadMovieNum function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
loadVariables function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
loadVariablesNum function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
mbchr function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
mblength function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
mbord function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
mbsubstring function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
nextFrame function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
nextScene function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Number function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Object function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
on handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
onClipEvent handler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
ord function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
parseFloat function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
parseInt function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
play function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
prevFrame function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
prevScene function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
random function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
removeMovieClip function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
setInterval function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
setProperty function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
startDrag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
stop function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
stopAllSounds function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
stopDrag function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
String function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
substring function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
targetPath function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
tellTarget function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
toggleHighQuality function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
trace function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
unescape function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
unloadMovie function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
unloadMovieNum function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Global Properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
$version property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
_cap4WayKeyAS property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
_capCompoundSound property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
_capEmail property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
_capLoadData property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
_capMFi property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
_capMIDI property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
_capMMS property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
4Contents
_capSMAF property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
_capSMS property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
_capStreamSound property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
_focusrect property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
_forceframerate property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .103
_global property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .104
_highquality property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
_level property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
maxscroll property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
_parent property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
_quality property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107
_root property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
scroll property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
_soundbuftime property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109
this property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
+ addition operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
+= addition assignment operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
[] array access operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120
= assignment operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .123
& bitwise AND operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
&= bitwise AND assignment operator . . . . . . . . . . . . . . . . . . . . . . . . .126
<< bitwise left shift operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
<<= bitwise left shift and assignment operator. . . . . . . . . . . . . . . . . . .128
~ bitwise NOT operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
| bitwise OR operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
|= bitwise OR assignment operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
>> bitwise right shift operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132
>>= bitwise right shift and assignment operator . . . . . . . . . . . . . . . . .133
>>> bitwise unsigned right shift operator . . . . . . . . . . . . . . . . . . . . . . . .134
>>>= bitwise unsigned right shift and assignment operator . . . . . . . .135
^ bitwise XOR operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
^= bitwise XOR assignment operator. . . . . . . . . . . . . . . . . . . . . . . . . . 137
/* block comment delimiter operator. . . . . . . . . . . . . . . . . . . . . . . . . . 137
, comma operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
add concatenation (strings) operator . . . . . . . . . . . . . . . . . . . . . . . . .140
?: conditional operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
-- decrement operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
/ division operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
/= division assignment operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143
. dot operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144
== equality operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145
eq equality (strings) operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146
> greater than operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
gt greater than (strings) operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148
Contents 5
>= greater than or equal to operator. . . . . . . . . . . . . . . . . . . . . . . . . . . 148
ge greater than or equal to (strings) operator . . . . . . . . . . . . . . . . . . 149
++ increment operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
!= inequality operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
<> inequality operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
instanceof operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
< less than operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
lt less than (strings) operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
<= less than or equal to operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
le less than or equal to (strings) operator. . . . . . . . . . . . . . . . . . . . . . 157
// line comment delimiter operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
&& logical AND operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
and logical AND operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
! logical NOT operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
not logical NOT operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
|| logical OR operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
or logical OR operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
% modulo operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
%= modulo assignment operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
* multiplication operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
*= multiplication assignment operator . . . . . . . . . . . . . . . . . . . . . . . . 166
new operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
ne not equal (strings) operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
{} object initializer operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
() parentheses operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
=== strict equality operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
!== strict inequality operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
" string delimiter operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
- subtraction operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
-= subtraction assignment operator . . . . . . . . . . . . . . . . . . . . . . . . . . 175
: type operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
typeof operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
void operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
break statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
case statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181
class statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
continue statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
default statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
delete statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
do..while statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
dynamic statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
else statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
else if statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
extends statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
6Contents
for statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196
for..in statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
function statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198
get statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
if statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
implements statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
import statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
interface statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
intrinsic statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
private statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
public statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
return statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
set statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210
set variable statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
static statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213
super statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214
switch statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215
throw statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216
try..catch..finally statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .217
var statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .221
while statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
with statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
fscommand2 Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
ExtendBacklightDuration fscommand2 Command. . . . . . . . . . . . 227
FullScreen fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . . . 227
GetBatteryLevel fscommand2 Command. . . . . . . . . . . . . . . . . . . . 228
GetDevice fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . . . 228
GetDeviceID fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . 229
GetFreePlayerMemory fscommand2 Command . . . . . . . . . . . . . . 229
GetMaxBatteryLevel fscommand2 Command. . . . . . . . . . . . . . . . 230
GetMaxSignalLevel fscommand2 Command . . . . . . . . . . . . . . . . . 230
GetMaxVolumeLevel fscommand2 Command. . . . . . . . . . . . . . . . .231
GetNetworkConnectionName fscommand2 Command. . . . . . . . .231
GetNetworkConnectStatus fscommand2 Command . . . . . . . . . . 232
GetNetworkGeneration fscommand2 Command. . . . . . . . . . . . . . 233
GetNetworkName fscommand2 Command . . . . . . . . . . . . . . . . . . 233
GetNetworkRequestStatus fscommand2 Command . . . . . . . . . . 234
GetNetworkStatus fscommand2 Command . . . . . . . . . . . . . . . . . . 235
GetPlatform fscommand2 Command. . . . . . . . . . . . . . . . . . . . . . . . 236
GetPowerSource fscommand2 Command . . . . . . . . . . . . . . . . . . . 237
GetSignalLevel fscommand2 Command . . . . . . . . . . . . . . . . . . . . . 237
GetTotalPlayerMemory fscommand2 Command . . . . . . . . . . . . . 238
GetVolumeLevel fscommand2 Command. . . . . . . . . . . . . . . . . . . . 238
Quit fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
ResetSoftKeys fscommand2 Command . . . . . . . . . . . . . . . . . . . . . 239
Contents 7
SetFocusRectColor fscommand2 Command . . . . . . . . . . . . . . . . 240
SetInputTextType fscommand2 Command . . . . . . . . . . . . . . . . . . 240
SetSoftKeys fscommand2 Command. . . . . . . . . . . . . . . . . . . . . . . . 241
StartVibrate fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . .243
StopVibrate fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . .243
Chapter 2: ActionScript classes . . . . . . . . . . . . . . . . . . . . . . . . . 245
arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
callee (arguments.callee property) . . . . . . . . . . . . . . . . . . . . . . . . . . .246
caller (arguments.caller property) . . . . . . . . . . . . . . . . . . . . . . . . . . . .246
length (arguments.length property) . . . . . . . . . . . . . . . . . . . . . . . . . .247
Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .247
Array constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
CASEINSENSITIVE (Array.CASEINSENSITIVE property) . . . . .252
concat (Array.concat method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .252
DESCENDING (Array.DESCENDING property). . . . . . . . . . . . . . 254
join (Array.join method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
length (Array.length property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .255
NUMERIC (Array.NUMERIC property) . . . . . . . . . . . . . . . . . . . . . . .256
pop (Array.pop method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256
push (Array.push method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257
RETURNINDEXEDARRAY
(Array.RETURNINDEXEDARRAY property) . . . . . . . . . . . . . . .257
reverse (Array.reverse method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .258
shift (Array.shift method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .258
slice (Array.slice method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .258
sort (Array.sort method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
sortOn (Array.sortOn method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262
splice (Array.splice method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
toString (Array.toString method). . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
UNIQUESORT (Array.UNIQUESORT property) . . . . . . . . . . . . . . .267
unshift (Array.unshift method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268
Boolean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268
Boolean constructor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .269
toString (Boolean.toString method). . . . . . . . . . . . . . . . . . . . . . . . . .270
valueOf (Boolean.valueOf method) . . . . . . . . . . . . . . . . . . . . . . . . . .270
Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
_alpha (Button._alpha property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . .274
enabled (Button.enabled property). . . . . . . . . . . . . . . . . . . . . . . . . . .275
_focusrect (Button._focusrect property) . . . . . . . . . . . . . . . . . . . . . .276
getDepth (Button.getDepth method). . . . . . . . . . . . . . . . . . . . . . . . . 277
_height (Button._height property) . . . . . . . . . . . . . . . . . . . . . . . . . . . .278
_highquality (Button._highquality property). . . . . . . . . . . . . . . . . . . .278
_name (Button._name property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .278
onDragOut (Button.onDragOut handler). . . . . . . . . . . . . . . . . . . . . .279
8Contents
onDragOver (Button.onDragOver handler) . . . . . . . . . . . . . . . . . . . 280
onKeyDown (Button.onKeyDown handler). . . . . . . . . . . . . . . . . . . 280
onKeyUp (Button.onKeyUp handler) . . . . . . . . . . . . . . . . . . . . . . . . .281
onKillFocus (Button.onKillFocus handler) . . . . . . . . . . . . . . . . . . . . 282
onPress (Button.onPress handler). . . . . . . . . . . . . . . . . . . . . . . . . . . 283
onRelease (Button.onRelease handler) . . . . . . . . . . . . . . . . . . . . . . 283
onReleaseOutside (Button.onReleaseOutside handler). . . . . . . . 284
onRollOut (Button.onRollOut handler) . . . . . . . . . . . . . . . . . . . . . . . 284
onRollOver (Button.onRollOver handler) . . . . . . . . . . . . . . . . . . . . . 285
onSetFocus (Button.onSetFocus handler) . . . . . . . . . . . . . . . . . . . 285
_parent (Button._parent property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
_quality (Button._quality property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
_rotation (Button._rotation property) . . . . . . . . . . . . . . . . . . . . . . . . . 287
_soundbuftime (Button._soundbuftime property). . . . . . . . . . . . . . 288
tabEnabled (Button.tabEnabled property). . . . . . . . . . . . . . . . . . . . 289
tabIndex (Button.tabIndex property) . . . . . . . . . . . . . . . . . . . . . . . . . 289
_target (Button._target property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
trackAsMenu (Button.trackAsMenu property) . . . . . . . . . . . . . . . . .291
_url (Button._url property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
_visible (Button._visible property). . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
_width (Button._width property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
_x (Button._x property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
_xmouse (Button._xmouse property). . . . . . . . . . . . . . . . . . . . . . . . . 294
_xscale (Button._xscale property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 295
_y (Button._y property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
_ymouse (Button._ymouse property). . . . . . . . . . . . . . . . . . . . . . . . . 297
_yscale (Button._yscale property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
capabilities (System.capabilities) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298
audioMIMETypes (capabilities.audioMIMETypes property) . . . . 304
avHardwareDisable
(capabilities.avHardwareDisable property) . . . . . . . . . . . . . . . . . 304
has4WayKeyAS (capabilities.has4WayKeyAS property) . . . . . . 305
hasAccessibility (capabilities.hasAccessibility property) . . . . . . . 305
hasAudio (capabilities.hasAudio property) . . . . . . . . . . . . . . . . . . . 305
hasAudioEncoder (capabilities.hasAudioEncoder property) . . . . 306
hasCMIDI (capabilities.hasCMIDI property). . . . . . . . . . . . . . . . . . . 306
hasCompoundSound
(capabilities.hasCompoundSound property) . . . . . . . . . . . . . . . 306
hasDataLoading (capabilities.hasDataLoading property) . . . . . . 307
hasEmail (capabilities.hasEmail property) . . . . . . . . . . . . . . . . . . . . 307
hasEmbeddedVideo
(capabilities.hasEmbeddedVideo property) . . . . . . . . . . . . . . . . 308
hasMappableSoftKeys
(capabilities.hasMappableSoftKeys property) . . . . . . . . . . . . . . 308
hasMFI (capabilities.hasMFI property) . . . . . . . . . . . . . . . . . . . . . . . 308
Contents 9
hasMIDI (capabilities.hasMIDI property) . . . . . . . . . . . . . . . . . . . . . 309
hasMMS (capabilities.hasMMS property). . . . . . . . . . . . . . . . . . . . 309
hasMouse (capabilities.hasMouse property) . . . . . . . . . . . . . . . . . 309
hasMP3 (capabilities.hasMP3 property). . . . . . . . . . . . . . . . . . . . . . 310
hasPrinting (capabilities.hasPrinting property) . . . . . . . . . . . . . . . . 310
hasQWERTYKeyboard
(capabilities.hasQWERTYKeyboard property) . . . . . . . . . . . . . . 310
hasScreenBroadcast
(capabilities.hasScreenBroadcast property) . . . . . . . . . . . . . . . . .311
hasScreenPlayback
(capabilities.hasScreenPlayback property) . . . . . . . . . . . . . . . . . .311
hasSharedObjects (capabilities.hasSharedObjects property) . . . .311
hasSMAF (capabilities.hasSMAF property). . . . . . . . . . . . . . . . . . . 312
hasSMS (capabilities.hasSMS property) . . . . . . . . . . . . . . . . . . . . . 312
hasStreamingAudio
(capabilities.hasStreamingAudio property) . . . . . . . . . . . . . . . . . 312
hasStreamingVideo
(capabilities.hasStreamingVideo property) . . . . . . . . . . . . . . . . . 313
hasStylus (capabilities.hasStylus property) . . . . . . . . . . . . . . . . . . . 313
hasVideoEncoder (capabilities.hasVideoEncoder property) . . . . 313
imageMIMETypes (capabilities.imageMIMETypes property). . . . 314
isDebugger (capabilities.isDebugger property) . . . . . . . . . . . . . . . . 314
language (capabilities.language property) . . . . . . . . . . . . . . . . . . . . 315
localFileReadDisable
(capabilities.localFileReadDisable property) . . . . . . . . . . . . . . . . 316
MIMETypes (capabilities.MIMETypes property) . . . . . . . . . . . . . . . 317
os (capabilities.os property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
screenOrientation (capabilities.screenOrientation property) . . . . 317
screenResolutionX (capabilities.screenResolutionX property) . . 318 screenResolutionY (capabilities.screenResolutionY property) . . 318
softKeyCount (capabilities.softKeyCount property) . . . . . . . . . . . . 318
version (capabilities.version property) . . . . . . . . . . . . . . . . . . . . . . . . 319
videoMIMETypes (capabilities.videoMIMETypes property) . . . . . 319
Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Color constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
getRGB (Color.getRGB method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321
getTransform (Color.getTransform method) . . . . . . . . . . . . . . . . . . 321
setRGB (Color.setRGB method). . . . . . . . . . . . . . . . . . . . . . . . . . . . .322
setTransform (Color.setTransform method) . . . . . . . . . . . . . . . . . . .323
Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .324
Date constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
getDate (Date.getDate method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
getDay (Date.getDay method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332
getFullYear (Date.getFullYear method). . . . . . . . . . . . . . . . . . . . . . .332
getHours (Date.getHours method) . . . . . . . . . . . . . . . . . . . . . . . . . . .333
10 Contents
getLocaleLongDate (Date.getLocaleLongDate method) . . . . . . 334
getLocaleShortDate (Date.getLocaleShortDate method). . . . . . 334
getLocaleTime (Date.getLocaleTime method). . . . . . . . . . . . . . . . 335
getMilliseconds (Date.getMilliseconds method). . . . . . . . . . . . . . . 335
getMinutes (Date.getMinutes method). . . . . . . . . . . . . . . . . . . . . . . 336
getMonth (Date.getMonth method) . . . . . . . . . . . . . . . . . . . . . . . . . 336
getSeconds (Date.getSeconds method) . . . . . . . . . . . . . . . . . . . . . 337
getTime (Date.getTime method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
getTimezoneOffset (Date.getTimezoneOffset method). . . . . . . . 338
getUTCDate (Date.getUTCDate method) . . . . . . . . . . . . . . . . . . . . 338
getUTCDay (Date.getUTCDay method). . . . . . . . . . . . . . . . . . . . . . 339
getUTCFullYear (Date.getUTCFullYear method). . . . . . . . . . . . . . 340
getUTCHours (Date.getUTCHours method) . . . . . . . . . . . . . . . . . . 340
getUTCMilliseconds (Date.getUTCMilliseconds method) . . . . . . .341
getUTCMinutes (Date.getUTCMinutes method) . . . . . . . . . . . . . . .341
getUTCMonth (Date.getUTCMonth method) . . . . . . . . . . . . . . . . . 342
getUTCSeconds (Date.getUTCSeconds method) . . . . . . . . . . . . 342
getUTCYear (Date.getUTCYear method) . . . . . . . . . . . . . . . . . . . . 343
getYear (Date.getYear method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
setDate (Date.setDate method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
setFullYear (Date.setFullYear method) . . . . . . . . . . . . . . . . . . . . . . 345
setHours (Date.setHours method). . . . . . . . . . . . . . . . . . . . . . . . . . . 346
setMilliseconds (Date.setMilliseconds method) . . . . . . . . . . . . . . . 346
setMinutes (Date.setMinutes method) . . . . . . . . . . . . . . . . . . . . . . . 347
setMonth (Date.setMonth method) . . . . . . . . . . . . . . . . . . . . . . . . . . 347
setSeconds (Date.setSeconds method) . . . . . . . . . . . . . . . . . . . . . 348
setTime (Date.setTime method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
setUTCDate (Date.setUTCDate method) . . . . . . . . . . . . . . . . . . . . 349
setUTCFullYear (Date.setUTCFullYear method) . . . . . . . . . . . . . . 350
setUTCHours (Date.setUTCHours method) . . . . . . . . . . . . . . . . . . .351
setUTCMilliseconds (Date.setUTCMilliseconds method) . . . . . . 352
setUTCMinutes (Date.setUTCMinutes method). . . . . . . . . . . . . . . 353
setUTCMonth (Date.setUTCMonth method) . . . . . . . . . . . . . . . . . 353
setUTCSeconds (Date.setUTCSeconds method) . . . . . . . . . . . . . 354
setYear (Date.setYear method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
toString (Date.toString method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
UTC (Date.UTC method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
valueOf (Date.valueOf method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Error. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Error constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
message (Error.message property) . . . . . . . . . . . . . . . . . . . . . . . . . . 359
name (Error.name property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
toString (Error.toString method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .361
Contents 11
ExtendedKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362
SOFT1 (ExtendedKey.SOFT1 property) . . . . . . . . . . . . . . . . . . . . . .364
SOFT10 (ExtendedKey.SOFT10 property). . . . . . . . . . . . . . . . . . . .364
SOFT11 (ExtendedKey.SOFT11 property). . . . . . . . . . . . . . . . . . . . .364
SOFT12 (ExtendedKey.SOFT12 property). . . . . . . . . . . . . . . . . . . .364
SOFT2 (ExtendedKey.SOFT2 property) . . . . . . . . . . . . . . . . . . . . .365
SOFT3 (ExtendedKey.SOFT3 property) . . . . . . . . . . . . . . . . . . . . .365
SOFT4 (ExtendedKey.SOFT4 property) . . . . . . . . . . . . . . . . . . . . .365
SOFT5 (ExtendedKey.SOFT5 property) . . . . . . . . . . . . . . . . . . . . .365
SOFT6 (ExtendedKey.SOFT6 property) . . . . . . . . . . . . . . . . . . . . .365
SOFT7 (ExtendedKey.SOFT7 property). . . . . . . . . . . . . . . . . . . . . .365
SOFT8 (ExtendedKey.SOFT8 property) . . . . . . . . . . . . . . . . . . . . .366
SOFT9 (ExtendedKey.SOFT9 property) . . . . . . . . . . . . . . . . . . . . .366
Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .366
apply (Function.apply method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .367
call (Function.call method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .369
Key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .370
addListener (Key.addListener method). . . . . . . . . . . . . . . . . . . . . . .372
BACKSPACE (Key.BACKSPACE property). . . . . . . . . . . . . . . . . .373
CAPSLOCK (Key.CAPSLOCK property). . . . . . . . . . . . . . . . . . . . .374
CONTROL (Key.CONTROL property) . . . . . . . . . . . . . . . . . . . . . . .374
DELETEKEY (Key.DELETEKEY property) . . . . . . . . . . . . . . . . . . .374
DOWN (Key.DOWN property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375
END (Key.END property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .376
ENTER (Key.ENTER property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .376
ESCAPE (Key.ESCAPE property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
getAscii (Key.getAscii method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
getCode (Key.getCode method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378
HOME (Key.HOME property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
INSERT (Key.INSERT property). . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
isDown (Key.isDown method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
LEFT (Key.LEFT property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382
_listeners (Key._listeners property) . . . . . . . . . . . . . . . . . . . . . . . . . . .383
onKeyDown (Key.onKeyDown event listener). . . . . . . . . . . . . . . . .383
onKeyUp (Key.onKeyUp event listener) . . . . . . . . . . . . . . . . . . . . . .384
PGDN (Key.PGDN property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .384
PGUP (Key.PGUP property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385
removeListener (Key.removeListener method) . . . . . . . . . . . . . . . .385
RIGHT (Key.RIGHT property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .386
SHIFT (Key.SHIFT property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
SPACE (Key.SPACE property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387
TAB (Key.TAB property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .388
UP (Key.UP property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .389
12 Contents
LoadVars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
addRequestHeader
(LoadVars.addRequestHeader method) . . . . . . . . . . . . . . . . . . . 392
contentType (LoadVars.contentType property) . . . . . . . . . . . . . . . 394
decode (LoadVars.decode method) . . . . . . . . . . . . . . . . . . . . . . . . . 394
getBytesLoaded (LoadVars.getBytesLoaded method) . . . . . . . . 395
getBytesTotal (LoadVars.getBytesTotal method). . . . . . . . . . . . . 396
load (LoadVars.load method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
loaded (LoadVars.loaded property). . . . . . . . . . . . . . . . . . . . . . . . . . 399
LoadVars constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
onData (LoadVars.onData handler) . . . . . . . . . . . . . . . . . . . . . . . . . 400
onLoad (LoadVars.onLoad handler) . . . . . . . . . . . . . . . . . . . . . . . . . .401
send (LoadVars.send method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402
sendAndLoad (LoadVars.sendAndLoad method). . . . . . . . . . . . . 404
toString (LoadVars.toString method) . . . . . . . . . . . . . . . . . . . . . . . . 405
Locale (mx.lang.Locale) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
addDelayedInstance (Locale.addDelayedInstance method). . . . 408
addXMLPath (Locale.addXMLPath method) . . . . . . . . . . . . . . . . . 408
checkXMLStatus (Locale.checkXMLStatus method) . . . . . . . . . 408
initialize (Locale.initialize method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
loadLanguageXML (Locale.loadLanguageXML method) . . . . . . 409
loadString (Locale.loadString method) . . . . . . . . . . . . . . . . . . . . . . 409
setDefaultLang (Locale.setDefaultLang method) . . . . . . . . . . . . . 409
setLoadCallback (Locale.setLoadCallback method) . . . . . . . . . . .410
Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .410
abs (Math.abs method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .413
acos (Math.acos method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .414
asin (Math.asin method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .414
atan (Math.atan method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415
atan2 (Math.atan2 method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416
ceil (Math.ceil method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416
cos (Math.cos method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
E (Math.E property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418
exp (Math.exp method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418
floor (Math.floor method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .419
LN10 (Math.LN10 property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
LN2 (Math.LN2 property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
log (Math.log method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
LOG10E (Math.LOG10E property) . . . . . . . . . . . . . . . . . . . . . . . . . . .421
LOG2E (Math.LOG2E property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . .421
max (Math.max method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
min (Math.min method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422
PI (Math.PI property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
pow (Math.pow method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
random (Math.random method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Contents 13
round (Math.round method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
sin (Math.sin method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426
sqrt (Math.sqrt method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427
SQRT1_2 (Math.SQRT1_2 property) . . . . . . . . . . . . . . . . . . . . . . . . .428
SQRT2 (Math.SQRT2 property). . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
tan (Math.tan method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
addListener (Mouse.addListener method) . . . . . . . . . . . . . . . . . . . .432
onMouseDown (Mouse.onMouseDown event listener). . . . . . . . .433
onMouseMove (Mouse.onMouseMove event listener) . . . . . . . . .435
onMouseUp (Mouse.onMouseUp event listener) . . . . . . . . . . . . . .436
removeListener (Mouse.removeListener method) . . . . . . . . . . . . .437
MovieClip. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
_alpha (MovieClip._alpha property). . . . . . . . . . . . . . . . . . . . . . . . . . .447
attachMovie (MovieClip.attachMovie method) . . . . . . . . . . . . . . . .448
beginFill (MovieClip.beginFill method). . . . . . . . . . . . . . . . . . . . . . . 449
beginGradientFill (MovieClip.beginGradientFill method). . . . . . . 450
clear (MovieClip.clear method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .453
createEmptyMovieClip
(MovieClip.createEmptyMovieClip method) . . . . . . . . . . . . . . . 454
createTextField (MovieClip.createTextField method) . . . . . . . . . 455
_currentframe (MovieClip._currentframe property) . . . . . . . . . . . . .457
curveTo (MovieClip.curveTo method) . . . . . . . . . . . . . . . . . . . . . . . .457
_droptarget (MovieClip._droptarget property) . . . . . . . . . . . . . . . . 460
duplicateMovieClip (MovieClip.duplicateMovieClip method) . . . . 461
enabled (MovieClip.enabled property) . . . . . . . . . . . . . . . . . . . . . . . .462
endFill (MovieClip.endFill method) . . . . . . . . . . . . . . . . . . . . . . . . . . .463
focusEnabled (MovieClip.focusEnabled property) . . . . . . . . . . . . 464
_focusrect (MovieClip._focusrect property) . . . . . . . . . . . . . . . . . . 464
_framesloaded (MovieClip._framesloaded property) . . . . . . . . . . .465
getBounds (MovieClip.getBounds method) . . . . . . . . . . . . . . . . . . .466
getBytesLoaded (MovieClip.getBytesLoaded method) . . . . . . . .467
getBytesTotal (MovieClip.getBytesTotal method) . . . . . . . . . . . . .468
getDepth (MovieClip.getDepth method) . . . . . . . . . . . . . . . . . . . . . 469
getInstanceAtDepth
(MovieClip.getInstanceAtDepth method). . . . . . . . . . . . . . . . . . .470
getNextHighestDepth
(MovieClip.getNextHighestDepth method) . . . . . . . . . . . . . . . . . 471
getSWFVersion (MovieClip.getSWFVersion method) . . . . . . . . . 472
getURL (MovieClip.getURL method). . . . . . . . . . . . . . . . . . . . . . . . .473
globalToLocal (MovieClip.globalToLocal method). . . . . . . . . . . . .474
gotoAndPlay (MovieClip.gotoAndPlay method) . . . . . . . . . . . . . . . 477
gotoAndStop (MovieClip.gotoAndStop method) . . . . . . . . . . . . . .478
_height (MovieClip._height property) . . . . . . . . . . . . . . . . . . . . . . . . .478
_highquality (MovieClip._highquality property). . . . . . . . . . . . . . . . .479
14 Contents
hitArea (MovieClip.hitArea property). . . . . . . . . . . . . . . . . . . . . . . . . 480
hitTest (MovieClip.hitTest method) . . . . . . . . . . . . . . . . . . . . . . . . . . 480
lineStyle (MovieClip.lineStyle method). . . . . . . . . . . . . . . . . . . . . . . 482
lineTo (MovieClip.lineTo method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
loadMovie (MovieClip.loadMovie method) . . . . . . . . . . . . . . . . . . . 484
loadVariables (MovieClip.loadVariables method). . . . . . . . . . . . . . 485
localToGlobal (MovieClip.localToGlobal method) . . . . . . . . . . . . . 487
_lockroot (MovieClip._lockroot property) . . . . . . . . . . . . . . . . . . . . . 489
moveTo (MovieClip.moveTo method). . . . . . . . . . . . . . . . . . . . . . . . 492
_name (MovieClip._name property) . . . . . . . . . . . . . . . . . . . . . . . . . . 493
nextFrame (MovieClip.nextFrame method). . . . . . . . . . . . . . . . . . . 493
onData (MovieClip.onData handler) . . . . . . . . . . . . . . . . . . . . . . . . . 494
onDragOut (MovieClip.onDragOut handler) . . . . . . . . . . . . . . . . . . 495
onDragOver (MovieClip.onDragOver handler) . . . . . . . . . . . . . . . . 496
onEnterFrame (MovieClip.onEnterFrame handler) . . . . . . . . . . . . 496
onKeyDown (MovieClip.onKeyDown handler) . . . . . . . . . . . . . . . . 497
onKeyUp (MovieClip.onKeyUp handler) . . . . . . . . . . . . . . . . . . . . . 498
onKillFocus (MovieClip.onKillFocus handler) . . . . . . . . . . . . . . . . . 499
onLoad (MovieClip.onLoad handler). . . . . . . . . . . . . . . . . . . . . . . . . 500
onMouseDown (MovieClip.onMouseDown handler). . . . . . . . . . . .501
onMouseMove (MovieClip.onMouseMove handler) . . . . . . . . . . . .501
onMouseUp (MovieClip.onMouseUp handler) . . . . . . . . . . . . . . . . 502
onPress (MovieClip.onPress handler). . . . . . . . . . . . . . . . . . . . . . . . 502
onRelease (MovieClip.onRelease handler) . . . . . . . . . . . . . . . . . . . 502
onReleaseOutside (MovieClip.onReleaseOutside handler). . . . . 503
onRollOut (MovieClip.onRollOut handler) . . . . . . . . . . . . . . . . . . . . 503
onRollOver (MovieClip.onRollOver handler) . . . . . . . . . . . . . . . . . . 504
onSetFocus (MovieClip.onSetFocus handler) . . . . . . . . . . . . . . . . 504
onUnload (MovieClip.onUnload handler) . . . . . . . . . . . . . . . . . . . . . 505
_parent (MovieClip._parent property) . . . . . . . . . . . . . . . . . . . . . . . . 505
play (MovieClip.play method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
prevFrame (MovieClip.prevFrame method). . . . . . . . . . . . . . . . . . . 507
_quality (MovieClip._quality property) . . . . . . . . . . . . . . . . . . . . . . . . 508
removeMovieClip (MovieClip.removeMovieClip method) . . . . . . 509
_rotation (MovieClip._rotation property) . . . . . . . . . . . . . . . . . . . . . . .510
setMask (MovieClip.setMask method) . . . . . . . . . . . . . . . . . . . . . . . . 511
_soundbuftime (MovieClip._soundbuftime property) . . . . . . . . . . . .512
startDrag (MovieClip.startDrag method) . . . . . . . . . . . . . . . . . . . . . .512
stop (MovieClip.stop method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .513
stopDrag (MovieClip.stopDrag method) . . . . . . . . . . . . . . . . . . . . . .514
swapDepths (MovieClip.swapDepths method) . . . . . . . . . . . . . . . .515
tabChildren (MovieClip.tabChildren property). . . . . . . . . . . . . . . . . .516
tabEnabled (MovieClip.tabEnabled property) . . . . . . . . . . . . . . . . . . 517
tabIndex (MovieClip.tabIndex property) . . . . . . . . . . . . . . . . . . . . . . . 517
_target (MovieClip._target property) . . . . . . . . . . . . . . . . . . . . . . . . . .518
_totalframes (MovieClip._totalframes property) . . . . . . . . . . . . . . . .519
Contents 15
trackAsMenu (MovieClip.trackAsMenu property). . . . . . . . . . . . . . 519
unloadMovie (MovieClip.unloadMovie method) . . . . . . . . . . . . . . 520
_url (MovieClip._url property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
_visible (MovieClip._visible property) . . . . . . . . . . . . . . . . . . . . . . . . .522
_width (MovieClip._width property). . . . . . . . . . . . . . . . . . . . . . . . . . .523
_x (MovieClip._x property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .523
_xmouse (MovieClip._xmouse property) . . . . . . . . . . . . . . . . . . . . . 524
_xscale (MovieClip._xscale property) . . . . . . . . . . . . . . . . . . . . . . . . 524
_y (MovieClip._y property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .526
_ymouse (MovieClip._ymouse property) . . . . . . . . . . . . . . . . . . . . . .526
_yscale (MovieClip._yscale property) . . . . . . . . . . . . . . . . . . . . . . . . .527
MovieClipLoader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .528
addListener (MovieClipLoader.addListener method) . . . . . . . . . 530
getProgress (MovieClipLoader.getProgress method) . . . . . . . . . .532
loadClip (MovieClipLoader.loadClip method) . . . . . . . . . . . . . . . . .533
MovieClipLoader constructor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .535
onLoadComplete
(MovieClipLoader.onLoadComplete event listener) . . . . . . . . .535
onLoadError (MovieClipLoader.onLoadError event listener). . . .537
onLoadInit (MovieClipLoader.onLoadInit event listener) . . . . . . .538
onLoadProgress
(MovieClipLoader.onLoadProgress event listener) . . . . . . . . . 539
onLoadStart (MovieClipLoader.onLoadStart event listener) . . . . 541
removeListener (MovieClipLoader.removeListener method). . . 542
unloadClip (MovieClipLoader.unloadClip method) . . . . . . . . . . . . .543
Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
MAX_VALUE (Number.MAX_VALUE property) . . . . . . . . . . . . . . .546
MIN_VALUE (Number.MIN_VALUE property). . . . . . . . . . . . . . . . .546
NaN (Number.NaN property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .547
NEGATIVE_INFINITY
(Number.NEGATIVE_INFINITY property) . . . . . . . . . . . . . . . . . .547
Number constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .548
POSITIVE_INFINITY
(Number.POSITIVE_INFINITY property) . . . . . . . . . . . . . . . . . . .548
toString (Number.toString method) . . . . . . . . . . . . . . . . . . . . . . . . . 549
valueOf (Number.valueOf method) . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
addProperty (Object.addProperty method) . . . . . . . . . . . . . . . . . . . 551
constructor (Object.constructor property) . . . . . . . . . . . . . . . . . . . 554
hasOwnProperty (Object.hasOwnProperty method) . . . . . . . . . . 555
isPropertyEnumerable (Object.isPropertyEnumerable method) 555
isPrototypeOf (Object.isPrototypeOf method) . . . . . . . . . . . . . . . .556
Object constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .557
__proto__ (Object.__proto__ property). . . . . . . . . . . . . . . . . . . . . . . . .557
prototype (Object.prototype property). . . . . . . . . . . . . . . . . . . . . . . .558
16 Contents
registerClass (Object.registerClass method). . . . . . . . . . . . . . . . . . 559
__resolve (Object.__resolve property) . . . . . . . . . . . . . . . . . . . . . . . . 560
toString (Object.toString method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 563
unwatch (Object.unwatch method) . . . . . . . . . . . . . . . . . . . . . . . . . . 565
valueOf (Object.valueOf method). . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
watch (Object.watch method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
security (System.security) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
allowDomain (security.allowDomain method). . . . . . . . . . . . . . . . . 570
allowInsecureDomain
(security.allowInsecureDomain method) . . . . . . . . . . . . . . . . . . . 572
loadPolicyFile (security.loadPolicyFile method) . . . . . . . . . . . . . . . 573
Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
addListener (Selection.addListener method) . . . . . . . . . . . . . . . . . 576
getFocus (Selection.getFocus method) . . . . . . . . . . . . . . . . . . . . . . 577
onSetFocus (Selection.onSetFocus event listener) . . . . . . . . . . . 578
removeListener (Selection.removeListener method) . . . . . . . . . . 580
setFocus (Selection.setFocus method) . . . . . . . . . . . . . . . . . . . . . . .581
SharedObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
addListener (SharedObject.addListener method) . . . . . . . . . . . . . 586
clear (SharedObject.clear method) . . . . . . . . . . . . . . . . . . . . . . . . . . 587
data (SharedObject.data property) . . . . . . . . . . . . . . . . . . . . . . . . . . 587
flush (SharedObject.flush method) . . . . . . . . . . . . . . . . . . . . . . . . . . 589
getLocal (SharedObject.getLocal method). . . . . . . . . . . . . . . . . . . .591
getMaxSize (SharedObject.getMaxSize method) . . . . . . . . . . . . . 592
getSize (SharedObject.getSize method) . . . . . . . . . . . . . . . . . . . . . 592
onStatus (SharedObject.onStatus handler) . . . . . . . . . . . . . . . . . . 593
removeListener (SharedObject.removeListener method) . . . . . . 595
Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
attachSound (Sound.attachSound method) . . . . . . . . . . . . . . . . . . 598
duration (Sound.duration property) . . . . . . . . . . . . . . . . . . . . . . . . . . 598
getBytesLoaded (Sound.getBytesLoaded method). . . . . . . . . . . 600
getBytesTotal (Sound.getBytesTotal method). . . . . . . . . . . . . . . . 602
getPan (Sound.getPan method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 602
getTransform (Sound.getTransform method). . . . . . . . . . . . . . . . . 603
getVolume (Sound.getVolume method). . . . . . . . . . . . . . . . . . . . . . 605
id3 (Sound.id3 property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
loadSound (Sound.loadSound method). . . . . . . . . . . . . . . . . . . . . . 609
onID3 (Sound.onID3 handler) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .610
onLoad (Sound.onLoad handler). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611
onSoundComplete (Sound.onSoundComplete handler) . . . . . . . .612
position (Sound.position property) . . . . . . . . . . . . . . . . . . . . . . . . . . .612
setPan (Sound.setPan method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .613
setTransform (Sound.setTransform method) . . . . . . . . . . . . . . . . . .613
setVolume (Sound.setVolume method) . . . . . . . . . . . . . . . . . . . . . . .615
Sound constructor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .616
Contents 17
start (Sound.start method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616
stop (Sound.stop method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618
addListener (Stage.addListener method) . . . . . . . . . . . . . . . . . . . . 620
align (Stage.align property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
height (Stage.height property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 621
onResize (Stage.onResize event listener) . . . . . . . . . . . . . . . . . . . .622
removeListener (Stage.removeListener method) . . . . . . . . . . . . . .623
scaleMode (Stage.scaleMode property) . . . . . . . . . . . . . . . . . . . . . .624
width (Stage.width property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .625
String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .626
charAt (String.charAt method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .628
charCodeAt (String.charCodeAt method). . . . . . . . . . . . . . . . . . . . .629
concat (String.concat method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 630
fromCharCode (String.fromCharCode method) . . . . . . . . . . . . . . 630
indexOf (String.indexOf method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
lastIndexOf (String.lastIndexOf method) . . . . . . . . . . . . . . . . . . . . . .632
length (String.length property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .633
slice (String.slice method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .634
split (String.split method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .635
String constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
substr (String.substr method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .637
substring (String.substring method) . . . . . . . . . . . . . . . . . . . . . . . . . .638
toLowerCase (String.toLowerCase method) . . . . . . . . . . . . . . . . . .639
toString (String.toString method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 640
toUpperCase (String.toUpperCase method) . . . . . . . . . . . . . . . . . . 641
valueOf (String.valueOf method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
System. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .642
onStatus (System.onStatus handler) . . . . . . . . . . . . . . . . . . . . . . . . .643
useCodepage (System.useCodepage property) . . . . . . . . . . . . . . 644
TextField . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .645
addListener (TextField.addListener method). . . . . . . . . . . . . . . . . 650
_alpha (TextField._alpha property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 651
autoSize (TextField.autoSize property) . . . . . . . . . . . . . . . . . . . . . . .652
background (TextField.background property) . . . . . . . . . . . . . . . . .654
backgroundColor (TextField.backgroundColor property) . . . . . . .654
border (TextField.border property) . . . . . . . . . . . . . . . . . . . . . . . . . . .655
borderColor (TextField.borderColor property) . . . . . . . . . . . . . . . . .655
bottomScroll (TextField.bottomScroll property) . . . . . . . . . . . . . . .655
condenseWhite (TextField.condenseWhite property) . . . . . . . . . .656
embedFonts (TextField.embedFonts property). . . . . . . . . . . . . . . .657
getDepth (TextField.getDepth method) . . . . . . . . . . . . . . . . . . . . . .658
getNewTextFormat (TextField.getNewTextFormat method). . . 659
getTextFormat (TextField.getTextFormat method) . . . . . . . . . . . 659
_height (TextField._height property) . . . . . . . . . . . . . . . . . . . . . . . . . . 661
18 Contents
_highquality (TextField._highquality property). . . . . . . . . . . . . . . . . .661
hscroll (TextField.hscroll property) . . . . . . . . . . . . . . . . . . . . . . . . . . .661
html (TextField.html property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662
htmlText (TextField.htmlText property) . . . . . . . . . . . . . . . . . . . . . . 663
length (TextField.length property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
maxChars (TextField.maxChars property) . . . . . . . . . . . . . . . . . . . . 664
maxhscroll (TextField.maxhscroll property). . . . . . . . . . . . . . . . . . . 664
maxscroll (TextField.maxscroll property) . . . . . . . . . . . . . . . . . . . . . 665
multiline (TextField.multiline property) . . . . . . . . . . . . . . . . . . . . . . . 665
_name (TextField._name property) . . . . . . . . . . . . . . . . . . . . . . . . . . 666
onChanged (TextField.onChanged handler) . . . . . . . . . . . . . . . . . . 666
onKillFocus (TextField.onKillFocus handler). . . . . . . . . . . . . . . . . . 667
onScroller (TextField.onScroller handler) . . . . . . . . . . . . . . . . . . . . 668
onSetFocus (TextField.onSetFocus handler). . . . . . . . . . . . . . . . . 670
_parent (TextField._parent property) . . . . . . . . . . . . . . . . . . . . . . . . . 670
password (TextField.password property). . . . . . . . . . . . . . . . . . . . . . 671
_quality (TextField._quality property). . . . . . . . . . . . . . . . . . . . . . . . . 672
removeListener (TextField.removeListener method) . . . . . . . . . . 673
removeTextField (TextField.removeTextField method) . . . . . . . . 674
replaceText (TextField.replaceText method) . . . . . . . . . . . . . . . . . 674
_rotation (TextField._rotation property). . . . . . . . . . . . . . . . . . . . . . . 675
scroll (TextField.scroll property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 676
selectable (TextField.selectable property) . . . . . . . . . . . . . . . . . . . . 677
setNewTextFormat (TextField.setNewTextFormat method). . . . 678
setTextFormat (TextField.setTextFormat method) . . . . . . . . . . . . 679
_soundbuftime (TextField._soundbuftime property) . . . . . . . . . . . .681
styleSheet (TextField.styleSheet property) . . . . . . . . . . . . . . . . . . . .681
tabEnabled (TextField.tabEnabled property) . . . . . . . . . . . . . . . . . 683
tabIndex (TextField.tabIndex property). . . . . . . . . . . . . . . . . . . . . . . 684
_target (TextField._target property) . . . . . . . . . . . . . . . . . . . . . . . . . . 685
text (TextField.text property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
textColor (TextField.textColor property). . . . . . . . . . . . . . . . . . . . . . 687
textHeight (TextField.textHeight property) . . . . . . . . . . . . . . . . . . . 687
textWidth (TextField.textWidth property) . . . . . . . . . . . . . . . . . . . . 688
type (TextField.type property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688
_url (TextField._url property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
variable (TextField.variable property) . . . . . . . . . . . . . . . . . . . . . . . . 689
_visible (TextField._visible property) . . . . . . . . . . . . . . . . . . . . . . . . . 690
_width (TextField._width property). . . . . . . . . . . . . . . . . . . . . . . . . . . 690
wordWrap (TextField.wordWrap property) . . . . . . . . . . . . . . . . . . . .691
_x (TextField._x property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692
_xmouse (TextField._xmouse property) . . . . . . . . . . . . . . . . . . . . . . 692
_xscale (TextField._xscale property) . . . . . . . . . . . . . . . . . . . . . . . . . 693
_y (TextField._y property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 694
_ymouse (TextField._ymouse property) . . . . . . . . . . . . . . . . . . . . . . 694
_yscale (TextField._yscale property) . . . . . . . . . . . . . . . . . . . . . . . . . 695
Contents 19
TextFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
align (TextFormat.align property) . . . . . . . . . . . . . . . . . . . . . . . . . . . .697
blockIndent (TextFormat.blockIndent property) . . . . . . . . . . . . . . .698
bold (TextFormat.bold property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
bullet (TextFormat.bullet property) . . . . . . . . . . . . . . . . . . . . . . . . . . 699
color (TextFormat.color property). . . . . . . . . . . . . . . . . . . . . . . . . . . .700
font (TextFormat.font property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
getTextExtent (TextFormat.getTextExtent method). . . . . . . . . . . . 701
indent (TextFormat.indent property) . . . . . . . . . . . . . . . . . . . . . . . . .704
italic (TextFormat.italic property) . . . . . . . . . . . . . . . . . . . . . . . . . . . .704
leading (TextFormat.leading property). . . . . . . . . . . . . . . . . . . . . . . .705
leftMargin (TextFormat.leftMargin property) . . . . . . . . . . . . . . . . . .705
rightMargin (TextFormat.rightMargin property). . . . . . . . . . . . . . . .706
size (TextFormat.size property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . .706
tabStops (TextFormat.tabStops property) . . . . . . . . . . . . . . . . . . . . 707
target (TextFormat.target property) . . . . . . . . . . . . . . . . . . . . . . . . . . 707
TextFormat constructor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .708
underline (TextFormat.underline property) . . . . . . . . . . . . . . . . . . . . 710
url (TextFormat.url property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
close (Video.close method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
onStatus (Video.onStatus handler). . . . . . . . . . . . . . . . . . . . . . . . . . . 713
pause (Video.pause method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
play (Video.play method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
resume (Video.resume method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
stop (Video.stop method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716
addRequestHeader (XML.addRequestHeader method). . . . . . . . 719
contentType (XML.contentType property) . . . . . . . . . . . . . . . . . . . .720
createElement (XML.createElement method) . . . . . . . . . . . . . . . . . 721
createTextNode (XML.createTextNode method) . . . . . . . . . . . . . . 722
docTypeDecl (XML.docTypeDecl property) . . . . . . . . . . . . . . . . . .723
getBytesLoaded (XML.getBytesLoaded method) . . . . . . . . . . . . .724
getBytesTotal (XML.getBytesTotal method) . . . . . . . . . . . . . . . . . .725
ignoreWhite (XML.ignoreWhite property) . . . . . . . . . . . . . . . . . . . .725
load (XML.load method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
loaded (XML.loaded property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .729
onData (XML.onData handler). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .729
onLoad (XML.onLoad handler) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .730
parseXML (XML.parseXML method). . . . . . . . . . . . . . . . . . . . . . . . . 731
send (XML.send method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
sendAndLoad (XML.sendAndLoad method). . . . . . . . . . . . . . . . . .733
status (XML.status property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .735
XML constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .736
xmlDecl (XML.xmlDecl property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737
20 Contents
XMLNode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738
appendChild (XMLNode.appendChild method) . . . . . . . . . . . . . . . 740
attributes (XMLNode.attributes property) . . . . . . . . . . . . . . . . . . . . 742
childNodes (XMLNode.childNodes property). . . . . . . . . . . . . . . . . 742
cloneNode (XMLNode.cloneNode method) . . . . . . . . . . . . . . . . . . 744
firstChild (XMLNode.firstChild property) . . . . . . . . . . . . . . . . . . . . . 745
hasChildNodes (XMLNode.hasChildNodes method) . . . . . . . . . . 747
insertBefore (XMLNode.insertBefore method) . . . . . . . . . . . . . . . 747
lastChild (XMLNode.lastChild property). . . . . . . . . . . . . . . . . . . . . . 748
nextSibling (XMLNode.nextSibling property) . . . . . . . . . . . . . . . . . 750
nodeName (XMLNode.nodeName property) . . . . . . . . . . . . . . . . . 750
nodeType (XMLNode.nodeType property) . . . . . . . . . . . . . . . . . . . 752
nodeValue (XMLNode.nodeValue property) . . . . . . . . . . . . . . . . . . 753
parentNode (XMLNode.parentNode property). . . . . . . . . . . . . . . . 754
previousSibling (XMLNode.previousSibling property) . . . . . . . . . 755
removeNode (XMLNode.removeNode method) . . . . . . . . . . . . . . 756
toString (XMLNode.toString method) . . . . . . . . . . . . . . . . . . . . . . . 756
XMLUI. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 757
accept (XMLUI.accept method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759
cancel (XMLUI.cancel method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759
get (XMLUI.get method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759
set (XMLUI.set method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759
Chapter 3: Deprecated ActionScript . . . . . . . . . . . . . . . . . . . . . . 761
Deprecated Function summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .761
Deprecated Property summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763
Deprecated Operator summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 763
Chapter 4: Unsupported ActionScript . . . . . . . . . . . . . . . . . . . . 765
Unsupported Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765
Unsupported Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765
Unsupported Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765
Unsupported Global Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766
Unsupported Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766
Unsupported fscommands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 766
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .767
Contents 21
22 Contents
CHAPTER 1
ActionScript language elements
This section provides syntax, usage information, and code samples for global functions and properties (those elements that do not belong to an ActionScript class); compiler directives; and for the constants, operators, statements, and keywords used in ActionScript and defined in the ECMAScript (ECMA-262) edition 4 draft language specification.
Compiler Directives
This section contains the directives to include in your ActionScript file to direct the compiler to preprocess certain instructions.
Compiler Directives summary
1
Directive Description
#endinitclip Compiler directive; indicates the end of a block of initialization
actions.
#include Compiler directive: includes the contents of the specified file, as if the
commands in the file are part of the calling script.
#initclip Compiler directive; indicates the beginning of a block of initialization
actions.
#endinitclip directive
#endinitclip
Compiler directive; indicates the end of a block of initialization actions.
Availability: ActionScript 1.0; Flash Lite 2.0
Example
#initclip ...initialization actions go here... #endinitclip
23
#include directive
#include "[path]filename.as" — Do not place a semicolon (;) at the end of the line that
contains the #include statement.
Compiler directive: includes the contents of the specified file, as if the commands in the file are part of the calling script. The you make any changes to an external file, you must save the file and recompile any FLA files that use it.
#include directive is invoked at compile time. Therefore, if
If you use the Check Syntax button for a script that contains
#include statements, the syntax
of the included files is also checked.
You can use
#include in FLA files and in external script files, but not in ActionScript 2.0
class files.
You can specify no path, a relative path, or an absolute path for the file to be included. If you don't specify a path, the AS file must be in one of the following locations:
The same directory as the FLA file. The same directory as the script containing the
#include statement
The global Include directory, which is one of the following:
--Windows 2000 or Windows XP: C:\Documents and Settings\user \Local Settings\ Application Data\Macromedia\Flash 8\language\Configuration\Include
--Macintosh OS X: Hard Drive/Users/Library/Application Support/Macromedia/Flash 8/ language/Configuration/Include
The Flash 8 program\language\First Run\Include directory; if you save a file here, it is
copied to the global Include directory the next time you start Flash.
To specify a relative path for the AS file, use a single dot (.) to indicate the current directory, two dots (
..) to indicate a parent directory, and forward slashes (/) to indicate subdirectories.
See the following example section.
To specify an absolute path for the AS file, use the format supported by your platform (Macintosh or Windows). See the following example section. (This usage is not recommended because it requires the directory structure to be the same on any computer that you use to compile the script.)
If you place files in the First Run/Include directory or in the global Include directory, back up these files. If you ever need to uninstall and reinstall Flash, these directories might be deleted and overwritten.
Availability: ActionScript 1.0; Flash Lite 2.0
24 ActionScript language elements
Parameters
[path]filename.as - filename.asThe filename and optional path for the script to add to
the Actions panel or to the current script; .as is the recommended filename extension.
Example
The following examples show various ways of specifying a path for a file to be included in your script:
// Note that #include statements do not end with a semicolon (;) // AS file is in same directory as FLA file or script // or is in the global Include directory or the First Run/Include directory #include "init_script.as"
// AS file is in a subdirectory of one of the above directories // The subdirectory is named "FLA_includes" #include "FLA_includes/init_script.as" // AS file is in a subdirectory of the script file directory // The subdirectory is named "SCRIPT_includes" #include "SCRIPT_includes/init_script.as" // AS file is in a directory at the same level as one of the above
directories // AS file is in a directory at the same level as the directory // that contains the script file // The directory is named "ALL_includes" #include "../ALL_includes/init_script.as"
// AS file is specified by an absolute path in Windows // Note use of forward slashes, not backslashes #include "C:/Flash_scripts/init_script.as"
// AS file is specified by an absolute path on Macintosh #include "Mac HD:Flash_scripts:init_script.as"
#initclip directive
#initclip order — Do not place a semicolon (;) at the end of the line that contains the
#initclip statement.
Compiler directive; indicates the beginning of a block of initialization actions. When multiple clips are initialized at the same time, you can use the initialization occurs first. Initialization actions execute when a movie clip symbol is defined. If the movie clip is an exported symbol, the initialization actions execute before the actions on Frame 1 of the SWF file. Otherwise, they execute immediately before the frame actions of the frame that contains the first instance of the associated movie clip symbol.
order parameter to specify which
Compiler Directives 25
Initialization actions execute only once when a SWF file plays; use them for one-time initializations, such as class definition and registration.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
order - A non-negative integer that specifies the execution order of blocks of #initclip
code. This is an optional parameter. You must specify the value by using an integer literal (only decimal—not hexidecimal—values are allowed), and not by using a variable. If you include multiple last
order value specified in that movie clip symbol for all #initclip blocks in that symbol.
#initclip blocks in a single movie clip symbol, then the compiler uses the
Example
In the following example, ActionScript is placed on Frame 1 inside a movie clip instance. A variables.txt text file is placed in the same directory.
#initclip
trace("initializing app");
var variables:LoadVars = new LoadVars();
variables.load("variables.txt");
variables.onLoad = function(success:Boolean) {
trace("variables loaded:"+success);
if (success) { for (i in variables) { trace("variables."+i+" = "+variables[i]); } } };
#endinitclip
26 ActionScript language elements
Constants
A constant is a variable used to represent a property whose value never changes. This section describes global constants that are available to every script.
Constants summary
Modifiers Constant Description
false A unique Boolean value that represents the
opposite of true.
Infinity Specifies the IEEE-754 value representing
positive infinity.
-Infinity Specifies the IEEE-754 value representing
negative infinity.
NaN A predefined variable with the IEEE-754 value for
NaN (not a number).
newline Inserts a carriage return character (\r) that
generates a blank line in text output generated by your code.
null A special value that can be assigned to variables or
returned by a function if no data was provided.
true A unique Boolean value that represents the
opposite of false.
undefined A special value, usually used to indicate that a
variable has not yet been assigned a value.
false constant
A unique Boolean value that represents the opposite of true.
When automatic data typing converts
false to a string, it becomes "false".
Availability: ActionScript 1.0; Flash Lite 1.1
false to a number, it becomes 0; when it converts
Constants 27
Example
This example shows how automatic data typing converts false to a number and to a string:
var bool1:Boolean = Boolean(false);
// converts it to the number 0 trace(1 + bool1); // outputs 1
// converts it to a string trace("String: " + bool1); // outputs String: false
Infinity constant
Specifies the IEEE-754 value representing positive infinity. The value of this constant is the same as
Availability: ActionScript 1.0; Flash Lite 2.0
See also
POSITIVE_INFINITY (Number.POSITIVE_INFINITY property)
Number.POSITIVE_INFINITY.
-Infinity constant
Specifies the IEEE-754 value representing negative infinity. The value of this constant is the same as
Number.NEGATIVE_INFINITY.
Availability: ActionScript 1.0; Flash Lite 2.0
See also
NEGATIVE_INFINITY (Number.NEGATIVE_INFINITY property)
NaN constant
A predefined variable with the IEEE-754 value for NaN (not a number). To determine if a number is NaN, use
Availability: ActionScript 1.0; Flash Lite 1.1
See also
isNaN function, NaN (Number.NaN property)
isNaN().
28 ActionScript language elements
newline constant
Inserts a carriage return character (\r) that generates a blank line in text output generated by your code. Use statement in your code.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
The following example shows how newline displays output from the trace() statement on multiple lines.
var myName:String = "Lisa", myAge:Number = 30; trace(myName+myAge); trace("-----"); trace(myName+newline+myAge); // output: Lisa30
----­Lisa 30
See also
newline to make space for information that is retrieved by a function or
trace function
null constant
A special value that can be assigned to variables or returned by a function if no data was provided. You can use data type.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
In a numeric context, null evaluates to 0. Equality tests can be performed with null. In this statement, a binary tree node has no left child, so the field for its left child could be set to
null.
if (tree.left == null) { tree.left = new TreeNode(); }
null to represent values that are missing or that do not have a defined
Constants 29
true constant
A unique Boolean value that represents the opposite of false. When automatic data typing converts
"true".
Availability: ActionScript 1.0; Flash Lite 1.1
Example
The following example shows the use of true in an if statement:
var shouldExecute:Boolean; // ... // code that sets shouldExecute to either true or false goes here // shouldExecute is set to true for this example:
shouldExecute = true;
if (shouldExecute == true) { trace("your statements here"); }
// true is also implied, so the if statement could also be written: // if (shouldExecute) { // trace("your statements here"); // }
true to a number, it becomes 1; when it converts true to a string, it becomes
The following example shows how automatic data typing converts true to the number 1:
var myNum:Number; myNum = 1 + true; trace(myNum); // output: 2
See also
false constant, Boolean
undefined constant
A special value, usually used to indicate that a variable has not yet been assigned a value. A reference to an undefined value returns the special value
typeof(undefined) returns the string "undefined". The only value of type undefined is undefined.
In files published for Flash Player 6 or earlier, the value of empty string). In files published for Flash Player 7 or later, the value of is
"undefined" (undefined is converted to a string).
undefined. The ActionScript code
String(undefined) is "" (an
String(undefined)
30 ActionScript language elements
In files published for Flash Player 6 or earlier, the value of Number(undefined) is 0. In files published for Flash Player 7 or later, the value of
Number(undefined) is NaN.
The value undefined is similar to the special value null. When null and undefined are compared with the equality (
undefined are compared with the strict equality (===) operator, they compare as not equal.
==) operator, they compare as equal. However, when null and
Availability: ActionScript 1.0; Flash Lite 1.1
Example
In the following example, the variable x has not been declared and therefore has the value
undefined.
In the first section of code, the equality operator (
undefined, and the appropriate result is sent to the Output panel. In the first section of code,
the equality operator (
==) compares the value of x to the value undefined, and the
==) compares the value of x to the value
appropriate result is sent to the log file.
In the second section of code, the equality (
undefined.
// x has not been declared trace("The value of x is "+x);
if (x == undefined) { trace("x is undefined"); } else { trace("x is not undefined"); }
trace("typeof (x) is "+typeof (x));
if (null == undefined) { trace("null and undefined are equal"); } else { trace("null and undefined are not equal"); }
==) operator compares the values null and
The following result is displayed in the Output panel.
The value of x is undefined x is undefined typeof (x) is undefined null and undefined are equal
Constants 31
Global Functions
This section contains a set of built-in functions that are available in any part of a SWF file where ActionScript is used. These global functions cover a wide variety of common programming tasks such as working with data types ( producing debugging information ( browser (
fscommand()).
trace()), and communicating with Flash Player or the
Global Functions summary
Modifiers Signature Description
Boolean(), int(), and so on),
Array([numElements], [elementN]) : Array
Boolean(expression:Object) : Boolean Converts the parameter
call(frame:Object) Deprecated since Flash Player 5.
chr(number:Number) : String Deprecated since Flash Player 5.
clearInterval(intervalID:Number) Cancels an interval created by a call
duplicateMovieClip(target:Object,
newname:String, depth:Number)
Creates a new, empty array or converts specified elements to an array.
expression to a Boolean value and returns true or false.
This action was deprecated in favor of the function statement. Executes the script in the called frame without moving the playhead to that frame.
This function was deprecated in favor of String.fromCharCode(). Converts ASCII code numbers to characters.
to setInterval().
Creates an instance of a movie clip while the SWF file is playing.
escape(expression:String) : String Converts the parameter to a string
eval(expression:Object) : Object Accesses variables, properties,
32 ActionScript language elements
and encodes it in a URL-encoded format, where all nonalphanumeric characters are replaced with % hexadecimal sequences.
objects, or movie clips by name.
Modifiers Signature Description
fscommand(command:String,
parameters:String)
Lets a SWF file communicate with the Flash Lite player or the environment for a mobile device (such as an operating system).
fscommand2(command:String,
parameters:String)
Lets the SWF file communicate with the Flash Lite player or a host application on a mobile device.
getProperty(my_mc:Object,
property:Object) : Object
Deprecated since Flash Player 5. This function was deprecated in favor of the dot syntax, which was introduced in Flash Player 5. Returns the value of the specified property for the movie clip my_mc.
getTimer() : Number Returns the number of milliseconds
that have elapsed since the SWF file started playing.
getURL(url:String, [window:String],
[method:String])
Loads a document from a specific URL into a window or passes variables to another application at a defined URL.
getVersion() : String Returns a string containing Flash
Player version and platform information.
gotoAndPlay([scene:String],
frame:Object)
Sends the playhead to the specified frame in a scene and plays from that frame.
gotoAndStop([scene:String],
frame:Object)
ifFrameLoaded([scene:String],
frame:Object, statement(s):Object)
Sends the playhead to the specified frame in a scene and stops it.
Deprecated since Flash Player 5. This function has been deprecated. Macromedia recommends that you use the MovieClip._framesloaded property. Checks whether the contents of a specific frame are available locally.
Global Functions 33
Modifiers Signature Description
int(value:Number) : Number Deprecated since Flash Player 5.
This function was deprecated in favor of Math.round(). Converts a decimal number to an integer value by truncating the decimal value.
isFinite(expression:Object) : Boolean Evaluates expression and returns
true if it is a finite number or false
if it is infinity or negative infinity.
isNaN(expression:Object) : Boolean Evaluates the parameter and returns
true if the value is NaN (not a
number).
length(expression:String,
variable:Object) : Number
loadMovie(url:String, target:Object,
[method:String])
loadMovieNum(url:String,
level:Number, [method:String])
loadVariables(url:String,
target:Object, [method:String])
Deprecated since Flash Player 5. This function, along with all the string functions, has been deprecated. Macromedia recommends that you use the methods of the String class and the String.length property to perform the same operations. Returns the length of the specified string or variable.
Loads a SWF or JPEG file into Flash Player while the original SWF file plays.
Loads a SWF or JPEG file into a level in Flash Player while the originally loaded SWF file plays.
Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, Active Server Pages (ASP), PHP, or Perl script, and sets the values for variables in a target movie clip.
loadVariablesNum(url:String,
level:Number, [method:String])
34 ActionScript language elements
Reads data from an external file, such as a text file or text generated by a ColdFusion, CGI script, ASP, PHP, or Perl script, and sets the values for variables in a Flash Player level.
Modifiers Signature Description
mbchr(number:Number) Deprecated since Flash Player 5.
This function was deprecated in favor of the String.fromCharCode() method. Converts an ASCII code number to a multibyte character.
mblength(string:String) : Number Deprecated since Flash Player 5.
This function was deprecated in favor of the String.length property. Returns the length of the multibyte character string.
mbord(character:String) : Number Deprecated since Flash Player 5.
This function was deprecated in favor of String.charCodeAt() method. Converts the specified character to a multibyte number.
mbsubstring(value:String,
index:Number, count:Number) : String
Deprecated since Flash Player 5. This function was deprecated in favor of String.substr() method. Extracts a new multibyte character string from a multibyte character string.
nextFrame() Sends the playhead to the next
frame.
nextScene() Sends the playhead to Frame 1 of
the next scene.
Number(expression:Object) : Number Converts the parameter
expression to a number.
Object([value:Object]) : Object Creates a new empty object or
converts the specified number, string, or Boolean value to an object.
on(mouseEvent:Object) Specifies the mouse event or
keypress that triggers an action.
onClipEvent(movieEvent:Object) Triggers actions defined for a
specific instance of a movie clip.
Global Functions 35
Modifiers Signature Description
ord(character:String) : Number Deprecated since Flash Player 5.
This function was deprecated in favor of the methods and properties of the String class. Converts characters to ASCII code numbers.
parseFloat(string:String) : Number Converts a string to a floating-point
number.
parseInt(expression:String,
[radix:Number]) : Number
play() Moves the playhead forward in the
Converts a string to an integer.
Timeline.
prevFrame() Sends the playhead to the previous
frame.
prevScene() Sends the playhead to Frame 1 of
the previous scene.
random(value:Number) : Number Deprecated since Flash Player 5.
This function was deprecated in favor of Math.random(). Returns a random integer between 0 and one less than the integer specified in the value parameter.
removeMovieClip(target:Object) Deletes the specified movie clip.
setInterval(functionName:Object,
interval:Number, [param:Object], objectName:Object, methodName:String) : Number
Calls a function or a method or an object at periodic intervals while a SWF file plays.
setProperty(target:Object,
property:Object, expression:Object)
startDrag(target:Object,
[lock:Boolean], [left,top,right,bottom:Number])
stop() Stops the SWF file that is currently
stopAllSounds() Stops all sounds currently playing in
36 ActionScript language elements
Changes a property value of a movie clip as the movie clip plays.
Makes the target movie clip draggable while the movie plays.
playing.
a SWF file without stopping the playhead.
Modifiers Signature Description
stopDrag() Stops the current drag operation.
String(expression:Object) : String Returns a string representation of
the specified parameter.
substring(string:String,
index:Number, count:Number) : String
Deprecated since Flash Player 5. This function was deprecated in favor of String.substr(). Extracts part of a string.
targetPath(targetObject:Object) : String
tellTarget(target:String,
statement(s):Object)
Returns a string containing the target path of movieClipObject.
Deprecated since Flash Player 5. Macromedia recommends that you use dot (.) notation and the with statement. Applies the instructions specified in the statements parameter to the Timeline specified in the target parameter.
toggleHighQuality() Deprecated since Flash Player 5.
This function was deprecated in favor of _quality. Turns anti-aliasing on and off in Flash Player.
trace(expression:Object) Evaluates the expression and
outputs the result.
unescape(string:String) : String Evaluates the parameter x as a
string, decodes the string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string.
unloadMovie(target) Removes a movie clip that was
loaded by means of loadMovie() from Flash Player.
unloadMovieNum(level:Number) Removes a SWF or image that was
loaded by means of loadMovieNum() from Flash Player.
Global Functions 37
Array function
Array(): Array Array(numElements:Number): Array Array( [element0:Object [,
element1, element2, ...elementN] ]) : Array
Creates a new array of length zero or more, or an array populated by a list of specified elements, possibly of different data types.
Lets you create one of the following:
an empty array
an array with a specific length but whose elements have undefined values
an array whose elements have specific values.
Using this function is similar to creating an array with the Array constructor (see "Constructor for the Array class").
You can pass a number ( types (
element0, element1, ... elementN).
numElements) or a list of elements comprising one or more different
Parameters that can accept more than one data type are listed as in the signature as type
Object.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
numElements [optional] - A positive integer that specifies the number of elements in the
array. You can specify either numElements or the list of elements, not both.
elementN [optional] - one or more parameters, element0, element1, ... , elementN,
the values of which can be of any type. Parameters that can accept more than one data type are listed as type
Object. You can specify either numElements or the list of elements, not both.
Returns
Array - An array.
Example
var myArray:Array = Array(); myArray.push(12); trace(myArray); //traces 12 myArray[4] = 7; trace(myArray); //traces 12,undefined,undefined,undefined,7
Usage 2: The following example creates an array of length 4 but with no elements defined:
var myArray:Array = Array(4); trace(myArray.length); // traces 4 trace(myArray); // traces undefined,undefined,undefined,undefined
38 ActionScript language elements
Usage 3: The following example creates an array with three defined elements:
var myArray:Array = Array("firstElement", "secondElement", "thirdElement"); trace (myArray); // traces firstElement,secondElement,thirdElement
Unlike the Array class constructor, the Array() function does not use the
keyword new .
See also
Array
Boolean function
Boolean(expression:Object) : Boolean
Converts the parameter expression to a Boolean value and returns a value as described in the following list:
If expression is a Boolean value, the return value is expression.
If expression is a number, the return value is true if the number is not zero; otherwise
the return value is
If expression is a string, the return value is as follows:
In files published for Flash Player 6 or earlier, the string is first converted to a number; the
value is
true if the number is not zero, false otherwise.
false.
In files published for Flash Player 7 or later, the result is true if the string has a length
greater than zero; the value is
false for an empty string.
If expression is a string, the result is true if the string has a length greater than zero; the value is
If expression is undefined or NaN (not a number), the return value is false.
If expression is a movie clip or an object, the return value is true.
false for an empty string.
Unlike the Boolean class constructor, the Boolean() function does not use the keyword new . Moreover, the Boolean class constructor initializes a Boolean object to false if no parameter is specified, while the Boolean() function returns undefined if no parameter is specified.
Availability: ActionScript 1.0; Flash Lite 2.0 - Behavior changed in Flash Player 7.
Parameters
expression:Object - An expression to convert to a Boolean value.
Returns
Boolean - A Boolean value.
Global Functions 39
Example
trace(Boolean(-1)); // output: true trace(Boolean(0)); // output: false trace(Boolean(1)); // output: true
trace(Boolean(true)); // output: true trace(Boolean(false)); // output: false
trace(Boolean("true")); // output: true trace(Boolean("false")); // output: true
trace(Boolean("Craiggers")); // output: true trace(Boolean("")); // output: false
If files are published for Flash Player 6 and earlier, the results differ for three of the preceding examples:
trace(Boolean("true")); // output: false trace(Boolean("false")); // output: false trace(Boolean("Craiggers")); // output: false
This example shows a significant difference between use of the Boolean() function and the Boolean class. The
Boolean() function creates a Boolean value, and the Boolean class creates
a Boolean object. Boolean values are compared by value, and Boolean objects are compared by reference.
// Variables representing Boolean values are compared by value var a:Boolean = Boolean("a"); // a is true var b:Boolean = Boolean(1); // b is true trace(a==b); // true
// Variables representing Boolean objects are compared by reference var a:Boolean = new Boolean("a"); // a is true var b:Boolean = new Boolean(1); // b is true trace(a == b); // false
See also
Boolean
call function
call(frame)
Deprecated since Flash Player 5. This action was deprecated in favor of the function statement.
40 ActionScript language elements
Executes the script in the called frame without moving the playhead to that frame. Local variables do not exist after the script executes.
If variables are not declared inside a block ({}) but the action list was executed with a
call() action, the variables are local and expire at the end of the current list.
If variables are not declared inside a block and the current action list was not executed
with the call() action, the variables are interpreted as Timeline variables.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
frame:Object - The label or number of a frame in the Timeline.
See also
function statement, call (Function.call method)
chr function
chr(number) : String
Deprecated since Flash Player 5. This function was deprecated in favor of
String.fromCharCode().
Converts ASCII code numbers to characters.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
number:Number - An ASCII code number.
Returns
String - The character value of the specified ASCII code.
Example
The following example converts the number 65 to the letter A and assigns it to the variable
myVar: myVar = chr(65);
See also
fromCharCode (String.fromCharCode method)
Global Functions 41
clearInterval function
clearInterval(intervalID:Number) : Void
Cancels an interval created by a call to setInterval().
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
intervalID:Number - A numeric (integer) identifier returned from a call to setInterval().
Example
The following example first sets and then clears an interval call:
function callback() { trace("interval called: "+getTimer()+" ms."); }
var intervalID:Number = setInterval(callback, 1000);
You need to clear the interval when you have finished using the function. Create a button called
clearInt_btn and use the following ActionScript to clear setInterval():
clearInt_btn.onRelease = function(){ clearInterval( intervalID ); trace("cleared interval"); };
See also
setInterval function
duplicateMovieClip function
duplicateMovieClip(target:String, newname:String, depth:Number) :
VoidduplicateMovieClip(target:MovieClip, newname:String, depth:Number) :
Void
Creates an instance of a movie clip while the SWF file is playing. The playhead in duplicate movie clips always starts at Frame 1, regardless of where the playhead is in the original movie clip. Variables in the original movie clip are not copied into the duplicate movie clip. Use the
removeMovieClip() function or method to delete a movie clip instance created with duplicateMovieClip().
Availability: ActionScript 1.0; Flash Lite 1.0
42 ActionScript language elements
Parameters
target:Object - The target path of the movie clip to duplicate. This parameter can be either
a String (e.g. "my_mc") or a direct reference to the movie clip instance (e.g. my_mc). Parameters that can accept more than one data type are listed as type
newname:String - A unique identifier for the duplicated movie clip.
depth:Number - A unique depth level for the duplicated movie clip. The depth level is a
Object.
stacking order for duplicated movie clips. This stacking order is similar to the stacking order of layers in the Timeline; movie clips with a lower depth level are hidden under clips with a higher stacking order. You must assign each duplicated movie clip a unique depth level to prevent it from replacing SWF files on occupied depths.
Example
In the following example, a new movie clip instance is created called img_mc. An image is loaded into the movie clip, and then the called
newImg_mc, and this new clip is moved on the Stage so it does not overlap the original
img_mc clip is duplicated. The duplicated clip is
clip, and the same image is loaded into the second clip.
this.createEmptyMovieClip("img_mc", this.getNextHighestDepth()); img_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg"); duplicateMovieClip(img_mc, "newImg_mc", this.getNextHighestDepth()); newImg_mc._x = 200; newImg_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");
To remove the duplicate movie clip, you could add this code for a button called
myButton_btn.
this.myButton_btn.onRelease = function(){ removeMovieClip(newImg_mc); };
See also
removeMovieClip function, duplicateMovieClip (MovieClip.duplicateMovieClip
method)
, removeMovieClip (MovieClip.removeMovieClip method)
escape function
escape(expression:String) : String
Converts the parameter to a string and encodes it in a URL-encoded format, where all nonalphanumeric characters are replaced with % hexadecimal sequences. When used in a URL-encoded string, the percentage symbol (%) is used to introduce escape characters, and is not equivalent to the modulo operator (%).
Availability: ActionScript 1.0; Flash Lite 2.0
Global Functions 43
Parameters
expression:String - The expression to convert into a string and encode in a URL-encoded
format.
Returns
String - URL-encoded string.
Example
The following code produces the result someuser%40somedomain%2Ecom:
var email:String = "someuser@somedomain.com"; trace(escape(email));
In this example, the at symbol (@) was replaced with %40 and the dot symbol (.) was replaced with
%2E. This is useful if you're trying to pass information to a remote server and the data has
special characters in it (for example,
var redirectUrl = "http://www.somedomain.com?loggedin=true&username=Gus"; getURL("http://www.myothersite.com?returnurl="+ escape(redirectUrl));
& or ?), as shown in the following code:
See also
unescape function
eval function
eval(expression:Object) : Objecteval(expression:String) : Object
Accesses variables, properties, objects, or movie clips by name. If expression is a variable or a property, the value of the variable or property is returned. If expression is an object or movie clip, a reference to the object or movie clip is returned. If the element named in expression cannot be found, undefined is returned.
In Flash 4, class to simulate arrays.
In Flash 4, you can also use instance name. However, you can also do this with the array access operator (
eval() was used to simulate arrays; in Flash 5 or later, you should use the Array
eval() to dynamically set and retrieve the value of a variable or
[]).
44 ActionScript language elements
In Flash 5 or later, you cannot use eval() to dynamically set and retrieve the value of a variable or instance name, because you cannot use
eval() on the left side of an equation. For
example, replace the code
eval ("var" + i) = "first";
with this:
this["var"+i] = "first"
or this:
set ("var" + i, "first");
Availability: ActionScript 1.0; Flash Lite 1.0 - Flash Player 5 or later for full functionality. You can use the
eval() function when exporting to Flash Player 4, but you must use slash
notation and can access only variables, not properties or objects.
Parameters
expression:Object - The name of a variable, property, object, or movie clip to retrieve. This
parameter can be either a String or a direct reference to the object instance (i.e use of quotation marks (" ") is optional.)
Returns
Object - A value, reference to an object or movie clip, or undefined .
Example
The following example uses eval() to set properties for dynamically named movie clips. This ActionScript sets the
square2_mc, and square3_mc.
for (var i = 1; i <= 3; i++) { setProperty(eval("square"+i+"_mc"), _rotation, 5); }
_rotation property for three movie clips, called square1_mc,
You can also use the following ActionScript:
for (var i = 1; i <= 3; i++) { this["square"+i+"_mc"]._rotation = -5; }
See also
Array, set variable statement
Global Functions 45
fscommand function
fscommand(command:String, parameters:String) : Void
The fscommand() function lets a SWF file communicate with the Flash Lite player or the environment for a mobile device (such as an operating system). The parameters define the name of the application being started and the parameters to it, separated by commas.
Command Parameters Purpose
launch application-path, arg1,
arg2,..., argn
This command launches another application on a mobile device. The name of the application its parameters are passed in as a single argument. Note: This feature is operating-system dependent. Please use this command carefully as it can call on the host device to perform an unsupported operation. Using it in this way could cause the host device to crash. This command is supported only when the Flash Lite player is running in stand-alone mode. It is not supported when the player is running in the context of another application (for example, as a plug-in to a browser).
Availability: ActionScript 1.0; Flash Lite 1.1
Parameters
command:String - A string passed to the host application for any use, or a command passed
to the Flash Lite player.
parameters:String - A string passed to the host application for any use, or a value passed to
the Flash Lite player.
Example
In the following example, fscommand() would open wap.yahoo.com on the services/Web browser on Series 60 phones:
on(keyPress "9") { status = fscommand("launch",
"z:\\system\\apps\\browser\\browser.app,http://wap.yahoo.com"); }
46 ActionScript language elements
fscommand2 function
fscommand2(command:String, parameter1:String,...parameterN:String) : Void
Lets the SWF file communicate with the Flash Lite player or a host application on a mobile device.
The
fscommand2() function is similar to the fscommand() function, with the following
differences:
The fscommand2()function can take any number of arguments. By contrast,
fscommand() can take only one argument.
Flash Lite executes fscommand2() immediately (in other words, within the frame),
whereas
The fscommand2() function returns a value that can be used to report success, failure, or
the result of the command.
To u s e fscommand2() to send a message to the Flash Lite player, you must use predefined commands and parameters. See the "fscommand2 Commands" section under "ActionScript language elements" for the values you can specify for the and parameters. These values control SWF files that are playing in the Flash Lite player.
fscommand() is executed at the end of the frame being processed.
fscommand() function's commands
Note: None of the
fscommand2() commands are available in Web players.
Deprecated fscommand2() commands
Some
fscommand2() commands from Flash Lite 1.1 have been deprecated in Flash Lite 2.0.
The following table shows the deprecated
Command Deprecated By
Escape escape global function
GetDateDay getDate() method of Date object
GetDateMonth getMonth() method of Date object
GetDateWeekday getDay() method of Date object
GetDateYear getYear() method of Date object
GetLanguage System.capabilities.language property
GetLocaleLongDate getLocaleLongDate() method of Date object
GetLocaleShortDate getLocaleShortDate() method of Date object
GetLocaleTime getLocaleTime() method of Date object
GetTimeHours getHours() method of Date object
fscommand2() commands:
GetTimeMinutes getMinutes() method of Date object
Global Functions 47
Command Deprecated By
GetTimeSeconds getSeconds() method of Date object
GetTimeZoneOffset getTimeZoneOffset() method of Date object
SetQuality MovieClip._quality
Unescape unescape() global function
Availability: ActionScript 1.0; Flash Lite 1.1
Parameters
command:String - A string passed to the host application for any use, or a command passed
to the Flash Lite player.
parameters:String - A string passed to the host application for any use, or a value passed to
the Flash Lite player.
getProperty function
getProperty(my_mc:Object, property:Object) : Object
Deprecated since Flash Player 5. This function was deprecated in favor of the dot syntax, which was introduced in Flash Player 5.
Returns the value of the specified property for the movie clip
my_mc.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
my_mc:Object - The instance name of a movie clip for which the property is being retrieved.
property:Object - A property of a movie clip.
Returns
Object - The value of the specified property.
Example
The following example creates a new movie clip someClip_mc and shows the alpha value
_alpha) for the movie clip someClip_mc in the Output panel:
(
this.createEmptyMovieClip("someClip_mc", 999); trace("The alpha of "+getProperty(someClip_mc, _name)+" is:
"+getProperty(someClip_mc, _alpha));
48 ActionScript language elements
getTimer function
getTimer() : Number
Returns the number of milliseconds that have elapsed since the SWF file started playing.
Availability: ActionScript 1.0; Flash Lite 1.0
Returns
Number - The number of milliseconds that have elapsed since the SWF file started playing.
Example
In the following example, the getTimer() and setInterval() functions are used to create a simple timer:
this.createTextField("timer_txt", this.getNextHighestDepth(), 0, 0, 100,
22); function updateTimer():Void { timer_txt.text = getTimer(); }
var intervalID:Number = setInterval(updateTimer, 100);
getURL function
getURL(url:String [, window:String [, method:String] ]) : Void
Loads a document from a specific URL into a window or passes variables to another application at a defined URL. To test this function, make sure the file to be loaded is at the specified location. To use an absolute URL (for example, need a network connection.
Availability: ActionScript 1.0; Flash Lite 1.0 - The and later versions.
Parameters
url:String - The URL from which to obtain the document.
window:String [optional] - Specifies the window or HTML frame into which the document
should load. You can enter the name of a specific window or select from the following reserved target names:
_self specifies the current frame in the current window.
_blank specifies a new window.
_parent specifies the parent of the current frame.
http://www.myserver.com), you
GET and POST options are available only in
_top specifies the top-level frame in the current window.
Global Functions 49
method:String [optional] - A GET or POST method for sending variables. If there are no
variables, omit this parameter. The and is used for small numbers of variables. The
GET method appends the variables to the end of the URL,
POST method sends the variables in a separate
HTTP header and is used for sending long strings of variables.
Example
This example loads an image into a movie clip. When the image is clicked, a new URL is loaded in a new browser window.
var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc:MovieClip) { target_mc.onRelease = function() { getURL("http://www.macromedia.com/software/flash/flashpro/", "_blank"); }; }; var logo:MovieClipLoader = new MovieClipLoader(); logo.addListener(listenerObject); logo.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.createEmptyMovieClip("macromedia_mc", this.getNextHighestDepth()));
In the following example, getURL() is used to send an e-mail message:
myBtn_btn.onRelease = function(){ getURL("mailto:you@somedomain.com"); };
You can also use GET or POST for sending variables. The following example uses GET to append variables to a URL:
var firstName:String = "Gus"; var lastName:String = "Richardson"; var age:Number = 92; myBtn_btn.onRelease = function() { getURL("http://www.macromedia.com", "_blank", "GET"); };
The following ActionScript uses POST to send variables in the HTTP header. Make sure you test your documents in a browser window, because otherwise your variables are sent using
GET:
var firstName:String = "Gus"; var lastName:String = "Richardson"; var age:Number = 92; getURL("http://www.macromedia.com", "_blank", "POST");
See also
loadVariables function, send (XML.send method), sendAndLoad (XML.sendAndLoad
method)
50 ActionScript language elements
getVersion function
getVersion() : String
Returns a string containing Flash Player version and platform information. The getVersion function returns information only for Flash Player 5 or later versions of Flash Player.
Availability: ActionScript 1.0; Flash Lite 2.0
Returns
String - A string containing Flash Player version and platform information.
Example
The following examples trace the version number of the Flash Player playing the SWF file:
var flashVersion:String = getVersion(); trace(flashVersion); // output: WIN 8,0,1,0 trace($version); // output: WIN 8,0,1,0 trace(System.capabilities.version); // output: WIN 8,0,1,0
The following string is returned by the getVersion function:
WIN 8,0,1,0
This returned string indicates that the platform is Microsoft Windows, and the version number of Flash Player is major version 8, minor version 1 (8.1).
See also
os (capabilities.os property), version (capabilities.version property)
gotoAndPlay function
gotoAndPlay( [scene:String,] frame:Object) : Void
Sends the playhead to the specified frame in a scene and plays from that frame. If no scene is specified, the playhead goes to the specified frame in the current scene. You can use the parameter only on the root Timeline, not within Timelines for movie clips or other objects in the document.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
scene:String [optional] - A string specifying the name of the scene to which the playhead is
sent.
frame:Object - A number representing the frame number, or a string representing the label
of the frame, to which the playhead is sent.
scene
Global Functions 51
Example
In the following example, a document has two scenes: sceneOne and sceneTwo. Scene one contains a frame label on Frame 10 called
myOtherBtn_btn. This ActionScript is placed on Frame 1, Scene 1 of the main Timeline.
stop(); myBtn_btn.onRelease = function(){ gotoAndPlay("newFrame"); };
myOtherBtn_btn.onRelease = function(){ gotoAndPlay("sceneTwo", 1); };
newFrame and two buttons, myBtn_btn and
When the user clicks the buttons, the playhead moves to the specified location and continues playing.
See also
gotoAndPlay (MovieClip.gotoAndPlay method), nextFrame function, play
function
, prevFrame function
gotoAndStop function
gotoAndStop( [scene:String,] frame:Object) : Void
Sends the playhead to the specified frame in a scene and stops it. If no scene is specified, the playhead is sent to the frame in the current scene.You can use the
scene parameter only on
the root Timeline, not within Timelines for movie clips or other objects in the document.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
scene:String [optional] - A string specifying the name of the scene to which the playhead is
sent.
frame:Object - A number representing the frame number, or a string representing the label
of the frame, to which the playhead is sent.
52 ActionScript language elements
Example
In the following example, a document has two scenes: sceneOne and sceneTwo. Scene one contains a frame label on Frame 10 called
myOtherBtn_btn. This ActionScript is placed on Frame 1, Scene 1 of the main Timeline:
stop();
myBtn_btn.onRelease = function(){ gotoAndStop("newFrame"); };
myOtherBtn_btn.onRelease = function(){ gotoAndStop("sceneTwo", 1); };
newFrame, and two buttons, myBtn_btn and
When the user clicks the buttons, the playhead moves to the specified location and stops.
See also
gotoAndStop (MovieClip.gotoAndStop method), stop function, play function,
gotoAndPlay function
ifFrameLoaded function
ifFrameLoaded( [scene,] frame) { statement(s); }
Deprecated since Flash Player 5. This function has been deprecated. Macromedia recommends that you use the
Checks whether the contents of a specific frame are available locally. Use start playing a simple animation while the rest of the SWF file downloads to the local computer. The difference between using
_framesloaded lets you add custom if or else statements.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
scene:String [optional] - A string that specifies the name of the scene that must be loaded.
frame:Object - The frame number or frame label that must be loaded before the next
statement is executed.
statement(s):Object - The instructions to execute if the specified scene, or scene and
frame, are loaded.
MovieClip._framesloaded property.
ifFrameLoaded to
_framesloaded and ifFrameLoaded is that
Global Functions 53
See also
addListener (MovieClipLoader.addListener method)
int function
int(value) : Number
Deprecated since Flash Player 5. This function was deprecated in favor of Math.round().
Converts a decimal number to an integer value by truncating the decimal value. This function is equivalent to
value parameter is negative.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
value:Number - A number to be rounded to an integer.
Returns
Number - The truncated integer value.
Math.floor() if the value parameter is positive and Math.ceil() if the
See also
round (Math.round method), floor (Math.floor method), ceil (Math.ceil method)
isFinite function
isFinite(expression:Object) : Boolean
Evaluates expression and returns true if it is a finite number or false if it is infinity or negative infinity. The presence of infinity or negative infinity indicates a mathematical error condition such as division by 0.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
expression:Object - A Boolean value, variable, or other expression to be evaluated.
Returns
Boolean - A Boolean value.
54 ActionScript language elements
Example
The following example shows return values for isFinite:
isFinite(56) // returns true
isFinite(Number.POSITIVE_INFINITY) //returns false
isNaN function
isNaN(expression:Object) : Boolean
Evaluates the parameter and returns true if the value is NaN(not a number). This function is useful for checking whether a mathematical expression evaluates successfully to a number.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
expression:Object - A Boolean, variable, or other expression to be evaluated.
Returns
Boolean - A Boolean value.
Example
The following code illustrates return values for the isNaN() function:
trace( isNaN("Tree") ); // returns true
trace( isNaN(56) ); // returns false
trace( isNaN(Number.POSITIVE_INFINITY) ) // returns false
Global Functions 55
The following example shows how you can use isNAN() to check whether a mathematical expression contains an error:
var dividend:Number; var divisor:Number; divisor = 1; trace( isNaN(dividend/divisor) ); // output: true // The output is true because the variable dividend is undefined. // Do not use isNAN() to check for division by 0 because it will return
false.
// A positive number divided by 0 equals Infinity
(Number.POSITIVE_INFINITY).
// A negative number divided by 0 equals -Infinity
(Number.NEGATIVE_INFINITY).
See also
NaN constant, NaN (Number.NaN property)
length function
length(expression)length(variable)
Deprecated since Flash Player 5. This function, along with all the string functions, has been deprecated. Macromedia recommends that you use the methods of the String class and the
String.length property to perform the same operations.
Returns the length of the specified string or variable.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
expression:String - A string.
variable:Object - The name of a variable.
Returns
Number - The length of the specified string or variable.
Example
The following example returns the length of the string "Hello": length("Hello"); The result is 5.
See also
" string delimiter operator, String, length (String.length property)
56 ActionScript language elements
loadMovie function
loadMovie(url:String, target:Object [, method:String]) :
VoidloadMovie(url:String, target:String [, method:String]) : Void
Loads a SWF or JPEG file into Flash Player while the original SWF file plays. JPEG files saved in progressive format are not supported.
Tip: If you want to monitor the progress of the download, use
MovieClipLoader.loadClip() instead of this function.
The
loadMovie() function lets you display several SWF files at once and switch among SWF
files without loading another HTML document. Without the Player displays a single SWF file.
loadMovie() function, Flash
If you want to load a SWF or JPEG file into a specific level, use
loadMovie().
loadMovieNum() instead of
When a SWF file is loaded into a target movie clip, you can use the target path of that movie clip to target the loaded SWF file. A SWF file or image loaded into a target inherits the position, rotation, and scale properties of the targeted movie clip. The upper left corner of the loaded image or SWF file aligns with the registration point of the targeted movie clip. Alternatively, if the target is the root Timeline, the upper left corner of the image or SWF file aligns with the upper left corner of the Stage.
Use
unloadMovie() to remove SWF files that were loaded with loadMovie().
Availability: ActionScript 1.0; Flash Lite 1.1 - Loading JPEG files requires Flash Player 6 or later.
Parameters
url:String - The absolute or relative URL of the SWF or JPEG file to be loaded. A relative
path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// or file:///.
target:Object - A reference to a movie clip object or a string representing the path to a
target movie clip. The target movie clip is replaced by the loaded SWF file or image.
method:String [optional] - Specifies an HTTP method for sending variables. The parameter
must be the string
GET method appends the variables to the end of the URL and is used for small numbers of
variables. The
GET or POST . If there are no variables to be sent, omit this parameter. The
POST method sends the variables in a separate HTTP header and is used for
long strings of variables.
Global Functions 57
Example
Usage 1: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called
loadMovie("circle.swf", mySquare); // equivalent statement (Usage 1): loadMovie("circle.swf",
_level0.mySquare);
// equivalent statement (Usage 2): loadMovie("circle.swf", "mySquare");
mySquare that already exists on the Stage:
The following example loads the SWF file circle.swf from the same directory, but replaces the main movie clip instead of the
loadMovie("circle.swf", this); // Note that using "this" as a string for the target parameter will not work // equivalent statement (Usage 2): loadMovie("circle.swf", "_level0");
mySquare movie clip:
The following loadMovie() statement loads the SWF file sub.swf from the same directory into a new movie clip called
this.createEmptyMovieClip("logo_mc", 999); loadMovie("sub.swf", logo_mc);
logo_mc that's created using createEmptyMovieClip():
You could add the following code to load a JPEG image called image1.jpg from the same directory as the SWF file loading sub.swf. The JPEG is loaded when you click a button called
myBtn_btn. This code loads the JPEG into logo_mc. Therefore, it will replace sub.swf with
the JPEG image.
myBtn_btn.onRelease = function(){ loadMovie("image1.jpg", logo_mc); };
Usage 2: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called
loadMovie("circle.swf", "mySquare");
mySquare that already exists on the Stage:
See also
_level property, loadMovieNum function, loadMovie (MovieClip.loadMovie
method)
, loadClip (MovieClipLoader.loadClip method), unloadMovie function
loadMovieNum function
loadMovieNum(url:String, level:Number [, method:String]) : Void
Loads a SWF or JPEG file into a level in Flash Player while the originally loaded SWF file plays.
Tip: If you want to monitor the progress of the download, use
MovieClipLoader.loadClip() instead of this function.
58 ActionScript language elements
Normally, Flash Player displays a single SWF file and then closes. The loadMovieNum() action lets you display several SWF files at once and switch among SWF files without loading another HTML document.
If you want to specify a target instead of a level, use
loadMovieNum().
loadMovie() instead of
Flash Player has a stacking order of levels starting with level 0. These levels are like layers of acetate; they are transparent except for the objects on each level. When you use
loadMovieNum(), you must specify a level in Flash Player into which the SWF file will load.
When a SWF file is loaded into a level, you can use the syntax,
_levelN, where N is the level
number, to target the SWF file.
When you load a SWF file, you can specify any level number and you can load SWF files into a level that already has a SWF file loaded into it. If you do, the new SWF file will replace the existing SWF file. If you load a SWF file into level 0, every level in Flash Player is unloaded, and level 0 is replaced with the new file. The SWF file in level 0 sets the frame rate, background color, and frame size for all other loaded SWF files.
The
loadMovieNum() action also lets you load JPEG files into a SWF file while it plays. For
images and SWF files, the upper left corner of the image aligns with the upper left corner of the Stage when the file loads. Also in both cases, the loaded file inherits rotation and scaling, and the original content is overwritten in the specified level.
Note: JPEG files saved in progressive format are not supported.
Use
unloadMovieNum() to remove SWF files or images that were loaded with
loadMovieNum().
Availability: ActionScript 1.0; Flash Lite 1.1 - Flash 4 files opened in Flash 5 or later are converted to use the correct syntax. Loading JPEG files requires Flash Player 6 or later.
Parameters
url:String - The absolute or relative URL of the SWF or JPEG file to be loaded. A relative
path must be relative to the SWF file at level 0. For use in the stand-alone Flash Player or for testing in test mode in the Flash authoring application, all SWF files must be stored in the same folder and the filenames cannot include folder or disk drive specifications.
level:Number - An integer specifying the level in Flash Player into which the SWF file will
load.
Global Functions 59
method:String [optional] - Specifies an HTTP method for sending variables. The parameter
must be the string
GET method appends the variables to the end of the URL and is used for small numbers of
variables. The
GET or POST . If there are no variables to be sent, omit this parameter. The
POST method sends the variables in a separate HTTP header and is used for
long strings of variables.
Example
The following example loads the JPEG image tim.jpg into level 2 of Flash Player:
loadMovieNum("http://www.helpexamples.com/flash/images/image1.jpg", 2);
See also
unloadMovieNum function, loadMovie function, loadClip
(MovieClipLoader.loadClip method)
, _level property
loadVariables function
loadVariables(url:String, target:Object [, method:String]) : Void
Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, Active Server Pages (ASP), PHP, or Perl script, and sets the values for variables in a target movie clip. This action can also be used to update variables in the active SWF file with new values.
The text at the specified URL must be in the standard MIME format application/x-www- form-urlencoded (a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables:
company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103
In SWF files running in a version earlier than Flash Player 7, url must be in the same superdomain as the SWF file that is issuing this call. A superdomain is derived by removing the leftmost component of a file's URL. For example, a SWF file at www.someDomain.com can load data from a source at store.someDomain.com because both files are in the same superdomain of someDomain.com.
In SWF files of any version running in Flash Player 7 or later,
url must be in exactly the same
domain as the SWF file that is issuing this call (see "Flash Player security features" in Using ActionScript in Flash). For example, a SWF file at www.someDomain.com can load data only
from sources that are also at www.someDomain.com. If you want to load data from a different domain, you can place a cross-domain policy file on the server hosting the SWF file that is being accessed. For more information, see "About allowing cross-domain data loading" in Using ActionScript in Flash.
60 ActionScript language elements
If you want to load variables into a specific level, use loadVariablesNum() instead of
loadVariables().
Availability: ActionScript 1.0; Flash Lite 1.1 - Behavior changed in Flash Player 7.
Parameters
url:String - An absolute or relative URL where the variables are located. If the SWF file
issuing this call is running in a web browser,
url must be in the same domain as the SWF file;
for details, see the Description section.
target:Object - The target path to a movie clip that receives the loaded variables.
method:String [optional] - Specifies an HTTP method for sending variables. The parameter
must be the string
GET method appends the variables to the end of the URL and is used for small numbers of
variables. The
GET or POST . If there are no variables to be sent, omit this parameter. The
POST method sends the variables in a separate HTTP header and is used for
long strings of variables.
Example
The following example loads information from a text file called params.txt into the
target_mc movie clip that is created using createEmptyMovieClip(). The setInterval()
function is used to check the loading progress. The script checks for a variable in the params.txt file named
done.
this.createEmptyMovieClip("target_mc", this.getNextHighestDepth()); loadVariables("params.txt", target_mc); function checkParamsLoaded() { if (target_mc.done == undefined) { trace("not yet."); } else { trace("finished loading. killing interval."); trace("-------------"); for (i in target_mc) { trace(i+": "+target_mc[i]); } trace("-------------"); clearInterval(param_interval); } } var param_interval = setInterval(checkParamsLoaded, 100);
The external file, params.txt, includes the following text:
var1="hello"&var2="goodbye"&done="done"
Global Functions 61
See also
loadVariablesNum function, loadMovie function, loadMovieNum function, getURL
function
(MovieClip.loadVariables method)
, loadMovie (MovieClip.loadMovie method), loadVariables
, load (LoadVars.load method)
loadVariablesNum function
loadVariablesNum(url:String, level:Number [, method:String]) : Void
Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, ASP, PHP, or a Perl script, and sets the values for variables in a Flash Player level. You can also use this function to update variables in the active SWF file with new values.
The text at the specified URL must be in the standard MIME format
form-urlencoded
(a standard format used by CGI scripts). Any number of variables can be
application/x-www-
specified. For example, the following phrase defines several variables:
company=Macromedia&address=601+Townsend&city=San+Francisco&zip=94103
In SWF files running in a version of the player earlier than Flash Player 7, url must be in the same superdomain as the SWF file that is issuing this call. A superdomain is derived by removing the leftmost component of a file's URL. For example, a SWF file at www.someDomain.com can load data from a source at store.someDomain.com, because both files are in the same superdomain of someDomain.com.
In SWF files of any version running in Flash Player 7 or later,
url must be in exactly the same
domain as the SWF file that is issuing this call (see "Flash Player security features" in Using ActionScript in Flash). For example, a SWF file at www.someDomain.com can load data only
from sources that are also at www.someDomain.com. If you want to load data from a different domain, you can place a cross-domain policy file on the server hosting the SWF file. For more information, see "About allowing cross-domain data loading" in Using ActionScript in Flash.
If you want to load variables into a target MovieClip, use
loadVariablesNum().
loadVariables() instead of
Availability: ActionScript 1.0; Flash Lite 1.1 - Behavior changed in Flash Player 7. Flash 4 files opened in Flash 5 or later are converted to use the correct syntax.
Parameters
url:String - An absolute or relative URL where the variables are located. If the SWF file
issuing this call is running in a web browser, for details, see the Description section.
level:Number - An integer specifying the level in Flash Player to receive the variables.
62 ActionScript language elements
url must be in the same domain as the SWF file;
method:String [optional] - Specifies an HTTP method for sending variables. The parameter
must be the string
GET method appends the variables to the end of the URL and is used for small numbers of
variables. The
GET or POST . If there are no variables to be sent, omit this parameter. The
POST method sends the variables in a separate HTTP header and is used for
long strings of variables.
Example
The following example loads information from a text file called params.txt into the main Timeline of the SWF at level 2 in Flash Player. The variable names of the text fields must match the variable names in the params.txt file. The
setInterval() function is used to
check the progress of the data being loaded into the SWF. The script checks for a variable in the params.txt file named
loadVariablesNum("params.txt", 2); function checkParamsLoaded() { if (_level2.done == undefined) { trace("not yet."); } else { trace("finished loading. killing interval."); trace("-------------"); for (i in _level2) { trace(i+": "+_level2[i]); } trace("-------------"); clearInterval(param_interval); } } var param_interval = setInterval(checkParamsLoaded, 100);
done.
// Params.txt includes the following text var1="hello"&var2="goodbye"&done="done"
See also
getURL function, loadMovie function, loadMovieNum function, loadVariables
function
(MovieClip.loadVariables method)
, loadMovie (MovieClip.loadMovie method), loadVariables
, load (LoadVars.load method)
mbchr function
mbchr(number)
Deprecated since Flash Player 5. This function was deprecated in favor of the
String.fromCharCode() method.
Converts an ASCII code number to a multibyte character.
Global Functions 63
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
number:Number - The number to convert to a multibyte character.
See also
fromCharCode (String.fromCharCode method)
mblength function
mblength(string) : Number
Deprecated since Flash Player 5. This function was deprecated in favor of the String.length property.
Returns the length of the multibyte character string.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
string:String - The string to measure.
Returns
Number - The length of the multibyte character string.
See also
String, length (String.length property)
mbord function
mbord(character) : Number
Deprecated since Flash Player 5. This function was deprecated in favor of
String.charCodeAt() method.
Converts the specified character to a multibyte number.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
character:String - character The character to convert to a multibyte number.
64 ActionScript language elements
Returns
Number - The converted character.
See also
charCodeAt (String.charCodeAt method)
mbsubstring function
mbsubstring(value, index, count) : String
Deprecated since Flash Player 5. This function was deprecated in favor of String.substr() method.
Extracts a new multibyte character string from a multibyte character string.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
value:String - The multibyte string from which to extract a new multibyte string.
index:Number - The number of the first character to extract.
count:Number - The number of characters to include in the extracted string, not including
the index character.
Returns
String - The string extracted from the multibyte character string.
See also
substr (String.substr method)
Global Functions 65
nextFrame function
nextFrame() : Void
Sends the playhead to the next frame.
Availability: ActionScript 1.0; Flash Lite 1.0
Example
In the following example, when the user presses the Right or Down arrow key, the playhead goes to the next frame and stops. If the user presses the Left or Up arrow key, the playhead goes to the previous frame and stops. The listener is initialized to wait for the arrow key to be pressed, and the playhead returns to Frame 1.
stop();
if (init == undefined) { someListener = new Object(); someListener.onKeyDown = function() { if (Key.isDown(Key.LEFT) || Key.isDown(Key.UP)) { _level0.prevFrame(); } else if (Key.isDown(Key.RIGHT) || Key.isDown(Key.DOWN)) { _level0.nextFrame(); } }; Key.addListener(someListener); init = 1; }
init variable is used to prevent the listener from being redefined if the
See also
prevFrame function
nextScene function
nextScene() : Void
Sends the playhead to Frame 1 of the next scene.
Availability: ActionScript 1.0; Flash Lite 1.0
66 ActionScript language elements
Example
In the following example, when a user clicks the button that is created at runtime, the playhead is sent to Frame 1 of the next scene. Create two scenes, and enter the following ActionScript on Frame 1 of Scene 1.
stop();
if (init == undefined) { this.createEmptyMovieClip("nextscene_mc", this.getNextHighestDepth()); nextscene_mc.createTextField("nextscene_txt", this.getNextHighestDepth(),
200, 0, 100, 22); nextscene_mc.nextscene_txt.autoSize = true; nextscene_mc.nextscene_txt.border = true; nextscene_mc.nextscene_txt.text = "Next Scene"; this.createEmptyMovieClip("prevscene_mc", this.getNextHighestDepth()); prevscene_mc.createTextField("prevscene_txt", this.getNextHighestDepth(),
00, 0, 100, 22); prevscene_mc.prevscene_txt.autoSize = true; prevscene_mc.prevscene_txt.border = true; prevscene_mc.prevscene_txt.text = "Prev Scene"; nextscene_mc.onRelease = function() { nextScene(); };
prevscene_mc.onRelease = function() { prevScene(); };
init = true; }
Make sure you place a stop() action on Frame 1 of Scene 2.
See also
prevScene function
Global Functions 67
Number function
Number(expression) : Number
Converts the parameter expression to a number and returns a value as described in the following list:
If expression is a number, the return value is expression.
If expression is a Boolean value, the return value is 1 if expression is true, 0 if
expression is false.
If expression is a string, the function attempts to parse expression as a decimal
number with an optional trailing exponent (that is, 1.57505e-3).
If expression is NaN, the return value is NaN.
If expression is undefined, the return value is as follows:
- In files published for Flash Player 6 or earlier, the result is 0.
- In files published for Flash Player 7 or later, the result is NaN.
Availability: ActionScript 1.0; Flash Lite 2.0 -
Parameters
expression:Object - An expression to convert to a number. Numbers or strings that begin
with 0x are interpreted as hexadecimal values. Numbers or strings that begin with 0 are interpreted as octal values.
Returns
Number - A number or NaN (not a number).
Example
In the following example, a text field is created on the Stage at runtime:
this.createTextField("counter_txt", this.getNextHighestDepth(), 0, 0, 100,
22); counter_txt.autoSize = true; counter_txt.text = 0; function incrementInterval():Void { var counter:Number = counter_txt.text; // Without the Number() function, Flash would concatenate the value instead // of adding values. You could also use "counter_txt.text++;" counter_txt.text = Number(counter) + 1; } var intervalID:Number = setInterval(incrementInterval, 1000);
See also
NaN constant, Number, parseInt function, parseFloat function
68 ActionScript language elements
Object function
Object( [value] ) : Object
Creates a new empty object or converts the specified number, string, or Boolean value to an object. This command is equivalent to creating an object using the Object constructor (see "Constructor for the Object class").
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
value:Object [optional] - A number, string, or Boolean value.
Returns
Object - An object.
Example
In the following example, a new empty object is created, and then the object is populated with values:
var company:Object = new Object(); company.name = "Macromedia, Inc."; company.address = "600 Townsend Street"; company.city = "San Francisco"; company.state = "CA"; company.postal = "94103"; for (var i in company) { trace("company."+i+" = "+company[i]); }
See also
Object
on handler
on(mouseEvent:Object) { // your statements here }
Specifies the mouse event or keypress that triggers an action.
Availability: ActionScript 1.0; Flash Lite 1.0 - Flash 2. Not all events are supported in Flash 2.
Global Functions 69
Parameters
mouseEvent:Object - A mouseEvent is a trigger called an event . When the event occurs, the
statements following it within curly braces ({ }) execute. Any of the following values can be specified for the
press The mouse button is pressed while the pointer is over the button.
release The mouse button is released while the pointer is over the button.
releaseOutside While the pointer is over the button, the mouse button is pressed, rolled
outside the button area, and released. Both the precede a
mouseEvent parameter:
press and the dragOut events always
releaseOutside event.
Note: This event is supported in Flash Lite only if System.capabilities.hasMouse is
true or System.capabilities.hasStylus is true.
rollOut The pointer rolls outside the button area.
Note: This event is supported in Flash Lite only if System.capabilities.hasMouse is
true or System.capabilities.hasStylus is true.
rollOver The mouse pointer rolls over the button.
dragOut While the pointer is over the button, the mouse button is pressed and then rolls
outside the button area.
dragOver While the pointer is over the button, the mouse button has been pressed, then
rolled outside the button, and then rolled back over the button.
keyPress "<key> " The specified keyboard key is pressed. For the key portion of the
parameter, specify a key constant, as shown in the code hinting in the Actions Panel. You can use this parameter to intercept a key press, that is, to override any built-in behavior for the specified key. The button can be anywhere in your application, on or off the Stage. One limitation of this technique is that you can't apply the
on() handler at runtime; you
must do it at authoring time. Make sure that you select Control > Disable Keyboard Shortcuts, or certain keys with built-in behavior won't be overridden when you test the application using Control > Test Movie.
For a list of key constants, see the Key class.
70 ActionScript language elements
Example
In the following script, the startDrag() function executes when the mouse is pressed, and the conditional script is executed when the mouse is released and the object is dropped:
on (press) { startDrag(this); } on (release) { trace("X:"+this._x); trace("Y:"+this._y); stopDrag(); }
See also
onClipEvent handler, Key
onClipEvent handler
onClipEvent(movieEvent:Object) { // your statements here }
Triggers actions defined for a specific instance of a movie clip.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
movieEvent:Object - The movieEvent is a trigger called an event . When the event occurs,
the statements following it within curly braces ({}) are executed. Any of the following values can be specified for the
load The action is initiated as soon as the movie clip is instantiated and appears in the
movieEvent parameter:
Timeline.
unload The action is initiated in the first frame after the movie clip is removed from the
Timeline. The actions associated with the
Unload movie clip event are processed before
any actions are attached to the affected frame.
enterFrame The action is triggered continually at the frame rate of the movie clip. The
actions associated with the
enterFrame clip event are processed before any frame actions
that are attached to the affected frames.
mouseMove The action is initiated every time the mouse is moved. Use the _xmouse and
_ymouse properties to determine the current mouse position.
Note: This event is supported in Flash Lite only if System.capabilities.hasMouse is
true.
Global Functions 71
mouseDown The action is initiated when the left mouse button is pressed.
Note: This event is supported in Flash Lite only if System.capabilities.hasMouse is
true or System.capabilities.hasStylus is true.
mouseUp The action is initiated when the left mouse button is released.
Note: This event is supported in Flash Lite only if System.capabilities.hasMouse is
true or System.capabilities.hasStylus is true.
keyDown The action is initiated when a key is pressed. Use Key.getCode() to retrieve
information about the last key pressed.
keyUp The action is initiated when a key is released. Use the Key.getCode() method to
retrieve information about the last key pressed.
data The action is initiated when data is received in a loadVariables() or loadMovie()
action. When specified with a when the last variable is loaded. When specified with a
loadVariables() action, the data event occurs only once,
loadMovie() action, the data
event occurs repeatedly, as each section of data is retrieved.
Example
The following example uses onClipEvent() with the keyDown movie event and is designed to be attached to a movie clip or button. The more methods and properties of the Key object. The following script uses find out which key the user has pressed; if the pressed key matches the the playhead is sent to the next frame; if the pressed key matches the
keyDown movie event is usually used with one or
Key.getCode() to
Key.RIGHT property,
Key.LEFT property, the
playhead is sent to the previous frame.
onClipEvent (keyDown) { if (Key.getCode() == Key.RIGHT) { this._parent.nextFrame(); } else if (Key.getCode() == Key.LEFT) { this._parent.prevFrame(); } }
The following example uses onClipEvent() with the load and mouseMove movie events.
xmouse and _ymouse properties track the position of the mouse each time the mouse
The _ moves, which appears in the text field that's created at runtime.
onClipEvent (load) { this.createTextField("coords_txt", this.getNextHighestDepth(), 0, 0, 100,
22); coords_txt.autoSize = true; coords_txt.selectable = false; } onClipEvent (mouseMove) { coords_txt.text = "X:"+_root._xmouse+",Y:"+_root._ymouse; }
72 ActionScript language elements
See also
Key, _xmouse (MovieClip._xmouse property), _ymouse (MovieClip._ymouse
property)
, on handler
ord function
ord(character) : Number
Deprecated since Flash Player 5. This function was deprecated in favor of the methods and properties of the String class.
Converts characters to ASCII code numbers.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
character:String - The character to convert to an ASCII code number.
Returns
Number - The ASCII code number of the specified character.
See also
String, charCodeAt (String.charCodeAt method)
parseFloat function
parseFloat(string:String) : Number
Converts a string to a floating-point number. The function reads, or parses, and returns the numbers in a string until it reaches a character that is not a part of the initial number. If the string does not begin with a number that can be parsed, space preceding valid integers is ignored, as are trailing nonnumeric characters.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
string:String - The string to read and convert to a floating-point number.
Returns
Number - A number or NaN (not a number).
parseFloat() returns NaN. White
Global Functions 73
Example
The following examples use the parseFloat() function to evaluate various types of numbers:
trace(parseFloat("-2")); // output: -2 trace(parseFloat("2.5")); // output: 2.5 trace(parseFloat(" 2.5")); // output: 2.5 trace(parseFloat("3.5e6")); // output: 3500000 trace(parseFloat("foobar")); // output: NaN trace(parseFloat("3.75math")); // output: 3.75 trace(parseFloat("0garbage")); // output: 0
See also
NaN constant, parseInt function
parseInt function
parseInt(expression:String [, radix:Number]) : Number
Converts a string to an integer. If the specified string in the parameters cannot be converted to a number, the function returns numbers. Integers beginning with 0 or specifying a radix of 8 are interpreted as octal numbers. White space preceding valid integers is ignored, as are trailing nonnumeric characters.
NaN. Strings beginning with 0x are interpreted as hexadecimal
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
expression:String - A string to convert to an integer.
radix:Number [optional] - An integer representing the radix (base) of the number to parse.
Legal values are from 2 to 36.
Returns
Number - A number or NaN (not a number).
Example
The examples in this section use the parseInt() function to evaluate various types of numbers.
The following example returns 3:
parseInt("3.5")
The following example returns NaN:
parseInt("bar")
74 ActionScript language elements
The following example returns 4:
parseInt("4foo")
The following example shows a hexadecimal conversion that returns 1016:
parseInt("0x3F8")
The following example shows a hexadecimal conversion using the optional radix parameter that returns 1000:
parseInt("3E8", 16)
The following example shows a binary conversion and returns 10, which is the decimal representation of the binary 1010:
parseInt("1010", 2)
The following examples show octal number parsing and return 511, which is the decimal representation of the octal 777:
parseInt("0777") parseInt("777", 8)
See also
, parseFloat function
play function
play() : Void
Moves the playhead forward in the Timeline.
Availability: ActionScript 1.0; Flash Lite 1.0
Example
In the following example, there are two movie clip instances on the Stage with the instance names
stop_mc movie clip instance is clicked. Playback resumes when the play_mc instance is
clicked.
this.stop_mc.onRelease = function() { stop(); }; this.play_mc.onRelease = function() { play(); }; trace("frame 1");
See also
stop_mc and play_mc. The ActionScript stops the SWF file's playback when the
gotoAndPlay function, gotoAndPlay (MovieClip.gotoAndPlay method)
Global Functions 75
prevFrame function
prevFrame() : Void
Sends the playhead to the previous frame. If the current frame is Frame 1, the playhead does not move.
Availability: ActionScript 1.0; Flash Lite 1.0
Example
When the user clicks a button called myBtn_btn and the following ActionScript is placed on a frame in the Timeline for that button, the playhead is sent to the previous frame:
stop(); this.myBtn_btn.onRelease = function(){ prevFrame(); };
See also
nextFrame function, prevFrame (MovieClip.prevFrame method)
prevScene function
prevScene() : Void
Sends the playhead to Frame 1 of the previous scene.
Availability: ActionScript 1.0; Flash Lite 1.0
See also
nextScene function
random function
random(value) : Number
Deprecated since Flash Player 5. This function was deprecated in favor of Math.random().
Returns a random integer between 0 and one less than the integer specified in the value parameter.
Availability: ActionScript 1.0; Flash Lite 1.1
Parameters
value:Number - An integer.
76 ActionScript language elements
Returns
Number - A random integer.
Example
The following use of random() returns a value of 0, 1, 2, 3, or 4: random(5);
See also
random (Math.random method)
removeMovieClip function
removeMovieClip(target:Object)
Deletes the specified movie clip.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
target:Object - The target path of a movie clip instance created with duplicateMovieClip() or the instance name of a movie clip created with MovieClip.attachMovie(), MovieClip.duplicateMovieClip(), or MovieClip.createEmptyMovieClip().
Example
The following example creates a new movie clip called myClip_mc and duplicates the movie clip. The second movie clip is called When a button,
this.createEmptyMovieClip("myClip_mc", this.getNextHighestDepth()); myClip_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg"); duplicateMovieClip(this.myClip_mc, "newClip_mc",
this.getNextHighestDepth());
newClip_mc.loadMovie("http://www.helpexamples.com/flash/images/
image1.jpg"); newClip_mc._x = 200; this.button_mc.onRelease = function() { removeMovieClip(this._parent.newClip_mc); };
button_mc, is clicked, the duplicated movie clip is removed from the Stage.
newClip_mc. Images are loaded into both movie clips.
Global Functions 77
See also
duplicateMovieClip function, duplicateMovieClip
(MovieClip.duplicateMovieClip method)
method)
createEmptyMovieClip (MovieClip.createEmptyMovieClip method)
, removeMovieClip (MovieClip.removeMovieClip method),
, attachMovie (MovieClip.attachMovie
setInterval function
setInterval(functionName:Object, interval:Number [, param1:Object, param2, ..., paramN]) : Number setInterval(objectName:Object, methodName:String, interval:Number [, param1:Object, param2, ..., paramN]) : Number
Calls a function or a method or an object at periodic intervals while a SWF file plays. You can use an interval function to update variables from a database or to update a time display.
If
interval is greater than the SWF file's frame rate, the interval function is only called each
time the playhead enters a frame; this minimizes the impact each time the screen is refreshed.
Note: In Flash Lite 2.0, the interval passed into this method is ignored if it is less than the SWF file's frame rate and the interval function is called on the SWF file's frame rate interval only. If the interval is greater than the SWF file's frame rate, the event is called on the next frame after the interval has elapsed.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
functionName:Object - A function name or a reference to an anonymous function.
interval:Number - The time in milliseconds between calls to the functionName or
methodName parameter.
param:Object [optional] - Parameters passed to the functionName or methodName
parameter. Multiple parameters should be separated by commas:
...,paramN
objectName:Object
methodName:String - A method of objectName .
- An object containing the method methodName.
param1,param2,
Returns
Number - An identifying integer that you can pass to clearInterval() to cancel the interval.
78 ActionScript language elements
Example
Usage 1: The following example calls an anonymous function every 1000 milliseconds (1 second).
setInterval( function(){ trace("interval called"); }, 1000 );
Usage 2: The following example defines two event handlers and calls each of them. The first call to The second call to
callback2() as a parameter.
function callback1() { trace("interval called"); }
function callback2(arg) { trace(arg); }
setInterval( callback1, 1000 ); setInterval( callback2, 1000, "interval called" );
setInterval() calls the callback1() function, which contains a trace() statement.
setInterval() passes the "interval called" string to the function
Usage 3: This example uses a method of an object. You must use this syntax when you want to call a method that is defined for an object.
obj = new Object(); obj.interval = function() { trace("interval function called"); }
setInterval( obj, "interval", 1000 );
obj2 = new Object(); obj2.interval = function(s) { trace(s); } setInterval( obj2, "interval", 1000, "interval function called" );
You must use the second form of the setInterval() syntax to call a method of an object, as shown in the following example:
setInterval( obj2, "interval", 1000, "interval function called" );
Global Functions 79
When working with this function, you need to be careful about the memory you use in a SWF file. For example, when you remove a movie clip from the SWF file, it will not remove any
setInterval() function running within it. Always remove the setInterval() function
by using
clearInterval() when you have finished using it, as shown in the following
example:
// create an event listener object for our MovieClipLoader instance var listenerObjectbject = new Object(); listenerObject.onLoadInit = function(target_mc:MovieClip) { trace("start interval"); /* after the target movie clip loaded, create a callback which executes about every 1000 ms (1 second) and calls the intervalFunc function. */ target_mc.myInterval = setInterval(intervalFunc, 1000, target_mc); }; function intervalFunc(target_mc) { // display a trivial message which displays the instance name and arbitrary
text. trace(target_mc+" has been loaded for "+getTimer()/1000+" seconds."); /* when the target movie clip is clicked (and released) you clear the
interval and remove the movie clip. If you don't clear the interval before deleting the movie clip, the function still calls itself every second even though
the movie clip instance is no longer present. */ target_mc.onRelease = function() { trace("clear interval"); clearInterval(this.myInterval); // delete the target movie clip removeMovieClip(this); }; } var jpeg_mcl:MovieClipLoader = new MovieClipLoader(); jpeg_mcl.addListener(listenerObject); jpeg_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.createEmptyMovieClip("jpeg_mc", this.getNextHighestDepth()));
If you work with setInterval() within classes, you need to be sure to use the this keyword when you call the function. The members if you do not use the keyword. This is illustrated in the following example. For a FLA file with a button called
var me:User = new User("Gary"); this.deleteUser_btn.onRelease = function() { trace("Goodbye, "+me.username); clearInterval(me.intervalID); delete me; };
80 ActionScript language elements
setInterval()function does not have access to class
deleteUser_btn, add the following ActionScript to Frame 1:
Then create a file called User.as in the same directory as your FLA file. Enter the following ActionScript:
class User { var intervalID:Number; var username:String; function User(param_username:String) { trace("Welcome, "+param_username); this.username = param_username; this.intervalID = setInterval(this, "traceUsername", 1000, this.username); } function traceUsername(str:String) { trace(this.username+" is "+getTimer()/1000+" seconds old, happy
birthday."); } }
See also
clearInterval function
setProperty function
setProperty(target:Object, property:Object, expression:Object) : Void
Changes a property value of a movie clip as the movie clip plays.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
target:Object - The path to the instance name of the movie clip whose property is to be set.
property:Object - The property to be set.
expression:Object - Either the new literal value of the property, or an equation that
evaluates to the new value of the property.
Example
The following ActionScript creates a new movie clip and loads an image into it. The _xand _y coordinates are set for the clip using
right_btn, the _x coordinate of a movie clip named params_mc is incremented by 20 pixels.
this.createEmptyMovieClip("params_mc", 999); params_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg"); setProperty(this.params_mc, _y, 20); setProperty(this.params_mc, _x, 20); this.right_btn.onRelease = function() { setProperty(params_mc, _x, getProperty(params_mc, _x)+20); };
setProperty(). When you click the button called
Global Functions 81
See also
getProperty function
startDrag function
startDrag(target:Object [, lock:Boolean, left:Number, top:Number,
right:Number, bottom:Number]) : Void
Makes the target movie clip draggable while the movie plays. Only one movie clip can be dragged at a time. After a draggable until it is explicitly stopped by another movie clip is called.
startDrag() operation is executed, the movie clip remains
stopDrag() or until a startDrag() action for
Note: This method is supported in Flash Lite only if
true or System.capabilities.hasStylus is true.
System.capabilities.hasMouse is
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
target:Object - The target path of the movie clip to drag.
lock:Boolean [optional] - A Boolean value specifying whether the draggable movie clip is
locked to the center of the mouse position ( clicked the movie clip (
left,top,right,bottom:Number [optional] - Values relative to the coordinates of the movie
false ).
true ) or locked to the point where the user first
clip's parent that specify a constraint rectangle for the movie clip.
Example
The following example creates a movie clip, pic_mc, at runtime that users can drag to any location by attaching the is loaded into
var pic_mcl:MovieClipLoader = new MovieClipLoader(); pic_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth())); var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc) { target_mc.onPress = function() { startDrag(this); }; target_mc.onRelease = function() { stopDrag(); }; }; pic_mcl.addListener(listenerObject);
pic_mc using the MovieClipLoader class.
startDrag() and stopDrag() actions to the movie clip. An image
82 ActionScript language elements
See also
stopDrag function, _droptarget (MovieClip._droptarget property), startDrag
(MovieClip.startDrag method)
stop function
stop() : Void
Stops the SWF file that is currently playing. The most common use of this action is to control movie clips with buttons.
Availability: ActionScript 1.0; Flash Lite 1.0
See also
gotoAndStop function, gotoAndStop (MovieClip.gotoAndStop method)
stopAllSounds function
stopAllSounds() : Void
Stops all sounds currently playing in a SWF file without stopping the playhead. Sounds set to stream will resume playing as the playhead moves over the frames in which they are located.
Availability: ActionScript 1.0; Flash Lite 1.0
Example
The following code creates a text field, in which the song's ID3 information appears. A new Sound object instance is created, and your MP3 is loaded into the SWF file. ID3 information is extracted from the sound file. When the user clicks the user clicks
this.createTextField("songinfo_txt", this.getNextHighestDepth, 0, 0,
Stage.width, 22); var bg_sound:Sound = new Sound(); bg_sound.loadSound("yourSong.mp3", true); bg_sound.onID3 = function() { songinfo_txt.text = "(" + this.id3.artist + ") " + this.id3.album + " - " +
this.id3.track + " - " + this.id3.songname; for (prop in this.id3) { trace(prop+" = "+this.id3[prop]); } trace("ID3 loaded."); }; this.play_mc.onRelease = function() {
play_mc, the song resumes from its paused position.
stop_mc, the sound is paused. When
Global Functions 83
/* get the current offset. if you stop all sounds and click the play
button, the MP3 continues from where it was stopped, instead of restarting from the beginning. */ var numSecondsOffset:Number = (bg_sound.position/1000); bg_sound.start(numSecondsOffset); }; this.stop_mc.onRelease = function() { stopAllSounds(); };
See also
Sound
stopDrag function
stopDrag() : Void
Stops the current drag operation.
Note: This method is supported in Flash Lite only if
true or System.capabilities.hasStylus is true.
System.capabilities.hasMouse is
Availability: ActionScript 1.0; Flash Lite 2.0
Example
The following code, placed in the main Timeline, stops the drag action on the movie clip instance
my_mc.onPress = function () { startDrag(this); }
my_mc.onRelease = function() { stopDrag(); }
my_mc when the user releases the mouse button:
See also
startDrag function, _droptarget (MovieClip._droptarget property), startDrag
(MovieClip.startDrag method)
, stopDrag (MovieClip.stopDrag method)
84 ActionScript language elements
String function
String(expression:Object) : String
Returns a string representation of the specified parameter, as described in the following list:
If expression is a number, the return string is a text representation of the number.
If expression is a string, the return string is expression.
If expression is an object, the return value is a string representation of the object
generated by calling the string property for the object or by calling no such property exists.
If expression is a Boolean value, the return string is "true" or "false".
If expression is a movie clip, the return value is the target path of the movie clip in slash
(/) notation.
If expression is undefined, the return values are as follows:
In files published for Flash Player 6 or earlier, the result is an empty string ("").
In files published for Flash Player 7 or later, the result is undefined.
Note:Slash notation is not supported by ActionScript 2.0.
Availability: ActionScript 1.0; Flash Lite 1.0 - Behavior changed in Flash Player 7.
Object.toString() if
Parameters
expression:Object - An expression to convert to a string.
Returns
String - A string.
Example
In the following example, you use ActionScript to convert specified expressions to a string:
var string1:String = String("3"); var string2:String = String("9"); trace(string1+string2); // output: 39
Because both parameters are strings, the values are concatenated rather than added.
See also
toString (Number.toString method), toString (Object.toString method), String,
" string delimiter operator
Global Functions 85
substring function
substring("string", index, count) : String
Deprecated since Flash Player 5. This function was deprecated in favor of String.substr().
Extracts part of a string. This function is one-based, whereas the String object methods are zero-based.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
string:String - The string from which to extract the new string.
index:Number - The number of the first character to extract.
count:Number - The number of characters to include in the extracted string, not including
the index character.
Returns
String - The extracted substring.
See also
substr (String.substr method)
targetPath function
targetpath(targetObject:Object) : String
Returns a string containing the target path of a MovieClip, Button, or TextFieldobject. The target path is returned in dot (.) notation. To retrieve the target path in slash (/) notation, use the
_target property.
Availability: ActionScript 1.0; Flash Lite 2.0 - Support for Button and TextField objects added in Flash Player 6.
Parameters
targetObject:Object - Reference (for example, _root or _parent ) to the object for which
the target path is being retrieved. This can be a MovieClip, Button, or TextField object.
86 ActionScript language elements
Returns
String - A string containing the target path of the specified object.
Example
The following example traces the target path of a movie clip as soon as it loads:
this.createEmptyMovieClip("myClip_mc", this.getNextHighestDepth()); trace(targetPath(myClip_mc)); // _level0.myClip_mc
See also
eval function
tellTarget function
tellTarget("target") { statement(s); }
Deprecated since Flash Player 5. Macromedia recommends that you use dot (.) notation and the
with statement.
Applies the instructions specified in the the
target parameter. The tellTarget action is useful for navigation controls. Assign
tellTarget to buttons that stop or start movie clips elsewhere on the Stage. You can also
statements parameter to the Timeline specified in
make movie clips go to a particular frame in that clip. For example, you might assign
tellTarget to buttons that stop or start movie clips on the Stage or prompt movie clips to
jump to a particular frame.
In Flash 5 or later, you can use dot (.) notation instead of the the
with action to issue multiple actions to the same Timeline. You can use the with action to
target any object, whereas the
tellTarget action can target only movie clips.
tellTarget action. You can use
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
target:String - A string that specifies the target path of the Timeline to be controlled.
statement(s):Object - The instructions to execute if the condition is true.
Global Functions 87
Example
This tellTarget statement controls the movie clip instance ball on the main Timeline. Frame 1 of the ball instance is blank and has a stop() action so it isn't visible on the Stage. When you click the button with the following action, tellTarget tells the playhead in ball to go to Frame 2, where the animation starts:
on(release) { tellTarget("_parent.ball") { gotoAndPlay(2); } }
The following example uses dot (.) notation to achieve the same results:
on(release) { _parent.ball.gotoAndPlay(2); }
If you need to issue multiple commands to the ball instance, you can use the with action, as shown in the following statement:
on(release) { with(_parent.ball) { gotoAndPlay(2); _alpha = 15; _xscale = 50; _yscale = 50; } }
See also
with statement
toggleHighQuality function
toggleHighQuality()
Deprecated since Flash Player 5. This function was deprecated in favor of _quality.
Turns anti-aliasing on and off in Flash Player. Anti-aliasing smooths the edges of objects and slows down SWF playback. This action affects all SWF files in Flash Player.
Availability: ActionScript 1.0; Flash Lite 1.0
88 ActionScript language elements
Example
The following code could be applied to a button that, when clicked, would toggle anti­aliasing on and off:
on(release) { toggleHighQuality(); }
See also
_quality property
trace function
trace(expression:Object)
You can use Flash Debug Player to capture output from the trace() function and write that output to the log file.
Statement; evaluates the expression and displays the result in the Output panel in test mode.
Use this statement to record programming notes or to display messages in the Output panel while testing a SWF file. Use the or to display values in the Output panel. The function in JavaScript.
expression parameter to check whether a condition exists,
trace() statement is similar to the alert
You can use the Omit Trace Actions command in the Publish Settings dialog box to remove
trace()actions from the exported SWF file.
Availability: ActionScript 1.0; Flash Lite 1.0
Parameters
expression:Object - An expression to evaluate. When a SWF file is opened in the Flash
authoring tool (using the Test Movie command), the value of the
expression parameter is
displayed in the Output panel.
Global Functions 89
Example
The following example uses a trace() statement to display in the Output panel the methods and properties of the dynamically created text field called
this.createTextField("error_txt", this.getNextHighestDepth(), 0, 0, 100,
22); for (var i in error_txt) { trace("error_txt."+i+" = "+error_txt[i]); } /* output: error_txt.styleSheet = undefined error_txt.mouseWheelEnabled = true error_txt.condenseWhite = false ... error_txt.maxscroll = 1 error_txt.scroll = 1 */
error_txt:
unescape function
unescape(x:String) : String
Evaluates the parameter x as a string, decodes the string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string.
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
string:String - A string with hexadecimal sequences to escape.
Returns
String - A string decoded from a URL-encoded parameter.
Example
The following example shows the escape-to-unescape conversion process:
var email:String = "user@somedomain.com"; trace(email); var escapedEmail:String = escape(email); trace(escapedEmail); var unescapedEmail:String = unescape(escapedEmail); trace(unescapedEmail);
The following result is displayed in the Output panel.
user@somedomain.com user%40somedomain%2Ecom user@somedomain.com
90 ActionScript language elements
unloadMovie function
unloadMovie(target:MovieClip) : Void unloadMovie(target:String) : Void
Removes a movie clip that was loaded by means of loadMovie() from Flash Player. To unload a movie clip that was loaded by means of of
unloadMovie().
Availability: ActionScript 1.0; Flash Lite 1.1
Parameters
target - The target path of a movie clip. This parameter can be either a String (e.g.
"my_mc") or a direct reference to the movie clip instance (e.g. my_mc). Parameters that can accept more than one data type are listed as type
Example
The following example creates a new movie clip called pic_mc and loads an image into that clip. It is loaded using the MovieClipLoader class. When you click the image, the movie clip unloads from the SWF file:
var pic_mcl:MovieClipLoader = new MovieClipLoader(); pic_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth())); var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc) { target_mc.onRelease = function() { unloadMovie(pic_mc); /* or you could use the following, which refers to the movie clip
referenced by 'target_mc'. */ //unloadMovie(this); }; }; pic_mcl.addListener(listenerObject);
loadMovieNum(), use unloadMovieNum() instead
Object.
See also
loadMovie (MovieClip.loadMovie method), unloadClip
(MovieClipLoader.unloadClip method)
unloadMovieNum function
unloadMovieNum(level:Number) : Void
Removes a SWF or image that was loaded by means of loadMovieNum() from Flash Player. To unload a SWF or image that was loaded with
unloadMovie() instead of unloadMovieNum().
MovieClip.loadMovie(), use
Global Functions 91
Availability: ActionScript 1.0; Flash Lite 1.1
Parameters
level:Number - The level (_level N ) of a loaded movie.
Example
The following example loads an image into a SWF file. When you click unload_btn, the loaded content is removed.
loadMovieNum("yourimage.jpg", 1); unload_btn.onRelease = function() { unloadMovieNum(1); }
See also
loadMovieNum function, unloadMovie function, loadMovie (MovieClip.loadMovie
method)
Global Properties
Global properties are available in every script, and are visible to every Timeline and scope in your document. For example, global properties allow access to the timelines of other loaded movie clips, both relative ( expand (
super) scope. And, you can use global properties to adjust runtime settings like
_parent) and absolute (_root). They also let you restrict (this) or
screen reader accessibility, playback quality, and sound buffer size.
Global Properties summary
Modifiers Property Description
$version Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.version property. Contains the version number of Flash Lite.
_cap4WayKeyAS Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.has4WayKeyAS property. Indicates whether Flash Lite executes ActionScript expressions attached to key event handlers associated with the Right, Left, Up, and Down Arrow keys.
92 ActionScript language elements
Modifiers Property Description
_capCompoundSound Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasCompoundSound property. Indicates whether Flash Lite can process compound sound data.
_capEmail Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasEmail property. Indicates whether the Flash Lite client can send e­mail messages by using the GetURL() ActionScript command.
_capLoadData Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasDataLoading property. Indicates whether the host application can dynamically load additional data through calls to the loadMovie(), loadMovieNum(), loadVariables(), and loadVariablesNum() functions.
_capMFi Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasMFi property. Indicates whether the device can play sound data in the Melody Format for i-mode (MFi) audio format.
_capMIDI Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasMIDI property. Indicates whether the device can play sound data in the Musical Instrument Digital Interface (MIDI) audio format.
_capMMS Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasMMS property. Indicates whether Flash Lite can send Multimedia Messaging Service (MMS) messages by using the GetURL() ActionScript command. If so, this variable is defined and has a value of 1; if not, this variable is undefined.
Global Properties 93
Modifiers Property Description
_capSMAF Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasSMAF property. Indicates whether the device can play multimedia files in the Synthetic music Mobile Application Format (SMAF). If so, this variable is defined and has a value of 1; if not, this variable is undefined.
_capSMS Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasSMS property. Indicates whether Flash Lite can send Short Message Service (SMS) messages by using the
GetURL() ActionScript command.
_capStreamSound Deprecated since Flash Lite Player 2.0. This
action was deprecated in favor of the System.capabilities.hasStreamingAudio property. Indicates whether the device can play streaming (synchronized) sound.
_focusrect Property (global); specifies whether a yellow
rectangle appears around the button or movie clip that has keyboard focus.
_forceframerate Tells the Flash Lite player to render at the
specified frame rate.
_global A reference to the global object that holds the core
ActionScript classes, such as String, Object, Math, and Array.
_highquality Deprecated since Flash Player 5. This property
was deprecated in favor of _quality. Specifies the level of anti-aliasing applied to the current SWF file.
_level A reference to the root Timeline of _levelN.
maxscroll Deprecated since Flash Player 5. This property
was deprecated in favor of TextField.maxscroll. Indicates the line number of the top line of visible text in a text field when the bottom line in the field is also visible.
94 ActionScript language elements
Modifiers Property Description
_parent Specifies or returns a reference to the movie clip or
object that contains the current movie clip or object.
_quality Sets or retrieves the rendering quality used for a
movie clip.
_root Specifies or returns a reference to the root movie
clip Timeline.
scroll Deprecated since Flash Player 5. This property
was deprecated in favor of TextField.scroll. Controls the display of information in a text field associated with a variable.
_soundbuftime Establishes the number of seconds of streaming
sound to buffer.
this References an object or movie clip instance.
$version property
$version
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.version property.
String variable; contains the version number of Flash Lite. It contains a major number, minor number, build number, and an internal build number, which is generally
0 in all released
versions. The major number reported for all Flash Lite 1.x products is 5. Flash Lite 1.0 has a minor number of 1; Flash Lite 1.1 has a minor number of 2.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
In the Flash Lite 1.1 player, the following code sets the value of myVersion to "5, 2, 12, 0":
myVersion = $version;
See also
version (capabilities.version property)
Global Properties 95
_cap4WayKeyAS property
_cap4WayKeyAS
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.has4WayKeyAS property.
Numeric variable; indicates whether Flash Lite executes ActionScript expressions attached to key event handlers associated with the Right, Left, Up, and Down Arrow keys. This variable is defined and has a value of 1 only when the host application uses four-way key navigation mode to move between Flash controls (buttons and input text fields). Otherwise, this variable is undefined.
When one of the four-way keys is pressed, if the value of the
_cap4WayKeyAS variable is 1,
Flash Lite first looks for a handler for that key. If it finds none, Flash control navigation occurs. However, if an event handler is found, no navigation action occurs for that key. For example, if a key press handler for the Down Arrow key is found, the user cannot navigate.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
The following example sets canUse4Way to 1 in Flash Lite 1.1, but leaves it undefined in Flash Lite 1.0 (however, not all Flash Lite 1.1 phones support four-way keys, so this code is still dependent on the phone):
canUse4Way = _cap4WayKeyAS; if (canUse4Way == 1) { msg = "Use your directional joypad to navigate this application"; } else { msg = "Please use the 2 key to scroll up, the 6 key to scroll right,
the 8 key to scroll down, and the 4 key to scroll left."; }
See also
capabilities (System.capabilities)
_capCompoundSound property
_capCompoundSound
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.hasCompoundSound property.
96 ActionScript language elements
Numeric variable; indicates whether Flash Lite can process compound sound data. If so, this variable is defined and has a value of 1; if not, this variable is undefined. For example, a single Flash file can contain the same sound represented in both MIDI and MFi formats. The player will then play back data in the appropriate format based on the format supported by the device. This variable defines whether the Flash Lite player supports this ability on the current handset.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
In the following example, useCompoundSound is set to 1 in Flash Lite 1.1, but is undefined in Flash Lite 1.0:
useCompoundSound = _capCompoundSound;
if (useCompoundSound == 1) { gotoAndPlay("withSound"); } else { gotoAndPlay("withoutSound");
See also
capabilities (System.capabilities)
_capEmail property
_capEmail
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.hasEmail property.
Numeric variable; indicates whether the Flash Lite client can send e-mailmessages by using the
GetURL() ActionScript command. If so, this variable is defined and has a value of 1; if
not, this variable is undefined.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
If the host application can send e-mail messages by using the GetURL() ActionScript command, the following example sets
canEmail = _capEmail;
if (canEmail == 1) { getURL("mailto:someone@somewhere.com?subject=foo&body=bar"); }
canEmail() to 1:
Global Properties 97
See also
capabilities (System.capabilities)
_capLoadData property
_capLoadData
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.hasDataLoading property.
Numeric variable; indicates whether the host application can dynamically load additional data through calls to the
loadVariablesNum() functions. If so, this variable is defined and has a value of 1; if not, this
variable is undefined.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
If the host application can perform dynamic loading of movies and variables, the following example sets
canLoad = _capLoadData;
CanLoad to 1:
loadMovie(), loadMovieNum(), loadVariables(), and
if (canLoad == 1) { loadVariables("http://www.somewhere.com/myVars.php", GET); } else { trace ("client does not support loading dynamic data"); }
See also
capabilities (System.capabilities)
_capMFi property
_capMFi
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.hasMFi property.
Numeric variable; indicates whether the device can play sound data in the Melody Format for i-mode (MFi) audio format. If so, this variable is defined and has a value of 1; if not, this variable is undefined.
Availability: ActionScript 1.0; Flash Lite 1.1
98 ActionScript language elements
Example
If the device can play MFi sound data, the following example sets canMFi to 1:
canMFi = _capMFi;
if (canMFi == 1) { // send movieclip buttons to frame with buttons that trigger events
sounds tellTarget("buttons") { gotoAndPlay(2); } }
_capMIDI property
_capMIDI
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.hasMIDI property.
Numeric variable; indicates whether the device can play sound data in the Musical Instrument Digital Interface (MIDI) audio format. If so, this variable is defined and has a value of 1; if not, this variable is undefined.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
If the device can play MIDI sound data, the following example sets _capMIDI to 1:
canMIDI = _capMIDI;
if (canMIDI == 1) { // send movieclip buttons to frame with buttons that trigger events
sounds tellTarget("buttons") { gotoAndPlay(2); } }
See also
capabilities (System.capabilities)
_capMMS property
_capMMS
Global Properties 99
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.hasMMS property.
Numeric variable; indicates whether Flash Lite can send Multimedia Messaging Service (MMS) messages by using the
GetURL() ActionScript command. If so, this variable is defined
and has a value of 1; if not, this variable is undefined.
Availability: ActionScript 1.0; Flash Lite 1.1
Example
The following example sets canMMS to 1 in Flash Lite 1.1, but leaves it undefined in Flash Lite
1.0 (however, not all Flash Lite 1.1 phones can send MMS messages, so this code is still dependent on the phone):
on(release) { canMMS = _capMMS; if (canMMS == 1) { // send an MMS myMessage = "mms:4156095555?body=sample mms message"; } else { // send an SMS myMessage = "sms:4156095555?body=sample sms message"; } getURL(myMessage); }
See also
capabilities (System.capabilities)
_capSMAF property
_capSMAF
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the
System.capabilities.hasSMAF property.
Numeric variable; indicates whether the device can play multimedia files in the Synthetic music Mobile Application Format (SMAF). If so, this variable is defined and has a value of 1; if not, this variable is undefined.
Availability: ActionScript 1.0; Flash Lite 1.1
100 ActionScript language elements
Loading...