background image

Math

413

Methods inherited from class Object

abs (Math.abs method)

public static abs(x:

Number

) : Number

Computes and returns an absolute value for the number specified by the parameter 

x

.

Availability: 

 ActionScript 1.0; Flash Lite 2.0 - In Flash Player 4, the methods and properties 

of the Math class are emulated using approximations and might not be as accurate as the non-
emulated math functions that Flash Player 5 supports.

Parameters

x

:

Number

 - A number.

Returns

Number

 - A number.

Example

The following example shows how 

Math.abs()

 returns the absolute value of a number and 

does not affect the value of the 

x

 parameter (called 

num

 in this example): 

var num:Number = -12;
var numAbsolute:Number = Math.abs(num);
trace(num); // output: -12
trace(numAbsolute); // output: 12

static

sin

(x:

Number

) : 

Number

Computes and returns the sine of the 
specified angle in radians.

static

sqrt

(x:

Number

) : 

Number

Computes and returns the square root of the 
specified number.

static

tan

(x:

Number

) : 

Number

Computes and returns the tangent of the 
specified angle.

addProperty (Object.addProperty method)

hasOwnProperty 

(Object.hasOwnProperty method)

isPropertyEnumerable 

(Object.isPropertyEnumerable method)

isPrototypeOf (Object.isPrototypeOf 

method)

registerClass (Object.registerClass method)

toString 

(Object.toString method)

unwatch (Object.unwatch method)

valueOf 

(Object.valueOf method)

watch (Object.watch method)

Modifiers

Signature

Description

Summary of Contents for FLASHLITE2 ACTIONSCRIPT-LANGUAGE

Page 1: ...Flash Lite 2 x ActionScript Language Reference...

Page 2: ...pendent 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 suppli...

Page 3: ...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 fsc...

Page 4: ...nction 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 fu...

Page 5: ...twise 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 bitwis...

Page 6: ...ogical 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 i...

Page 7: ...atteryLevel fscommand2 Command 228 GetDevice fscommand2 Command 228 GetDeviceID fscommand2 Command 229 GetFreePlayerMemory fscommand2 Command 229 GetMaxBatteryLevel fscommand2 Command 230 GetMaxSignal...

Page 8: ...rray 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...

Page 9: ...sible 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...

Page 10: ...313 imageMIMETypes capabilities imageMIMETypes property 314 isDebugger capabilities isDebugger property 314 language capabilities language property 315 localFileReadDisable capabilities localFileRead...

Page 11: ...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 setMillisecon...

Page 12: ...od 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...

Page 13: ...e addXMLPath method 408 checkXMLStatus Locale checkXMLStatus method 408 initialize Locale initialize method 409 loadLanguageXML Locale loadLanguageXML method 409 loadString Locale loadString method 40...

Page 14: ...frame property 457 curveTo MovieClip curveTo method 457 _droptarget MovieClip _droptarget property 460 duplicateMovieClip MovieClip duplicateMovieClip method 461 enabled MovieClip enabled property 462...

Page 15: ...andler 501 onMouseUp MovieClip onMouseUp handler 502 onPress MovieClip onPress handler 502 onRelease MovieClip onRelease handler 502 onReleaseOutside MovieClip onReleaseOutside handler 503 onRollOut M...

Page 16: ...Init MovieClipLoader onLoadInit event listener 538 onLoadProgress MovieClipLoader onLoadProgress event listener 539 onLoadStart MovieClipLoader onLoadStart event listener 541 removeListener MovieClipL...

Page 17: ...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...

Page 18: ...bstring 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...

Page 19: ...674 _rotation TextField _rotation property 675 scroll TextField scroll property 676 selectable TextField selectable property 677 setNewTextFormat TextField setNewTextFormat method 678 setTextFormat T...

Page 20: ...roperty 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 metho...

Page 21: ...52 nodeValue XMLNode nodeValue property 753 parentNode XMLNode parentNode property 754 previousSibling XMLNode previousSibling property 755 removeNode XMLNode removeNode method 756 toString XMLNode to...

Page 22: ...22 Contents...

Page 23: ...your ActionScript file to direct the compiler to preprocess certain instructions Compiler Directives summary endinitclip directive endinitclip Compiler directive indicates the end of a block of initia...

Page 24: ...hich 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...

Page 25: ...tories 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 abs...

Page 26: ...al values are allowed and not by using a variable If you include multiple initclip blocks in a single movie clip symbol then the compiler uses the last order value specified in that movie clip symbol...

Page 27: ...ion 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 i...

Page 28: ...Number POSITIVE_INFINITY Availability ActionScript 1 0 Flash Lite 2 0 See also POSITIVE_INFINITY Number POSITIVE_INFINITY property Infinity constant Specifies the IEEE 754 value representing negative...

Page 29: ...myAge Number 30 trace myName myAge trace trace myName newline myAge output Lisa30 Lisa 30 See also trace function null constant A special value that can be assigned to variables or returned by a func...

Page 30: ...the if statement could also be written if shouldExecute trace your statements here The following example shows how automatic data typing converts true to the number 1 var myNum Number myNum 1 true tr...

Page 31: ...In the first section of code the equality operator compares the value of x to the value undefined and the appropriate result is sent to the Output panel In the first section of code the equality oper...

Page 32: ...true or false call frame Object Deprecated since Flash Player 5 This action was deprecated in favor of the function statement Executes the script in the called frame without moving the playhead to th...

Page 33: ...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 de...

Page 34: ...tring length property to perform the same operations Returns the length of the specified string or variable loadMovie url String target Object method String Loads a SWF or JPEG file into Flash Player...

Page 35: ...te 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 str...

Page 36: ...as 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 s...

Page 37: ...ment 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...

Page 38: ...pt 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 el...

Page 39: ...ing is first converted to a number the value is true if the number is not zero false otherwise In files published for Flash Player 7 or later the result is true if the string has a length greater than...

Page 40: ...t 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 objec...

Page 41: ...ne 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...

Page 42: ...Int_btn and use the following ActionScript to clear setInterval clearInt_btn onRelease function clearInterval intervalID trace cleared interval See also setInterval function duplicateMovieClip functio...

Page 43: ...The duplicated clip is called newImg_mc and this new clip is moved on the Stage so it does not overlap the original clip and the same image is loaded into the second clip this createEmptyMovieClip img...

Page 44: ...com loggedin true username Gus getURL http www myothersite com returnurl escape redirectUrl See also unescape function eval function eval expression Object Objecteval expression String Object Accesse...

Page 45: ...ot 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 instanc...

Page 46: ...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 ya...

Page 47: ...Commands section under ActionScript language elements for the values you can specify for the fscommand function s commands and parameters These values control SWF files that are playing in the Flash...

Page 48: ...ed 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...

Page 49: ...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 abso...

Page 50: ...istener 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...

Page 51: ...n 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 v...

Page 52: ...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 i...

Page 53: ...frame statement s 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 f...

Page 54: ...Flash Lite 1 0 Parameters value Number A number to be rounded to an integer Returns Number The truncated integer value See also round Math round method floor Math floor method ceil Math ceil method is...

Page 55: ...ot 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 Boolea...

Page 56: ...N 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 re...

Page 57: ...e 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...

Page 58: ...this createEmptyMovieClip logo_mc 999 loadMovie sub swf logo_mc 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...

Page 59: ...le 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...

Page 60: ...xt 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 p...

Page 61: ...the variables to the end of the URL and is used for small numbers of variables The POST method sends the variables in a separate HTTP header and is used for long strings of variables Example The foll...

Page 62: ...onent 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...

Page 63: ...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 done loadVariablesNum params txt 2 function checkParamsLoaded if _level2...

Page 64: ...gth 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 S...

Page 65: ...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 ind...

Page 66: ...The listener is initialized to wait for the arrow key to be pressed and the init variable is used to prevent the listener from being redefined if the playhead returns to Frame 1 stop if init undefined...

Page 67: ...Depth 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 getNextHighest...

Page 68: ...yer 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...

Page 69: ...n 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 c...

Page 70: ...s 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 out...

Page 71: ...d Any of the following values can be specified for the movieEvent parameter load The action is initiated as soon as the movie clip is instantiated and appears in the Timeline unload The action is init...

Page 72: ...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 but...

Page 73: ...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 rea...

Page 74: ...nnot be converted to a number the function returns NaN Strings beginning with 0x are interpreted as hexadecimal numbers Integers beginning with 0 or specifying a radix of 8 are interpreted as octal nu...

Page 75: ...urn 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 A...

Page 76: ...vious 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 pre...

Page 77: ...ateMovieClip 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 newClip_mc Images a...

Page 78: ...ters 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 int...

Page 79: ...ion callback1 trace interval called function callback2 arg trace arg setInterval callback1 1000 setInterval callback2 1000 interval called Usage 3 This example uses a method of an object You must use...

Page 80: ...mer 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 c...

Page 81: ...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...

Page 82: ...alue specifying whether the draggable movie clip is locked to the center of the mouse position true or locked to the point where the user first clicked the movie clip false left top right bottom Numbe...

Page 83: ...ver 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 ins...

Page 84: ...ps the current drag operation Note This method is supported in Flash Lite only if System capabilities hasMouse is true or System capabilities hasStylus is true Availability ActionScript 1 0 Flash Lite...

Page 85: ...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 Pl...

Page 86: ...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 Stri...

Page 87: ...useful for navigation controls Assign tellTarget to buttons that stop or start movie clips elsewhere on the Stage You can also make movie clips go to a particular frame in that clip For example you mi...

Page 88: ...tation 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...

Page 89: ...o record programming notes or to display messages in the Output panel while testing a SWF file Use the expression parameter to check whether a condition exists or to display values in the Output panel...

Page 90: ...valuates 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...

Page 91: ...ded 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 i...

Page 92: ...ess to the timelines of other loaded movie clips both relative _parent and absolute _root They also let you restrict this or expand super scope And you can use global properties to adjust runtime sett...

Page 93: ...he 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 Ind...

Page 94: ...abilities hasStreamingAudio property Indicates whether the device can play streaming synchronized sound _focusrect Property global specifies whether a yellow rectangle appears around the button or mov...

Page 95: ...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 _parent Specifies or returns a reference to th...

Page 96: ...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 can...

Page 97: ...t is undefined in Flash Lite 1 0 useCompoundSound _capCompoundSound if useCompoundSound 1 gotoAndPlay withSound else gotoAndPlay withoutSound See also capabilities System capabilities _capEmail proper...

Page 98: ...nScript 1 0 Flash Lite 1 1 Example If the host application can perform dynamic loading of movies and variables the following example sets CanLoad to 1 canLoad _capLoadData if canLoad 1 loadVariables h...

Page 99: ...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...

Page 100: ...owever 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 messa...

Page 101: ...2 0 This action was deprecated in favor of the System capabilities hasSMS property Numeric variable indicates whether Flash Lite can send Short Message Service SMS messages by using the GetURL ActionS...

Page 102: ...streaming sound if canStreamSound is enabled on press canStreamSound _capStreamSound if canStreamSound play a streaming sound in a movieclip with this button tellTarget music gotoAndPlay 2 See also ca...

Page 103: ...t events but will not receive the press and release events Also for Flash Lite 2 0 you can change the color of the focus rectangle by using the fscommand2 SetFocusRectColor command This behavior is di...

Page 104: ...le of the same name that obscures the global variable you are attempting to set ReturnsA reference to the global object that holds the core ActionScript classes such as String Object Math and Array Av...

Page 105: ..._levelN You must use loadMovieNum to load SWF files into the Flash Player before you use the _level property to target them You can also use _levelN to target a loaded SWF file at the level assigned b...

Page 106: ...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...

Page 107: ...y String Sets or retrieves the rendering quality used for a movie clip Device fonts are always aliased and therefore are unaffected by the _quality property The _quality property can be set to the fol...

Page 108: ...ne of the loading movie clip not the Timeline that contains _root If you want to ensure that _root refers to the Timeline of the loaded movie clip even if it is loaded into another movie clip use Movi...

Page 109: ...long passage or creating scrolling text fields This property can be retrieved and modified Availability ActionScript 1 0 Flash Lite 1 1 Example The following code is attached to an Up button that scro...

Page 110: ...nce var bg_sound Sound new Sound load the MP3 sound file and set streaming to true bg_sound loadSound yourSound mp3 true function is triggered when the song finishes loading bg_sound onLoad function d...

Page 111: ...obj addStr call abj null output defined in FLA or AS trace obj addStr call this null output undefined trace obj addStr call obj null output Defined in applyThis as Similarly to call a function defined...

Page 112: ...ement inside a MovieClip onPress handler the keyword this references the current movie clip this square_mc onPress function startDrag this this square_mc onRelease function stopDrag See also on handle...

Page 113: ...d expression2 to 32 bit unsigned integers and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1 bitwise OR assignment Assigns expression1 the val...

Page 114: ...Instructs Flash to evaluate expression1 and if the value of expression1 is true it returns the value of expression2 otherwise it returns the value of expression3 decrement A pre decrement and post dec...

Page 115: ...nt A pre increment and post increment unary operator that adds 1 to expression inequality Tests for the exact opposite of the equality operator inequality Deprecated since Flash Player 5 This operator...

Page 116: ...cal NOT operation in Flash Player 4 logical OR Evaluates expression1 the expression on the left side of the operator and returns true if the expression evaluates to true or logical OR Deprecated since...

Page 117: ...strict equality operator performs in the same way as the equality operator except that data types are not converted strict inequality Tests for the exact opposite of the strict equality operator strin...

Page 118: ...ersion of a Flash 4 file that contains a numeric quality comparison Flash 4 file x y Converted Flash 5 or later file Number x Number y Operands expression1 A number or string expression2 A number or s...

Page 119: ...s use the Number function to convert the string to a number as in the following var oldBalance Number 1345 23 var currentBalance Number Number deposit_txt text oldBalance trace currentBalance The foll...

Page 120: ...re called elements which are each identified by a number called an index When you create an array you surround the elements with the array access operator or brackets An array can contain elements of...

Page 121: ...ically set and retrieve values for movie clip names or any property of an object The following line of code sends the number 6 to the Output panel name mc i left_corner Availability ActionScript 1 0 F...

Page 122: ...d from the my_mc movie clip In this example the variable i must live on the same Timeline as the button If the variable i is equal to 5 for example the value of the variable piece5 in the my_mc movie...

Page 123: ...the operator is used to evaluate equality Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity Flash 4 file x y...

Page 124: ...ration on each bit of the integer parameters Floating point numbers are converted to integers by discarding any digits after the decimal point The result is a new 32 bit integer Positive integers are...

Page 125: ...bits at the same position are 1 In the following ActionScript code you add 13 binary 1101 and 11 binary 1011 and return 1 only in the position where both numbers have a 1 var insert Number 13 var upd...

Page 126: ...y Number 9 trace x y output 9 See also bitwise AND operator bitwise XOR operator bitwise XOR assignment operator bitwise OR operator bitwise OR assignment operator bitwise NOT operator bitwise left s...

Page 127: ...A number or expression to be shifted left expression2 Number A number or expression that converts to an integer from 0 to 31 Returns Number The result of the bitwise operation Example In the followin...

Page 128: ...ator to shift all bits one space to the left var x Number 4 shift all bits one slot to the left x 1 trace x output 8 4 decimal 0100 binary 8 decimal 1000 binary See also bitwise left shift operator bi...

Page 129: ...st significant digits discarded The return value is interpreted as a two s complement number with sign so the return value is an integer in the range 2147483648 to 2147483647 Availability ActionScript...

Page 130: ...ficant digits discarded when they are converted so the value is still 32 bit Negative numbers are converted to an unsigned hex value via the two s complement notation with the minimum being 2147483648...

Page 131: ...ability ActionScript 1 0 Flash Lite 2 0 Operands expression1 Number A number or variable expression2 Number A number or variable Returns Number The result of the bitwise operation Example The followin...

Page 132: ...the value is still 32 bit Negative numbers are converted to an unsigned hex value via the two s complement notation with the minimum being 2147483648 or 0x800000000 numbers less than the minimum are c...

Page 133: ...signment operator bitwise right shift and assignment operator expression1 expression2 This operator performs a bitwise right shift operation and stores the contents as a result in expression1 The foll...

Page 134: ...converted to an unsigned hex value with a maximum value of 4294967295 or 0xFFFFFFFF values larger than the maximum have their most significant digits discarded when they are converted so the value is...

Page 135: ...erator bitwise unsigned right shift and assignment operator expression1 expression2 Performs an unsigned bitwise right shift operation and stores the contents as a result in expression1 The following...

Page 136: ...tation with the minimum being 2147483648 or 0x800000000 numbers less than the minimum are converted to two s complement with greater precision and also have the most significant digits discarded The r...

Page 137: ...xpression2 Number Integers and variables Returns Number The result of the bitwise operation Example The following example shows a bitwise XOR assignment operation 15 decimal 1111 binary var x Number 1...

Page 138: ...aced between them Availability ActionScript 1 0 Flash Lite 1 0 Operands comment Any characters Example The following script uses comment delimiters at the beginning of the script records the X and Y p...

Page 139: ...turns only the value of the first expression without the parentheses operator var v Number 0 v 4 5 6 trace v output 4 The following example uses the comma operator with the parentheses operator and il...

Page 140: ...dition operator when creating content for Flash Player 5 or later Note Flash Lite 2 0 also deprecates the add operator in favor of the addition operator Concatenates two or more strings The add operat...

Page 141: ...Object Values of any type expression3 Object Values of any type Returns Object The value of expression2 or expression3 Example The following statement assigns the value of variable x to variable z bec...

Page 142: ...ession Number A number or a variable that evaluates to a number Returns Number The result of the decremented value Example The pre decrement form of the operator decrements x to 2 x 1 2 and returns th...

Page 143: ...5 and 150 See also modulo operator division assignment operator expression1 expression2 Assigns expression1 the value of expression1 expression2 For example the following two statements are equivalent...

Page 144: ...associated with an object All the valid methods and properties for the built in classes are listed in the method and property summary tables for that class This parameter is always to the right of the...

Page 145: ...qual depends on the data type of the parameter Numbers and Boolean values are compared by value and are considered equal if they have the same value String expressions are equal if they have the same...

Page 146: ...erence requires that they both refer to the same array The second example creates the thirdArray variable which points to the same array as the variable firstArray The equality operator will return tr...

Page 147: ...less than or equal to expression2 the operator returns false String expressions are evaluated using alphabetical order all capital letters come before lowercase letters Availability ActionScript 1 0...

Page 148: ...Compares the string representation of expression1 with the string representation of expression2 and returns true if expression1 is greater than expression2 false otherwise Availability ActionScript 1...

Page 149: ...nteger or floating point number Returns Boolean The Boolean result of the comparison Example In the following example the greater than or equal to operator is used to determine whether the current hou...

Page 150: ...the operator expression adds 1 to expression and returns the initial value of expression the value prior to the addition The pre increment form of the operator increments x to 2 x 1 2 and returns the...

Page 151: ...2 3 4 5 6 7 8 9 10 This example also uses as a pre increment operator var a Array for var i 1 i 10 i a push i trace a toString traces 1 2 3 4 5 6 7 8 9 10 This script shows the following result in th...

Page 152: ...pressions have the same value For example the expression 2 3 is equal to the expression 1 4 when compared by value Comparison by reference means that two expressions are equal only if they both refer...

Page 153: ...t foo foo true foo foo false The following example illustrates comparison by reference with two arrays var a Array 1 2 3 var b Array 1 2 3 trace a 1 2 3 trace b 1 2 3 trace a b true a b trace a 1 2 3...

Page 154: ...ct array or function expression2 Object A number string Boolean value variable object array or function Returns Boolean The Boolean result of the comparison See also inequality operator instanceof ope...

Page 155: ...phabetical order all capital letters come before lowercase letters Availability ActionScript 1 0 Flash Lite 1 0 In Flash 4 is a numeric operator In Flash 5 and later the less than operator is a compar...

Page 156: ...expression2 and returns true if expression1 is less than expression2 false otherwise Availability ActionScript 1 0 Flash Lite 1 0 Operands expression1 Object Numbers strings or variables expression2 O...

Page 157: ...umber or string expression2 Object A number or string Returns Boolean The Boolean result of the comparison Example The following examples show true and false results for both numeric and string compar...

Page 158: ...omment and ignored by the ActionScript interpreter Availability ActionScript 1 0 Flash Lite 1 0 Operands comment Any characters Example The following script uses comment delimiters to identify the fir...

Page 159: ...that converts to a Boolean value expression2 Number A Boolean value or an expression that converts to a Boolean value Returns Boolean A Boolean result of the logical operation Example The following e...

Page 160: ...ssions that evaluate to true or false Returns Boolean A Boolean result of the logical operation See also logical AND operator logical NOT operator expression Inverts the Boolean value of a variable or...

Page 161: ...See also inequality operator strict inequality operator logical AND operator logical OR operator equality operator strict equality operator not logical NOT operator not expression Deprecated since Fl...

Page 162: ...with any number of operands if any operand evaluates to true the result is true Availability ActionScript 1 0 Flash Lite 1 0 Operands expression1 Number A Boolean value or an expression that converts...

Page 163: ...e fx1 called IF statement entered See also logical NOT operator inequality operator strict inequality operator logical AND operator equality operator strict equality operator or logical OR operator co...

Page 164: ...ns of Flash Player Operands expression1 Number A number or expression that evaluates to a number expression2 Number A number or expression that evaluates to a number Returns Number The result of the a...

Page 165: ...variable x var x Number 14 var y Number 5 trace x y output 4 See also modulo operator multiplication operator expression1 expression2 Multiplies two numerical expressions If both expressions are inte...

Page 166: ...ession1 Number A number or expression that evaluates to a number expression2 Number A number or expression that evaluates to a number Returns Number The value of expression1 expression2 If an expressi...

Page 167: ...Number or Object to be constructed Example The following example creates the Book function and then uses the new operator to create the objects book1 and book2 function Book name price this name name...

Page 168: ...newly created object is generically named the Object object This operator is also used to mark blocks of contiguous code associated with flow control statements for while if else switch and functions...

Page 169: ...the previous example and produces the same result using constructor functions var person Object new Object person name Gina Vechio person children new Array person children 0 Ruby person children 1 C...

Page 170: ...ion to be performed on the contents of the parentheses parameter1 parameterN Object A series of parameters to execute before the results are passed as parameters to the function outside the parenthese...

Page 171: ...if they have the same value String expressions are equal if they have the same number of characters and the characters are identical Variables representing objects arrays and functions are compared b...

Page 172: ...ace string1 bool2 true trace string1 bool2 false The following examples show how strict equality treats variables that are references differently than it treats variables that contain literal values T...

Page 173: ...A variable is compared by value or by reference depending on its type Availability ActionScript 1 0 Flash Lite 2 0 Operands expression1 Object A number string Boolean value variable object array or fu...

Page 174: ...name of a variable The value of province is a variable not a literal to determine the value of province the value of yourGuess must be located var yourGuess String Prince Edward Island submit_btn onR...

Page 175: ...3 The following statement subtracts the floating point number 1 5 from the floating point number 3 25 trace 3 25 1 5 output 1 75 The result 1 75 is a floating point number subtraction assignment opera...

Page 176: ...ator specifies the function s return type when used with a function parameter in a function definition this operator specifies the variable type expected for that parameter Types are a compile time on...

Page 177: ...med val of the Number type and returns the square root of val also a Number type function squareRoot val Number Number return Math sqrt val trace squareRoot 121 See also var statement function stateme...

Page 178: ...specify an action For example the return statement returns a result as a value of the function in which it executes The if statement evaluates a condition to determine the next action that should be t...

Page 179: ...f the condition in the initial if statement returns false extends Defines a class that is a subclass of another class the latter is the superclass for Evaluates the init initialize expression once and...

Page 180: ...caller return Specifies the value returned by a function set Permits implicit setting of properties associated with objects based on classes you have defined in external class files set variable Assi...

Page 181: ...expression parameter of the switch statement using strict equality then Flash Player will execute statements in the statement s parameter until it encounters a break statement or the end of the switch...

Page 182: ...ce Some summer month break case 8 trace September break default trace some other month See also break statement class statement dynamic class className extends superClass implements interfaceName inte...

Page 183: ...re you begin creating classes Otherwise if you decide to move class files after you create them you have to modify the class declaration statements to reflect their new location You cannot nest class...

Page 184: ...operty of a class function getLeafType String return leafType function getBloomSeason String return bloomSeason In an external script file or in the Actions panel use the new operator to create a Plan...

Page 185: ...the next iteration of the loop as if control had passed through to the end of the loop normally It has no effect outside a loop Availability ActionScript 1 0 Flash Lite 1 0 Example In the following wh...

Page 186: ...or i in _root if i version continue trace i default statement default statements Defines the default case for a switch statement The statements execute if the expression parameter of the switch statem...

Page 187: ...eak default trace Weekend See also switch statement delete statement delete reference Destroys the object reference specified by the reference parameter and returns true if the reference is successful...

Page 188: ...ct uses it and deletes it after it is no longer needed var account Object new Object account name Jon account balance 10000 trace account name output Jon delete account trace account name output undef...

Page 189: ...dition Subsequently the statements are executed only if the condition evaluates to true A do while loop ensures that the code inside the loop executes at least once Although this can also be done with...

Page 190: ...add and access dynamic properties at runtime Type checking on dynamic classes is less strict than type checking on nondynamic classes because members accessed inside the class definition and on class...

Page 191: ...Person2 new Person2 Craiggers 32 for i in craig trace craig i craig i output craig age 32 craig name Craiggers If you add an undeclared function dance an error is generated as shown in the following e...

Page 192: ...Object accessAllowed false In the following example curly braces are not necessary because only one statement follows the else statement if age_txt text 18 trace welcome user else trace sorry junior S...

Page 193: ...ord is supported only when used in external script files not in scripts written in the Actions panel Defines a class that is a subclass of another class the latter is the superclass The subclass inher...

Page 194: ...ends the Vehicle class modifying it in three ways First the Car class adds a variable fullSizeSpare to track whether the car object has a full size spare tire Second it adds a new method specific to c...

Page 195: ...example shows a third AS file called Truck as again in the same directory The Truck class uses the super keyword in the constructor and again in the overridden reverse function class Truck extends Veh...

Page 196: ...nScript 1 0 Flash Lite 1 0 Parameters init An expression to evaluate before beginning the looping sequence usually an assignment expression A var statement is also permitted for this parameter Example...

Page 197: ...both contain the property prop the for in statement called on child enumerates prop from child but ignores the one in parent The curly braces used to enclose the block of statements to be executed by...

Page 198: ...veral children _RedRadioButton_ _GreenRadioButton_ and _BlueRadioButton_ for var name in RadioButtonGroup RadioButtonGroup name gotoAndStop 2 function statement Usage 1 Declares a named function funct...

Page 199: ...ctionality you can use the arguments object in your function definition Some common uses of the arguments object are creating a function that accepts a variable number of parameters and creating a rec...

Page 200: ...defined in external class files Using implicit get methods lets you access properties of objects without accessing the property directly Implicit get set methods are syntactic shorthand for the Object...

Page 201: ...urly braces If the condition is false Flash skips the statements inside the curly braces and runs the statements following the curly braces Use the if statement along with the else and else if stateme...

Page 202: ...me Number getTimer this submit_btn onRelease function var difference Number getTimer startTime 1000 if difference 10 this _parent message_txt text Not very speedy you took difference seconds else this...

Page 203: ...util users You must issue the import statement before you try to access the imported class without fully specifying its name If you import a class but don t use it in your script the class isn t expor...

Page 204: ...hod declared in the interface Only public members are allowed in an interface definition instance and class members are not permitted The get and set statements are not allowed in interface definition...

Page 205: ...function o Void trace o external script or Actions panel script file mvar new D trace mvar k 15 trace mvar n 7 49 trace mvar o o interface Ic extends Ia function p Void class E implements Ib Ic funct...

Page 206: ...eeking to enable compile time type checking with previously defined classes especially if the classes are defined using ActionScript 1 0 This keyword is supported only when used in external script fil...

Page 207: ...keyword you must specify ActionScript 2 0 and Flash Player 6 or later in the Flash tab of your FLA file s Publish Settings dialog box This keyword is supported only when used in external script files...

Page 208: ...aram_password In the same directory as Login as create a new FLA or AS document Enter the following ActionScript in Frame 1 of the Timeline import Login var gus Login new Login Gus Smith trace gus use...

Page 209: ...or AS file in the same directory and enter the following ActionScript in Frame 1 of the Timeline import User var jimmy User new User jimmy age 27 jimmy name jimmy If you change one of the public vari...

Page 210: ...atement function set property varName your statements here Note To use this keyword you must specify ActionScript 2 0 and Flash Player 6 or later in the Flash tab of your FLA file s Publish Settings d...

Page 211: ...at is in the same directory as Login as enter the following ActionScript in Frame 1 of the Timeline var gus Login new Login Gus Smith trace gus username output Gus gus username Rupert trace gus userna...

Page 212: ...s assigned to it For example if you create a string variable named myVariable and assign it the value Tuesday and then forget to use quotation marks you will inadvertently create a new variable named...

Page 213: ...an instance of the class you can also access a static member using the instance but only through a non static function that accesses the static member You can use this keyword in class definitions on...

Page 214: ...dd additional behavior to superclass methods but also invoke the superclass methods to perform their original behavior The second syntax style may be used within the body of a constructor function to...

Page 215: ...rs expression Any expression Example In the following example if the String fromCharCode Key getAscii parameter evaluates to A the trace statement that follows case A executes if the parameter evaluat...

Page 216: ...that is passed to it is a properly formatted e mail address If the string does not contain an symbol the function throws an error function checkEmail email String if email indexOf 1 throw new Error In...

Page 217: ...statement control passes to the catch block if one exists and then to the finally code block if one exists The finally block always executes regardless of whether an error was thrown If code within th...

Page 218: ...0 Flash Lite 2 0 Parameters error Object The expression thrown from a throw statement typically an instance of the Error class or one of its subclasses Example The following example shows how to creat...

Page 219: ...ccount information finally if account null delete account The following example demonstrates a try catch statement The code within the try block is executed If an exception is thrown by any code withi...

Page 220: ...Error class Each is defined in its own AS class file In RecordSetException as class RecordSetException extends Error var message Record set exception occurred In MalformedRecord as class MalformedRec...

Page 221: ...all More specifically a variable defined using var is local to the code block containing it Code blocks are demarcated by curly braces If you declare variables outside a function the variables are ava...

Page 222: ...eries of statements is skipped and the loop ends The while statement performs the following series of steps Each repetition of steps 1 through 4 is called an iteration of the loop The condition is ret...

Page 223: ...with the statement s parameter This prevents you from having to repeatedly write the object s name or the path to the object The object parameter becomes the context in which the properties variables...

Page 224: ...tatement without declaring it the with statement will look for the value according to the scope chain If the variable doesn t already exist the new value will be set on the Timeline from which the wit...

Page 225: ...3 The following result is displayed in the Output panel area 28 2743338823081 x 3 y 3 fscommand2 Commands The following commands are available for the fscommand2 function For a description of the fsc...

Page 226: ...ered and whether the phone is currently roaming GetPlatform Sets a parameter that identifies the current platform which broadly describes the class of device GetPowerSource Returns a value that indica...

Page 227: ...the duration of the backlight for 45 seconds status FSCommand2 ExtendBacklightDuration 45 FullScreen fscommand2 Command FullScreen Sets the size of the display area to be used for rendering The size...

Page 228: ...el fscommand2 GetBatteryLevel GetDevice fscommand2 Command GetDevice Sets a parameter that identifies the device on which Flash Lite is running This identifier is typically the model name Availability...

Page 229: ...mple the serial number Availability ActionScript 1 0 Flash Lite 1 1 Example The following example assigns the unique identifier to the deviceID variable status fscommand2 GetDeviceID deviceID GetFreeP...

Page 230: ...the maximum battery level maxBatt fscommand2 GetMaxBatteryLevel GetMaxSignalLevel fscommand2 Command GetMaxSignalLevel Returns the maximum signal strength level as a numeric value Availability Action...

Page 231: ...fault network connection For mobile devices this connection is also known as an access point Availability ActionScript 1 0 Flash Lite 2 0 Example The following example returns the name of the active o...

Page 232: ...ommand2 GetNetworkConnectStatus switch connectstatus case 1 _root myText connectstatus not supported n break case 0 _root myText connectstatus shows active connection n break case 1 _root myText conne...

Page 233: ...e current network to the myNetName parameter and a status value to the netNameStatus variable netNameStatus fscommand2 GetNetworkName myNetName Command Parameters Value Returned GetNetworkGeneration N...

Page 234: ...tworkRequestStatus None 1 The command is not supported 0 There is a pending request a network connection has been established the server s host name has been resolved and a connection to the server ha...

Page 235: ...t no HTTP request has been made n break GetNetworkStatus fscommand2 Command GetNetworkStatus Returns a value indicating the network status of the phone that is whether there is a network registered an...

Page 236: ...describes the class of device For devices with open operating systems this identifier is typically the name and version of the operating system Availability ActionScript 1 0 Flash Lite 1 1 Example Th...

Page 237: ...alLevel fscommand2 Command GetSignalLevel Returns the current signal strength as a numeric value Availability ActionScript 1 0 Flash Lite 1 1 Example The following example assigns the signal level val...

Page 238: ...GetVolumeLevel Returns the current volume level of the device as a numeric value Availability ActionScript 1 0 Flash Lite 1 1 Example The following example assigns the current volume level to the vol...

Page 239: ...running in stand alone mode status fscommand2 Quit ResetSoftKeys fscommand2 Command ResetSoftKeys Resets the soft keys to their original settings This command is supported only when Flash Lite is runn...

Page 240: ...ifies the mode in which the input text field should be opened Flash Lite supports input text functionality by asking the host application to start the generic device specific text input interface ofte...

Page 241: ...ted only when Flash Lite 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 InputTextType Mode Se...

Page 242: ...SOFT2 soft key Next status fscommand2 SetSoftKeys Previous Next You can define variables or use constant string values for each soft key status fscommand2 SetSoftKeys soft1 soft2 soft3 soft4 softn Not...

Page 243: ...ate 2500 1000 2 StopVibrate fscommand2 Command StopVibrate Stops the current vibration if any Availability ActionScript 1 0 Flash Lite 1 1 Example The following example calls StopVibrate and saves the...

Page 244: ...244 ActionScript language elements...

Page 245: ...in the Index arguments Object arguments public class arguments extends Object An arguments object is used to store and access a function s arguments While inside the function s body it can be accessed...

Page 246: ...Description callee Object A reference to the currently executing function caller Object A reference to the function that called the currently executing function or null if it wasn t called from anoth...

Page 247: ...is 0 the second element is 1 and so on To create an Array object you use the constructor new Array To access the elements of an array you use the array access operator You can store a wide variety of...

Page 248: ...that you can then use an object literal to populate your associative array but only at the time you declare it The following example creates an associative array using an object literal accesses item...

Page 249: ...nts in the array static NUMERIC Number Represents numeric sorting instead of string based sorting static RETURNINDEXEDARRAY Number Represents the option to return an indexed array as a result of calli...

Page 250: ...verses the array in place shift Object Removes the first element from an array and returns that element slice startIndex Number endIndex Number Array Returns a new array that consists of a range of el...

Page 251: ...more arbitrary values The values can be of type Boolean Number String Object or Array The first element in an array always has an index or position of 0 Note If only a single numeric parameter is pas...

Page 252: ...gos_array 1 Gina go_gos_array 2 Kathy go_gos_array 3 Charlotte go_gos_array 4 Jane The following code adds a sixth element to the go_gos_array array and changes the second element go_gos_array 5 Donna...

Page 253: ...y new Array a b c var numeric_array Array new Array 1 2 3 var alphaNumeric_array Array alpha_array concat numeric_array trace alphaNumeric_array Creates array a b c 1 2 3 The following code concatenat...

Page 254: ...ring A nested array is always separated by a comma not by the separator passed to the join method Availability ActionScript 1 0 Flash Lite 2 0 Parameters delimiter String optional A character or strin...

Page 255: ...is a number and index 1 is greater than the length property the length property is updated to index 1 Note If you assign a value to the length property that is shorter than the existing length the arr...

Page 256: ...the sort or sortOn method The value of this constant is 16 Availability ActionScript 1 0 Flash Lite 2 0 See also sort Array sort method sortOn Array sortOn method pop Array pop method public pop Objec...

Page 257: ...of myPets_array 4 to the Output panel var myPets_array Array new Array cat dog var pushed Number myPets_array push bird fish trace pushed Displays 4 See also pop Array pop method shift Array shift met...

Page 258: ...urns Object The first element in an array Example The following code creates the array myPets_array and then removes the first element from the array and assigns it to the variable shifted var myPets_...

Page 259: ...xample creates an array of five pets and uses slice to populate a new array that contains only four legged pets var myPets_array Array new Array cat dog fish canary parrot var myFourLeggedPets_array A...

Page 260: ...unction to do the sorting If you create a custom function you can use it by calling the sort method using the name of your custom function as the first parameter compareFunction Availability ActionScr...

Page 261: ...use of Array sort with and without a value passed for options var fruits_array Array new Array oranges apples strawberries pineapples cherries trace fruits_array Displays oranges apples strawberries p...

Page 262: ...objects have at least one property in common the values of which can be used to sort the array Such a property is called a field If you pass multiple fieldName parameters the first field represents t...

Page 263: ...eter Array CASEINSENSITIVE or 1 Array DESCENDING or 2 Array UNIQUESORT or 4 Array RETURNINDEXEDARRAY or 8 Array NUMERIC or 16 Code hinting is enabled if you use the string form of the flag for example...

Page 264: ...city name for i 0 i rec_array length i trace rec_array i name rec_array i city Results john kansas city bob omaha john omaha The following array of objects is used by subsequent examples that show how...

Page 265: ...cending numeric sort on the age field produces the following results my_array sortOn age Array DESCENDING Array NUMERIC my_array 0 age 35 my_array 1 age 29 my_array 2 age 4 my_array 3 age 3 When using...

Page 266: ...parameter This removes all elements from the array starting with the second element leaving only the element at index 0 in the original array var myPets_array Array new Array cat dog bird fish trace m...

Page 267: ...my_array Array new Array my_array 0 1 my_array 1 2 my_array 2 3 my_array 3 4 my_array 4 5 trace my_array toString Displays 1 2 3 4 5 This example outputs 1 2 3 4 5 as a result of the trace statement S...

Page 268: ...h trace pets_array Displays dog cat fish pets_array unshift ferrets gophers engineers trace pets_array Displays ferrets gophers engineers dog cat fish See also pop Array pop method push Array push met...

Page 269: ...constructor Object constructor property __proto__ Object __proto__ property prototype Object prototype property __resolve Object __resolve property Signature Description Boolean value Object Creates a...

Page 270: ...lue to a string for use in the trace statement var myBool Boolean true trace The value of the Boolean myBool is myBool toString myBool false trace The value of the Boolean myBool is myBool toString va...

Page 271: ...stance name in the Property inspector and use the methods and properties of the Button class to manipulate buttons with ActionScript Button instance names are displayed in the Movie Explorer and in th...

Page 272: ...t MovieClip A reference to the movie clip or object that contains the current movie clip or object _quality String Property global sets or retrieves the rendering quality used for a SWF file _rotation...

Page 273: ...ymouse Number read only Returns the y coordinate of the mouse position relative to the button _yscale Number The vertical scale of the button as applied from the registration point of the button expre...

Page 274: ...tside function Invoked when the mouse is released with the pointer outside the button after the mouse button is pressed with the pointer inside the button onRollOut function Invoked when the button lo...

Page 275: ...sable part of your navigation for example you may want to disable a button in the currently displayed page so that it can t be clicked and the page cannot be reloaded Availability ActionScript 1 0 Fla...

Page 276: ...must set _focusrect to true Note For the Flash Lite 2 0 player when the _focusrect property is disabled in other words Button focusRect is false the button receives all events This behavior is differ...

Page 277: ...yBtn3_btn onRelease function trace myClip_mc myBtn4_btn getDepth You might notice that two of these buttons have the same depth value one in the main SWF file and one in the loaded SWF file This is mi...

Page 278: ...h bitmap smoothing always on Specify 1 high quality to apply anti aliasing this smooths bitmaps if the SWF file does not contain animation and is the default value Specify 0 low quality to prevent ant...

Page 279: ...er outside of the button You must define a function that is executed when the event handler is invoked Note The onDragOut Event Handler is supported for Flash Lite 2 0 only if System capabilities hasM...

Page 280: ...called my_btn on the Stage and enter the following ActionScript on the Timeline my_btn onDragOut function trace onDragOut this _name my_btn onDragOver function trace onDragOver this _name When you te...

Page 281: ...Test Movie to test the SWF file Make sure you select Control Disable Keyboard Shortcuts in the test environment Then press the Tab key until the button has focus a yellow rectangle appears around the...

Page 282: ...Press Control Enter to test the SWF file Make sure you select Control Disable Keyboard Shortcuts in the test environment Then press the Tab key until the button has focus a yellow rectangle appears ar...

Page 283: ...rowser window and try using the Tab key to move through the elements in the window When the button instance loses focus text is sent to the output_txt text field onPress Button onPress handler onPress...

Page 284: ...nReleaseOutside Event Handler is supported for Flash Lite 2 0 only if System capabilities hasMouse is true or System capabilities hasStylus is true Availability ActionScript 1 0 Flash Lite 2 0 Example...

Page 285: ...ity ActionScript 1 0 Flash Lite 2 0 Example In the following example a function that sends a trace statement to the Output panel is defined for the onRollOver handler my_btn onRollOver function trace...

Page 286: ...arent property public _parent MovieClip A reference to the movie clip or object that contains the current movie clip or object The current object is the one containing the ActionScript code that refer...

Page 287: ...hed if the movie is static This is the default rendering quality setting used by Flash Note Although you can specify this property for a Button object it is actually a global property and you can spec...

Page 288: ...Other_btn Button this createEmptyMovieClip rotater_mc this getNextHighestDepth rotater_mc onEnterFrame function myOther_btn _rotation 2 See also _rotation MovieClip _rotation property _rotation TextFi...

Page 289: ...order because tabEnabled is set to false for that instance To set the tab ordering for the four buttons add the following ActionScript to Frame 1 of the Timeline three_btn tabEnabled false two_btn ta...

Page 290: ...Script is used to set the tabEnabled property for one of four buttons to false However all four buttons one_btn two_btn three_btn and four_btn are placed in a custom tab order using tabIndex Although...

Page 291: ...val this _target trace target_btn _name displays my_btn See also _target MovieClip _target property trackAsMenu Button trackAsMenu property public trackAsMenu Boolean A Boolean value that indicates wh...

Page 292: ...contain trackAsMenu and test the SWF file again to see the difference in button behavior See also trackAsMenu MovieClip trackAsMenu property _url Button _url property public _url String read only Retr...

Page 293: ...Frame 1 of the Timeline myBtn1_btn onRelease function this _visible false trace clicked this _name myBtn2_btn onRelease function this _alpha 0 trace clicked this _name Notice how you can still click m...

Page 294: ...e system that is rotated 90 degrees counterclockwise The button s coordinates refer to the registration point position Availability ActionScript 1 0 Flash Lite 2 0 Example The following example sets t...

Page 295: ...ymouse newline table_str b Button b t x my_btn _xmouse t y my_btn _ymouse newline table_str textformat mouse_txt htmlText table_str Mouse addListener mouseListener See also _ymouse Button _ymouse prop...

Page 296: ...refers to the upper left corner of the Stage as 0 0 If the button is inside another movie clip that has transformations the button is in the local coordinate system of the enclosing movie clip Thus fo...

Page 297: ...button called my_btn that is placed on the Stage Enter the following ActionScript in Frame 1 of the Timeline this createTextField mouse_txt 999 5 5 150 40 mouse_txt html true mouse_txt wordWrap true m...

Page 298: ...operty _xscale Button _xscale property capabilities System capabilities Object System capabilities public class capabilities extends Object The Capabilities class determines the abilities of the syste...

Page 299: ...Lite player does not support the development nor playback of screen broadcast applications to be run through Flash Media Server that does not support printing on the device that the Flash Lite player...

Page 300: ...value that is true if the player is running in an environment that supports communication between Flash Player and accessibility aids false otherwise static hasAudio Boolean read only Specifies if the...

Page 301: ...mobile device can send MMS messages with the GetURL ActionScript command static hasMouse Boolean read only Indicates whether the mobile device sends mouse related events to a Flash Lite player static...

Page 302: ...ly A Boolean value that is true if the player can play streaming audio false otherwise static hasStreamingVideo Boolean read only A Boolean value that is true if the player can play streaming video fa...

Page 303: ...rrent screen orientation static screenResolutionX Number read only An integer that indicates the maximum horizontal resolution of the screen static screenResolutionY Number read only An integer that i...

Page 304: ...olean value that specifies whether access to the user s camera and microphone has been administratively prohibited true or allowed false The server string is AVD Note For Flash Lite 2 0 the value retu...

Page 305: ...h Lite 2 0 Example The following example traces the value of this read only property trace System capabilities has4WayKeyAS hasAccessibility capabilities hasAccessibility property public static hasAcc...

Page 306: ...Flash Lite 2 0 Example The following example traces the value of this read only property trace System capabilities hasAudioEncoder hasCMIDI capabilities hasCMIDI property public static hasCMIDI Boolea...

Page 307: ...ns loadMovie loadMovieNum loadVariables loadVariablesNum XML parseXML Sound loadSound MovieClip loadVariables MovieClip loadMovie MovieClipLoader loadClip LoadVars load LoadVars sendAndLoad Otherwise...

Page 308: ...this read only property trace System capabilities hasEmbeddedVideo hasMappableSoftKeys capabilities hasMappableSoftKeys property public static hasMappableSoftKeys Boolean Returns true if the mobile d...

Page 309: ...MIDI hasMMS capabilities hasMMS property public static hasMMS Boolean read only Returns true if the mobile device can send MMS messages with the GetURL ActionScript command Otherwise this property ret...

Page 310: ...hasPrinting property public static hasPrinting Boolean read only A Boolean value that is true if the player is running on a mobile device that supports printing false otherwise The server string is P...

Page 311: ...ead only property trace System capabilities hasScreenBroadcast hasScreenPlayback capabilities hasScreenPlayback property public static hasScreenPlayback Boolean read only A Boolean value that is true...

Page 312: ...value of this read only property trace System capabilities hasSMAF hasSMS capabilities hasSMS property public static hasSMS Number read only Indicates if the mobile device can send SMS messages with t...

Page 313: ...stem capabilities hasStreamingVideo hasStylus capabilities hasStylus property public static hasStylus Boolean read only Indicates if the mobile device supports stylus related events This property retu...

Page 314: ...urns an array that contains all MIME types that the loadMovie function and the codecs for a mobile device support for processing images Availability ActionScript 1 0 Flash Lite 2 0 Example The followi...

Page 315: ...n Flash Player 6 all English systems return the language code and the two letter country code subtag en US In Flash Player 7 English systems return only the language code en Second on Microsoft Window...

Page 316: ...t Flash Player launches with from the user s hard disk For example attempts to read a file on the user s hard disk using XML load LoadMovie or LoadVars load will fail if this property is set to true R...

Page 317: ...T Windows 98 ME Windows 95 Windows CE available only in Flash Player SDK not in the desktop version Linux and MacOS The server string is OS Availability ActionScript 1 0 Flash Lite 2 0 Example The fol...

Page 318: ...olutionX screenResolutionY capabilities screenResolutionY property public static screenResolutionY Number read only An integer that indicates the maximum vertical resolution of the screen The server s...

Page 319: ...cates all the MIME types for video that the mobile device s codecs support This property returns an array of all the MIME types for video that the mobile device s codecs support Availability ActionScr...

Page 320: ...r target Object Creates a Color object for the movie clip specified by the target_mc parameter Modifiers Signature Description getRGB Number Returns the R G B combination currently in use by the color...

Page 321: ...lue for the color specified Example The following code retrieves the RGB value for the Color object my_color converts the value to a hexadecimal string and assigns it to the myValue variable To see th...

Page 322: ...tTransform See also setTransform Color setTransform method setRGB Color setRGB method public setRGB offset Number Void Specifies an RGB color for a Color object Calling this method overrides any previ...

Page 323: ...omponent 255 to 255 ba is the percentage for the blue component 100 to 100 bb is the offset for the blue component 255 to 255 aa is the percentage for alpha 100 to 100 ab is the offset for alpha 255 t...

Page 324: ...Date class lets you retrieve date and time values relative to universal time Greenwich mean time now called universal time or UTC or relative to the operating system on which Flash Player is running...

Page 325: ...ing time are always applied which leads to incorrect transitions in Europe and other areas that employ daylight saving time but have different transition times than the U S Flash correctly detects whe...

Page 326: ...etLocaleLongDate String Returns a string representing the current date in long form formatted according to the currently defined locale getLocaleShortDate String Returns a string representing the curr...

Page 327: ...tUTCFullYear Number Returns the four digit year of the specified Date object according to universal time getUTCHours Number Returns the hour an integer from 0 to 23 of the specified Date object accord...

Page 328: ...setMinutes minute Number Number Sets the minutes for a specified Date object according to local time and returns the new time in milliseconds setMonth month Number date Number Number Sets the month fo...

Page 329: ...ied Date object in universal time and returns the new time in milliseconds setYear year Number Number Sets the year for the specified Date object in local time and returns the new time in milliseconds...

Page 330: ...he third line a Date object is created with year month and date parameters passed to it resulting in the time 09 30 15 GMT 0 milliseconds March 6 1965 Note that since the year parameter is specified a...

Page 331: ...The following example creates a new Date object and concatenates the returned values of Date getMonth Date getDate and Date getFullYear var today_date Date new Date var date_str String today_date get...

Page 332: ...al time is determined by the operating system on which Flash Player is running Availability ActionScript 1 0 Flash Lite 2 0 Returns Number An integer representing the day of the week Example The follo...

Page 333: ...is determined by the operating system on which Flash Player is running Availability ActionScript 1 0 Flash Lite 2 0 Returns Number An integer Example The following example uses the constructor to crea...

Page 334: ...nt time It also uses the getLocaleLongDate method to return the current date in long form formatted according to the currently defined locale as follows var my_date Date new Date trace my_date getLoca...

Page 335: ...e mobile device and the locale Availability ActionScript 1 0 Flash Lite 2 0 Returns String A string representing the current time formatted according to the currently defined locale Example The follow...

Page 336: ...d by the operating system on which Flash Player is running Availability ActionScript 1 0 Flash Lite 2 0 Returns Number An integer Example The following example uses the constructor to create a Date ob...

Page 337: ...eptember October November December return monthNames_array month getSeconds Date getSeconds method public getSeconds Number Returns the seconds an integer from 0 to 59 of the specified Date object acc...

Page 338: ...An integer Example The following example returns the difference between the local daylight saving time for San Francisco and universal time Daylight saving time is factored into the returned result on...

Page 339: ...Number Returns the day of the week 0 for Sunday 1 for Monday and so on of the specified Date object according to universal time Availability ActionScript 1 0 Flash Lite 2 0 Returns Number An integer E...

Page 340: ...differ from the value returned by Date getFullYear if today s date is December 31 or January 1 depending on the relationship between your local time zone and universal time var today_date Date new Dat...

Page 341: ...tUTCMilliseconds Date getUTCMilliseconds method public getUTCMilliseconds Number Returns the milliseconds an integer from 0 to 999 of the specified Date object according to universal time Availability...

Page 342: ...e creates a new Date object and uses Date getUTCMonth and Date getMonth The value returned by Date getUTCMonth can differ from the value returned by Date getMonth if today s date is the first or last...

Page 343: ...ses Date getUTCFullYear and Date getFullYear The value returned by Date getUTCFullYear may differ from the value returned by Date getFullYear if today s date is December 31 or January 1 depending on t...

Page 344: ...mber Number Sets the day of the month for the specified Date object according to local time and returns the new time in milliseconds Local time is determined by the operating system on which Flash Pla...

Page 345: ...year Number A four digit number specifying a year Two digit numbers do not represent four digit years for example 99 is not the year 1999 but the year 99 month Number optional An integer from 0 Janua...

Page 346: ...new Date object setting the time and date to 8 00 a m on May 15 2004 and uses Date setHours to change the time to 4 00 p m var my_date Date new Date 2004 4 15 8 trace my_date getHours output 8 my_dat...

Page 347: ...ed by the operating system on which Flash Player is running Availability ActionScript 1 0 Flash Lite 2 0 Parameters minute Number An integer from 0 to 59 Returns Number An integer Example The followin...

Page 348: ...getMonth output 5 setSeconds Date setSeconds method public setSeconds second Number Number Sets the seconds for the specified Date object in local time and returns the new time in milliseconds Local...

Page 349: ...my_date getTime convert my_date to milliseconds myDate_num 30 60 1000 add 30 minutes in milliseconds my_date setTime myDate_num set my_date Date object 30 minutes forward trace my_date getFullYear ou...

Page 350: ...rns the new time in milliseconds Optionally this method can also set the month and date represented by the specified Date object Calling this method does not modify the other fields of the specified D...

Page 351: ...nute Number second Number millisecond Number Number Sets the hour for the specified Date object in universal time and returns the new time in milliseconds Availability ActionScript 1 0 Flash Lite 2 0...

Page 352: ...CMilliseconds method public setUTCMilliseconds millisecond Number Number Sets the milliseconds for the specified Date object in universal time and returns the new time in milliseconds Availability Act...

Page 353: ...Number An integer Example The following example initially creates a new Date object setting the time and date to 8 00 a m on May 15 2004 and uses Date setUTCMinutes to change the time to 8 30 a m var...

Page 354: ...trace today_date getUTCMonth output 4 today_date setUTCMonth 5 trace today_date getUTCMonth output 5 See also getUTCDay Date getUTCDay method getDay Date getDay method setUTCSeconds Date setUTCSeconds...

Page 355: ...tem on which Flash Player is running Availability ActionScript 1 0 Flash Lite 2 0 Parameters year Number A number that represents the year If year is an integer between 0 and 99 setYear sets the year...

Page 356: ...mber date Number hour Number minute Number second Number millisecond Number Number Returns the number of milliseconds between midnight on January 1 1970 universal time and the time specified in the pa...

Page 357: ...valueOf Date valueOf method public valueOf Number Returns the number of milliseconds since midnight January 1 1970 universal time for this Date Availability ActionScript 1 0 Flash Lite 2 0 Returns Num...

Page 358: ...ototype property __resolve Object __resolve property Signature Description Error message String Creates a new Error object Modifiers Signature Description toString String Returns the string Error by d...

Page 359: ...t are not identical function compareStrings str1_str String str2_str String Void if str1_str str2_str throw new Error Strings do not match try compareStrings Dog dog output Strings do not match catch...

Page 360: ...ou test this ActionScript without any modifications to the numbers you divide you see an error displayed in the Output panel because you are trying to divide by 0 See also throw statement try catch fi...

Page 361: ...ng DivideByZeroError var message String Unable to divide by zero See also throw statement try catch finally statement toString Error toString method public toString String Returns the string Error by...

Page 362: ...sh Lite 2 0 Example The following example creates a listener that is called when a key is pressed It uses the Key getCode method to get the key code for the key that was pressed var myListener new Obj...

Page 363: ...SOFT4 soft key static SOFT5 String The key code value for the SOFT5 soft key static SOFT6 String The key code value for the SOFT6 soft key static SOFT7 String The key code value for the SOFT7 soft ke...

Page 364: ...unction var keyCode Key getCode switch keyCode case ExtendedKey SOFT1 Handle left soft key break case ExtendedKey SOFT2 Handle right soft key break Key addListener myListener SOFT10 ExtendedKey SOFT10...

Page 365: ...the SOFT3 soft key Availability ActionScript 2 0 Flash Lite 2 0 SOFT4 ExtendedKey SOFT4 property public static SOFT4 String The key code value for the SOFT4 soft key Availability ActionScript 2 0 Flas...

Page 366: ...soft key Availability ActionScript 2 0 Flash Lite 2 0 Function Object Function public dynamic class Function extends Object Both user defined and built in functions in ActionScript are represented by...

Page 367: ...tion specifies as the return value Availability ActionScript 1 0 Flash Lite 2 0 Parameters thisObject Object The object to which myFunction is applied argArray Array optional An array whose elements a...

Page 368: ...y null secondArray outputs a b c The following example shows how apply passes an array of parameters and specifies the value of this define a function function theFunction trace this myObj this myObj...

Page 369: ...t as shown in the following example myObject myMethod 1 2 3 In some situations you might want thisObject to point somewhere else for example if a function must be invoked as a method of an object but...

Page 370: ...obj true See also apply Function apply method Key Object Key public class Key extends Object The Key class is a top level class whose methods and properties you can use without a constructor Use the m...

Page 371: ...ey code value for the Insert key 45 static LEFT Number The key code value for the Left Arrow key 37 static _listeners Array read only A list of references to all listener objects registered with the K...

Page 372: ...iers Signature Description static addListener listener Object Void Registers an object to receive onKeyDown and onKeyUp notification static getAscii Number Returns the ASCII code of the last key press...

Page 373: ...event listener removeListener Key removeListener method BACKSPACE Key BACKSPACE property public static BACKSPACE Number The key code value for the Backspace key 8 Availability ActionScript 1 0 Flash L...

Page 374: ...cript 1 0 Flash Lite 2 0 Example The following example lets you draw lines with the mouse pointer using the Drawing API and listener objects Press the Backspace or Delete key to remove the lines that...

Page 375: ...ple moves a movie clip called car_mc a constant distance 10 when you press the arrow keys A sound plays when you press the Spacebar Give a sound in the library a linkage identifier of horn_id for this...

Page 376: ...istance 10 when you press the arrow keys The car_mc instance stops when you press Enter and delete the onEnterFrame event var DISTANCE Number 5 var keyListener Object new Object keyListener onKeyDown...

Page 377: ...two decimal places var timer Number Math round getTimer 10 100 trace you pressed the Esc key getTimer ms timer s Key addListener keyListener When using this example make sure that you select Control...

Page 378: ...i differentiates between uppercase and lowercase letters and Key getCode does not var keyListener Object new Object keyListener onKeyDown function trace For the last key typed trace tThe Key code is K...

Page 379: ...de ENTER key else trace Virtual key code Key getCode Key addListener keyListener When using this example make sure that you select Control Disable Keyboard Shortcuts in the test environment The follow...

Page 380: ...movie clip that has a linkage ID car_id and add the following ActionScript to Frame 1 of the Timeline this attachMovie car_id car_mc this getNextHighestDepth _x 0 _y 0 car_mc onPress function this sta...

Page 381: ...Key addListener keyListener isDown Key isDown method public static isDown code Number Boolean Returns true if the key specified in code is pressed false otherwise Availability ActionScript 1 0 Flash L...

Page 382: ...ou press the Spacebar Give a sound in the library a linkage identifier of horn_id for this example var DISTANCE Number 10 var horn_sound Sound new Sound horn_sound attachSound horn_id var keyListener_...

Page 383: ...n function trace You pressed a key Key addListener myListener trace Key _listeners length Output 1 onKeyDown Key onKeyDown event listener onKeyDown function Notified when a key is pressed To use onKey...

Page 384: ...Ascii tKey chr Key getAscii Key addListener keyListener Listeners enable different pieces of code to cooperate because multiple listeners can receive notification about a single event Availability Act...

Page 385: ..._rotation 5 else if Key isDown Key PGUP car_mc _rotation 5 Key addListener keyListener removeListener Key removeListener method public static removeListener listener Object Boolean Removes an object...

Page 386: ...erty public static RIGHT Number The key code value for the Right Arrow key 39 Availability ActionScript 1 0 Flash Lite 2 0 Example The following example moves a movie clip called car_mc a constant dis...

Page 387: ...ipt 1 0 Flash Lite 2 0 Example The following example scales car_mc when you press Shift var keyListener Object new Object keyListener onKeyDown function if Key isDown Key SHIFT car_mc _xscale 2 car_mc...

Page 388: ...horn_sound start break case Key LEFT car_mc _x DISTANCE break case Key UP car_mc _y DISTANCE break case Key RIGHT car_mc _x DISTANCE break case Key DOWN car_mc _y DISTANCE break Key addListener keyLis...

Page 389: ...a constant distance 10 when you press the arrow keys A sound plays when you press the Spacebar Give a sound in the library a linkage identifier of horn_id for this example var DISTANCE Number 10 var h...

Page 390: ...send specific variables rather than all the variables which can make your application more efficient You can use the LoadVars onLoad handler to ensure that your application runs when data is loaded a...

Page 391: ...peration has completed undefined by default constructor Object constructor property __proto__ Object __proto__ property prototype Object prototype property __resolve Object __resolve property Event De...

Page 392: ...adVars sendAndLoad load url String Boolean Downloads variables from the specified URL parses the variable data and places the resulting variables into my_lv send url String target String method String...

Page 393: ...ipt 1 0 Flash Lite 2 0 Parameters header Object A string or array of strings that represents an HTTP request header name headerValue String A string that represents the value associated with header Ex...

Page 394: ...ars decode method public decode queryString String Void Converts the variable string to properties of the specified LoadVars object This method is used internally by the LoadVars onData event handler...

Page 395: ...r refers to a valid text file using HTTP If you attempt to use this example to load a local file that resides on your hard disk this example will not work properly because in Test Movie mode Flash Pla...

Page 396: ...ad a text file When you test the file two things are displayed in the Output panel whether the file loads successfully and how much data loads into the SWF file You must replace the URL parameter of t...

Page 397: ...rlencoded This is the same format used by loadVariables 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...

Page 398: ...lication from a server side PHP script and then loads the data in passvars php var my_lv LoadVars new LoadVars my_lv onLoad function success Boolean if success trace this toString else trace Error loa...

Page 399: ...ActionScript 1 0 Flash Lite 2 0 Example The following example loads a text file and displays information in the Output panel when the operation completes var my_lv LoadVars new LoadVars my_lv onLoad...

Page 400: ...es LoadVars onLoad You can override this default implementation by assigning a custom function to LoadVars onData but LoadVars onLoad is not called unless you call it in your implementation of LoadVar...

Page 401: ...nce called submit_button to the Stage When the user clicks the Login button instance in the following example two LoadVars objects are created send_lv and result_lv The send_lv object copies the name...

Page 402: ...pe sent in the HTTP request headers is the value of my_lv contentType or the default application x www form urlencoded The POST method is used unless GET is specified You must specify the target param...

Page 403: ...ifies the parent of the current frame _top specifies the top level frame in the current window method String optional A string the GET or POST method of the HTTP protocol The default value is POST Ret...

Page 404: ...t 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 For exampl...

Page 405: ...an if success result_ta text result_lv welcomeMessage else result_ta text Error connecting to server var send_lv LoadVars new LoadVars send_lv name name_ti text send_lv sendAndLoad http www flash mx c...

Page 406: ...ation Interchange File Format XLIFF There are three ways to display the language specific strings contained in the XLIFF files automatically at runtime Flash Player replaces string IDs with strings fr...

Page 407: ...e static initialize Void Determine the language to use and begin xml loading static loadLanguageXML xmlLanguageCode String customXmlCompleteCallback Function Void Load the specified language xml file...

Page 408: ...public static addXMLPath langCode String path String Void Adds the languageCode and languagePath pair into the internal array for later use This is primarily used by Flash when the strings replacemen...

Page 409: ...ile Availability ActionScript 2 0 Flash Lite 2 0 Parameters xmlLanguageCode String customXmlCompleteCallback Function loadString Locale loadString method public static loadString id String String Retu...

Page 410: ...ethods of the Math class are static and must be called using the syntax Math method parameter or Math constant In ActionScript constants are defined with the maximum precision of double precision IEEE...

Page 411: ...931471805599453 static LOG10E Number A mathematical constant for the base 10 logarithm of the constant e Math E expressed as log10e with an approximate value of 0 4342944819032518 static LOG2E Number...

Page 412: ...of the circle static ceil x Number Number Returns the ceiling of the specified number or expression static cos x Number Number Computes and returns the cosine of the specified angle in radians static...

Page 413: ...ue of the x parameter called num in this example var num Number 12 var numAbsolute Number Math abs num trace num output 12 trace numAbsolute output 12 static sin x Number Number Computes and returns t...

Page 414: ...eral values trace Math acos 1 output 3 14159265358979 trace Math acos 0 output 1 5707963267949 trace Math acos 1 output 0 See also asin Math asin method atan Math atan method atan2 Math atan2 method c...

Page 415: ...nd positive pi divided by 2 Availability ActionScript 1 0 Flash Lite 2 0 In Flash Player 4 the methods and properties of the Math class are emulated using approximations and might not be as accurate a...

Page 416: ...ns Number A number Example The following example returns the angle in radians of the point specified by the coordinates 0 10 such that x 0 and y 10 Note that the first parameter to atan2 is always the...

Page 417: ...using approximations and might not be as accurate as the non emulated math functions that Flash Player 5 supports Parameters x Number A number that represents an angle measured in radians Returns Numb...

Page 418: ...er a one year period var principal Number 100 var simpleInterest Number 100 var continuouslyCompoundedInterest Number 100 Math E principal trace Beginning principal principal trace Simple interest aft...

Page 419: ...parameter x The floor is the closest integer that is less than or equal to the specified number or expression Availability ActionScript 1 0 Flash Lite 2 0 In Flash Player 4 the methods and properties...

Page 420: ...nt for the natural logarithm of 2 expressed as loge2 with an approximate value of 0 6931471805599453 Availability ActionScript 1 0 Flash Lite 2 0 In Flash Player 4 the methods and properties of the Ma...

Page 421: ...tions and might not be as accurate as the non emulated math functions that Flash Player 5 supports Example This example shows how to obtain the base 10 logarithm of a number trace Math log 1000 Math L...

Page 422: ...displays Thu Dec 30 00 00 00 GMT 0700 2004 which is the larger of the evaluated expressions var date1 Date new Date 2004 11 25 var date2 Date new Date 2004 11 30 var maxDate Number Math max date1 getT...

Page 423: ...are emulated using approximations and might not be as accurate as the non emulated math functions that Flash Player 5 supports Example The following example draws a circle using the mathematical cons...

Page 424: ...e the length of a line this createEmptyMovieClip canvas_mc this getNextHighestDepth var mouseListener Object new Object mouseListener onMouseDown function this origX _xmouse this origY _ymouse mouseLi...

Page 425: ...nclusively function randRange min Number max Number Number var randomNum Number Math floor Math random max min 1 min return randomNum for var i 0 i 100 i var n Number randRange 4 11 trace n round Math...

Page 426: ...public static sin x Number Number Computes and returns the sine of the specified angle in radians To calculate a radian see the description of the Math class entry Availability ActionScript 1 0 Flash...

Page 427: ...th tan Math PI 8 r x r y x r y mc curveTo Math tan Math PI 8 r x r y Math sin Math PI 4 r x Math sin Math PI 4 r y mc curveTo r x Math tan Math PI 8 r y r x y See also acos Math acos method asin Math...

Page 428: ...lineTo this newX this newY var hypLen Number Math sqrt Math pow line_mc _width 2 Math pow line_mc _height 2 line_mc createTextField length nextDepth _txt canvas_mc getNextHighestDepth this origX this...

Page 429: ...s the value of Math SQRT2 trace Math SQRT2 Output 1 4142135623731 tan Math tan method public static tan x Number Number Computes and returns the tangent of the specified angle To calculate a radian us...

Page 430: ...PI 4 r x Math sin Math PI 4 r y mc curveTo Math tan Math PI 8 r x r y x r y mc curveTo Math tan Math PI 8 r x r y Math sin Math PI 4 r x Math sin Math PI 4 r y mc curveTo r x Math tan Math PI 8 r y r...

Page 431: ...mouse button is released Modifiers Signature Description static addListener listener Object Void Registers an object to receive notifications of the onMouseDown onMouseMove and onMouseUp listeners sta...

Page 432: ...rs Note This method is supported in Flash Lite only if System capabilities hasMouse is true or System capabilities hasStylus is true Availability ActionScript 1 0 Flash Lite 2 0 Parameters listener Ob...

Page 433: ...Mouse onMouseDown event listener onMouseDown function Notified when the mouse button is pressed To use the onMouseDown listener you must create a listener object You can then define a function for onM...

Page 434: ...is orig_y _ymouse this target_mc canvas_mc createEmptyMovieClip canvas_mc getNextHighestDepth mouseListener onMouseMove function if this isDrawing this target_mc clear this target_mc lineStyle 1 0xFF0...

Page 435: ...ut a single event Note This event listener is supported in Flash Lite only if System capabilities hasMouse is true Availability ActionScript 1 0 Flash Lite 2 0 Example The following example uses the m...

Page 436: ...stener See also addListener Mouse addListener method onMouseUp Mouse onMouseUp event listener onMouseUp function Notified when the mouse button is released To use the onMouseUp listener you must creat...

Page 437: ...terEvent mouseListener onMouseUp function this isDrawing false Mouse addListener mouseListener See also addListener Mouse addListener method removeListener Mouse removeListener method public static re...

Page 438: ...start drawing startDrawing_button enabled false this createEmptyMovieClip canvas_mc this getNextHighestDepth var mouseListener Object new Object mouseListener onMouseDown function this isDrawing true...

Page 439: ...e new movie clip instances The attachMovie method allows you to create a new movie clip instance based on a movie clip symbol that exists in the library The createEmptyMovieClip method allows you to c...

Page 440: ...ifies whether a movie clip has a yellow rectangle around it when it has input focus _framesloaded Number read only The number of frames that are loaded from a streaming SWF file _height Number The hei...

Page 441: ...fied in the MovieClip parameter trackAsMenu Boolean A Boolean value that indicates whether other buttons or movie clips can receive a release event from a mouse or stylus _url String read only Retriev...

Page 442: ...object onDragOver function Invoked when the pointer is dragged outside and then over the movie clip onEnterFrame function Invoked repeatedly at the frame rate of the SWF file onKeyDown function Invoke...

Page 443: ...rea onRollOut function Invoked when the pointer moves outside a movie clip area onRollOver function Invoked when the pointer moves over a movie clip area onSetFocus function oldFocus Object Invoked wh...

Page 444: ...a child of an existing movie clip createTextField instanceName String depth Number x Number y Number width Number height Number TextField Creates a new empty text field as a child of the movie clip o...

Page 445: ...ts on the same level and layer in the current movie clip getSWFVersion Number Returns an integer that indicates the Flash Player version for the movie clip was published getURL url String window Strin...

Page 446: ...url String method String Void Reads data from an external file and sets the values for variables in the movie clip localToGlobal pt Object Void Converts the pt object from the movie clip s local coord...

Page 447: ...t Number top Number right Number bottom Number Void Lets the user drag the specified movie clip stop Void Stops the movie clip currently playing stopDrag Void Ends a MovieClip startDrag method swapDep...

Page 448: ...erty attachMovie MovieClip attachMovie method public attachMovie id String name String depth Number initObject Object MovieClip Takes a symbol from the library and attaches it to the movie clip Use Mo...

Page 449: ...ovieClip method unloadMovie MovieClip unloadMovie method removeMovieClip function beginFill MovieClip beginFill method public beginFill rgb Number alpha Number Void Indicates the beginning of a new dr...

Page 450: ...od beginGradientFill MovieClip beginGradientFill method public beginGradientFill fillType String colors Array alphas Array ratios Array matrix Object Void Indicates the beginning of a new drawing path...

Page 451: ...ercent matrix Object A transformation matrix that is an object with either of the following two sets of properties a b c d e f g h i which can be used to describe a 3 x 3 matrix of the following form...

Page 452: ...is the height of the gradient and r is the rotation in radians of the gradient The following example uses the beginGradientFill method with a matrix parameter of this type this createEmptyMovieClip g...

Page 453: ...lip lineStyle Shapes and lines that are manually drawn during authoring time with the Flash drawing tools are unaffected Availability ActionScript 1 0 Flash Lite 2 0 Example The following example draw...

Page 454: ...r for the new movie clip The registration point for a newly created empty movie clip is the upper left corner This method fails if any of the parameters are missing You can extend the methods and even...

Page 455: ...dy occupied or MovieClip getNextHighestDepth to determine the highest unoccupied depth The text field is positioned at x y with dimensions width by height The x and y parameters are relative to the co...

Page 456: ...the new text field y Number An integer that specifies the ycoordinate of the new text field width Number A positive integer that specifies the width of the new text field height Number A positive int...

Page 457: ...the playhead of the actionClip_mc movie clip to advance five frames ahead of its current location actionClip_mc gotoAndStop actionClip_mc _currentframe 5 curveTo MovieClip curveTo method public curveT...

Page 458: ...anchorY Number An integer that specifies the vertical position of the next anchor point relative to the registration point of the parent movie clip Example The following example draws a nearly circula...

Page 459: ...in Math PI 4 r x Math sin Math PI 4 r y mc curveTo Math tan Math PI 8 r x r y x r y mc curveTo Math tan Math PI 8 r x r y Math sin Math PI 4 r x Math sin Math PI 4 r y mc curveTo r x Math tan Math PI...

Page 460: ...s hasStylus is true Availability ActionScript 1 0 Flash Lite 2 0 Example The following example evaluates the _droptarget property of the garbage_mc movie clip instance and uses eval to convert it from...

Page 461: ...ecessary for the MovieClip class version because the target of the method is the movie clip instance on which the method is invoked Moreover the global version of duplicateMovieClip supports neither t...

Page 462: ...0 mc beginFill 0x333333 mc lineTo w 0 mc lineTo w h mc lineTo 0 h mc lineTo 0 0 mc endFill return mc See also loadMovie MovieClip loadMovie method removeMovieClip MovieClip removeMovieClip method dupl...

Page 463: ...the fill that was specified in the previous call to beginFill or beginGradientFill If the current drawing position does not equal the previous position specified in a moveTo method and a fill is defin...

Page 464: ...a movie clip has a yellow rectangle around it when it has input focus This property can override the global _focusrect property The default value of the _focusrect property of a movie clip instance is...

Page 465: ...sing Enter or the Spacebar when _focusrect is disabled You can also test your SWF file in the test environment Select Control Disable Keyboard Shortcuts in the test environment This allows you to view...

Page 466: ...Frame 3 Then add the following code to Frame 3 stop See also MovieClipLoader getBounds MovieClip getBounds method public getBounds bounds Object Object Returns properties that are the minimum and max...

Page 467: ...n bounds_obj trace i bounds_obj i The following information appears in the Output panel yMax 110 yMin 10 xMax 110 xMin 10 See also globalToLocal MovieClip globalToLocal method localToGlobal MovieClip...

Page 468: ...o Frame 3 stop See also getBytesTotal MovieClip getBytesTotal method getBytesTotal MovieClip getBytesTotal method public getBytesTotal Number Returns the size in bytes of the movie clip For movie clip...

Page 469: ...getDepth method public getDepth Number Returns the depth of the movie clip instance Each movie clip button and text field has a unique depth associated with it that determines how the object appears i...

Page 470: ...th parameter you want to pass to any of these methods already contains a movie clip You can extend the methods and event handlers of the MovieClip class by creating a subclass Availability ActionScrip...

Page 471: ...he movie clip in front of all other objects on the same level and layer in the current movie clip The value returned is 0 or higher that is negative numbers are not returned You can extend the methods...

Page 472: ...50 200 200 mc label text mc getDepth See also getDepth MovieClip getDepth method getInstanceAtDepth MovieClip getInstanceAtDepth method swapDepths MovieClip swapDepths method attachMovie MovieClip att...

Page 473: ...ng window String method String Void Loads a document from the specified URL into the specified window The getURL method can also be used to pass variables to another application defined at the URL by...

Page 474: ...eader and is used for long strings of variables Example The following ActionScript creates a new movie clip instance and opens the Macromedia website in a new browser window this createEmptyMovieClip...

Page 475: ...m from values relative to the Stage global coordinates to values relative to a specific movie clip local coordinates For example if you create a movie clip that is positioned at the point _x 100 _y 10...

Page 476: ...rds_txt multiline true coords_txt autoSize true this createEmptyMovieClip target_mc this getNextHighestDepth target_mc _x 100 target_mc _y 100 target_mc loadMovie photo1 jpg var mouseListener Object n...

Page 477: ...sent Example The following example uses the _framesloaded property to start a SWF file when all of the frames are loaded If all of the frames aren t loaded the _xscale property of the loader movie cl...

Page 478: ...WF file when all the frames are loaded If all the frames aren t loaded the _xscale property of the loader movie clip instance is increased proportionally to create a progress bar Enter the following A...

Page 479: ...erty public _highquality Number Deprecated since Flash Player 7 This property was deprecated in favor of MovieClip _quality Specifies the level of anti aliasing applied to the current SWF file Specify...

Page 480: ...clip Place these two movie clips on the Stage and test the document When you click circle_mc the square_mc movie clip traces that it was clicked square_mc hitArea circle_mc square_mc onRelease functi...

Page 481: ...arameters target Object The target path of the hit area that may intersect or overlap with the movie clip The target parameter usually represents a button or text entry field Availability ActionScript...

Page 482: ...pecified or if the parameter is undefined a line is not drawn If a value of less than 0 is passed Flash uses 0 The value 0 indicates hairline thickness the maximum thickness is 255 If a value greater...

Page 483: ...g position defaults to 0 0 If any of the parameters are missing this method fails and the current drawing position is not changed You can extend the methods and event handlers of the MovieClip class b...

Page 484: ...e MovieClip _lockroot property to true in the loader movie as shown in the following code example If you don t set _lockroot to true in the loader movie any references to _root in the loaded movie poi...

Page 485: ...prior to the call to loadMovie var mc MovieClip this createEmptyMovieClip mc this getNextHighestDepth mc onRelease function Void trace this image _url http www w3 org Icons w3c_main png var image Movi...

Page 486: ...ources that are also at www someDomain com To load data from a different domain you can place a cross domain policy file on the server hosting the data source that is being accessed To load variables...

Page 487: ...i in target_mc trace i target_mc i trace clearInterval param_interval var param_interval setInterval checkParamsLoaded 100 The params txt file includes the following text var1 hello var2 goodbye done...

Page 488: ...you send as the parameter It changes them from values relative to a specific movie clip local coordinates to values relative to the Stage global coordinates For example if you create a movie clip that...

Page 489: ...ion this startDrag my_mc onRelease function this stopDrag See also globalToLocal MovieClip globalToLocal method _lockroot MovieClip _lockroot property public _lockroot Boolean A Boolean value that spe...

Page 490: ...myMovieClip _lockroot true Availability ActionScript 1 0 Flash Lite 2 0 Example In the following example lockroot fla has _lockroot applied to the main SWF file If the SWF file is loaded into another...

Page 491: ...wing information from current SWF file dumpRoot type Function version WIN 7 0 19 0 nolockroot_mc _level0 nolockroot_mc lockroot_mc _level0 lockroot_mc from nolockroot swf myVar 1 i lockroot_mc dumpRoo...

Page 492: ...eClipLoader onLoadInit event listener moveTo MovieClip moveTo method public moveTo x Number y Number Void Moves the current drawing position to x y If any of the parameters are missing this method fai...

Page 493: ...mc endFill See also createEmptyMovieClip MovieClip createEmptyMovieClip method lineStyle MovieClip lineStyle method lineTo MovieClip lineTo method _name MovieClip _name property public _name String Th...

Page 494: ...r is linked to a symbol in the library This handler can be used only with movie clips for which you have a symbol in the library that is associated with a class If you want an event handler to be invo...

Page 495: ...s function output trace Will never be called dynamic_mc onData output dynamic_mc loadMovie replacement swf The following function is invoked for any movie clip that receives data whether it is in the...

Page 496: ...e MovieClip class or is linked to a symbol in the library Note This event handler is supported in Flash Lite only if System capabilities hasMouse is true or System capabilities hasStylus is true Avail...

Page 497: ...utes when the event handler is invoked You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library The onKeyDown event handl...

Page 498: ...parameters You can use the Key getAscii and Key getCode methods to determine which key was pressed You must define a function that executes when the event handler is invoked You can define the functi...

Page 499: ...a function that executes when the event handler is invoked You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library Avai...

Page 500: ...Lite 2 0 Example This example shows you how to use the onLoad event handler in an ActionScript 2 0 class definition that extends the MovieClip class First create a class file named Oval as and define...

Page 501: ...function for the onMouseDown method that sends a trace action to the Output panel my_mc onMouseDown function trace onMouseDown called onMouseMove MovieClip onMouseMove handler onMouseMove function Inv...

Page 502: ...p function trace onMouseUp called onPress MovieClip onPress handler onPress function Invoked when the user clicks the mouse while the pointer is over a movie clip You must define a function that execu...

Page 503: ...symbol in the library Note This event handler is supported in Flash Lite only if System capabilities hasMouse is true or System capabilities hasStylus is true Availability ActionScript 1 0 Flash Lite...

Page 504: ...onRollOver method that sends a trace action to the Output panel my_mc onRollOver function trace onRollOver called onSetFocus MovieClip onSetFocus handler onSetFocus function oldFocus Object Invoked w...

Page 505: ...processes the actions associated with the onUnload event handler before attaching any actions to the affected frame You must define a function that executes when the event handler is invoked You can d...

Page 506: ...e is this _parent When you click the movie clip the following information appears in the Output panel You clicked the movie clip _level0 my_mc The parent of my_mc is _level0 See also _parent Button _p...

Page 507: ...ovieClip class by creating a subclass Availability ActionScript 1 0 Flash Lite 2 0 Example In the following example two movie clip buttons control the Timeline The prev_mc button moves the playhead to...

Page 508: ...uality Availability ActionScript 1 0 Flash Lite 2 0 Example This example sets the rendering quality of a movie clip named my_mc to LOW my_mc _quality LOW See also _quality property Value Description G...

Page 509: ...Manager class to assign depth values you may find that removeMovieClip fails silently When any V2 component is used the DepthManager class automatically reserves the highest 1048575 and lowest 16383 a...

Page 510: ...ase function this removeMovieClip bugNum See also duplicateMovieClip function createEmptyMovieClip MovieClip createEmptyMovieClip method duplicateMovieClip MovieClip duplicateMovieClip method attachMo...

Page 511: ...hich is possible by using mask layers If you have device fonts in a masked movie clip they are drawn but not masked You can t set a movie clip to be its own mask for example my_mc setMask my_mc If you...

Page 512: ...ipt 1 0 Flash Lite 2 0 See also _soundbuftime property startDrag MovieClip startDrag method public startDrag lockCenter Boolean left Number top Number right Number bottom Number Void Lets the user dra...

Page 513: ...p s parent that specify a constraint rectangle for the movie clip Example The following example creates a draggable movie clip instance called mc_1 this createEmptyMovieClip mc_1 1 with mc_1 lineStyle...

Page 514: ...ip is draggable at a time You can extend the methods and event handlers of the MovieClip class by creating a subclass Note This method is supported in Flash Lite only if System capabilities hasMouse i...

Page 515: ...e MovieClip class by creating a subclass Availability ActionScript 1 0 Flash Lite 2 0 Parameters target Object This parameter can take one of two forms A number that specifies the depth level where th...

Page 516: ...ms inside the list box should be excluded from tab ordering To do this the tabChildren property of the list box should be set to false The tabChildren property has no effect if the tabIndex property i...

Page 517: ...abEnabled is false Availability ActionScript 1 0 Flash Lite 2 0 Example The following example does not include myMC2_mc in the automatic tab ordering myMC1_mc onRelease function myMC2_mc onRelease fun...

Page 518: ...tab order for three movie clip instances myMC1_mc onRelease function myMC2_mc onRelease function myMC3_mc onRelease function myMC1_mc tabIndex 2 myMC2_mc tabIndex 1 myMC3_mc tabIndex 3 See also tabIn...

Page 519: ...nt if parent_mc _currentframe 1 parent_mc prevFrame else parent_mc gotoAndStop parent_mc _totalframes next_mc onRelease function var parent_mc MovieClip this _parent if parent_mc _currentframe parent_...

Page 520: ...h instance receives the event myMC1_mc trackAsMenu true myMC2_mc trackAsMenu true myMC3_mc trackAsMenu false myMC1_mc onRelease clickMC myMC2_mc onRelease clickMC myMC3_mc onRelease clickMC function c...

Page 521: ...neTo 0 60 lineTo 0 0 endFill box onRelease function box unloadMovie See also removeMovieClip MovieClip removeMovieClip method attachMovie MovieClip attachMovie method loadMovie MovieClip loadMovie met...

Page 522: ...ndicates whether the movie clip is visible Movie clips that are not visible _visible property set to false are disabled For example a button in a movie clip with _visible set to false cannot be clicke...

Page 523: ...MovieClip _x property public _x Number An integer that sets the x coordinate of a movie clip relative to the local coordinates of the parent movie clip If a movie clip is in the main Timeline its coo...

Page 524: ...e b my_mc onMouseMove function mouse_txt htmlText textformat tabStops 50 100 mouse_txt htmlText row1_str mouse_txt htmlText b _level0 b t _xmouse t _ymouse mouse_txt htmlText b my_mc b t this _xmouse...

Page 525: ...his createEmptyMovieClip box_mc 1 box_mc _x 100 box_mc _y 100 with box_mc lineStyle 1 0xCCCCCC beginFill 0xEEEEEE moveTo 0 0 lineTo 80 0 lineTo 80 60 lineTo 0 60 lineTo 0 0 endFill box_mc onRollOver f...

Page 526: ...MovieClip _xscale property _yscale MovieClip _yscale property _ymouse MovieClip _ymouse property public _ymouse Number read only Indicates the y coordinate of the mouse position Note This property is...

Page 527: ...re at 100 Availability ActionScript 1 0 Flash Lite 2 0 Example The following example creates a movie clip at runtime called box_mc The Drawing API is used to draw a box in this instance and when the m...

Page 528: ...ake place in the order listed When the first bytes of the downloaded file are written to disk the MovieClipLoader onLoadStart listener is invoked If you implemented the MovieClipLoader onLoadProgress...

Page 529: ...vieClipLoader loadClip has failed to load onLoadInit function target_mc Invoked when the actions on the first frame of the loaded clip are executed onLoadProgress function target_mc loadedBytes totalB...

Page 530: ...lip for compressed movies the getProgress method reflects the number of compressed bytes loadClip url String target Object Boolean Loads a SWF or JPEG file into a movie clip in Flash Player while the...

Page 531: ...MovieClip target_mc _x Stage width 2 target_mc _width 2 target_mc _y Stage height 2 target_mc _width 2 var w Number target_mc _width var h Number target_mc _height target_mc lineStyle 4 0x000000 targe...

Page 532: ...than using this method one will usually create a listener object and listen for the onLoadProgress event Another important note about this method is that the first synchronous call to getProgress can...

Page 533: ...ner object You activate the listener by using MovieClipLoader addListener listenerObject to register it with the MovieClipLoader class The MovieClipLoader onLoadStart handler is invoked when loading b...

Page 534: ...filer provides Availability ActionScript 1 0 Flash Lite 2 0 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...

Page 535: ...ners to respond to events while a SWF JPEG GIF or PNG file is downloading Availability ActionScript 1 0 Flash Lite 2 0 Example See MovieClipLoader loadClip See also addListener MovieClipLoader addList...

Page 536: ...t and onLoadComplete events are used to determine how long it takes to load the image The information appears in a dynamically created text field called timer_txt this createEmptyMovieClip image_mc th...

Page 537: ...is not found The string LoadNeverCompleted is returned if MovieClipLoader onLoadStart was called but MovieClipLoader onLoadComplete was not called for example if the download was interrupted because o...

Page 538: ...e value for target_mc identifies the movie clip this call is being made for This parameter is useful if you are loading multiple files with the same set of listeners Parameterstarget_mc MovieClip opti...

Page 539: ...er MovieClipLoader addListener method loadClip MovieClipLoader loadClip method onLoadStart MovieClipLoader onLoadStart event listener onLoadProgress MovieClipLoader onLoadProgress event listener onLoa...

Page 540: ...Loader and an anonymous event listener It should periodically output the progress of a load and finally provide notification when the load is complete and the asset is available to ActionScript var co...

Page 541: ...oads an image into a movie clip instance called image_mc The onLoadInit and onLoadComplete events are used to determine how long it takes to load the image This information appears in a text field cal...

Page 542: ...A listener object that was added using MovieClipLoader addListener Returns Boolean Example The following example loads an image into a movie clip and enables the user to start and stop the loading pro...

Page 543: ...rue stop_button enabled false image_mcl removeListener mclListener stop_button enabled false See also addListener MovieClipLoader addListener method unloadClip MovieClipLoader unloadClip method public...

Page 544: ...Listener mclListener image_mcl loadClip http www helpexamples com flash images image1 jpg image_mc See also loadClip MovieClipLoader loadClip method onLoadError MovieClipLoader onLoadError event liste...

Page 545: ...UE Number The largest representable number double precision IEEE 754 static MIN_VALUE Number The smallest representable number double precision IEEE 754 static NaN Number The IEEE 754 value representi...

Page 546: ...69313486232e 308 MIN_VALUE Number MIN_VALUE property public static MIN_VALUE Number The smallest representable number double precision IEEE 754 This number is approximately 5e 324 Availability ActionS...

Page 547: ...ITY Number NEGATIVE_INFINITY property public static NEGATIVE_INFINITY Number Specifies the IEEE 754 value representing negative infinity The value of this property is the same as that of the constant...

Page 548: ...so toString Number toString method valueOf Number valueOf method POSITIVE_INFINITY Number POSITIVE_INFINITY property public static POSITIVE_INFINITY Number Specifies the IEEE 754 value representing po...

Page 549: ...tion of the number 9 var myNumber Number new Number 9 trace myNumber toString 2 output 1001 trace myNumber toString 8 output 11 The following example results in a hexadecimal value var r Number new Nu...

Page 550: ...onScript 2 0 or constructor function ActionScript 1 0 used to create the object static prototype Object A reference to the superclass of a class or function object __resolve Object A reference to a us...

Page 551: ...etter property to a prototype object all object instances that inherit the prototype object inherit the getter setter property This makes it possible to add a getter setter property in one location th...

Page 552: ...otherwise Example In the following example an object has two internal methods setQuantity and getQuantity A property bookcount can be used to invoke these methods when it is either set or retrieved A...

Page 553: ...the properties to Book prototype so that the bookcount and bookname properties exist only in one place The effect however is the same as that of the code in the example that added bookcount and bookn...

Page 554: ...name String return Catcher in the Rye The following code can then be placed in a FLA file and will function the same way as it does in the previous examples var myBook Book new Book myBook bookcount 5...

Page 555: ...tes whether an object has a specified property defined This method returns true if the target object has a property that matches the string specified by the name parameter and false otherwise This met...

Page 556: ...ject new Object myObj prop1 hello trace myObj isPropertyEnumerable prop1 Output true var myArray new Array trace myArray isPropertyEnumerable length Output false See also for in statement isPrototypeO...

Page 557: ...ction ActionScript 1 0 used to create the object The __proto__ property is automatically assigned to all objects when they are created The ActionScript interpreter uses the __proto__ property to acces...

Page 558: ...erty is shared by all instances of the class and is accessible only as a class property Instances of your custom class cannot directly access the prototype property but can access it through the __pro...

Page 559: ...ctionScript class definition associated with the specified movie clip symbol or class identifier For movie clip symbols any existing instances of the movie clip remain unchanged but new instances of t...

Page 560: ...ActionScript code refers to an undefined property or method of an object Flash Player determines whether the object s __resolve property is defined If __resolve is defined the function to which it re...

Page 561: ...nction name return function this myFunction name test __resolve using undefined method names myObject someMethod output Method someMethod was called myObject someOtherMethod output Method someOtherMet...

Page 562: ...ct var myObject Object new Object define a function for __resolve to call myObject myFunction function name trace Method name was called define the __resolve function myObject __resolve function name...

Page 563: ...arguments create a new object method and assign it the reference this name f return the reference to the function return f test __resolve using undefined method names with parameters myObject someMet...

Page 564: ...n t tell us whether the value is a string or number we will also use typeof to test whether toString works var myNumber Number 5 trace typeof myNumber output number trace myNumber toString output 5 tr...

Page 565: ...false otherwise Availability ActionScript 1 0 Flash Lite 2 0 Parameters name String A string the name of the object property that should no longer be watched Returns Boolean A Boolean value true if t...

Page 566: ...reate a new Date object set to February 1 2004 8 15 AM The toString method returns the current time in human readable form The valueOf method returns the primitive value in milliseconds var myDate Dat...

Page 567: ...oint The Object watch method behaves similarly to the Object watch function in JavaScript 1 2 and later The primary difference is the userData parameter which is a Flash addition to Object watch that...

Page 568: ...operty changes var speedWatcher Function function prop oldVal newVal speedLimit Check whether speed is above the limit if newVal speedLimit trace You are speeding else trace You are not speeding Retur...

Page 569: ...tains methods that specify how SWF files in different domains can communicate with each other Availability ActionScript 1 0 Flash Lite 2 0 Property summary Properties inherited from class Object const...

Page 570: ...owDomain www domain com store domain com Modifiers Signature Description static allowDomain domain1 String Void Lets SWF files and HTML files in the identified domains access objects and variables in...

Page 571: ...when a child SWF finishes loading is to use MovieClipLoader onLoadComplete The opposite situation can also occur that is you might create a child SWF file that wants to allow its parent to script it b...

Page 572: ...ver you might need to do so for example if you must permit access to HTTPS files published for Flash Player 7 or later from HTTP files published for Flash Player 6 A SWF file published for Flash Playe...

Page 573: ...h Player 7 0 14 0 looked for policy files in only one location crossdomain xml on the server to which a data loading request was being made For an XMLSocket connection attempt Flash Player 7 0 14 0 lo...

Page 574: ...nsmitting a policy file A server can also be set up to serve policy files over a separate port from standard connections in which case it can send a policy file as soon as a connection is established...

Page 575: ...RL where the cross domain policy file to be loaded is located Selection Object Selection public class Selection extends Object The Selection class lets you set and control the text field in which the...

Page 576: ...fiers Signature Description static addListener listener Object Void Registers an object to receive keyboard focus change notifications static getFocus String Returns a string specifying the target pat...

Page 577: ...tener onSetFocus function oldFocus_txt newFocus_txt oldFocus_txt border false newFocus_txt border true Selection addListener focusListener When you test the SWF file try using Tab to move between the...

Page 578: ...er Test the SWF file and use Tab to move between the instances on the Stage Make sure you have Control Disable Keyboard Shortcuts selected in the test environment See also onSetFocus Selection onSetFo...

Page 579: ...txt 4 0 75 100 22 for var i in this if this i instanceof TextField this i border true this i type input this createTextField status_txt this getNextHighestDepth 200 10 300 100 status_txt html true sta...

Page 580: ...several text field instances When you select a text field information displays in the Output panel When you click the remove_btn instance the listener is removed and information no longer displays in...

Page 581: ...in a browser window If the user does not fill in one of the required text fields username_txt and password_txt the cursor automatically focuses in the text field thats missing data For example if the...

Page 582: ...ts store a set of name value pairs to the device Note The name SharedObject is derived from the Flash SharedObject class The Flash version of this class allows multiple Flash SWF files to share their...

Page 583: ...ts users store information about their favorite albums The information can be stored on the remote server but this causes problems if the application cannot connect to the service Also retrieving the...

Page 584: ...turned from the call to the getLocal method in the same way a shared object is used in Flash The application can add modify or remove properties while the content is playing When the content is unload...

Page 585: ...f attributes assigned to the data property of the object constructor Object constructor property __proto__ Object __proto__ property prototype Object prototype property __resolve Object __resolve prop...

Page 586: ...data from the shared object and deletes the shared object from the disk flush minDiskSpace Number Object Writes shared object to a local persistent file static getLocal name String SharedObject Retur...

Page 587: ...The following example sets data in the shared object and then empties all of the data from the shared object var my_so SharedObject SharedObject getLocal superfoo my_so data name Hector trace before m...

Page 588: ...and the shared object contains the following information userName Ramona adminPrivileges true itemNumbers 101 346 483 Note Do not assign values directly to the data property of a shared object for ex...

Page 589: ...ined when this script is first run if myText text undefined myText text changedListener new Object changedListener onChanged function changedField my_so data myTextSaved changedField text inputText te...

Page 590: ...ble to shared objects To allow space for the shared object to expand when it is saved in the future which avoids return values of pending you can pass a value for minimumDiskSpace When the Flash Lite...

Page 591: ...vailability ActionScript 1 0 Flash Lite 2 0 Parameters name String A string that represents the name of the object The name can include forward slashes for example work addresses is a valid name Space...

Page 592: ...umeric value that specifies the total number of bytes the movie is allowed to store on the device This is also the size available to all content that is loaded dynamically through loadMovie Example Th...

Page 593: ...erName currentUserName var soSize Number my_so getSize trace soSize onStatus SharedObject onStatus handler onStatus function infoObject Object Invoked every time an error warning or informational note...

Page 594: ...Array new Array 101 346 483 var currentUserIsAdmin Boolean true var currentUserName String Ramona var my_so SharedObject SharedObject getLocal superfoo my_so data itemNumbers items_array my_so data a...

Page 595: ...oveListener objectName String Removes any listeners that were added using the addListener method Availability ActionScript 2 0 Flash Lite 2 0 Parameters objectName String A string that represents the...

Page 596: ...lliseconds a sound has been playing constructor Object constructor property __proto__ Object __proto__ property prototype Object prototype property __resolve Object __resolve property Event Descriptio...

Page 597: ...the sound volume level as an integer from 0 to 100 where 0 is off and 100 is full volume loadSound url String isStreaming Boolean Void Loads an MP3 file into a Sound object setPan value Number Void D...

Page 598: ...kage Properties dialog box Example The following example attaches the sound logoff_id to my_sound A sound in the library has the linkage identifier logoff_id var my_sound Sound new Sound my_sound atta...

Page 599: ...loading progress When the music starts and completes loading information displays in the Output panel When the music starts and completes loading information writes to the log file Add the following A...

Page 600: ...r 100 my_sound function updateProgressBar the_sound Sound Void var pos Number Math round the_sound position the_sound duration 100 pb bar_mc _xscale pos pb vBar_mc _x pb bar_mc _width pb pos_txt text...

Page 601: ...my_sound Sound new Sound my_sound onLoad function success Boolean if success this start message_txt text Finished loading my_sound onSoundComplete function message_txt text Clearing interval clearInte...

Page 602: ...ts the left and right channels equally The pan setting controls the left right balance of the current and future sounds in a SWF file This method is cumulative with setVolume or setTransform Note Flas...

Page 603: ...pecific to a host device are not supported Availability ActionScript 1 0 Flash Lite 2 0 Returns Object An object with properties that contain the channel percentage values for the specified sound obje...

Page 604: ...l knob_ll onPress pressKnob knob_ll onRelease releaseKnob knob_ll onReleaseOutside releaseKnob knob_lr top knob_lr _y knob_lr bottom knob_lr _y 100 knob_lr left knob_lr _x knob_lr right knob_lr _x kno...

Page 605: ...ansform ll ll_num lr lr_num rl rl_num rr rr_num transform_mc transform_txt htmlText textformat tabStops 0 30 60 90 transform_mc transform_txt htmlText ll_num t lr_num t rl_num t rr_num transform_mc tr...

Page 606: ...ob_mc _x knob_mc right knob_mc left 100 knob_mc top knob_mc _y knob_mc bottom knob_mc _y knob_mc _x my_sound getVolume with knob_mc lineStyle 0 0x000000 beginFill 0xCCCCCC moveTo 0 0 lineTo 4 0 lineTo...

Page 607: ...specifically 2 3 and 2 4 The following table lists the standard ID3 2 0 tags and the type of content the tags represent you query them in the format my_sound id3 COMM my_sound id3 TIME and so on MP3...

Page 608: ...TPE3 Conductor performer refinement TPE4 Interpreted remixed or otherwise modified by TPOS Part of a set TPUB Publisher TRCK Track number position in set TRDA Recording dates TRSN Internet radio stati...

Page 609: ...onScript Sound class and respond to all methods and properties of this class Streaming sounds play while they are downloading Playback begins when sufficient data is received to start the decompressor...

Page 610: ...mp3 to an instance of the DataGrid component Add a DataGrid with the instance name id3_dg to your document and add the following ActionScript to your FLA or AS file import mx controls gridclasses Data...

Page 611: ...lse otherwise Example The following example creates a new Sound object and loads a sound Loading the sound is handled by the onLoad handler which allows you to start the song after it is successfully...

Page 612: ...Sound mySoundID my_sound onSoundComplete function trace mySoundID completed my_sound start Usage 2 The following example uses a named function function callback1 trace mySoundID completed var my_sound...

Page 613: ...nce for a sound The range of valid values is 100 to 100 where 100 uses only the left channel 100 uses only the right channel and 0 balances the sound evenly between the two channels Example For a samp...

Page 614: ...ker 0 100 rr A percentage value that specifies how much of the right input to play in the right speaker 0 100 rl A percentage value that specifies how much of the left input to play in the right speak...

Page 615: ...bjectMono object has the following parameters var mySoundTransformObjectMono Object new Object mySoundTransformObjectMono ll 50 mySoundTransformObjectMono lr 50 mySoundTransformObjectMono rr 50 mySoun...

Page 616: ...al The movie clip instance on which the Sound object operates Example The following example creates a new Sound object called global_sound The second line calls setVolume and adjusts the volume on all...

Page 617: ...cessfully loaded Then the sound uses the start method to start playing Create a new FLA file and add the following ActionScript to your FLA or ActionScript file For this example to work you must have...

Page 618: ...your FLA or AS file var my_sound Sound new Sound my_sound loadSound song1 mp3 true stop_btn onRelease function trace sound stopped my_sound stop play_btn onRelease function trace sound started my_sou...

Page 619: ...__proto__ property prototype Object prototype property __resolve Object __resolve property Event Description onResize function Invoked when Stage scaleMode is set to noScale and the SWF file is resiz...

Page 620: ...his example creates a new listener object called stageListener It then uses stageListener to call onResize and define a function that will be called when onResize is triggered Finally the code adds th...

Page 621: ...ew Object cbListener change function evt Object var align String evt target selectedItem Stage align align stageAlign_cb addEventListener change cbListener Stage scaleMode noScale Select different ali...

Page 622: ...also align Stage align property scaleMode Stage scaleMode property width Stage width property onResize Stage onResize event listener onResize function Invoked when Stage scaleMode is set to noScale an...

Page 623: ...Add the following ActionScript to Frame 1 of the Timeline this createTextField stageSize_txt this getNextHighestDepth 10 10 100 22 stageSize_txt autoSize true stageSize_txt border true var stageListe...

Page 624: ...e application exactFit makes the entire Flash content visible in the specified area without trying to preserve the original aspect ratio Distortion can occur noScale makes the size of the Flash conten...

Page 625: ...presents the width of the SWF file as set at author time in the Document Properties dialog box This means that the value of width will stay constant as you resize the player window Availability Action...

Page 626: ...ctionScript interpreter automatically converts it to a temporary String object calls the method and then discards the temporary String object You can also use the String length property with a string...

Page 627: ...ising the characters represented by the Unicode values in the parameters indexOf value String startIndex Number Number Searches the string and returns the position of the first occurrence of value fou...

Page 628: ...ber end Number String Returns a string comprising the characters between the points specified by the start and end parameters toLowerCase String Returns a copy of the String object with all uppercase...

Page 629: ...charCodeAt index Number Number Returns a 16 bit integer from 0 to 65535 that represents the character specified by index If index is not a number from 0 to string length 1 NaN is returned This method...

Page 630: ...ings and combines them using String concat var stringA String Hello var stringB String World var combinedAB String stringA concat stringB trace combinedAB output Hello World fromCharCode String fromCh...

Page 631: ...for startIndex Number optional An integer specifying the starting index of the search Returns Number The position of the first occurrence of the specified substring or 1 Example The following examples...

Page 632: ...artIndex Number optional An integer specifying the starting point from which to search for value Returns Number The position of the last occurrence of the specified substring or 1 Example The followin...

Page 633: ...ode checks the characters within a string and if the string contains the character true displays in the Output panel If it does not contain the character then false displays in the Output panel functi...

Page 634: ...by the end parameter is not included in the extracted string If this parameter is omitted String length is used If end is a negative number the ending point is determined by counting back from the en...

Page 635: ...ials Samples ActionScript See also substr String substr method substring String substring method split String split method public split delimiter String limit Number Array Splits a String object into...

Page 636: ...f you use an empty string for the delimiter parameter each character in the string is placed as an element in the array var my_str String new String Joe var my_array Array my_str split for var i 0 i m...

Page 637: ...ers in a string from the index specified in the start parameter through the number of characters specified in the length parameter The substr method does not change the string specified by my_str it r...

Page 638: ...ising the characters between the points specified by the start and end parameters If the end parameter is not specified the end of the substring is the end of the string If the value of start equals t...

Page 639: ...ples ActionScript Macintosh Macintosh HD Applications Macromedia Flash 8 Samples and Tutorials Samples ActionScript toLowerCase String toLowerCase method public toLowerCase String Returns a copy of th...

Page 640: ...her the properties are strings Availability ActionScript 1 0 Flash Lite 2 0 Returns String The string Example The following example outputs an uppercase string that lists all of an object s properties...

Page 641: ...toUpperCase trace lowerCase lowerCase output lowerCase lorem ipsum dolor trace upperCase upperCase output upperCase LOREM IPSUM DOLOR An example is also found in the Strings fla file in the ActionScr...

Page 642: ...s with shared objects and the clipboard Additional properties and methods are in specific classes within the System package the capabilities class see System capabilities and the security class see Sy...

Page 643: ...dary error message handler If an instance of the SharedObject class passes an information object with a level property of error but you did not define an onStatus function for that particular instance...

Page 644: ...the traditional code page of the operating system running the player Text that you load as an external file using the loadVariables or getURL statements or the LoadVars class or XML class must be enc...

Page 645: ...ulate it with ActionScript TextField instance names are displayed in the Movie Explorer and in the Insert Target Path dialog box in the Actions panel To create a text field dynamically you do not use...

Page 646: ...oolean A Boolean value that specifies whether extra white space spaces line breaks and so on in an HTML text field should be removed when the field is rendered in a browser embedFonts Boolean A Boolea...

Page 647: ...field in degrees from its original orientation scroll Number Defines the vertical position of text in a text field selectable Boolean A Boolean value that indicates whether the text field is selectabl...

Page 648: ...lip _xmouse Number read only Returns the x coordinate of the mouse position relative to the text field _xscale Number Determines the horizontal scale of the text field as applied from the registration...

Page 649: ...eceive TextField event notifications getDepth Number Returns the depth of a text field getNewTextFormat TextFormat Returns a TextFormat object containing a copy of the text field s text format object...

Page 650: ...at is passed to the onScroller event handler The parameter is then used in a trace statement to send the instance name of the text field to the Output panel The parameter is then used in a trace metho...

Page 651: ...ce textfield_txt _name changed var txtListener Object new Object txtListener onChanged function textfield_txt TextField trace textfield_txt _name changed and notified myListener my_txt addListener txt...

Page 652: ...none The values of autoSize and TextField wordWrap determine whether a text field expands or contracts to the left side right side or bottom side The default value for each of these properties is fals...

Page 653: ...ent settings for autoSize this createTextField left_txt 997 10 10 70 30 this createTextField center_txt 998 10 50 70 30 this createTextField right_txt 999 10 100 70 30 this createTextField true_txt 10...

Page 654: ...the keyboard is pressed this createTextField my_txt this getNextHighestDepth 10 10 320 240 my_txt border true my_txt text Lorum ipsum my_txt backgroundColor 0xFF0000 var keyListener Object new Object...

Page 655: ...is 0x000000 black This property may be retrieved or set even if there is currently no border Availability ActionScript 1 0 Flash Lite 2 0 Example The following example creates a text field called my_t...

Page 656: ...hexadecimal color system uses six digits to represent color values Each digit has sixteen possible values or characters The characters range from 0 to 9 and then A to F Black is represented by 000000...

Page 657: ...ap true second_txt condenseWhite true second_txt border true second_txt htmlText my_str See also html TextField html property embedFonts TextField embedFonts property public embedFonts Boolean A Boole...

Page 658: ...ordWrap true my_txt embedFonts true my_txt text Hello world my_txt setTextFormat my_fmt my_txt _rotation 45 getDepth TextField getDepth method public getDepth Number Returns the depth of a text field...

Page 659: ...y_fmt TextFormat my_txt getNewTextFormat trace TextFormat has the following properties for var prop in my_fmt trace prop my_fmt prop getTextFormat TextField getTextFormat method public getTextFormat b...

Page 660: ...endIndex the TextFormat object returned is for the entire TextField endIndex Number optional An integer that specifies the end position of a span of text If you specify beginIndex but do not specify e...

Page 661: ...pecify 0 low quality to prevent anti aliasing Availability ActionScript 1 0 Flash Lite 2 0 See also _quality TextField _quality property hscroll TextField hscroll property public hscroll Number Indica...

Page 662: ...xt multiline false my_txt wordWrap false my_txt text Lorem ipsum dolor sit amet consectetuer adipiscing scrollLeft_btn onRelease function my_txt hscroll 10 scroll_txt text my_txt hscroll of my_txt max...

Page 663: ...text property You can indicate that a text field is an HTML text field in the Property inspector or by setting the text field s html property to true Availability ActionScript 1 0 Flash Lite 2 0 Exam...

Page 664: ...xChars allows the maxChars property indicates only how much text a user can enter If the value of this property is null there is no limit on the amount of text a user can enter Availability ActionScri...

Page 665: ...HighestDepth 10 30 320 240 my_txt multiline true my_txt wordWrap true for var i 0 i 10 i my_txt text Lorem ipsum dolor sit amet consectetuer adipiscing elit sed diam nonummy nibh euismod tincidunt ut...

Page 666: ...he Stage Add the following ActionScript to your FLA or ActionScript file which dynamically creates two text fields at runtime and displays their depths in the Output panel this createTextField first_m...

Page 667: ...lts from user interaction for example when the user is typing something on the keyboard changing something in the text field using the mouse or selecting a menu item Programmatic changes to the text f...

Page 668: ...handler listener invoked when one of the text field scroll properties changes A reference to the text field instance is passed as a parameter to the onScroller handler You can capture this data by pu...

Page 669: ...ollUp_btn and scrollDown_btn to scroll the contents of the text field When the onScroller event handler is called a trace statement is used to display information in the Output panel Create two button...

Page 670: ...d object oldFocus contains a null value Availability ActionScript 1 0 Flash Lite 2 0 Parameters oldFocus Object The object to lose focus Example See the example for TextField onKillFocus See also onKi...

Page 671: ...following information is displayed in the Output panel The following information writes to the log file first_txt s _parent is _level0 second_txt s _parent is _level0 holder_mc See also _parent Butto...

Page 672: ...ile Device fonts are always aliased and therefore are unaffected by the _quality property Note Although you can specify this property for a TextField object it is actually a global property and you ca...

Page 673: ...listener list the method returns a value of false Example The following example creates an input text field called my_txt When the user types into the field information about the number of characters...

Page 674: ...ash Lite 2 0 Example The following example creates a text field that you can remove from the Stage when you click the remove_btn instance Create a button and call it remove_btn and then add the follow...

Page 675: ...t this getNextHighestDepth 10 10 320 22 my_txt autoSize true my_txt text dog house net var symbol String var symbolPos Number my_txt text indexOf symbol if symbolPos 1 my_txt replaceText 0 symbolPos b...

Page 676: ...Clip _rotation property TextFormat scroll TextField scroll property public scroll Number Defines the vertical position of text in a text field The scroll property is useful for directing users to a sp...

Page 677: ...scroll of my_txt maxscroll See also hscroll TextField hscroll property maxscroll TextField maxscroll property selectable TextField selectable property public selectable Boolean A Boolean value that i...

Page 678: ...Sets the default new text format of a text field The default new text format is the new text format used for newly inserted text such as text entered by a user When text is inserted the newly inserte...

Page 679: ...r formatting settings such as font name font size bold and italic For paragraphs the first character of the paragraph is examined for the paragraph formatting settings for the entire paragraph Example...

Page 680: ...formation Example The following example sets the text format for two different strings of text The setTextFormat method is called and applied to the my_txt text field var format1_fmt TextFormat new Te...

Page 681: ...tionScript 1 0 Flash Lite 2 0 See also _soundbuftime property styleSheet TextField styleSheet property public styleSheet StyleSheet Attaches a style sheet to the text field For information on creating...

Page 682: ...t onLoad span callback handler to determine when the file has finished loading span class important The CSS file must reside in exactly the same domain as the SWF file that is loading it span For more...

Page 683: ...00 font family Arial Helvetica sans serif font size 18px font weight bold display block tabEnabled TextField tabEnabled property public tabEnabled Boolean Specifies whether the text field is included...

Page 684: ...ed false See also tabEnabled Button tabEnabled property tabEnabled MovieClip tabEnabled property tabIndex TextField tabIndex property public tabIndex Number Lets you customize the tab ordering of obje...

Page 685: ...s getNextHighestDepth 10 10 100 22 one_txt border true one_txt type input this createTextField two_txt this getNextHighestDepth 10 40 100 22 two_txt border true two_txt type input this createTextField...

Page 686: ...eates an HTML text field called my_txt and assigns an HTML formatted string of text to the field When you trace the htmlText property the Output panel displays the HTML formatted stringthe HTML format...

Page 687: ...Script 1 0 Flash Lite 2 0 Example The following example creates a text field and assigns a string of text to the field A trace statement is used to display the text height and width in the Output pane...

Page 688: ...nput text field Availability ActionScript 1 0 ActionScript 1 0 Flash Lite 2 0 Example The following example creates two text fields username_txt and password_txt Text is entered into both text fields...

Page 689: ...ample the URL of the SWF file you are testing and the file called best_flash_ever swf are displayed in the Output panel When you test this example the URL of the SWF file you are testing and the file...

Page 690: ...border true my_txt type input visible_btn onRelease function my_txt _visible my_txt _visible See also _visible Button _visible property _visible MovieClip _visible property _width TextField _width pr...

Page 691: ...extField _height property wordWrap TextField wordWrap property public wordWrap Boolean A Boolean value that indicates if the text field has word wrap If the value of wordWrap is true the text field ha...

Page 692: ...ing example creates a text field wherever you click the mouse When it creates a text field that field displays the current x and y coordinates of the text field this createTextField coords_txt this ge...

Page 693: ..._txt border true var mouseListener Object new Object mouseListener onMouseMove function mouse_txt text MOUSE X Math round _xmouse tY Math round _ymouse textfield_txt text TEXTFIELD X Math round my_txt...

Page 694: ...t has transformations the text field is in the local coordinate system of the enclosing movie clip Thus for a movie clip rotated 90 degrees counterclockwise the enclosed text field inherits a coordina...

Page 695: ...e for TextField _xscale See also _x TextField _x property _xscale TextField _xscale property _y TextField _y property TextFormat Object TextFormat public class TextFormat extends Object The TextFormat...

Page 696: ...to the first character in the paragraph italic Boolean A Boolean value that indicates whether text in this text format is italicized leading Number An integer that represents the amount of vertical sp...

Page 697: ...rty Signature Description TextFormat font String size Number color Number bold Boolean italic Boolean underline Boolean url String target String align String leftMargin Number rightMargin Number inden...

Page 698: ...erty public blockIndent Number A number that indicates the block indentation in points Block indentation is applied to an entire block of text that is to all lines of the text In contrast normal inden...

Page 699: ...xtFormat new TextFormat my_fmt bold true this createTextField my_txt 1 100 100 300 100 my_txt multiline true my_txt wordWrap true my_txt border true my_txt text This is my text field object text my_tx...

Page 700: ...ewline my_txt setTextFormat my_fmt color TextFormat color property public color Number A number that indicates the color of text The number contains three 8 bit RGB components for example 0xFF0000 is...

Page 701: ...ext in the format specified by my_fmt The text string is treated as plain text not HTML The method returns an object with six properties ascent descent width height textFieldHeight and textFieldWidth...

Page 702: ...ont size and leading The default value for leading is 2 Availability ActionScript 1 0 Flash Lite 2 0 The width parameter is supported in Flash Player 7 Parameters text String A string width Number opt...

Page 703: ...l wide text field that s high enough to display a string with the specified formatting Create a TextFormat object var my_fmt TextFormat new TextFormat Specify formatting properties for the TextFormat...

Page 704: ...ext field object text mytext setTextFormat myformat See also blockIndent TextFormat blockIndent property italic TextFormat italic property public italic Boolean A Boolean value that indicates whether...

Page 705: ...y_txt wordWrap true my_txt border true my_txt text This is my first text field object text my_txt setTextFormat my_fmt leftMargin TextFormat leftMargin property public leftMargin Number The left margi...

Page 706: ...20 mytext text this is my first text field object text mytext setTextFormat myformat size TextFormat size property public size Number The point size of text in this text format The default value is nu...

Page 707: ...xt A tB tC tD t is the tab stop character mytext setTextFormat myformat this createTextField mytext2 2 100 220 400 100 mytext2 border true var myformat2 TextFormat new TextFormat myformat2 tabStops 75...

Page 708: ...er indent Number leading Number Creates a TextFormat object with the specified properties You can then change the properties of the TextFormat object to change the formatting of text fields Any parame...

Page 709: ...rom the left margin to the first character in the paragraph leading Number optional A number that indicates the amount of leading vertical space between lines Example The following example creates a T...

Page 710: ...00 200 100 mytext multiline true mytext wordWrap true mytext border true var myformat TextFormat new TextFormat myformat underline true mytext text This is my first text field object text mytext setTe...

Page 711: ...e or stream it by using the Video object and assigning either a NetStream object or Camera object as the source of the video information However the player for Flash Lite 2 0 does not support the NetS...

Page 712: ...ciated with this Video object and clears the video area onscreen pause Void Stops playback of the video and continues to render the current frame onscreen play Boolean Calling this method opens a vide...

Page 713: ...bject Callback handler that can be invoked by the device to indicate status or error conditions Availability ActionScript 2 0 Flash Lite 2 0 Parameters infoObject Object The infoObject parameter has t...

Page 714: ...ser clicks the close_btn instance video1 is the name of a Video object on Stage video1 pause See also play Video play method play Video play method public play Boolean Calling this method opens a vide...

Page 715: ...ing in a Video object called video1 video1 resume See also pause Video pause method stop Video stop method public stop Void Stops playback of the video and continues to render the current frame onscre...

Page 716: ...deName nodeType nodeValue parentNode previousSibling removeNode toString In earlier versions of the ActionScript Language Reference the methods and properties above were documented in the XML class Th...

Page 717: ...ype String The MIME content type that is sent to the server when you call the XML send or XML sendAndLoad method docTypeDecl String Specifies information about the XML document s DOCTYPE declaration i...

Page 718: ...ignature Description XML text String Creates a new XML object Modifiers Signature Description addRequestHeader header Obje ct headerValue String Void Adds or changes HTTP request headers such as Conte...

Page 719: ...ends it to the specified URL using the POST method in a browser sendAndLoad url String resultXML XML Void Encodes the specified XML object into an XML document sends it to the specified URL using the...

Page 720: ...s the value associated with header Example The following example adds a custom HTTP header named SOAPAction with a value of Foo to an XML object named my_xml my_xml addRequestHeader SOAPAction Foo The...

Page 721: ...w flash mx com mm highscore cfm _blank Press F12 to test this example in a browser See also send XML send method sendAndLoad XML sendAndLoad method createElement XML createElement method public create...

Page 722: ...e doc output element1 element2 element3 element1 See also createTextNode XML createTextNode method createTextNode XML createTextNode method public createTextNode value String XMLNode Creates a new XML...

Page 723: ...he XML tree element2 appendChild textNode1 element3 appendChild textNode2 trace doc output with line breaks added between tags element1 element2 textNode1 String value element2 element3 textNode2 Stri...

Page 724: ...d streamed for the XML document You can compare the value of getBytesLoaded with the value of getBytesTotal to determine what percentage of an XML document has loaded Availability ActionScript 1 0 Fla...

Page 725: ...rogress 100 doc See also getBytesTotal XML getBytesTotal method getBytesTotal XML getBytesTotal method public getBytesTotal Number Returns the size in bytes of the XML document Availability ActionScri...

Page 726: ...e kitchen bathroom linoleum bathroom foyer foyer house Create a new Flash document named flooring fla and save it to the same directory as the XML file Place the following code into the main Timeline...

Page 727: ...n SWF files running in a version of the player earlier than Flash Player 7 the url parameter must be in the same superdomain as the SWF file that issues this call A superdomain is derived by removing...

Page 728: ...o parameter null is passed true otherwise Use the onLoad event handler to check the success of a loaded XML document Example The following simple example uses the XML load method create a new XML obje...

Page 729: ...m problems products xml Information displays in the Output panel when the onLoad handler invokes If the call completes successfully true displays for the loaded status in the Output panel success true...

Page 730: ...ad handler onLoad XML onLoad handler onLoad function success Boolean Invoked by Flash Player when an XML document is received from the server If the XML document is received successfully the success p...

Page 731: ...yLoginReply_xml firstChild nodeName packet myLoginReply_xml firstChild attributes success true gotoAndStop loggedIn else gotoAndStop loginFailed else gotoAndStop connectionFailed my_xml sendAndLoad ht...

Page 732: ...String method String Boolean Encodes the specified XML object into an XML document and sends it to the specified URL using the POST method in a browser The Flash test environment only uses the GET me...

Page 733: ...in the same superdomain as the SWF file that is issuing this call A superdomain is derived by removing the left most component of a file s URL For example a SWF file at www someDomain com can load dat...

Page 734: ...ent that contains the user s name and password and uses an onLoad handler to process the reply from the server var login_str String login username username_txt text password password_txt text var my_x...

Page 735: ...t matched with an end tag 10 An end tag was encountered without a matching start tag Availability ActionScript 1 0 Flash Lite 2 0 Example The following example loads an XML packet into a SWF file A st...

Page 736: ...ed without a matching start tag break default errorMessage An unknown error has occurred break trace status my_xml status errorMessage else trace Unable to load parse XML status my_xml status my_xml l...

Page 737: ...entation of the XML declaration not an XML node object If no XML declaration is encountered during a parse operation the property is set to undefined XML The XML toString method outputs the contents o...

Page 738: ...ine my_xml docTypeDecl newline newline my_txt text packet newline my_xml toString newline newline else my_txt text Unable to load remote XML newline newline my_txt text loaded in elapsedTime ms my_xml...

Page 739: ...d only An XMLNode value that references the next sibling in the parent node s child list nodeName String A string representing the node name of the XML object nodeType Number read only A nodeType valu...

Page 740: ...s the specified node to the XML object s child list cloneNode deep Boolean XMLNode Constructs and returns a new XML node of the same type name value and attributes as the specified XML object hasChild...

Page 741: ...new node and appends it to the root node of the XML document doc1 var doc1 XML new XML var doc2 XML new XML create a root node and add it to doc1 var rootnode XMLNode doc1 createElement root doc1 appe...

Page 742: ...create a tag called mytag with an attribute called name with value Val var doc XML new XML mytag name Val item mytag assign the value of the name attribute to variable y var y String doc firstChild at...

Page 743: ...ocument tree doc appendChild rootNode add each of the child nodes as children of rootNode rootNode appendChild oldest rootNode appendChild middle rootNode appendChild youngest create an array and use...

Page 744: ...0 Flash Lite 2 0 Parameters deep Boolean A Boolean value if set to true the children of the specified XML object will be recursively cloned Returns XMLNode An XMLNode Object Example The following exam...

Page 745: ...race rootNode output with line breaks added rootNode oldest middle middle youngest rootNode oldest middle middle youngest rootNode rootNode firstChild XMLNode firstChild property public firstChild XML...

Page 746: ...h the child nodes of rootNode for var aNode XMLNode rootNode firstChild aNode null aNode aNode nextSibling trace aNode output oldest middle youngest The following example is from the XML_languagePicke...

Page 747: ...value of the node Add the following ActionScript to your FLA or AS file var my_xml XML new XML hankrudolph if my_xml firstChild hasChildNodes use firstChild to iterate through the child nodes of rootN...

Page 748: ...d list The XML lastChild property is null if the node does not have children This property cannot be used to manipulate child nodes use the appendChild insertBefore and removeNode methods to manipulat...

Page 749: ...middle oldest The following example creates a new XML packet and uses the XML lastChild property to iterate through the child nodes of the root node create a new XML document var doc XML new XML var r...

Page 750: ...how you can use the XML nextSibling property to loop through an XML node s child nodes for var aNode XMLNode rootNode firstChild aNode null aNode aNode nextSibling trace aNode See also firstChild XMLN...

Page 751: ...trace myTextNode nodeName output rootNode null The following example creates a new XML packet If the root node has child nodes the code loops over each child node to display the name and value of the...

Page 752: ...E Availability ActionScript 1 0 Flash Lite 2 0 Example The following example creates an element node and a text node and checks the node type of each create an XML document var doc XML new XML create...

Page 753: ...ML object is an XML element nodeType is 1 nodeValue is null and read only Availability ActionScript 1 0 Flash Lite 2 0 Example The following example creates an element node and a text node and checks...

Page 754: ...irstChild trace trace using firstChild nodeValue for var i 0 i my_xml firstChild childNodes length i trace t my_xml firstChild childNodes i firstChild nodeValue The following information is displayed...

Page 755: ...pendChild method insertBefore XMLNode insertBefore method removeNode XMLNode removeNode method XML previousSibling XMLNode previousSibling property public previousSibling XMLNode read only An XMLNode...

Page 756: ...d XML object and its descendant nodes var xml_str String state name California city San Francisco city state var my_xml XML new XML xml_str var cityNode XMLNode my_xml firstChild firstChild trace befo...

Page 757: ...ility ActionScript 1 0 Flash Lite 2 0 Returns String String Example The following code uses the toString method to convert an XMLNode object to a String and then uses the toUpperCase method of the Str...

Page 758: ...lass Object Method summary Methods inherited from class Object constructor Object constructor property __proto__ Object __proto__ property prototype Object prototype property __resolve Object __resolv...

Page 759: ...get method public static get name String String Retrieves the value of the specified property of the current XMLUI dialog Availability ActionScript 1 0 Flash Lite 2 0 Parameters name String The name...

Page 760: ...760 ActionScript classes...

Page 761: ...function statement chr number Number String Deprecated since Flash Player 5 This function was deprecated in favor of String fromCharCode ifFrameLoaded scene String frame Object Deprecated since Flash...

Page 762: ...ion was deprecated in favor of String substr ord character String Number Deprecated since Flash Player 5 This function was deprecated in favor of the methods and properties of the String class random...

Page 763: ...y was deprecated in favor of _quality maxscroll Deprecated since Flash Player 5 This property was deprecated in favor of TextField maxscroll scroll Deprecated since Flash Player 5 This property was de...

Page 764: ...an or equal to strings Deprecated since Flash Player 5 This operator was deprecated in Flash 5 in favor of the less than or equal to operator lt less than strings Deprecated since Flash Player 5 This...

Page 765: ...ield getFontList TextField replaceSel Video attachVideo Video clear Button blendMode Button cacheAsBitmap Button filters Button menu Button useHandCursor System capabilities language System capabiliti...

Page 766: ...rted Global Functions Unsupported Event Handlers Unsupported fscommands asfunction MMExecute print printAsBitmap printAsBitmapNum printNum updateAfterEvent onUpdate Mouse onMouseWheel allowscale exec...

Page 767: ...rator 145 strict equality operator 171 greater than operator 147 greater than or equal to operator 148 bitwise right shift operator 132 bitwise right shift and assignment operator 133 bitwise unsigned...

Page 768: ...er property 246 length property 247 arguments class 245 Array Array constructor 251 CASEINSENSITIVE property 252 concat method 252 DESCENDING property 254 join method 254 length property 255 NUMERIC p...

Page 769: ...asAudioEncoder property 306 hasCMIDI property 306 hasCompoundSound property 306 hasDataLoading property 307 hasEmail property 307 hasEmbeddedVideo property 308 hasMappableSoftKeys property 308 hasMFI...

Page 770: ...eTo method 457 D data property 587 Date Date constructor 330 getDate method 331 getDay method 332 getFullYear method 332 getHours method 333 getLocaleLongDate method 334 getLocaleShortDate method 334...

Page 771: ...45 floor method 419 flush method 589 focusEnabled property 464 font property 701 for statement 196 for in statement 197 fromCharCode method 630 fscommand function 46 fscommand2 Commands 225 fscommand2...

Page 772: ...es 92 globalToLocal method 474 gotoAndPlay function 51 gotoAndPlay method 477 gotoAndStop function 52 gotoAndStop method 478 gt greater than strings operator 148 H has4WayKeyAS property 305 hasAccessi...

Page 773: ...language property 315 lastChild property 748 lastIndexOf method 632 le less than or equal to strings operator 157 leading property 705 LEFT property 382 leftMargin property 705 length function 56 len...

Page 774: ...ring function 65 message property 359 MIMETypes property 317 min method 422 MIN_VALUE property 546 Mouse addListener method 432 removeListener method 437 Mouse class 430 onMouseDown event 433 onMouseM...

Page 775: ...useUp event 502 onPress event 502 onRelease event 502 onReleaseOutside event 503 onRollOut event 503 onRollOver event 504 onSetFocus event 504 onUnload event 505 MovieClipLoader addListener method 530...

Page 776: ...3 502 onRelease event 283 502 onReleaseOutside event 284 503 onResize event 622 onRollOut event 284 503 onRollOver event 285 504 onScroller event 668 onSetFocus event 285 504 578 670 onSoundComplete e...

Page 777: ...346 setMinutes method 347 setMonth method 347 setNewTextFormat method 678 setPan method 613 setProperty function 81 setRGB method 322 setSeconds method 348 SetSoftKeys command 241 setTextFormat metho...

Page 778: ...nction 84 stopDrag method 514 StopVibrate command 243 String charAt method 628 charCodeAt method 629 concat method 630 fromCharCode method 630 indexOf method 631 lastIndexOf method 632 length property...

Page 779: ...operty 686 textColor property 687 textHeight property 687 textWidth property 688 type property 688 variable property 689 wordWrap property 691 TextField class 645 onChanged event 666 onKillFocus event...

Page 780: ...od 722 docTypeDecl property 723 getBytesLoaded method 724 getBytesTotal method 725 ignoreWhite property 725 load method 727 loaded property 729 parseXML method 731 send method 732 sendAndLoad method 7...

Reviews: