background image

ActionScript Reference Guide

Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT

Page 1: ...ActionScript Reference Guide...

Page 2: ...cromedia provides these links only as a convenience and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third party sites Speec...

Page 3: ...w security model and legacy SWF files 14 Porting existing scripts to Flash Player 7 15 ActionScript editor changes 21 Debugging changes 22 New object oriented programming model 22 CHAPTER 2 ActionScri...

Page 4: ...n 91 Controlling SWF file playback 92 Creating interactivity and visual effects 94 Deconstructing a sample script 108 PART III Working with Objects and Classes CHAPTER 6 Using the Built In Classes 113...

Page 5: ...ce and class members 165 Creating and using interfaces 167 Understanding the classpath 169 Using packages 171 Importing classes 171 Implicit get set methods 172 Creating dynamic classes 173 How classe...

Page 6: ...Function class 389 Key class 408 LoadVars class 425 LocalConnection class 434 Math class 445 Microphone class 461 Mouse class 476 MovieClip class 482 MovieClipLoader class 544 NetConnection class 555...

Page 7: ...dard numbers 0 to 9 789 Keys on the numeric keypad 790 Function keys 791 Other keys 792 APPENDIX D Writing Scripts for Earlier Versions of Flash Player 795 About targeting older versions of Flash Play...

Page 8: ...8 Contents...

Page 9: ...build more complexity as you go along System requirements ActionScript does not have any system requirements in addition to Flash MX 2004 or Flash MX Professional 2004 However the documentation assume...

Page 10: ...applications Compile time is the time at which you publish export test or debug your document Runtime is the time at which your script is running in Flash Player ActionScript terms such as method and...

Page 11: ...have used ActionScript before be sure to review this information carefully If you are new to ActionScript read Chapters 2 and 3 to get a good foundation for understanding ActionScript terminology and...

Page 12: ......

Page 13: ...in your scripts you must target Flash Player 7 the default when you publish your documents The Array sort and Array sortOn methods let you add parameters to specify additional sorting options such as...

Page 14: ...eWhite property lets you remove extra white space from HTML text fields that are rendered in a browser The TextField mouseWheelEnabled property lets you specify whether a text field s contents should...

Page 15: ...ndition Also Flash Player 7 implements a number of changes that affect how one SWF file can access another SWF file how external data can be loaded and how local settings and data such as privacy sett...

Page 16: ...nterpreted as being the same variable Evaluating undefined in a numeric context returns NaN myCount 1 trace myCount NaN Evaluating undefined in a numeric context returns 0 myCount 1 trace myCount 1 Wh...

Page 17: ...main access between SWF files When you develop a series of SWF files that communicate with each other for example when using loadMovie MovieClip loadMovie MovieClipLoader LoadClip or Local Connection...

Page 18: ...on sendingDomain return sendingDomain www someSite com sendingDomain store someSite com You might also have to add statements like these to your files if you aren t currently using them For example if...

Page 19: ...hed for Flash Player 7 or Flash Player 6 you must implement either one of the allowDomain statements see Cross domain and subdomain access between SWF files on page 17 or use the new LocalConnection a...

Page 20: ...d file using exact domain name matching as shown in the code examples earlier in this section This statement is required even if both files are in same domain If the called file is published for Flash...

Page 21: ...n the left margin selected a line of code The new way to select a line of code is to Control click Windows or Command click Macintosh Normal and expert modes no longer in Actions panel In previous ver...

Page 22: ...significant enhancement to the core ActionScript language they represent a new version of ActionScript itself ActionScript 2 0 ActionScript 2 0 is not a new language Rather it comprises a core set of...

Page 23: ...by using the import command you can import packages collections of class files in a directory by using wildcards Applications developed with ActionScript 2 0 are supported by Flash Player 6 and later...

Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...

Page 25: ...ng There are many resources that provide more information about general programming concepts and the JavaScript language The European Computers Manufacturers Association ECMA document ECMA 262 is deri...

Page 26: ...Under Editing Options do one or both of the following For Open Import select UTF 8 to open or import using Unicode encoding or select Default Encoding to open or import using the encoding form of the...

Page 27: ...n or movie clip or the user types on the keyboard Event handlers are special actions that manage events such as mouseDown or load There are two kinds of ActionScript event handlers event handler metho...

Page 28: ...hat act as methods either for objects based on built in classes or for objects based on classes that you create For example in the following code clear becomes a method of a controller object that you...

Page 29: ...with any language ActionScript has syntax rules that you must follow in order to create scripts that can compile and run correctly This section describes the elements that comprise ActionScript synta...

Page 30: ...x axis position on the Stage The expression ballMC _x refers to the _x property of the movie clip instance ballMC As another example submit is a variable set in the form movie clip which is nested ins...

Page 31: ...onth myDate getMonth on release myDate new Date currentMonth myDate getMonth Class class Circle radius class Square side Function circleArea function radius return radius radius MATH PI squareArea fun...

Page 32: ...x and punctuation on page 66 Comments Using comments to add notes to scripts is highly recommended Comments are useful for keeping track of what you intended and for passing information to other devel...

Page 33: ...pt reserves words for specific use within the language so you can t use them as identifiers such as variable function or label names The following table lists all ActionScript keywords Constants A con...

Page 34: ...and is described in the following topics String on page 34 Number on page 35 Boolean on page 35 Object on page 36 MovieClip on page 36 Null on page 36 Undefined on page 36 When you debug scripts you...

Page 35: ...re information see Numeric operators on page 45 Boolean A Boolean value is one that is either true or false ActionScript also converts the values true and false to 1 and 0 when appropriate Boolean val...

Page 36: ...ferent pieces of information for example you might need a user s name the speed of a ball the names of items in a shopping cart the number of frames loaded the user s ZIP Code or the key that was pres...

Page 37: ...on see Strict data typing on page 38 Automatic data typing In Flash you do not need to explicitly define an item as holding either a number a string or other data type Flash determines the data type o...

Page 38: ...you have a file named Student as in which you define the Student class you can specify that objects you create are of type Student var student Student new Student You can also specify that objects are...

Page 39: ...or failed casts is implemented The syntax for casting is type item where you want the compiler to behave as if the data type of item is type Casting is essentially a function call and the function cal...

Page 40: ...d type undefined undefined You can t override primitive data types such as Boolean Date and Number with a cast operator of the same name About variables A variable is a container that holds informatio...

Page 41: ...lass hello_str new String trace hello_str length returns undefined The ActionScript editor supports code hints for built in classes and for variables that are based on these classes If you want Flash...

Page 42: ...to store a user name in one context and a movie clip instance name in another because these variables would run in separate scopes there would be no conflict It s good practice to use local variables...

Page 43: ...example the variable s value will be NaN or undefined and your script might produce unintended results var squared x x trace squared NaN var x 6 In the following example the statement declaring the v...

Page 44: ...g is an example of passing by reference var myArray tom josie var newArray myArray myArray 1 jack trace newArray The above code creates an Array object called myArray that has two elements The variabl...

Page 45: ...tors to execute first For example multiplication is always performed before addition however items in parentheses take precedence over multiplication So without parentheses ActionScript performs the m...

Page 46: ...ates the two string operands For example the following statement adds Congratulations to Donna Congratulations Donna The result is Congratulations Donna If only one of the operator s operands is a str...

Page 47: ...n the operator but all bitwise operations evaluate each binary digit bit of the 32 bit integer individually to compute a new value The following table lists the ActionScript bitwise operators Equality...

Page 48: ...to the variables b c and d a b c d You can also use compound assignment operators to combine operations Compound operators perform on both operands and then assign the new value to the first operand...

Page 49: ...hat named property For example the following expressions access the same variable velocity in the movie clip rocket rocket velocity rocket velocity You can use the array access operator to dynamically...

Page 50: ...stance name For example in the following statement the _alpha property of the movie clip named star is set to 50 visibility star _alpha 50 To give a movie clip an instance name 1 Select the movie clip...

Page 51: ...ation on each function see its entry in Chapter 12 ActionScript Dictionary on page 205 Creating functions You can define functions to execute a series of statements on passed values Your functions can...

Page 52: ...s the instance name of a movie clip display and score are input text fields in the instance The following function call assigns the value JEB to the variable display and the value 45000 to the variabl...

Page 53: ...nitializes a series of global variables function initialize boat_x _global boat _x boat_y _global boat _y car_x _global car _x car_y _global car _y Calling a user defined function You can use a target...

Page 54: ...54 Chapter 2 ActionScript Basics...

Page 55: ...ript window on page 58 When using the ActionScript editor you can also check syntax for errors automatically format code and use code hints to help you complete syntax In addition the punctuation bala...

Page 56: ...while do while for in or switch statements which are briefly described in the rest of this section Checking a condition Statements that check whether a condition is true or false begin with the term...

Page 57: ...The third expression i is called the post expression and is evaluated each time after the loop runs for var i 4 i 0 i myMC duplicateMovieClip newMC i i 10 To loop through the children of a movie clip...

Page 58: ...ce code on other Frames or attach it to objects you ll have to look at only one layer to find it all To create scripts that are part of your document you enter ActionScript directly into the Actions p...

Page 59: ...on the Timeline If you double click an item in the Script navigator the script gets pinned see Managing scripts in a FLA file on page 60 There are also several buttons above the Script pane You edit...

Page 60: ...n a script 1 Position your pointer on the Timeline so the script appears in a tab at the lower left of the Script pane in the Actions panel 2 Do one of the following Click the pushpin icon to the righ...

Page 61: ...type var the word var appears in green However if you mistakenly type vae the word vae remains black providing you with an immediate clue that you made a typing error To set preferences for syntax co...

Page 62: ...f each object when you create it For example the suffixes that trigger code hinting for the Array class and the Camera class are _array and _cam respectively If you type the following code var my_arra...

Page 63: ...y MovieClip mc However Macromedia recommends using strict data typing see Strictly typing objects to trigger code hints on page 62 or suffixes see Using suffixes to trigger code hints on page 62 inste...

Page 64: ...er an element that requires parentheses such as a method name a command such as if or do while and so on The code hint appears Note If a code hint doesn t appear make sure you haven t disabled code hi...

Page 65: ...losing parenthesis if you ve already typed an open parenthesis Press Escape To manually display a code hint 1 Click in a code location where code hints can appear Here are some examples After the dot...

Page 66: ...ughly determine whether the code you wrote performs as planned you need to publish or test the file However you can do a quick check of your ActionScript code without leaving the FLA file Syntax error...

Page 67: ...look in the Preview pane After you set Auto Format Options your settings are applied automatically to code you write but not to existing code To apply your settings to existing code you must do so man...

Page 68: ...keystrokes and lets them pass through to the player For example in the authoring environment Control U opens the Preferences dialog box If your script assigns Control U to an action that underlines t...

Page 69: ...les in the Flash Debug Player you can publish your file with a debugging password As in JavaScript or HTML it s possible for users to view client side variables in ActionScript To store variables secu...

Page 70: ...one of the following commands Control Debug Movie File Export Movie File Publish Settings Publish Flash creates a debugging file with the swd extension and saves it alongside the SWF file The SWD file...

Page 71: ...the SWF file to display the context menu and select Debugger 3 In the Remote Debug dialog box select Localhost or Other Machine Select Localhost if the Debug player and the Flash authoring applicatio...

Page 72: ...e from the display list To display global variables select the _global clip in the display list 2 Click the Variables tab The display list updates automatically as the SWF file plays If a movie clip i...

Page 73: ...find the value of the variable the value is listed as Undefined The Watch list can display only variables not properties or functions Variables marked for the Watch list and variables in the Watch lis...

Page 74: ...0 The value can be a string any value surrounded by quotation marks a number or a Boolean value true or false You can t enter object or array values for example id rogue or 1 2 3 in the Debugger For m...

Page 75: ...s button above the code view Right click Windows or Control click Macintosh to display the context menu and select Breakpoint Remove Breakpoint or Remove All Breakpoints Press Control Shift B Windows...

Page 76: ...Function 8 mover 0 Step Out advances the Debugger out of a function This button works only if you are currently stopped in a user defined function it moves the yellow arrow to the line after the one w...

Page 77: ...op up menu in the upper right corner Listing a SWF file s objects In test mode the List Objects command displays the level frame object type shape movie clip or button target paths and instance names...

Page 78: ...t of variables in a SWF file 1 If your SWF file is not running in test mode select Control Test Movie 2 Select Debug List Variables A list of all the variables currently in the SWF file is displayed i...

Page 79: ...l or have specific results appear when a button is pressed or a frame is played The trace statement is similar to the JavaScript alert statement When you use the trace statement in a script you can us...

Page 80: ...80 Chapter 3 Writing and Debugging Scripts...

Page 81: ...loading over the network The first chapter in this part describes the different types of events in Macromedia Flash and discusses how to handle them in ActionScript The second chapter shows how to app...

Page 82: ......

Page 83: ...event handler methods An event handler method is a class method that is invoked when an event occurs on an instance of that class For example the Button class defines an onPress event handler that is...

Page 84: ...extField onSetFocus event handler is invoked when a text field instance gains keyboard focus This event handler receives a reference to the text field object that previously had keyboard focus For exa...

Page 85: ...rs the listener object to receive its events To use event listeners you create a listener object with a property that has the name of the event being generated by the broadcaster object You then assig...

Page 86: ...is object defines for itself an onSetFocus property to which it assigns a function The function takes two parameters a reference to the text field that lost focus and one to the text field that gained...

Page 87: ...he same movie clip instance The first executes when the movie clip first loads or appears on the Stage the second executes when the movie clip is unloaded from the Stage onClipEvent load trace I ve lo...

Page 88: ...ess onRelease and so forth as discussed in Using event handler methods on page 83 Event handler scope The scope or context of variables and commands that you declare and execute within an event handle...

Page 89: ...utton s parent Timeline But when the same handler is attached to a movie clip object then the play applies to the movie clip that bears the handler Within an event handler or event listener function d...

Page 90: ...stener method For example in the following code this refers to myClip itself onPress event handler attached to _level0 myClip myClip onPress function trace this displays _level0 myClip Within an on ha...

Page 91: ...on and then performing an action Many ActionScript commands are simple and let you create basic controls for a SWF file Other actions require some familiarity with programming languages and are intend...

Page 92: ...d of the Timeline that contains the button to Frame 10 jump_btn onRelease function gotoAndPlay 10 In the next example the MovieClip gotoAndStop method sends the Timeline of a movie clip named categori...

Page 93: ...MovieClip getURL method For example you can have a button that links to a new website or you can send Timeline variables to a CGI script for processing in the same way as you would an HTML form You ca...

Page 94: ...nge its color To create a custom pointer you design the pointer movie clip on the Stage Then in ActionScript you hide the standard pointer and track its the movement To hide the standard pointer you u...

Page 95: ...at returns the location of the mouse within its coordinate system The position is always relative to the registration point For the main Timeline _level0 the registration point is the upper left corne...

Page 96: ...ing keypresses You can use the methods of the built in Key class to detect the last key pressed by the user The Key class does not require a constructor function to use its methods you simply call the...

Page 97: ...ressed is the right left up or down arrow The event handler onEnterFrame determines the Key isDown keyCode value from the if statements Depending on the value the handler instructs Flash Player to upd...

Page 98: ...e 10 5 To create the event handler for the car movie clip that checks which arrow key left right up or down is currently pressed add the following code to the Actions panel car onEnterFrame function 6...

Page 99: ...400 _x 400 _root display_txt text Right else if Key isDown Key LEFT _x distance if _x 0 _x 0 _root display_txt text Left else if Key isDown Key UP _y distance if _y 0 _y 0 _root display_txt text Up e...

Page 100: ...Property inspector enter carColor as the instance name 3 Create a button named color chip place four instances of the button on the Stage and name them red green blue and black 4 Select Frame 1 in th...

Page 101: ...black onRelease function myColor setRGB 0x000000 8 Select Control Test Movie to change the color of the movie clip For more information about the methods of the Color class see the Color class entry i...

Page 102: ...to create sound controls like the ones shown above To attach a sound to a Timeline 1 Select File Import to import a sound 2 Select the sound in the library right click Windows or Control click Macinto...

Page 103: ...ly onRelease handlers associated with the playButton and stopButton objects start and stop the sound using the Sound start and Sound stop methods and also play and stop the speaker movie clip 8 Select...

Page 104: ...lopment Panels Actions 5 Enter the following actions on press startDrag false left top right bottom dragging true on release releaseOutside stopDrag dragging false The startDrag parameters left top ri...

Page 105: ...mine these results You can use the parameters of hitTest to specify the x and y coordinates of a hit area on the Stage or use the target path of another movie clip as a hit area When specifying x and...

Page 106: ...the collision The value true is displayed whenever the mouse is over a nontransparent pixel To perform collision detection on two movie clips 1 Drag two movie clips to the Stage and give them the ins...

Page 107: ...r beginGradientFill The clear method erases what s been drawn in the specified movie clip object For more information see MovieClip beginFill on page 489 MovieClip beginGradientFill on page 490 MovieC...

Page 108: ...let and a reset button Each of these objects is a movie clip instance There is one script in the SWF file it s attached to the bug instance as shown in the following Actions panel The Actions panel wi...

Page 109: ...is touching the outlet instance _root zapper There are two possible outcomes of the evaluation true or false onClipEvent load initx _x inity _y _root Reset onRelease function zapped false _x initx _y...

Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...

Page 111: ...ities focusing on working with movie clips and text This part also describes how to create your own classes and interfaces with ActionScript 2 0 Chapter 6 Using the Built In Classes 113 Chapter 7 Work...

Page 112: ......

Page 113: ...st of the built in ActionScript classes are specific to Macromedia Flash and Flash Player object model To understand the distinction between core ActionScript classes and those specific to Flash consi...

Page 114: ...s the value of a property in an object Put the name of the object on the left side of the dot and put the name of the property on the right side For example in the following statement myObject is the...

Page 115: ...pt Dictionary on page 205 Error The Error class contains information about errors that occur in your scripts You typically use the throw statement to generate an error condition which you can then han...

Page 116: ...ethods properties and event handlers for working with buttons See the Button class entry in Chapter 12 ActionScript Dictionary on page 205 Color The Color class lets you get and set RGB color values f...

Page 117: ...ction spans and text field insertion points See the Selection class entry in Chapter 12 ActionScript Dictionary on page 205 SharedObject The SharedObject class provides local data storage on the clien...

Page 118: ...sed with Flash Communication Server MX your SWF file can broadcast and record audio from a user s microphone See the Microphone class entry in Chapter 12 ActionScript Dictionary on page 205 NetConnect...

Page 119: ...L class on page 181 and the XML class entry in Chapter 12 ActionScript Dictionary on page 205 XMLNode The XMLNode class represents a single node in an XML document tree It is the XML class s superclas...

Page 120: ...120 Chapter 6 Using the Built In Classes...

Page 121: ...of component based architecture in Macromedia Flash MX 2004 and Macromedia Flash MX Professional 2004 In fact the components available in the Components panel Window Development Panels Components are...

Page 122: ...nctions MovieClip attachMovie MovieClip createEmptyMovieClip MovieClip createTextField MovieClip getBounds MovieClip getBytesLoaded MovieClip getBytesTotal MovieClip getDepth MovieClip getInstanceAtDe...

Page 123: ...WF file Develop a branching interface that lets the user choose among several different SWF files Build a navigation interface with navigation controls in level 0 that load other levels Loading levels...

Page 124: ...target_mc will refer to its own Timeline not the actual root Timeline of container swf Equivalently the author of contents swf could add the following code to its main Timeline Within contents swf th...

Page 125: ...uivalent to the following code which uses the getProperty function onClipEvent enterFrame customCursor _x getProperty _root _xmouse The _x _y _rotation _xscale _yscale _height _width _alpha and _visib...

Page 126: ...p named new_mc at a depth of 10 in the movie clip named parent_mc parent_mc createEmptyMovieClip new_mc 10 The following code creates a new movie clip named canvas_mc on the root Timeline of the SWF f...

Page 127: ...f you don t the element will not be exported to the SWF file To assign a linkage identifier to movie clip 1 Select Window Library to open the Library panel 2 Select a movie clip in the Library panel 3...

Page 128: ...ts own stacking order with level 0 as the level of the originating movie clip Attached movie clips are always on top of the original movie clip Here is an example myMovieClip attachMovie calif califor...

Page 129: ...movie clip s text field Managing movie clip depths Every movie clip has its own z order space that determines how objects overlap within its parent SWF file or movie clip Every movie clip has an asso...

Page 130: ...tance at a particular depth on page 130 Determining the instance at a particular depth To determine the instance at particular depth use MovieClip getInstanceAtDepth This method returns a reference to...

Page 131: ...hat is created in authoring mode is drawn on top of content drawn with the drawing methods You can use movie clips with drawing methods as masks however as with all movie clip masks strokes are ignore...

Page 132: ...elopment Panels Actions if it isn t already open 6 In the Actions panel enter the following code image setMask mask For detailed information see MovieClip setMask on page 533 About masking device font...

Page 133: ...llTest 2 Create a new ActionScript file by doing one of the following Flash MX Professional 2004 Select File New and select ActionScript file from the list of document types Flash MX 2004 Create a tex...

Page 134: ...ing a class to a movie clip symbol on page 133 The difference is a new property named distance whose value determines how many pixels a movie clip moves each time it is clicked MoveRightDistance class...

Page 135: ...external images but also external SWF files as well as movie clips that reside in the library see Image tag img on page 149 In Flash Player 7 and later you can apply Cascading Style Sheets CSS styles...

Page 136: ...line_txt text Brazil wins World Cup 5 Select Control Test Movie to test the movie About text field instance and variable names In the Property inspector you can also assign a variable name to a dynami...

Page 137: ...extField method does not work on a text field placed by the Timeline during authoring For more information see MovieClip createTextField on page 494 and TextField removeTextField on page 698 Using the...

Page 138: ...xt field you created in step 1 using TextField setTextFormat myText_txt setTextFormat txtfmt_fmt This version of setTextFormat applies the specified formatting to the entire text field There are two o...

Page 139: ...ext text align left You can create styles that redefine built in HTML formatting tags used by Flash Player such as p and li create style classes that can be applied to specific HTML elements using the...

Page 140: ...n Recognized values are left center and right font size fontSize Only the numeric part of the value is used units px pt are not parsed pixels and points are equivalent text decoration textDecoration R...

Page 141: ...ily Arial Helvetica sans serif font size 24px 3 Save the CSS file as styles css 4 In Flash create a FLA document 5 In the Timeline Window Timeline select Layer 1 6 Open the Actions panel Window Develo...

Page 142: ...roperties and any variable associated with the text field always contain the same value and behave identically The text field becomes read only and cannot be edited by the user The setTextFormat and r...

Page 143: ...nce of a built in HTML tag that appears in a text field For example the following defines a style for the built in p HTML tag All instances of that tag will be styled in the manner specified by the st...

Page 144: ...ans serif font size 18px font weight bold display block byline color 666600 font style italic font weight bold display inline This style sheet defines styles for two built in HTML tags p and a that wi...

Page 145: ...d coded into the script in a real world application you ll probably want to load the text from an external file For information on loading external data see Chapter 10 Working with External Data on pa...

Page 146: ...ctor select Dynamic Text from the Text Type menu select Multiline from the Line Type menu select the Render Text as HTML option and type news_txt in the Instance Name text box 5 On Layer 1 in the Time...

Page 147: ...ly paragraph formatting styles of the TextFormat class to HTML enabled text fields For more information see Using the TextFormat class on page 137 Overview of using HTML formatted text To use HTML in...

Page 148: ...lay the text b This is bold text b Break tag br The br tag creates a line break in the text field as shown in this example One line of text br Another line of text br Font tag font The font tag specif...

Page 149: ...l other attributes are optional External files JPEG and SWF files are not displayed until they have downloaded completely Note Flash Player does not support progressive JPEG files id Specifies the nam...

Page 150: ...st 10 0 0 300 100 createTextField test 10 0 0 300 100 test styleSheet myStyleSheet test htmlText p class body This is some body styled text p Span tag span The span tag is available only for use with...

Page 151: ...ext tool create a dynamic text field that s approximately 300 pixels wide and 100 pixels high 2 In the Property inspector enter table_txt in the Instance Name text box select Multiline from the Line T...

Page 152: ...g tag s src attribute For information on defining a linkage identifier see Attaching a movie clip symbol to the Stage on page 127 For example the following code inserts a movie clip symbol with the li...

Page 153: ...enclosed by a tags Creating scrolling text There are several ways to create scrolling text in Flash You can make dynamic and input text fields scrollable by selecting the Scrollable Mode option in the...

Page 154: ...textField as a parameter of the method 2 Create an Up button and a Down button or select Window Other Panels Common Libraries Buttons and drag buttons to the Stage You will use these buttons to scroll...

Page 155: ...o you if you ve ever programmed with Java The OOP model provided by ActionScript 2 0 is a syntactic formalization of the prototype chaining method used in previous versions of Macromedia Flash to crea...

Page 156: ...ting sleeping are called methods of the class and are represented as functions For example you could create a Person class and then create an individual person that would be an instance of that class...

Page 157: ...simple example For those who are new to object oriented programming this section provides an overview of the workflow involved in creating and using classes in Flash At a minimum this workflow involv...

Page 158: ...d the class body and is where the class s properties and methods are defined Note The name of the class Person matches the name of the AS file that contains it Person as This is very important if thes...

Page 159: ...er var name String Method to return property values function showInfo String return Hello my name is name and I m age years old Constructor function function Person myName String myAge Number name myN...

Page 160: ...in a Flash document 1 In Flash select File New select Flash Document from the list of document types and click OK 2 Save the file as createPerson fla in the PersonFiles directory you created previous...

Page 161: ...dollar sign and each subsequent character must be a letter number underscore or dollar sign Also the class name must be fully qualified within the file in which it is declared that is it must reflect...

Page 162: ...and String For example the following class definition initializes several properties inline class CompileTimeTest var foo String my foo OK var bar Number 5 OK var bool Boolean true OK var name String...

Page 163: ...ew Array beethoven mp3 bach mp3 mozart mp3 function playSong songID Number this loadSound songList songID If you don t place a call to super in the constructor function of a subclass the compiler auto...

Page 164: ...oginClass private var userName String private function getUserName return userName Constructor function LoginClass user String this userName user Private members properties and methods are accessible...

Page 165: ...y of static methods and properties To call any of its methods you don t create an instance of the Math class Instead you simply call the methods on the Math class itself The following code calls the s...

Page 166: ...nt Number 0 initialize class variable function Widget trace Creating widget widgetCount widgetCount The widgetCount variable is declared as static and so initializes to 0 only once Each time the Widge...

Page 167: ...n interface or communication protocol that all the classes must adhere to One way to do this would be to create a Communication class that defines all of these methods and then have each class extend...

Page 168: ...see Creating and using classes on page 161 and Using packages on page 171 Interfaces as data types Like a class an interface defines a new data type Any class that implements an interface can be consi...

Page 169: ...and FLA files and is set in the Preferences dialog box Edit Preferences The document level classpath applies only to FLA files and is set in the Publish Settings dialog File Publish Settings for a pa...

Page 170: ...a new line to the Classpath list Double click the new line type a relative or absolute path and click OK To edit an existing classpath directory select the path in the Classpath list click the Browse...

Page 171: ...hs are denoted with dot syntax where each dot indicates a subdirectory For example if you placed each AS file that defines a shape in the Shapes directory you would need to change the name of each cla...

Page 172: ...In another script you could import both classes in that package using the wildcard character as shown below import macr util In the same script you can then reference either the foo or bar class direc...

Page 173: ...med user you could not also have a property named user in the same class Unlike ordinary methods get set methods are invoked without any parentheses or arguments For example the following syntax could...

Page 174: ...and exported This is useful for example if a SWF file uses many classes that require a long time to download If the classes are exported on the first frame the user would have to wait until all the cl...

Page 175: ...External Data and Media This part discusses how to incorporate external data and media into your Macromedia Flash applications Chapter 10 Working with External Data 177 Chapter 11 Working with Extern...

Page 176: ......

Page 177: ...hat resides in the same domain for example www macromedia com that the Flash movie originated from For more information see Flash Player security features on page 188 Sending and loading variables to...

Page 178: ...ure the variable has loaded from the file myData txt loadVariables myData txt 0 gotoAndPlay lastFrameVisited Each function or method has a specific technique you can use to check data it has loaded If...

Page 179: ...see About multiple Timelines and levels in Using Flash Help Variables sets the HTTP method either GET or POST by which the variables will be sent When omitted Flash Player defaults to GET but no vari...

Page 180: ...e loaded data The following procedure shows how to use a LoadVars object to load variables from a text file and display those variables in a text field To load data with the LoadVars object 1 In a tex...

Page 181: ...hild node This hierarchical tree structure of nodes is called the XML Document Object Model DOM much like the JavaScript DOM which is the structure of elements in a web browser In the following exampl...

Page 182: ...e server The first section of the script loads the variables into a newly created XML object called loginXML When a user clicks the Submit button the loginXML object is converted to a string of XML an...

Page 183: ...must load into a blank XML object in the SWF file The following statement creates the XML object loginreplyXML to receive the XML node B Construct an XML object to hold the server s reply loginReplyX...

Page 184: ...nd the LOGIN element to the server place the reply in loginReplyXML loginXML sendAndLoad https www imexstocks com main cgi loginReplyXML Note This design is only an example and Macromedia can make no...

Page 185: ...to assign to the sock object that handles the server s response If the connection succeeds send the myXML object If it fails provide an error message in a text field function onSockConnect success if...

Page 186: ...xpressions and will be used in a JavaScript function that catches or handles the fscommand function An fscommand function invokes the JavaScript function moviename_DoFSCommand in the HTML page that em...

Page 187: ...ommand messagebox Hello name welcome to our website 3 Select File Publish Preview HTML to test the document The fscommand function can send messages to Macromedia Director that are interpreted by Ling...

Page 188: ...ash Player 7 and later prevents a SWF file served from one domain from accessing data objects or variables from SWF files that are served from different domains cannot access each other s objects and...

Page 189: ...allowDomain For example suppose main swf is served from www macromedia com That SWF file then loads another SWF file data swf from data macromedia com into a movie clip instance target_mc In macromedi...

Page 190: ...ed libraries must reside in the same domain as the SWF that is loading that external data or media To make data and assets in runtime shared libraries available to SWF files in different domains use a...

Page 191: ...allow access from domain www friendOfFoo com allow access from domain foo com allow access from domain 105 216 0 40 cross domain policy A policy file that contains no allow access from tags has the s...

Page 192: ...192 Chapter 10 Working with External Data...

Page 193: ...ion might display a JPEG image of each product By loading the JPEG files for each image at runtime you can easily update a product s image without modifying the original FLA file Take advantage of run...

Page 194: ...vie clip target the upper left corner of the SWF file or JPEG image is placed on the registration point of the movie clip Because this registration point is often the center of the movie clip the load...

Page 195: ...System security allowDomain in Chapter 12 ActionScript Dictionary on page 205 Loading external MP3 files To load MP3 files at runtime use the loadSound method of the Sound class First create a Sound o...

Page 196: ...To determine when ID3 tags for a downloading MP3 file are available use the Sound onID3 event handler Flash Player 7 supports version 1 0 1 1 2 3 and 2 4 tags version 2 2 tags are not supported For e...

Page 197: ...certain capabilities that are not available when you use imported video You can use longer video clips in your Flash documents without slowing down playback External FLV files are played using cached...

Page 198: ...a local streaming connection netConn connect null Create a NetStream object and define an onStatus function var netStream NetStream new NetStream netConn netStream onStatus function infoObject status...

Page 199: ...ener object var loadListener Object new Object loadListener onLoadStart function loadTarget trace Loading into loadTarget has started loadListener onLoadProgress function loadTarget bytesLoaded bytesT...

Page 200: ...ment Panels Actions 6 Add the following code to the Actions panel create both a MovieClipLoader object and a listener object myLoader new MovieClipLoader myListener new Object add the MovieClipLoader...

Page 201: ...undObj getBytesLoaded var bytesTotal soundObj getBytesTotal var percentLoaded Math floor bytesLoaded bytesTotal 100 trace percentLoaded loaded When the file has finished loading clear the interval pol...

Page 202: ...202 Chapter 11 Working with External Media...

Page 203: ...t provide reference material you may want to review as you write your scripts Chapter 12 ActionScript Dictionary 205 Appendix A Error Messages 783 Appendix B Operator Precedence and Associativity 787...

Page 204: ......

Page 205: ...ns classes and methods For an overview of all dictionary entries see Contents of the dictionary on page 207 the tables in this section are a good starting point for looking up symbolic operators or me...

Page 206: ...In a few cases this section also indicates which version of the authoring tool supports an element For an example see System setClipboard Finally if an element is supported only in ActionScript 2 0 th...

Page 207: ...o access its methods and properties the constructor is described in each class entry This description has all of the standard elements syntax description and so on of other dictionary entries Method a...

Page 208: ...t delimiter division assignment array access bitwise XOR bitwise XOR assignment object initializer bitwise OR logical OR bitwise OR assignment bitwise NOT addition addition assignment less than bitwis...

Page 209: ...ovieClip _framesloaded _global _global object _height Button _height MovieClip _height TextField _height _highquality _highquality Button _highquality MovieClip _highquality TextField _highquality _lo...

Page 210: ...er Key addListener Mouse addListener MovieClipLoader addListener Selection addListener Stage addListener TextField addListener addPage PrintJob addPage addProperty Object addProperty addRequestHeader...

Page 211: ...Format bold Boolean Boolean Boolean class border TextField border borderColor TextField borderColor bottomScroll TextField bottomScroll break break bufferLength NetStream bufferLength bufferTime NetSt...

Page 212: ...em class Date class Error class LoadVars class LocalConnection class Microphone class NetConnection class NetStream class Number class Object class PrintJob class SharedObject class Sound class String...

Page 213: ...eClip duplicateMovieClip duration Sound duration dynamic dynamic E Math E else else else if else if embedFonts TextField embedFonts enabled Button enabled ContextMenuItem enabled MovieClip enabled END...

Page 214: ...s MovieClip getBounds getBytesLoaded LoadVars getBytesLoaded MovieClip getBytesLoaded Sound getBytesLoaded XML getBytesLoaded getBytesTotal LoadVars getBytesTotal MovieClip getBytesTotal Sound getByte...

Page 215: ...Style getStyleNames TextField StyleSheet getStyleNames getSWFVersion MovieClip getSWFVersion getText TextSnapshot getText getTextExtent TextFormat getTextExtent getTextFormat TextField getTextFormat g...

Page 216: ...asMP3 System capabilities hasMP3 hasPrinting System capabilities hasPrinting hasScreenBroadcast System capabilities hasScreenBroadcast hasScreenPlayback System capabilities hasScreenPlayback hasStream...

Page 217: ...rface isActive Accessibility isActive isDebugger System capabilities isDebugger isDown Key isDown isFinite isFinite isNaN isNaN isToggled Key isToggled italic TextFormat italic join Array join Key Key...

Page 218: ...riablesNum loadVariablesNum LoadVars LoadVars class LocalConnection LocalConnection class localFileReadDisable System capabilities localFileReadDisable localToGlobal MovieClip localToGlobal log Math l...

Page 219: ...TextField multiline muted Camera muted Microphone muted name Error name Microphone name names Camera names Microphone names NaN NaN Number NaN ne ne not equal string specific NEGATIVE_INFINITY Number...

Page 220: ...onLoad Sound onLoad TextField StyleSheet onLoad XML onLoad onLoadComplete MovieClipLoader onLoadComplete onLoadError MovieClipLoader onLoadError onLoadInit MovieClipLoader onLoadInit onLoadProgress M...

Page 221: ...tNode parseCSS TextField StyleSheet parseCSS parseFloat parseFloat parseInt parseInt parseXML XML parseXML password TextField password pause NetStream pause PGDN Key PGDN PGUP Key PGUP PI Math PI pixe...

Page 222: ...L removeNode removeTextField TextField removeTextField replaceSel TextField replaceSel replaceText TextField replaceText resolutionX System capabilities screenResolutionX resolutionY System capabiliti...

Page 223: ...Date setFullYear setGain Microphone setGain setHours Date setHours setInterval setInterval setMask MovieClip setMask setMilliseconds Date setMilliseconds setMinutes Date setMinutes setMode Camera setM...

Page 224: ...UTCMinutes setUTCMonth Date setUTCMonth setUTCSeconds Date setUTCSeconds setVolume Sound setVolume setYear Date setYear SharedObject SharedObject class SHIFT constant Key SHIFT shift method Array shif...

Page 225: ...Sheet substr String substr substring substring String substring super super swapDepths MovieClip swapDepths switch switch System System class TAB Key TAB tabChildren MovieClip tabChildren tabEnabled B...

Page 226: ...ckAsMenu true true try try catch finally type TextField type typeof typeof undefined undefined underline TextFormat underline unescape unescape uninstall CustomActions uninstall unloadClip MovieClipLo...

Page 227: ...form of the operator expression subtracts 1 from the expression and returns the initial value of expression the value prior to the subtraction valueOf Boolean valueOf Number valueOf Object valueOf var...

Page 228: ...rement and post increment unary operator that adds 1 to expression The expression can be a variable element in an array or property of an object The pre increment form of the operator expression adds...

Page 229: ...a var i 0 while i 10 a push i trace a join This script displays the following result in the Output panel 0 1 2 3 4 5 6 7 8 9 logical NOT Availability Flash Player 4 Usage expression Parameters None Re...

Page 230: ...Operator inequality tests for the exact opposite of the operator If expression1 is equal to expression2 the result is false As with the operator the definition of equal depends on the data types being...

Page 231: ...r the definition of equal depends on the data types being compared Numbers strings and Boolean values are compared by value Variables objects arrays and functions are compared by reference Example The...

Page 232: ...the expression parameters are non numeric the modulo operator attempts to convert them to numbers The expression can be a number or string that converts to a numeric value Example The following is a...

Page 233: ...atenate strings Flash 4 files that use the operator are automatically updated to use add when brought into the Flash 5 or later authoring environment Usage expression1 expression2 Parameters None Retu...

Page 234: ...layer has won the game The turns variable and the score variable are updated when a player takes a turn or scores points during the game The following script displays You Win the Game in the Output pa...

Page 235: ...perators are executed in the expression Parentheses override the normal precedence order and cause the expressions within the parentheses to be evaluated first When parentheses are nested the contents...

Page 236: ...erical expressions subtracting expression2 from expression1 When both expressions are integers the difference is an integer When either or both expressions are floating point numbers the difference is...

Page 237: ...t number Example Usage 1 The following statement multiplies the integers 2 and 3 2 3 The result is 6 which is an integer Usage 2 This statement multiplies the floating point numbers 2 0 and 3 1416 2 0...

Page 238: ...the results to x and y i 5 x 4 6 y i 2 trace x y returns 14 See also multiplication comma Availability Flash Player 4 Usage expression1 expression2 Parameters None Returns Nothing Description Operato...

Page 239: ...vie clip childinstance A movie clip instance that is a child of or nested in another movie clip variable A variable on the Timeline of the movie clip instance name to the left of the dot operator Retu...

Page 240: ...erencing using the dot operator To avoid type mismatch errors use explicit typing see Strict data typing on page 38 Types that you can use include all native object types classes and interfaces that y...

Page 241: ...ression1 is true it returns the value of expression2 otherwise it returns the value of expression3 Example The following statement assigns the value of variable x to variable z because expression1 eva...

Page 242: ...ates the beginning of a script comment Any characters that appear between the comment delimiter and the end of line character are interpreted as a comment and ignored by the ActionScript interpreter E...

Page 243: ...eted as a comment and ignored by the ActionScript interpreter Use the first type of syntax to identify single line comments Use the second type of syntax to identify comments on multiple successive li...

Page 244: ...The following code illustrates using the operator with variables and numbers x 10 y 2 x y x now contains the value 5 array access Availability Flash Player 4 Usage my_array a0 a1 aN myMultiDimensional...

Page 245: ...ts ticTacToe 1 2 3 4 5 6 7 8 9 choose Debug List Variables in test movie mode to see a list of the array elements Usage 3 Surround the index of each element with brackets to access it directly you can...

Page 246: ...ive 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 clip will be displayed in the Output panel on release x my_mc pie...

Page 247: ...binary 9 decimal 1001 binary x 15 9 trace x 1111 1001 0110 returns 6 decimal 0110 binary bitwise XOR assignment Availability Flash Player 5 Usage expression1 expression2 Parameters expression1 expres...

Page 248: ...he following code creates an empty object using the object initializer operator the second line creates a new object using a constructor function object object new Object The following example creates...

Page 249: ...and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1 Example The following is an example of a bitwise OR operation 15 decimal 1111 binary x 15 9...

Page 250: ...t expression Example Usage 1 The following example uses the operator in an if statement The second expression evaluates to true so the final result is true x 10 y 250 start false if x 25 y 200 start t...

Page 251: ...01 returns 15 decimal 1111 binary See also bitwise OR bitwise NOT Availability Flash Player 5 Usage expression Parameters expression A number Returns None Description Operator bitwise converts the exp...

Page 252: ...pressions are integers the sum is an integer if either or both expressions are floating point numbers the sum is a floating point number Example Usage 1 The following example concatenates two strings...

Page 253: ...umber or string Returns Nothing Description Operator arithmetic compound assignment assigns expression1 the value of expression1 expression2 For example the following two statements have the same resu...

Page 254: ...ted Flash 5 or later file Number x Number y Usage expression1 expression2 Parameters expression1 expression2 A number or string Description Operator comparison compares two expressions and determines...

Page 255: ...iplying it by 2 Example In the following example the integer 1 is shifted 10 bits to the left x 1 10 The result of this operation is x 1024 This is because 1 decimal equals 1 binary 1 binary shifted l...

Page 256: ...compares two expressions and determines whether expression1 is less than or equal to expression2 if it is the operator returns true If expression1 is greater than expression2 the operator returns fal...

Page 257: ...unction Returns A Boolean value Description Operator inequality tests for the exact opposite of the operator If expression1 is equal to expression2 the result is false As with the operator the definit...

Page 258: ...the right to the variable array element or property in expression1 In Flash 5 or later is an assignment operator and the operator is used to evaluate equality In Flash 4 is a numeric equality operato...

Page 259: ...gnment assigns expression1 the value of expression1 expression2 For example the following two statements are the same x y x x y String expressions must be converted to numbers otherwise NaN is returne...

Page 260: ...ave the same value String expressions are equal if they have the same number of characters and the characters are identical Variables objects arrays and functions are compared by reference Two variabl...

Page 261: ...g expressions are equal if they have the same number of characters and the characters are identical Variables objects arrays and functions are compared by reference Two variables are equal if they ref...

Page 262: ...operator returns false String expressions are evaluated using alphabetical order all capital letters come before lowercase letters In Flash 5 or later the less than or equal to operator is a comparis...

Page 263: ...on1 to the right by the number of places specified by the integer resulting from the conversion of expression2 Bits that are shifted to the right are discarded To preserve the sign of the original exp...

Page 264: ...ber or expression that converts to an integer from 0 to 31 Returns Nothing Description Operator bitwise compound assignment this operator performs a bitwise right shift operation and stores the conten...

Page 265: ...ign of the original expression because the bits on the left are always filled with 0 Example The following example converts 1 to a 32 bit integer and shifts it 1 bit to the right x 1 1 The result of t...

Page 266: ...gnment Accessibility class Availability Flash Player 6 version 65 Description The Accessibility class manages communication with screen readers The methods of the Accessibility class are static that i...

Page 267: ...tly in the presence of a screen reader To determine whether the player is running in an environment that supports accessibility aids use System capabilities hasAccessibility Note If you call this meth...

Page 268: ...uivalent this iconImage this iconImages newIconNum if newTextEquivalent undefined if this _accProps undefined this _accProps new Object this _accProps name newTextEquivalent Accessibility updateProper...

Page 269: ...r changes made to _accProps properties apply to the whole movie For example the following code sets the Accessibility name property for the whole movie to the string Pet Store and then calls Accessibi...

Page 270: ...ert to default value To revert all accessibility values for an object to default values you can delete the instanceName _accProps object delete my_btn _accProps To revert accessibility values for all...

Page 271: ...and Macromedia recommends that you use the operator when creating content for Flash Player 5 or later Use the add operator to concatenate strings if you are creating content for Flash Player 4 or earl...

Page 272: ...the Arguments class arguments callee Availability Flash Player 5 Usage arguments callee Description Property refers to the function that is currently being called Example You can use the arguments ca...

Page 273: ...ption The Array class lets you access and manipulate arrays An array is an object whose properties are identified by a number representing their position in the array This number is referred to as the...

Page 274: ...parameters and returns them as a new array Array join Joins all elements of an array into a string Array pop Removes the last element of an array and returns its value Array push Adds one or more ele...

Page 275: ...an initial length of 0 my_array new Array trace my_array length returns 0 Usage 2 The following example creates a new Array object with an initial length of 4 my_array new Array 4 trace my_array lengt...

Page 276: ...e concatenates two arrays alpha_array new Array a b c numeric_array new Array 1 2 3 alphaNumeric_array alpha_array concat numeric_array trace alphaNumeric_array creates array a b c 1 2 3 The following...

Page 277: ...elements concatenates them and returns the resulting string A nested array is always separated by a comma not by the separator passed to the join method Example The following example creates an array...

Page 278: ...the length property is updated my_array new Array trace my_array length initial length is 0 my_array 0 a trace my_array length my_array length is updated to 1 my_array 1 b trace my_array length my_ar...

Page 279: ...ray After the push method is called the variable pushed contains four elements Because the push method returns the new length of the array the trace action in the last line sends the new length of myP...

Page 280: ...myPets_array shift trace shifted returns cat See also Array pop Array slice Availability Flash Player 5 Usage my_array slice start end Parameters start A number specifying the index of the starting p...

Page 281: ...s 1 if A should appear before B in the sorted sequence 0 if A B 1 if A should appear after B in the sorted sequence option One or more numbers or strings separated by the bitwise OR operator that chan...

Page 282: ...ple if you want to sort alphabetically by last name ascending and then by ZIP code descending If you want to specify one or more fields on which to sort using either the default sort or the options pa...

Page 283: ...sortOn fieldName fieldName my_array sortOn fieldName fieldName option option Note Where brackets are shown you must include them in the code that is the brackets don t represent optional parameters P...

Page 284: ...is ascending a precedes b The array is modified to reflect the sort order multiple elements that have identical sort fields are placed consecutively in the sorted array in no particular order Numeric...

Page 285: ...abcd Performing a default sort on the age field produces the following results my_array sortOn age 29 3 35 4 Performing a numeric sort on the age field produces the following results my_array sortOn a...

Page 286: ...orts it according to the fields name and city The first sort uses name as the first sort value and city as the second The second sort uses city as the first sort value and name as the second var rec_a...

Page 287: ...array If the value is 0 no elements are deleted value An optional parameter specifying the values to insert into the array at the insertion point specified in the start parameter Returns Nothing Desc...

Page 288: ...or variables to be inserted at the beginning of the array Returns The new length of the array Description Method adds one or more elements to the beginning of an array and returns the array s new len...

Page 289: ...s of code The TextField object myTextField is associated with an HTML text field The text Click Me is a hyperlink inside the text field The MyFunc function is called when the user clicks on the hyperl...

Page 290: ...er the method evaluates it and returns the result as a Boolean value according to the rules in the Boolean function Example The following code creates a new empty Boolean object called myBoolean myBoo...

Page 291: ...Boolean value or the value expression as described below Description Function converts the parameter expression to a Boolean value and returns a value as follows If expression is a Boolean value the...

Page 292: ...icular case within a switch action The break action instructs Flash to skip the rest of the loop body stop the looping action and execute the statement following the loop statement When using the brea...

Page 293: ...w rectangle around it Button _height The height of a button instance in pixels Button _highquality The level of anti aliasing applied to the current SWF file Button menu Associates a ContextMenu objec...

Page 294: ...n onDragOut Invoked when the mouse button is pressed over the button and the pointer then rolls outside the button Button onDragOver Invoked when the user presses and drags the mouse button outside an...

Page 295: ...pha property of a button named star_btn to 30 when the button is clicked on release star_btn _alpha 30 See also MovieClip _alpha TextField _alpha Button enabled Availability Flash Player 6 Usage my_bt...

Page 296: ...e sets the height and width of a button when the user clicks the mouse my_btn _width 200 my_btn _height 200 Button _highquality Availability Flash Player 6 Usage my_btn _highquality Description Proper...

Page 297: ...Example The following example assigns a ContextMenu object to a Button object named save_btn The ContextMenu object contains a single menu item labeled Save with an associated callback handler functi...

Page 298: ...utes when the event handler is invoked Button onDragOver Availability Flash Player 6 Usage my_btn onDragOver function your statements here Parameters None Returns Nothing Description Event handler inv...

Page 299: ...s invoked with no parameters You can use Key getAscii and Key getCode to determine which key was pressed You must define a function that executes when the event handler is invoked Example In the follo...

Page 300: ...l is defined for the onKeyPress handler my_btn onKeyUp function trace onKeyUp called Button onKillFocus Availability Flash Player 6 Usage my_btn onKillFocus function newFocus your statements here Para...

Page 301: ...dler my_btn onPress function trace onPress called Button onRelease Availability Flash Player 6 Usage my_btn onRelease function your statements here Parameters None Returns Nothing Description Event ha...

Page 302: ...u must define a function that executes when the event handler is invoked Example In the following example a function that sends a trace action to the Output panel is defined for the onReleaseOutside h...

Page 303: ...ns Nothing Description Event handler invoked when the pointer moves over a button area You must define a function that executes when the event handler is invoked Example In the following example a fun...

Page 304: ...The current object is the one containing the ActionScript code that references _parent Use _parent to specify a relative path to movie clips or objects that are above the current movie clip or object...

Page 305: ...pecifies the number of seconds a sound prebuffers before it starts to stream Note Although you can specify this property for a Button object it is actually a global property and you can specify its va...

Page 306: ...a tabIndex value of 1 precedes an object with a tabIndex value of 2 If two objects have the same tabIndex value the one that precedes the other in the tab ordering is undefined The custom tab ordering...

Page 307: ...s on the new behavior See also MovieClip trackAsMenu Button _url Availability Flash Player 6 Usage my_btn _url Description Property read only retrieves the URL of the SWF file that created the button...

Page 308: ...tn is visible Buttons that are not visible _visible property set to false are disabled See also MovieClip _visible TextField _visible Button _width Availability Flash Player 6 Usage my_btn _width Desc...

Page 309: ...that has transformations the button is in the local coordinate system of the enclosing movie clip Thus for a movie clip rotated 90 degrees counterclockwise the enclosed button inherits a coordinate s...

Page 310: ...le were at 100 See also Button _x Button _y Button _yscale Button _y Availability Flash Player 6 Usage my_btn _y Description Property the y coordinate of the button relative to the local coordinates o...

Page 311: ...gistration point of the button expressed as a percentage The default registration point is 0 0 See also Button _y Button _x Button _xscale call Availability Flash Player 4 This action was deprecated i...

Page 312: ...era setMode Sets aspects of the camera capture mode including height width and frames per second Camera setMotionLevel Specifies how much motion is required to invoke Camera onActivity true and how mu...

Page 313: ...vent handler Otherwise it is undefined See also Camera motionLevel Camera setMotionLevel Camera motionTimeOut The number of milliseconds between the time when the camera stops detecting motion and the...

Page 314: ...Example The following example loads another SWF file if the camera s bandwidth is 32 kilobytes or greater if myCam bandwidth 32768 loadMovie splat swf _root hiddenvar See also Camera setQuality Camera...

Page 315: ...ctive camera myCam fps to the value provided by the user s text box this config txt_fps if this config txt_fps undefined myCam setMode myCam width myCam height this config txt_fps false Note The setMo...

Page 316: ...get to return a reference to the default camera By means of the Camera settings panel discussed later in this section the user can specify the default camera Flash should use If you pass a value for...

Page 317: ...renced by Camera get use System showSettings 3 Scanning the hardware for cameras takes time When Flash finds at least one camera the hardware is not scanned again for the lifetime of the player instan...

Page 318: ...user interface with the current height value my_txt _height myCam height See also the example for Camera setMode See also Camera setMode Camera width Camera index Availability Flash Player 6 Usage act...

Page 319: ...nStatus Camera setMotionLevel Camera motionTimeOut Availability Flash Player 6 Usage active_cam motionTimeOut Description Read only property the number of milliseconds between the time the camera stop...

Page 320: ...For more information see Camera get See also Camera get Camera onStatus Camera name Availability Flash Player 6 Usage active_cam name Description Read only property a string that specifies the name of...

Page 321: ...era names length For more information see the Array class entry Calling the Camera names property requires an extensive examination of the hardware and it may take several seconds to build the array I...

Page 322: ...amed myVideoObject is on the Stage my_cam Camera get myVideoObject attachVideo my_cam my_cam setMotionLevel 10 500 my_cam onActivity function mode trace mode See also Camera onActivity Camera setMotio...

Page 323: ...acy setting For more information see Camera get Example The following event handler displays a message whenever the user allows or denies access to the camera myCam Camera get myVideoObject attachVide...

Page 324: ...ameters you pass Flash selects a capture mode that most closely synthesizes the requested mode This manipulation may involve cropping the image and dropping frames By default Flash drops frames as nee...

Page 325: ...voke Camera onActivity true Optionally sets the number of milliseconds that must elapse without activity before Flash considers motion to have stopped and invokes Camera onActivity false Note Video ca...

Page 326: ...t named myVideoObject is on the Stage c Camera get x 0 function motion mode trace x mode x c onActivity function mode motion mode c setMotionLevel 30 500 myVideoObject attachVideo c See also Camera ac...

Page 327: ...ameQuality Flash will use as much bandwidth as required to maintain the specified quality If necessary Flash will reduce the frame rate to maintain picture quality In general as motion increases bandw...

Page 328: ...r Camera setMode See also Camera height case Availability Flash Player 4 Usage case expression statements Parameters expression Any expression statements Any statements Returns Nothing Description Sta...

Page 329: ...ility Flash Player 6 Usage dynamic class className extends superClass implements interfaceName interfaceName class definition here Note To use this keyword you must specify ActionScript 2 0 and Flash...

Page 330: ...reflect their new location You cannot nest class definitions that is you cannot define additional classes within a class definition To indicate that objects can add and access dynamic properties at r...

Page 331: ...t returned from a call to setInterval Returns Nothing Description Function clears a call to setInterval Example The following example first sets and then clears an interval call function callback trac...

Page 332: ...following example creates a Color object called my_color for the movie clip my_mc and sets its RGB value my_color new Color my_mc my_color setRGB 0xff9933 Color getRGB Availability Flash Player 5 Usa...

Page 333: ...contain the current offset and percentage values for the specified color Description Method returns the transform value set by the last Color setTransform call See also Color setTransform Color setRGB...

Page 334: ...are explained below Returns Nothing Description Method sets color transform information for a Color object The colorTransformObject parameter is a generic object that you create from the new Object co...

Page 335: ...ct myColorTransform new Object Set the values for myColorTransform myColorTransform ra 50 rb 244 ga 40 gb 112 ba 12 bb 90 aa 40 ab 70 Associate the color transform object with the Color object created...

Page 336: ...ject before calling its methods Method summary for the ContextMenu class Property summary for the ContextMenu class Event handler summary for the ContextMenu class Constructor for the ContextMenu clas...

Page 337: ...nables or disables a custom menu item using the ContextMenu customItems array based on the value of a Boolean variable named showItem If false the custom menu item is disabled otherwise it s enabled v...

Page 338: ...ms propName trace propName propValue ContextMenu copy Availability Flash Player 7 Usage my_cm copy Parameters None Returns A ContextMenu object Description Method creates a copy of the specified Conte...

Page 339: ...em_cm with a caption of Send e mail and a callback handler named emailHandler not shown The new menu item is then added to the ContextMenu object my_cm using the customItems array Lastly the new menu...

Page 340: ...hideBuiltInItems my_cm builtInItems print true _root menu my_cm ContextMenu onSelect Availability Flash Player 7 Usage my_cm onSelect function item Object item_menu ContextMenu your code here Paramet...

Page 341: ...u object You can enable or disable specific menu items make items visible or invisible or change the caption or callback handler associated with a menu item Custom menu items appear at the top of the...

Page 342: ...s true visible A Boolean value that indicates whether the menu item is visible or invisible This parameter is optional its default value is true Returns Nothing Description Constructor creates a new C...

Page 343: ...string that specifies the menu item caption text displayed in the context menu Example This example displays the caption for the selected menu item Pause Game in the Output panel my_cm new ContextMen...

Page 344: ...Usage menuItem_cmi enabled Description Property a Boolean value that indicates whether the specified menu item is enabled or disabled By default this property is true Example The following example cre...

Page 345: ...sh Player 7 Usage menuItem_cmi separatorBefore Description Property a Boolean value that indicates whether a separator bar should appear above the specified menu item By default this property is false...

Page 346: ...type of loop In a while loop continue causes the Flash interpreter to skip the rest of the loop body and jump to the top of the loop where the condition is tested In a do while loop continue causes th...

Page 347: ...ame Parameters customActionsName The name of the custom action definition to retrieve Returns If the custom action XML definition is located returns a string otherwise returns undefined Description Me...

Page 348: ...finition The name of the definition file must be a simple filename without the xml file extension and without any directory separators or If a custom actions file already exists with the name customAc...

Page 349: ...ly only to the individual Date object specified when the method is called The Date UTC method is an exception it is a static method The Date class handles daylight saving time differently depending on...

Page 350: ...eturns the month according to local time Date getSeconds Returns the seconds according to local time Date getTime Returns the number of milliseconds since midnight January 1 1970 universal time Date g...

Page 351: ...TCDate Sets the date according to universal time Returns the new time in milliseconds Date setUTCFullYear Sets the year according to universal time Returns the new time in milliseconds Date setUTCHour...

Page 352: ...Date object for Gary s birthday August 12 1974 Because the month parameter is zero based the example uses 7 for the month not 8 garyBirthday_date new Date 74 7 12 The following example creates a new D...

Page 353: ...s running Date getFullYear Availability Flash Player 5 Usage my_date getFullYear Parameters None Returns An integer Description Method returns the full year a four digit number for example 2000 of the...

Page 354: ...termined by the operating system on which Flash Player is running Date getMilliseconds Availability Flash Player 5 Usage my_date getMilliseconds Parameters None Returns An integer Description Method r...

Page 355: ...An integer Description Method returns the month 0 for January 1 for February and so on of the specified Date object according to local time Local time is determined by the operating system on which F...

Page 356: ...imezoneOffset Parameters None Returns An integer Description Method returns the difference in minutes between the computer s local time and universal time Example The following example returns the dif...

Page 357: ...ns the day of the month an integer from 1 to 31 in the specified Date object according to universal time Date getUTCDay Availability Flash Player 5 Usage my_date getUTCDay Parameters None Returns An i...

Page 358: ...None Returns An integer Description Method returns the four digit year of the specified Date object according to universal time Date getUTCHours Availability Flash Player 5 Usage my_date getUTCHours P...

Page 359: ...eturns An integer Description Method returns the milliseconds of the specified Date object according to universal time Date getUTCMinutes Availability Flash Player 5 Usage my_date getUTCMinutes Parame...

Page 360: ...uary 1 for February and so on of the specified Date object according to universal time Date getUTCSeconds Availability Flash Player 5 Usage my_date getUTCSeconds Parameters None Returns An integer Des...

Page 361: ...ns An integer Description Method 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 syst...

Page 362: ...Date setHours Availability Flash Player 5 Usage my_date setHours hour Parameters hour An integer from 0 midnight to 23 11 p m Returns An integer Description Method sets the hours for the specified Da...

Page 363: ...l time is determined by the operating system on which Flash Player is running Date setMonth Availability Flash Player 5 Usage my_date setMonth month date Parameters month An integer from 0 January to...

Page 364: ...l time and returns the new time in milliseconds Local time is determined by the operating system on which Flash Player is running Date setTime Availability Flash Player 5 Usage my_date setTime millise...

Page 365: ...Flash Player 5 Usage my_date setUTCFullYear year month date Parameters year The year specified as a full four digit year for example 2000 month An integer from 0 January to 11 December This parameter...

Page 366: ...tional millisecond An integer from 0 to 999 This parameter is optional Returns An integer Description Method sets the hour for the specified Date object in universal time and returns the new time in m...

Page 367: ...e in milliseconds Date setUTCMonth Availability Flash Player 5 Usage my_date setUTCMonth month date Parameters month An integer from 0 January to 11 December date An integer from 1 to 31 This paramete...

Page 368: ...cified Date object in universal time and returns the new time in milliseconds Date setYear Availability Flash Player 5 Usage my_date setYear year Parameters year If year is an integer between 0 99 set...

Page 369: ...ce dateOfBirth_date toString Output for Pacific Standard Time Mon Aug 12 18 15 00 GMT 0700 1974 Date UTC Availability Flash Player 5 Usage Date UTC year month date hour minute second millisecond Param...

Page 370: ...ailability Flash Player 6 Usage default statements Parameters statements Any statements Returns Nothing Description Statement defines the default case for a switch action The statements execute if the...

Page 371: ...ed with var may not be deleted You cannot use the delete operator to remove movie clips Example Usage 1 The following example creates an object uses it and then deletes it after it is no longer needed...

Page 372: ...een deleted when ref1 was deleted because there would be no references to it If you delete ref2 there will no longer be any references to the object it will be destroyed and the memory it was using wi...

Page 373: ...a movie clip while the SWF file is playing The playhead in duplicate movie clips always starts at Frame 1 regardless of where the playhead is in the original or parent movie clip Variables in the par...

Page 374: ...t ways of adding properties and objects to a movie clip dynamically such as MovieClip createEmptyMovieClip and MovieClip createTextField Subclasses of dynamic classes are also dynamic For more informa...

Page 375: ...in the if statement is false Returns Nothing Description Statement specifies the statements to run if the condition in the if statement returns false See also if else if Availability Flash Player 4 Us...

Page 376: ...ng logic in your scripts Example The following example uses else if actions to check whether each side of an object is within a specific boundary if the object goes off bounds send it back and reverse...

Page 377: ...also equality Error class Availability Flash Player 7 Description Contains information about an error that occurred in a script You create an Error object using the Error constructor function Typicall...

Page 378: ...r with a specified message if the two strings that are passed to it are not identical function compareStrings string_1 string_2 if string_1 string_2 throw new Error Strings do not match try compareStr...

Page 379: ...cription Method returns the string Error by default or the value contained in Error message if defined See also Error message throw try catch finally escape Availability Flash Player 5 Usage escape ex...

Page 380: ...s by name If expression is a variable or a property the value of the variable or property is returned If expression is an object or movie clip a reference to the object or movie clip is returned If th...

Page 381: ...Flash tab of your FLA file s Publish Settings dialog box This keyword is supported only when used in external script files not in scripts written in the Actions panel Parameters className The name of...

Page 382: ...e Availability Flash Player 5 Usage false Description Constant a unique Boolean value that represents the opposite of true See also true _focusrect Availability Flash Player 4 Usage _focusrect Boolean...

Page 383: ...on Statement a loop construct that evaluates the init initialize expression once and then begins a looping sequence by which as long as the condition evaluates to true statement is executed and the ne...

Page 384: ...ns For example the built in methods of the Array class such as Array sort and Array reverse are not included in the enumeration of an Array object and movie clip properties such as _x and _y are not e...

Page 385: ...their respective Timelines The RadioButtonGroup movie clip is a parent with several children _RedRadioButton_ _GreenRadioButton_ and _BlueRadioButton for var name in RadioButtonGroup RadioButtonGroup...

Page 386: ...ommand Usage 3 The fscommand action can send messages to Macromedia Director that are interpreted by Lingo as strings events or executable Lingo code If the message is a string or an event you must wr...

Page 387: ...your JavaScript or VBScript code in any way you like In this example the function contains a conditional if statement that checks to see if the command string is messagebox If it is a JavaScript alert...

Page 388: ...ent parameters to a function each time you call it This lets you reuse one function in many different situations Use the return action in a function s statement s to cause a function to return or gene...

Page 389: ...Object An array whose elements are passed to myFunction as parameters Returns Any value that the called function specifies Description Method specifies the value of this to be used within any function...

Page 390: ...eters Up to 10 parameters are specified in text fields called parameter1 parameter2 up to parameter10 on release callTheFunction function callTheFunction var theFunction eval functionName text var n N...

Page 391: ...unction and not as a method of an object For example the following function invocations are equivalent Math sin Math PI 4 Math sin call null Math PI 4 Example This example uses Function call to make a...

Page 392: ...yword 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 no...

Page 393: ...on returns the value of the specified property for the movie clip my_mc Example The following example retrieves the horizontal axis coordinate _x for the movie clip my_mc and assigns it to the variabl...

Page 394: ...e GET method appends 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 sending long strings o...

Page 395: ...or later versions of the Player Example The following is an example of a string returned by the getVersion function WIN 5 0 17 0 This indicates that the platform is Microsoft Windows and the version n...

Page 396: ...le _global factorial function n if n 1 return 1 else return n factorial n 1 See also var set variable gotoAndPlay Availability Flash 2 Usage gotoAndPlay scene frame Parameters scene An optional string...

Page 397: ...n the current scene Example When the user clicks a button that gotoAndStop is assigned to the playhead is sent to Frame 5 in the current scene and the SWF file stops playing on release gotoAndStop 5 S...

Page 398: ...condition statement s Parameters condition An expression that evaluates to true or false statement s The instructions to execute if or when the condition evaluates to true Returns Nothing Description...

Page 399: ...0 if the condition is true the object was thrown what is the new location of this object xNewLoc this _x yNewLoc this _y how hard did they throw it xTravel xNewLoc xLoc yTravel yNewLoc yLoc setting th...

Page 400: ...ox This keyword is supported only when used in external script files not in scripts written in the Actions panel Description Keyword defines a class that must supply implementations for all the method...

Page 401: ...e of your SWF file the bytecode associated with a class is included in a SWF file only if that class is actually used The import statement applies only to the current script frame or object in which i...

Page 402: ...icate a parent directory and forward slashes See the following examples To specify an absolute path for the AS file use the format supported by your platform Macintosh or Windows See the following exa...

Page 403: ...e This is an optional parameter Description Compiler directive indicates the beginning of a block of initialization actions When multiple clips are initialized at the same time you can use the order p...

Page 404: ...determines whether an object belongs to a specified class Tests whether object is an instance of class The instanceof operator does not convert primitive types to wrapper objects For example the foll...

Page 405: ...implements an interface must provide an implementation for each method declared in the interface Only public members are allowed in an interface definition In addition instance and class members are...

Page 406: ...E implements Ib Ic function k Number return 25 function n x Number Number return x 5 function o Void trace o function p Void trace p See also class extends implements isFinite Availability Flash Playe...

Page 407: ...ession A Boolean variable or other expression to be evaluated Returns A Boolean value Description Function evaluates the parameter and returns true if the value is not a number NaN indicating the pres...

Page 408: ...eturns true if the Num Lock or Caps Lock key is activated Key removeListener Removes an object that was previously registered with Key addListener Property Description Key BACKSPACE Constant associate...

Page 409: ...and defines a function for onKeyDown and onKeyUp The last line uses addListener to register the listener with the Key object so that it can receive notification from the key down and key up events my...

Page 410: ...n if Key isDown Key CONTROL Key getCode 55 55 is key code for 7 Selection setFocus myButton myButton onPress var myListener new Object myListener onKeyDown myOnKeyDown Key addListener myListener myBut...

Page 411: ...layer 5 Usage Key DELETEKEY Description Property constant associated with the key code value for the Delete key 46 Key DOWN Availability Flash Player 5 Usage Key DOWN Description Property constant ass...

Page 412: ...tant associated with the key code value for the Escape key 27 Key getAscii Availability Flash Player 5 Usage Key getAscii Parameters None Returns An integer that represents the ASCII value of the last...

Page 413: ...pressed To match the returned key code value with the key on a standard keyboard see Appendix C Keyboard Keys and Key Code Values on page 789 Key HOME Availability Flash Player 5 Usage Key HOME Descr...

Page 414: ...is pressed false if it is not On the Macintosh the key code values for the Caps Lock and Num Lock keys are identical Example The following script lets the user control a movie clip s location onClipEv...

Page 415: ...ct as in the following someListener new Object someListener onKeyDown function Key addListener someListener Listeners enable different pieces of code to cooperate because multiple listeners can receiv...

Page 416: ...GUP Availability Flash Player 5 Usage Key PGUP Description Property constant associated with the key code value for the Page Up key 33 Key removeListener Availability Flash Player 6 Usage Key removeLi...

Page 417: ...h Player 5 Usage Key SHIFT Description Property constant associated with the key code value for the Shift key 16 Key SPACE Availability Flash Player 5 Usage Key SPACE Description Property constant ass...

Page 418: ...Numbers strings or variables Returns Nothing Description Operator comparison compares expression1 to expression2 and returns a value of true if expression1 is less than or equal to expression2 otherw...

Page 419: ...sh Player is automatically loaded into _level0 The SWF file in _level0 sets the frame rate background color and frame size for all subsequently loaded SWF files SWF files are then stacked in higher nu...

Page 420: ...JPEG file into Flash Player while the original SWF file is playing Tip If you want to monitor the progress of the download use MovieClipLoader loadClip instead of this function The loadMovie function...

Page 421: ...Flash Player or for testing in test movie mode in the Flash authoring application all SWF files must be stored in the same folder and the filenames cannot include folder or disk drive specifications l...

Page 422: ...per left corner of the image aligns with the upper left corner of the Stage when the file loads Also in both cases the loaded file inherits rotation and scaling and the original content is overwritten...

Page 423: ...security features on page 188 For example a SWF file at www someDomain com can load variables only from SWF files that are also at www someDomain com If you want to load variables from a different do...

Page 424: ...San Francisco zip 94103 In SWF files running in a version of the player earlier than Flash Player 7 url must be in the same superdomain as the SWF file that is issuing this call For example a SWF file...

Page 425: ...adVars addRequestHeader Adds or changes HTTP headers for POST operations LoadVars getBytesLoaded Returns the number of bytes downloaded by LoadVars load or LoadVars sendAndLoad LoadVars getBytesTotal...

Page 426: ...equestHeader headerName headerValue my_lv addRequestHeader headerName_1 headerValue_1 headerName_n headerValue_n Parameters headerName An HTTP request header name headerValue The value associated with...

Page 427: ...with a value of Foo to the my_lv object my_lv addRequestHeader SOAPAction Foo This next example creates an array named headers that contains two alternating HTTP headers and their associated values T...

Page 428: ...peration has not yet begun LoadVars getBytesTotal Availability Flash Player 6 Usage my_lv getBytesTotal Parameters None Returns An integer Description Method returns the total number of bytes download...

Page 429: ...WF files running in a version of the player earlier than Flash Player 7 url must be in the same superdomain as the SWF file that is issuing this call For example a SWF file at www someDomain com can l...

Page 430: ...hing Description Event handler invoked when data has been completely downloaded from the server or when an error occurs while data is downloading from a server This handler is invoked before the data...

Page 431: ...nded in success true or failure false Returns A Boolean value Description Event handler invoked when a LoadVars load or LoadVars sendAndLoad operation has ended If the operation was successful my_lv i...

Page 432: ...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 If the target parameter is specif...

Page 433: ...es of any version running in Flash Player 7 or later url must be in exactly the same domain see Flash Player security features on page 188 For example a SWF file at www someDomain com can load variabl...

Page 434: ...the receiving movie receiving_lc new LocalConnection receiving_lc methodToExecute function param1 param2 Code to be executed receiving_lc connect lc_name Code in the sending movie sending_lc new Loca...

Page 435: ...ements here my_lc connect connectionName Code in the sending SWF my_lc new LocalConnection my_lc send connectionName someMethod See also LocalConnection connect LocalConnection send Event handler Desc...

Page 436: ...in your handler would be simply return true If you do declare sendingDomain you probably want to compare the value of sendingDomain with domains from which you want to accept commands The following ex...

Page 437: ...tion object return true aLocalConnection connect _trace In the following example the receiving SWF file accepts commands only from SWF files located in thisDomain com or thatDomain com var aLocalConne...

Page 438: ...ompromises HTTPS security However you may need to do so for example if you need to permit access to HTTPS files published for Flash Player 7 or later from HTTP files published for Flash Player 6 A SWF...

Page 439: ...ere superdomain is the superdomain of the SWF file containing the LocalConnection connect command For example if the SWF file containing the receiving LocalConnection object is located at www someDoma...

Page 440: ...ct trace stop SWF 1 contains the following code attached to a button labeled PushMe When you push the button you see the sentence The button was pushed in the receiving SWF file on press var lc new Lo...

Page 441: ...se this command is to include the domain name of the sending LocalConnection object as a parameter to the method you plan to invoke in the receiving LocalConnection object or in conjunction with Local...

Page 442: ...ing values sender mydomain com result replyMethod aResult n1 123 and n2 456 It therefore executes the following line of code this send mydomain com result aResult 123 456 The aResult method line 54 di...

Page 443: ...allow connections from the sending domain or if the method does not exist The only way to know for sure if the method was invoked is to have the receiving object send a reply to the sending object If...

Page 444: ...ened with the LocalConnection connect connectionName command called the receiving LocalConnection object The object used with this command is called the sending LocalConnection object The SWF files th...

Page 445: ...n LocalConnection objects located in specified domains see LocalConnection allowDomain and LocalConnection domain See also LocalConnection allowDomain LocalConnection connect LocalConnection domain Lo...

Page 446: ...h SIN 7854 The Math class is fully supported in Flash Player 5 In Flash Player 4 you can use methods of the Math class but they are emulated using approximations and may not be as accurate as the non...

Page 447: ...nd properties of the Math class are emulated using approximations and may not be as accurate as the non emulated math functions supported by Flash Player 5 Usage Math acos x Parameters x A number from...

Page 448: ...x A number from 1 0 to 1 0 Returns A number Description Method computes and returns the arc sine for the number specified in the parameter x in radians Math atan Availability Flash Player 5 In Flash...

Page 449: ...ngent of y x in radians The return value represents the angle opposite the opposite angle of a right triangle where x is the adjacent side length and y is the opposite side length Math ceil Availabili...

Page 450: ...value from 1 0 to 1 0 of the angle specified by the parameter x The angle x must be specified in radians Use the information outlined in the Math class entry to calculate a radian Math E Availability...

Page 451: ...ecified in the parameter x The constant Math E can provide the value of e Math floor Availability Flash Player 5 In Flash Player 4 the methods and properties of the Math class are emulated using appro...

Page 452: ...ith a value greater than 0 Returns A number Description Method returns the logarithm of parameter x Math LN2 Availability Flash Player 5 In Flash Player 4 the methods and properties of the Math class...

Page 453: ...the natural logarithm of 10 expressed as loge10 with an approximate value of 2 3025850929940459011 Math LOG2E Availability Flash Player 5 In Flash Player 4 the methods and properties of the Math class...

Page 454: ...t a mathematical constant for the base 10 logarithm of the constant e Math E expressed as log10e with an approximate value of 0 43429448190325181667 Math max Availability Flash Player 5 In Flash Playe...

Page 455: ...on Returns A number Description Method evaluates x and y and returns the smaller value Math PI Availability Flash Player 5 In Flash Player 4 the methods and properties of the Math class are emulated u...

Page 456: ...er to be raised to a power y A number specifying a power the parameter x is raised to Returns A number Description Method computes and returns x to the power of y xy Math random Availability Flash Pla...

Page 457: ...properties of the Math class are emulated using approximations and may not be as accurate as the non emulated math functions supported by Flash Player 5 Usage Math sin x Parameters x An angle measured...

Page 458: ...on emulated math functions supported by Flash Player 5 Usage Math SQRT1_2 Parameters None Returns Nothing Description Constant a mathematical constant for the square root of one half Math SQRT2 Availa...

Page 459: ...layer 4 This function has been deprecated in favor of the TextField maxscroll property Usage variable_name maxscroll Description Property read only a deprecated property that indicates the line number...

Page 460: ...sage mblength string Parameters string A string Returns A number Description String function returns the length of the multibyte character string mbord Availability Flash Player 4 This function was de...

Page 461: ...Player 6 Description The Microphone class lets you capture audio from a microphone attached to the computer that is running Flash Player The Microphone class is primarily for use with Flash Communicat...

Page 462: ...has allowed or denied access to the microphone Microphone name The name of the current sound capture device as returned by the sound capture hardware Microphone names Class property an array of strin...

Page 463: ...s the variable level to the activity level of the current microphone myMic activityLevel var level myMic activityLevel See also Microphone setGain Microphone gain Availability Flash Player 6 Usage act...

Page 464: ...rophone which is recommended for most applications omit this parameter Returns If index is not specified this method returns a reference to the default microphone or if it is not available to the firs...

Page 465: ...r Stage size is at least 215 x 138 pixels this is the minimum size Flash requires to display the dialog box When the user responds to this dialog box the Microphone onStatus event handler returns an i...

Page 466: ...e index of the microphone as reflected in the array returned by Microphone names See also Microphone get Microphone names Microphone muted Availability Flash Player 6 Usage activeMicrophone muted Desc...

Page 467: ...is myMic name See also Microphone get Microphone names Microphone names Availability Flash Player 6 Usage Microphone names Note The correct syntax is Microphone names To assign the return value to a...

Page 468: ...e name Microphone onActivity Availability Flash Player 6 Usage activeMicrophone onActivity function activity your statements here Parameters activity A Boolean value set to true when the microphone st...

Page 469: ...user allows access the Microphone muted property is set to false and this event handler is invoked with an information object whose code property is Microphone Unmuted and whose level property is Sta...

Page 470: ...r 6 Usage activeMicrophone setGain gain Parameters gain An integer that specifies the amount by which the microphone should boost the signal Valid values are 0 to 100 The default value is 50 however t...

Page 471: ...ce supports this value Otherwise the default value is the next available capture level above 8 kHz that your sound capture device supports usually 11 kHz Returns Nothing Description Method sets the ra...

Page 472: ...en audio levels suggest that a person is talking When someone is not talking bandwidth can be saved because there is no need to send the associated audio stream This information can also be used for v...

Page 473: ...n should be used true or not false Returns Nothing Description Method specifies whether to use the echo suppression feature of the audio codec The default value is false unless the user has selected R...

Page 474: ...ample See the example for Microphone silenceTimeout See also Microphone gain Microphone setSilenceLevel Microphone silenceTimeout Availability Flash Player 6 Usage activeMicrophone silenceTimeout Desc...

Page 475: ...seEchoSuppression true See also Microphone setUseEchoSuppression MMExecute Availability Flash Player 7 Usage MMExecute Flash JavaScript API command Parameters Flash JavaScript API command Any command...

Page 476: ...You can use the methods of the Mouse class to hide and show the mouse pointer cursor in the SWF file The mouse pointer is visible by default but you can hide it and implement a custom pointer that you...

Page 477: ...s pressed moved or released regardless of the input focus all listening objects that are registered with this method have their onMouseDown onMouseMove or onMouseUp method invoked Multiple objects can...

Page 478: ...ouse Mouse onMouseDown Availability Flash Player 6 Usage someListener onMouseDown Parameters None Returns Nothing Description Listener notified when the mouse is pressed To use the onMouseDown listene...

Page 479: ...ion Mouse addListener someListener Listeners enable different pieces of code to cooperate because multiple listeners can receive notification about a single event See also Mouse addListener Mouse onMo...

Page 480: ...ify a value for scrollTarget pass null for delta scrollTarget The topmost movie clip instance under the mouse when the mouse wheel was scrolled Returns Nothing Description Listener notified when the u...

Page 481: ...cessfully removed for example if the listener was not on the Mouse object s listener list the method returns false Description Method removes an object that was previously registered with addListener...

Page 482: ...ied movie clip MovieClip getBounds Returns the minimum and maximum x and y coordinates of a SWF file in a specified coordinate space MovieClip getBytesLoaded Returns the number of bytes loaded for the...

Page 483: ...coordinates MovieClip nextFrame Sends the playhead to the next frame of the movie clip MovieClip play Plays the specified movie clip MovieClip prevFrame Sends the playhead to the previous frame of th...

Page 484: ...get The absolute path in slash syntax notation of the movie clip instance on which a draggable movie clip was dropped MovieClip enabled Indicates whether a button movie clip is enabled MovieClip focus...

Page 485: ...d is displayed when a user rolls over a button movie clip MovieClip _visible A Boolean value that determines whether a movie clip instance is hidden or visible MovieClip _width The width of a movie cl...

Page 486: ...nvoked when focus is removed from a button MovieClip onLoad Invoked when the movie clip is instantiated and appears in the Timeline MovieClip onMouseDown Invoked when the left mouse button is pressed...

Page 487: ...The following code sets the _alpha property of a movie clip named star_mc to 30 when the button is clicked on release star_mc _alpha 30 See also Button _alpha TextField _alpha MovieClip attachAudio Av...

Page 488: ...o attach to a movie clip on the Stage This is the name entered in the Identifier field in the Linkage Properties dialog box newname A unique instance name for the movie clip being attached to the movi...

Page 489: ...l is not created alpha An integer between 0 100 that specifies the alpha value of the fill If this value is not provided 100 solid is used If the value is less than 0 Flash uses 0 If the value is grea...

Page 490: ...y of color distribution ratios valid values are 0 255 This value defines the percentage of the width where the color is sampled at 100 percent matrix A transformation matrix that is an object with eit...

Page 491: ...parent clip for the upper left corner of the gradient w is the width of the gradient h is the height of the gradient and r is the rotation in radians of the gradient The following example uses a begin...

Page 492: ...ers are not equal The fillType parameter is not linear or radial Any of the fields in the object for the matrix parameter are missing or invalid Example The following code uses both methods to draw tw...

Page 493: ...h Player 6 Usage my_mc clear Parameters None Returns Nothing Description Method removes all the graphics created during runtime using the movie clip draw methods including line styles specified with M...

Page 494: ...ew 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 See also MovieClip attachMovie MovieClip creat...

Page 495: ...ne false html false embedFonts false variable null maxChars null A text field created with createTextField receives the following default TextFormat object font Times New Roman size 12 textColor 0x000...

Page 496: ...position relative to the registration point of the parent movie clip of the control point anchorX An integer that specifies a horizontal position relative to the registration point of the parent movi...

Page 497: ...starts with a slash To compare the _droptarget property of an instance to a reference use the eval function to convert the returned value from slash syntax to a dot syntax reference Note You must per...

Page 498: ...rties of initObject are copied into the new instance The properties specified with initObject are available to the constructor function This parameter is optional Returns A reference to the duplicated...

Page 499: ...enabled property only governs the button like properties of a button movie clip You can change the enabled property at any time the modified button movie clip is immediately enabled or disabled The en...

Page 500: ...ie clip has a yellow rectangle around it when it has keyboard focus This property can override the global _focusrect property MovieClip _framesloaded Availability Flash Player 4 Usage my_mc _framesloa...

Page 501: ...o use as a reference point Returns An object with the properties xMin xMax yMin and yMax Description Method returns properties that are the minimum and maximum x and y coordinate values of the instanc...

Page 502: ...turned by MovieClip getBytesTotal to determine what percentage of a movie clip has loaded See also MovieClip getBytesTotal MovieClip getBytesTotal Availability Flash Player 5 Usage my_mc getBytesTotal...

Page 503: ...An integer that specifies the depth level to query Returns A string representing the name of the movie clip located at the specified depth or undefined if there is no movie clip at that depth Descrip...

Page 504: ...jects 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 For more information see Managing movie clip depths on page 129...

Page 505: ...ts the tab index order of the static text fields in the movie clip Text fields that don t have tab index values are placed in a random order in the object and precede any text from fields that do have...

Page 506: ...ng variables associated with the SWF file to load If there are no variables omit this parameter otherwise specify whether to load variables using a GET or POST method GET appends the variables to the...

Page 507: ...use trace point x point y updateAfterEvent See also MovieClip getBounds MovieClip localToGlobal MovieClip gotoAndPlay Availability Flash Player 5 Usage my_mc gotoAndPlay frame Parameters frame A numbe...

Page 508: ...er clicks the mouse button onClipEvent mouseDown _width 200 _height 200 MovieClip _highquality Availability Flash Player 6 Usage my_mc _highquality Description Property global specifies the level of a...

Page 509: ...st Availability Flash Player 5 Usage my_mc hitTest x y shapeFlag my_mc hitTest target Parameters x The x coordinate of the hit area on the Stage y The y coordinate of the hit area on the Stage The x a...

Page 510: ...laps or intersects the movie clip square if _root ball hitTest _root square trace ball intersects square See also MovieClip getBounds MovieClip globalToLocal MovieClip localToGlobal MovieClip lineStyl...

Page 511: ...lip curveTo MovieClip lineTo MovieClip moveTo MovieClip lineTo Availability Flash Player 6 Usage my_mc lineTo x y Parameters x An integer indicating the horizontal position relative to the registratio...

Page 512: ...r sending or loading variables The parameter must be the string GET or POST If there are no variables to be sent omit this parameter The GET method appends the variables to the end of the URL and is u...

Page 513: ...urns Nothing Description Method reads data from an external file and sets the values for variables in my_mc The external file can be a text file generated by a CGI script Active Server Page ASP or PHP...

Page 514: ...movie clip s local coordinates to the Stage global coordinates Example The following example converts x and y coordinates of the point object from the movie clip s local coordinates to the Stage globa...

Page 515: ...ers to _root in Chess swf after being loaded into Games swf If you have access to Chess fla and publish it to Flash Player 7 or later you can add this statement to it this _lockroot true If you don t...

Page 516: ...clip content_mc The ContextMenu object contains a custom menu item labeled Print that has an associated callback handler named doPrint var menu_cm new ContextMenu menu_cm customItems push new Context...

Page 517: ...awing position is indicated by the moveTo method _root createEmptyMovieClip triangle 1 with _root triangle lineStyle 5 0xff00ff 100 moveTo 200 200 lineTo 300 300 lineTo 100 300 lineTo 200 200 See also...

Page 518: ...e correct use of MovieClip onData and onClipEvent data symbol_mc is a movie clip symbol in the library It is linked to the MovieClip class The following function is triggered for each instance of symb...

Page 519: ...nd the pointer rolls outside the object You must define a function that executes when the event handler is invoked Example The following example defines a function for the onDragOut method that sends...

Page 520: ...gOut MovieClip onEnterFrame Availability Flash Player 6 Usage my_mc onEnterFrame function your statements here Parameters None Returns Nothing Description Event handler invoked continually at the fram...

Page 521: ...ie clip has input focus enabled and set First the focusEnabled property must be set to true for the movie clip Then the clip must be given focus This can be done either by using Selection setFocus or...

Page 522: ...movie clip has input focus enabled and set First the focusEnabled property must be set to true for the movie clip Then the clip must be given focus This can be done either by using Selection setFocus...

Page 523: ...vieClip onLoad Availability Flash Player 6 Usage my_mc onLoad function your statements here Parameters None Returns Nothing Description Event handler invoked when the movie clip is instantiated and ap...

Page 524: ...the loaded SWF is not a symbol in the library associated with the MovieClip class function output trace Will never be called dynamic_mc onLoad output dynamic_mc loadMovie replacement swf The followin...

Page 525: ...e Availability Flash Player 6 Usage my_mc onMouseMove function your statements here Parameters None Returns Nothing Description Event handler invoked when the mouse moves You must define a function th...

Page 526: ...handler is invoked Example The following example defines a function for the onMouseUp method that sends a trace action to the Output panel my_mc onMouseUp function trace onMouseUp called MovieClip on...

Page 527: ...e Parameters None Returns Nothing Description Event handler invoked when a button movie clip is released You must define a function that executes when the event handler is invoked Example The followin...

Page 528: ...sends a trace action to the Output panel my_mc onReleaseOutside function trace onReleaseOutside called MovieClip onRollOut Availability Flash Player 6 Usage my_mc onRollOut function your statements he...

Page 529: ...a trace to the Output panel my_mc onRollOver function trace onRollOver called MovieClip onSetFocus Availability Flash Player 6 Usage my_mc onSetFocus function oldFocus your statements here Parameters...

Page 530: ...n for the MovieClip onUnload method that sends a trace action to the Output panel my_mc onUnload function trace onUnload called MovieClip _parent Availability Flash Player 5 Usage my_mc _parent proper...

Page 531: ...e Returns Nothing Description Method moves the playhead in the Timeline of the movie clip See also play MovieClip prevFrame Availability Flash Player 5 Usage my_mc prevFrame Parameters None Returns No...

Page 532: ...vieClip _rotation Availability Flash Player 4 Usage my_mc _rotation Description Property the rotation of the movie clip in degrees from its original orientation Values from 0 to 180 represent clockwis...

Page 533: ..._mc setMask my_mc If you create a mask layer that contains a movie clip and then apply the setMask method to it the setMask call takes priority and this is not reversible For example you could have a...

Page 534: ...coordinates of the movie clip s parent that specify a constraint rectangle for the movie clip These parameters are optional Returns Nothing Description Method lets the user drag the specified movie cl...

Page 535: ...he depth level where my_mc is to be placed target A string specifying the movie clip instance whose depth is swapped by the instance specified by my_mc Both instances must have the same parent movie c...

Page 536: ...alse The tabChildren property has no effect if the tabIndex property is used the tabChildren property affects only automatic tab ordering See also Button tabIndex MovieClip tabEnabled MovieClip tabInd...

Page 537: ...SWF file The custom tab ordering includes only objects that have tabIndex properties The tabIndex property must be a positive integer The objects are ordered according to their tabIndex properties in...

Page 538: ...Boolean property that indicates whether or not other buttons or movie clips can receive mouse release events This allows you to create menus You can set the trackAsMenu property on any button or movi...

Page 539: ...lip was downloaded MovieClip useHandCursor Availability Flash Player 6 Usage my_mc useHandCursor Description Property a Boolean value that indicates whether the hand cursor pointing hand appears when...

Page 540: ...e are disabled For example a button in a movie clip with _visible set to false cannot be clicked See also Button _visible TextField _visible MovieClip _width Availability Flash Player 4 as a read only...

Page 541: ...lip that has transformations the movie clip is in the local coordinate system of the enclosing movie clip Thus for a movie clip rotated 90 degrees counterclockwise the movie clip s children inherit a...

Page 542: ...e also MovieClip _x MovieClip _y MovieClip _yscale MovieClip _y Availability Flash Player 3 Usage my_mc _y Description Property sets the y coordinate of a movie clip relative to the local coordinates...

Page 543: ...ty sets the vertical scale percentage of the movie clip as applied from the registration point of the movie clip The default registration point is 0 0 Scaling the local coordinate system affects the _...

Page 544: ...he MovieClipLoader onLoadComplete listener is invoked After the downloaded file s first frame actions have been executed the MovieClipLoader onLoadInit listener is invoked After MovieClipLoader onLoad...

Page 545: ...lso MovieClipLoader addListener Listener Description MovieClipLoader onLoadComplete Invoked when a file loaded with MovieClipLoader loadClip has completely downloaded MovieClipLoader onLoadError Invok...

Page 546: ...adInit MovieClipLoader onLoadProgress MovieClipLoader onLoadStart MovieClipLoader removeListener MovieClipLoader getProgress Availability Flash Player 7 Usage my_mcl getProgress target_mc Parameters t...

Page 547: ...her HTML document Using this method instead of loadMovie or MovieClip loadMovie has a number of advantages The MovieClipLoader onLoadStart handler is invoked when loading begins The MovieClipLoader on...

Page 548: ...mc var loadProgress my_mcl getProgress target_mc myTrace loadProgress bytesLoaded bytes loaded at end myTrace loadProgress bytesTotal bytes total at end myListener onLoadInit function target_mc myTrac...

Page 549: ...loadProgress my_mcl getProgress target_mc myTrace loadProgress bytesLoaded bytes loaded at end myTrace loadProgress bytesTotal bytes total at end myListener2 onLoadError function target_mc errorCode...

Page 550: ...ded Example See MovieClipLoader loadClip See also MovieClipLoader addListener MovieClipLoader onLoadStart MovieClipLoader onLoadError MovieClipLoader onLoadError Availability Flash Player 7 Usage list...

Page 551: ...r crash and so on MovieClipLoader onLoadComplete will not be called Example See MovieClipLoader loadClip MovieClipLoader onLoadInit Availability Flash Player 7 Usage listenerObject onLoadInit function...

Page 552: ...rns Nothing Description Listener invoked every time the loading content is written to disk during the loading process that is between MovieClipLoader onLoadStart and MovieClipLoader onLoadComplete You...

Page 553: ...ash Player 7 Usage my_mcl removeListener listenerObject Parameters listenerObject A listener object that was added using MovieClipLoader addListener Returns Nothing Description Method deletes an objec...

Page 554: ...ble with the IEEE 754 value for NaN Not a Number To determine if a number is NaN use isNaN See also isNaN Number NaN ne not equal string specific Availability Flash Player 4 This operator has been dep...

Page 555: ...ver For more information see your Flash Communication Server documentation Usage new NetConnection Parameters None Returns Nothing Description Constructor creates a NetConnection object that you can u...

Page 556: ...th Flash Communication Server For more information see your Flash Communication Server documentation Description The NetStream class provides methods and properties for playing Flash Video FLV files f...

Page 557: ...ferTime Specifies how long to buffer data before starting to display the stream Property Description NetStream bufferLength The number of seconds of data currently in the buffer NetStream bufferTime R...

Page 558: ...onstruct a new NetStream object called videoStream_ns my_nc new NetConnection my_nc connect null videoStream_ns new NetStream my_nc See also NetConnection class NetStream class Video attachVideo NetSt...

Page 559: ...etStream bufferLength See also NetStream time NetStream bytesLoaded Availability Flash Player 7 Usage my_ns bytesLoaded Description Read only property the number of bytes of data that have been loaded...

Page 560: ...on and deletes the temporary copy of someFile flv that was stored on the local disk my_nc new NetConnection my_nc connect null my_ns new NetStream my_nc my_ns play http www someDomain com videos someF...

Page 561: ...tatus handler and a level property containing a string that is either Status or Error In addition to this onStatus handler Flash also provides a super function called System onStatus If onStatus is in...

Page 562: ...e specifying whether to pause play true or resume play false If you omit this parameter NetStream pause acts as a toggle the first time it is called on a specified stream it pauses play and the next t...

Page 563: ...see MovieClip attachAudio If the FLV file can t be found the NetStream onStatus event handler is invoked If you want to stop a stream that is currently playing use NetStream close You can play local F...

Page 564: ...15 seconds from the beginning use myStream seek 15 To seek relative to the current position pass mystream time n or mystream time n to seek n seconds forward or backward respectively from the current...

Page 565: ...ies how long to buffer messages before starting to display the stream For example if you want to make sure that the first 15 seconds of the stream play without interruption set numberOfSeconds to 15 F...

Page 566: ...es to the function any optional parameters in parentheses as well as the newly created object which is referenced using the keyword this The constructor function can then use this to set the variables...

Page 567: ...tion or action in your code Example The following example shows how newline displays output from the trace action on multiple lines var myName String Lisa myAge Number 30 trace myName myAge trace myNa...

Page 568: ...when a user releases the button the playhead is sent to Frame 1 of the next scene on release nextScene See also prevScene not Availability Flash Player 4 This operator has been deprecated in favor of...

Page 569: ...sh Player 6 which improved performance significantly Description The Number class is a simple wrapper object for the Number data type You can manipulate primitive numeric values by using the methods a...

Page 570: ...a parameter to a primitive value Example The following code constructs new Number objects n1 new Number 3 4 n2 new Number 10 See also Number Method Description Number toString Returns the string repre...

Page 571: ...s number is approximately 1 79E 308 Number MIN_VALUE Availability Flash Player 5 Usage Number MIN_VALUE Description Property the smallest representable number double precision IEEE 754 This number is...

Page 572: ...TY Availability Flash Player 5 Usage Number POSITIVE_INFINITY Description Property specifies the IEEE 754 value representing positive infinity The value of this property is the same as that of the con...

Page 573: ...parameter and returns a string that contains the corresponding representation of the number 9 myNumber new Number 9 trace myNumber toString 2 1001 trace myNumber toString 8 11 See also NaN Number valu...

Page 574: ...ise AND operator See also NaN Number class Object class Availability Flash Player 5 became a native object in Flash Player 6 which improved performance significantly Description The Object class is at...

Page 575: ...ction object If you pass the value null for this parameter the property is read only Returns Returns a value of true if the property is successfully created otherwise returns false Description Method...

Page 576: ...r set or retrieved A third internal method getTitle returns a read only value that is associated with the property bookname function Book this setQuantity function numBooks this books numBooks this ge...

Page 577: ...thods getScroll setScroll and getMaxScroll The TextField constructor creates the getter setter properties and points them to the internal get set methods as in the following this addProperty scroll th...

Page 578: ...r the ActionScript class theClass A reference to the constructor function of the ActionScript class or null to unregister the symbol Returns If the class registration succeeds a value of true is retur...

Page 579: ...clip with an ActionScript class other than MovieClip the movie clip symbol doesn t inherit the methods properties and events of the built in MovieClip class unless you include the MovieClip class in t...

Page 580: ...a watchpoint that Object watch created This method returns a value of true if the watchpoint was successfully removed otherwise it returns a false value Object valueOf Availability Flash Player 5 Usag...

Page 581: ...hich a watchpoint has been set that watchpoint does not disappear If you later recreate the property the watchpoint is still in effect To remove a watchpoint use the Object unwatch method Only a singl...

Page 582: ...modified the function specified by the component is invoked to perform any tasks needed to update the appearance and state of the component The following example invokes an Object watch method to noti...

Page 583: ...er the button dragOut While the pointer is over the button the mouse button is pressed and then rolls outside the button area dragOver While the pointer is over the button the mouse button has been pr...

Page 584: ...ime the mouse is moved Use the _xmouse and _ymouse properties to determine the current mouse position mouseDown The action is initiated when the left mouse button is pressed mouseUp The action is init...

Page 585: ...e each time the mouse moves onClipEvent mouseMove stageX _root _xmouse stageY _root _ymouse See also Key class MovieClip _xmouse MovieClip _ymouse on updateAfterEvent onUpdate Availability Flash Playe...

Page 586: ...abelColor which specifies the color of the text label color The following code is in the first frame of the main Timeline of the component movie Define the textColor parameter variable to specify the...

Page 587: ...y Description Identifier specifies or returns a reference to the movie clip or object that contains the current movie clip or object The current object is the object containing the ActionScript code t...

Page 588: ...es a character that is not a part of the initial number If the string does not begin with a number that can be parsed parseFloat returns NaN White space preceding valid integers is ignored as are trai...

Page 589: ...inning with 0 or specifying a radix of 8 are interpreted as octal numbers White space preceding valid integers is ignored as are trailing nonnumeric characters Example The following examples use the p...

Page 590: ...ers Steve the play action is called and the playhead moves forward in the Timeline If the user enters anything other than Steve the SWF file does not play and a text field with the variable name alert...

Page 591: ...4 20 Note If you are authoring for Flash Player 7 or later you can create a PrintJob object which gives you and the user more control over the printing process For more information see the PrintJob cl...

Page 592: ...specific frames in the target movie clip attach a p frame label to those frames Although print results in higher quality prints than printAsBitmap it cannot be used to print movie clips that use alpha...

Page 593: ...ntable frame should be used as the print area for that frame This changes the print area for each frame and scales the objects to fit the print area Use bframe if you have objects of different sizes i...

Page 594: ...changes the print area for each frame and scales the objects to fit the print area Use bframe if you have objects of different sizes in each frame and want each object to fill the printed page Return...

Page 595: ...nt and dynamic text Additionally with properties populated by PrintJob start your document can access your user s printer settings such as page height width and orientation and you can configure your...

Page 596: ...continuing to print See the examples for PrintJob addPage You cannot create a PrintJob object until any PrintJob object that you already created is no longer active that is it either completed success...

Page 597: ...The default value is false which represents a request for vector printing Keep in mind the following suggestions when determining which value to use If the content that you re printing includes a bitm...

Page 598: ...hen set them back to their original values afterward The scale of a movie clip has no relation to printArea That is if you specify that you print an area that is 50 x 50 pixels in size 2500 pixels are...

Page 599: ...wide and 600 pixels high of frame 3 of the dance_mc movie clip in vector format at 50 of its actual size var x dance_mc _xscale var y dance_mc _yscale dance_mc _xscale 50 dance_mc _yscale 50 if my_pj...

Page 600: ...int dialog box the player begins spooling a print job to the operating system You should issue any ActionScript commands that affect the printout and then you can begin using PrintJob addPage commands...

Page 601: ...level in Flash Player to print By default all of the frames in the level print If you want to print specific frames in the level assign a p frame label to those frames Bounding box A modifier that set...

Page 602: ...PostScript printers convert vectors to bitmaps See also print printAsBitmap printAsBitmapNum PrintJob class private Availability Flash Player 6 Usage class someClassName private var name private func...

Page 603: ...t calls it Because variables and functions are public by default this keyword is used primarily for stylistic reasons For example you might want to use it for reasons of consistency in a block of code...

Page 604: ...is the default rendering quality setting used by Flash BEST Very high rendering quality Graphics are anti aliased using a 4 x 4 grid in pixels and bitmaps are always smoothed Example The following exa...

Page 605: ...5 Usage return expression Parameters expression A string number array or object to evaluate and return as a value of the function This parameter is optional Returns The evaluated expression parameter...

Page 606: ...ovie Timeline If a movie has multiple levels the root movie Timeline is on the level containing the currently executing script For example if a script in level 1 evaluates _root _level1 is returned Sp...

Page 607: ...creating scrolling text fields This property can be retrieved and modified Example The following code is attached to an Up button that scrolls the text field myText on release myText scroll myText sc...

Page 608: ...Focus is invoked Selection getBeginIndex Returns the index at the beginning of the selection span Returns 1 if there is no index or currently selected field Selection getCaretIndex Returns the current...

Page 609: ...s 1 Selection span indexes are zero based for example the first position is 0 the second position is 1 and so on Selection getCaretIndex Availability Flash Player 5 Usage Selection getCaretIndex Param...

Page 610: ...r 6 and later Usage Selection getFocus Parameters None Returns A string or null Description Method returns the variable name of the text field that has focus If no text field has focus the method retu...

Page 611: ...istener someListener Listeners enable different pieces of code to cooperate because multiple listeners can receive notification about a single event See also Selection addListener Selection removeList...

Page 612: ...th If you are using ActionScript 2 0 you must use dot notation If null is passed the current focus is removed Example The following example gives focus to a text field associated with myVar on the mai...

Page 613: ...le s Publish Settings dialog box This keyword is supported only when used in external script files not in scripts written in the Actions panel Parameters property Word you want to use to refer to the...

Page 614: ...se Variables can hold any data type for example String Number Boolean Object or MovieClip The Timeline of each SWF file and movie clip has its own set of variables and each variable has its own value...

Page 615: ...alled as close to interval as possible You must use the updateAfterEvent function to make sure that the screen refreshes often enough If interval is greater than the SWF file s frame rate the interval...

Page 616: ...l obj2 interval 1000 interval function called See also clearInterval updateAfterEvent setProperty Availability Flash Player 4 Usage setProperty target property value expression Parameters target The p...

Page 617: ...d object use the following syntax Create a local shared object so SharedObject getLocal foo Local disk space considerations Local shared objects are always persistent on the client up to available mem...

Page 618: ...s explained above Additionally if the user selects a value that is less than the amount of disk space currently being used for locally persistent data the player warns the user that any locally saved...

Page 619: ...ared and or stored Each attribute can be an object of any of the basic ActionScript or JavaScript types Array Number Boolean and so on For example the following lines assign values to various aspects...

Page 620: ...ing value of pending If the user has permitted local information storage for objects from this domain and the amount of space allotted is sufficient to store the object this method returns true If you...

Page 621: ...future attempts to flush the object as long as its size doesn t exceed 500 bytes After the user responds to the dialog box this method is called again and returns either true or false also SharedObjec...

Page 622: ...ecified but no such directory exists this method returns null Description Method returns a reference to a locally persistent shared object that is available only to the current client To avoid name co...

Page 623: ...ou have a specific need for it Example The following example gets the size of the shared object so var soSize this so getSize SharedObject onStatus Availability Flash Player 6 Usage myLocalSharedObjec...

Page 624: ...g the methods of the Sound class Method summary for the Sound class Code property Level property Meaning SharedObject Flush Failed Error A SharedObject flush command that returned pending has failed t...

Page 625: ...e amount of each channel left and right to be played in each speaker Sound setVolume Sets the volume level for a sound Sound start Starts playing a sound from the beginning or optionally from an offse...

Page 626: ...ttachSound idName Parameters idName The identifier of an exported sound in the library The identifier is located in the Linkage Properties dialog box Returns Nothing Description Method attaches the so...

Page 627: ...ed Sound object You can compare the value of getBytesLoaded with the value of getBytesTotal to determine what percentage of a sound has loaded See also Sound getBytesTotal Sound getBytesTotal Availabi...

Page 628: ...setting controls the left right balance of the current and future sounds in a SWF file This method is cumulative with setVolume or setTransform See also Sound setPan Sound getTransform Availability F...

Page 629: ...oadSound contains ID3 tags you can query these properties Only ID3 tags that use the UTF 8 character set are supported Flash Player 6 release 40 and later use the Sound id3 property to support ID3 1 0...

Page 630: ...ngth TMED Media type TOAL Original album movie show title TOFN Original filename TOLY Original lyricists text writers TOPE Original artists performers TORY Original release year TOWN File owner licens...

Page 631: ...und Sound loadSound Sound loadSound Availability Flash Player 6 Usage my_sound loadSound url isStreaming Parameters url The location on a server of an MP3 sound file isStreaming A Boolean value that i...

Page 632: ...with this method are saved in the browser s file cache on the user s system Example The following example loads an event sound my_sound loadSound http serverpath port mp3filename false The following...

Page 633: ...layer 6 Usage my_sound onLoad function success your statements here Parameters success A Boolean value of true if my_sound has been loaded successfully false otherwise Returns Nothing Description Even...

Page 634: ...ing You must create a function that executes when this handler is invoked You can use either an anonymous function or a named function Example Usage 1 The following example uses an anonymous function...

Page 635: ...ns An integer Description Method determines how the sound is played in the left and right channels speakers For mono sounds pan determines which speaker left or right the sound plays through Example T...

Page 636: ...play mono sounds as stereo play stereo sounds as mono and to add interesting effects to sounds The properties for the soundTransformObject are as follows 11 A percentage value specifying how much of t...

Page 637: ...bject you then need to pass the object to the Sound object using setTransform as follows my_sound setTransform mySoundTransformObject The following example plays a stereo sound as mono the soundTransf...

Page 638: ...ent load i 100 my_sound new Sound my_sound setVolume 50 onClipEvent enterFrame if i 100 my_sound setPan i See also Sound setPan Sound setTransform Sound start Availability Flash Player 5 Usage my_soun...

Page 639: ...pecifying a specific sound to stop playing The idName parameter must be enclosed in quotation marks Returns Nothing Description Method stops all sounds currently playing if no parameter is specified o...

Page 640: ...ummary for the Stage class Method Description Stage addListener Adds a listener object that detects when a SWF file is resized Stage removeListener Removes a listener object from the Stage object Prop...

Page 641: ...e listener objects receive notification from Stage onResize Example This example creates a new listener object called myListener It then uses myListener to call onResize and define a function that wil...

Page 642: ...e When the value of Stage scaleMode is noScale the height property represents the height of the player When the value of Stage scaleMode is not noScale height represents the height of the SWF file See...

Page 643: ...resized Stage scaleMode noScale myListener new Object myListener onResize function trace Stage size is now Stage width by Stage height Stage addListener myListener later call Stage removeListener myLi...

Page 644: ...ilability Flash Player 6 Usage Stage showMenu Description Property read write specifies whether to show or hide the default items in the Flash Player context menu If showMenu is set to true the defaul...

Page 645: ...ent that specify a constraint rectangle for the movie clip These parameters are optional Returns Nothing Description Function makes the target movie clip draggable while the movie is playing Only one...

Page 646: ...l Parameters name The name of the variable or function that you want to specify as static Description Keyword specifies that a variable or function is created only once per class rather than being cre...

Page 647: ...the playhead Sounds set to stream will resume playing as the playhead moves over the frames they are in Example The following code could be applied to a button that when clicked stops all sounds in th...

Page 648: ...ters quotation marks indicate that the characters have a literal value and are considered a string not a variable numerical value or other ActionScript element Example This example uses quotation mark...

Page 649: ...the String length property with a string literal Do not confuse a string literal with a String object In the following example the first line of code creates the string literal s1 and the second line...

Page 650: ...ameters index An integer that specifies the position of a character in the string The first character is indicated by 0 and the last character is indicated by my_str length 1 Returns A character Strin...

Page 651: ...ity Flash Player 5 Usage my_str charCodeAt index Parameters index An integer that specifies the position of a character in the string The first character is indicated by 0 and the last character is in...

Page 652: ...formed string the original value my_str is unchanged String fromCharCode Availability Flash Player 5 Usage String fromCharCode c1 c2 cN Parameters c1 c2 cN Decimal integers that represent ASCII value...

Page 653: ...or after startIndex within the calling string If substring is not found the method returns 1 See also String lastIndexOf String lastIndexOf Availability Flash Player 5 Usage my_str lastIndexOf substri...

Page 654: ...tted String length is used If end is a negative number the ending point is determined by counting back from the end of the string where 1 is the last character Returns A substring of the specified str...

Page 655: ...reaking it wherever the specified delimiter parameter occurs and returns the substrings in an array If you use an empty string as a delimiter each character in the string is placed as an element in th...

Page 656: ...Availability Flash Player 5 Usage my_str substring start end Parameters start An integer that indicates the position of the first character of my_str used to create the substring Valid values for sta...

Page 657: ...l value is unchanged String toUpperCase Availability Flash Player 5 Usage my_str toUpperCase Parameters None Returns A string Description Method returns a copy of the String object with all of the low...

Page 658: ...later the result is undefined If expression is a Boolean value the return string is true or false If expression is a movie clip the return value is the target path of the movie clip in slash notation...

Page 659: ...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 invoke the superclass version of the constructor...

Page 660: ...uates to 2 the trace action that follows case 2 executes and so on If no case expression matches the number parameter the trace action that follows the default keyword executes switch number case 1 tr...

Page 661: ...the System class Method Description System setClipboard Replaces the contents of the system clipboard with a text string System showSettings Displays a Flash Player Settings panel Method Description...

Page 662: ...file hosted at here xyz com and true in a SWF file hosted at xyz com both files will use the same settings and data namely those at xyz com If this isn t the behavior you want make sure that you set...

Page 663: ...ned to System onStatus if it exists Note The Camera and Microphone classes also have onStatus handlers but do not pass information objects with a level property of error Therefore System onStatus is n...

Page 664: ...ks Returns A Boolean value of true if the text was successfully placed on the clipboard false otherwise Description Method replaces the contents of the system clipboard with a specified text string Sy...

Page 665: ...iles must be encoded as Unicode when you save them When the property is set to true Flash Player interprets external text files using the traditional code page of the operating system running the play...

Page 666: ...to determine the type of device a user has You can then either specify to the server to send different SWF files based on the device capabilities or tell the SWF file to alter its presentation based o...

Page 667: ...ties isDebugger Indicates whether the player is an officially released version or a special debugging version DEB System capabilities language Indicates the language of the system on which the player...

Page 668: ...hether the player is running in an environment that supports communication between Flash Player and accessibility aids The server string is ACC See also Accessibility isActive Accessibility updateProp...

Page 669: ...cription Property a Boolean value that indicates whether the player is running on a system that supports embedded video The server string is EV System capabilities hasMP3 Availability Flash Player 6 U...

Page 670: ...scription Property a Boolean value that indicates whether the player supports the playback of screen broadcast applications that are being run through the Flash Communication Server The server string...

Page 671: ...leased version false or a special debugging version true The server string is DEB System capabilities language Availability Flash Player 6 Usage System capabilities language Description Property indic...

Page 672: ...Availability Flash Player 6 Usage System capabilities manufacturer Description Property a string that indicates the manufacturer of Flash Player in the format Macromedia OSName OSName could be Window...

Page 673: ...ability Flash Player 6 Usage System capabilities pixelAspectRatio Description Property an integer that indicates the pixel aspect ratio of the screen The server string is AR System capabilities player...

Page 674: ...layer 6 Usage System capabilities screenResolutionX Description Property an integer that indicates the maximum horizontal resolution of the screen The server string is R which returns both the width a...

Page 675: ...Property a string containing the Flash Player platform and version information for example WIN 7 0 0 231 The server string is V System security object Availability Flash Player 6 Description This obj...

Page 676: ...osted at either www domain com or store domain com both domain names must be passed For Flash Player 6 System security allowDomain domain com Corresponding commands to allow access by SWF files that a...

Page 677: ...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 Player 6 can use System security allowDomain to permit HT...

Page 678: ...bject The target path is returned in dot notation To retrieve the target path in slash notation use the _target property Example This example displays the target path of a movie clip as soon as it loa...

Page 679: ...to issue multiple actions to the same Timeline You can use the with action to target any object whereas the tellTarget action can only target movie clips Example This tellTarget statement controls the...

Page 680: ...as an array TextField getDepth Returns the depth of a text field TextField getNewTextFormat Gets the default text format assigned to newly inserted text TextField getTextFormat Returns a TextFormat o...

Page 681: ...sh Player should automatically scroll multiline text fields when the mouse pointer is positioned over a text field and the user rolls the mouse wheel TextField multiline Indicates if the text field co...

Page 682: ...the text field word wraps TextField _x The x coordinate of a text field instance TextField _xmouse The x coordinate of the pointer relative to a text field instance Read only TextField _xscale The va...

Page 683: ...ta by putting a parameter in the event handler method For example the following code uses txt as the parameter that is passed to the onScroller event handler The parameter is then used in a trace stat...

Page 684: ..._txt autoSize Description Property controls automatic sizing and alignment of text fields Acceptable values for autoSize are none the default left right and center When you set the autoSize property t...

Page 685: ...nd fill TextField backgroundColor Availability Flash Player 6 Usage my_txt backgroundColor Description Property the color of the text field background Default is 0xFFFFFF white This property may be re...

Page 686: ...ld as a window onto a block of text The property TextField scroll is the one based index of the topmost visible line in the window All the text between lines TextField scroll and TextField bottomScrol...

Page 687: ...epth Parameters None Returns An integer Description Method returns the depth of a text field TextField getFontList Availability Flash Player 6 Usage TextField getFontList Parameters None Returns An ar...

Page 688: ...bject The text format object is the format that newly inserted text such as text inserted with the replaceSel method or text entered by a user receives When getNewTextFormat is invoked the TextFormat...

Page 689: ...ex to endIndex See also TextField getNewTextFormat TextField setNewTextFormat TextField setTextFormat TextField _height Availability Flash Player 6 Usage my_txt _height Description Property the height...

Page 690: ...ling text see Creating scrolling text on page 153 Example The following example scrolls the text horizontally on release my_txt hscroll 1 See also TextField maxhscroll TextField scroll TextField html...

Page 691: ...ield is an HTML text field in the Property inspector or by setting the text field s html property to true Example In the following example the text in the text field text2 is rendered bold text2 html...

Page 692: ...there is no limit on the amount of text a user can enter TextField maxhscroll Availability Flash Player 6 Usage my_txt maxhscroll Description Property read only indicates the maximum value of TextFie...

Page 693: ...rint doPrint function doPrint menu obj Print code here news_txt menu menu_cm See also Button menu ContextMenu class ContextMenuItem class MovieClip menu TextField mouseWheelEnabled Availability Flash...

Page 694: ...t handler invoked when the content of a text field changes By default it is undefined you can define it in a script A reference to the text field instance is passed as a parameter to the onChanged han...

Page 695: ...ldInstance your statements here Parameters textFieldInstance A reference to the TextField object whose scroll position was changed Returns Nothing Description Event handler invoked when one of the tex...

Page 696: ...the text field instance If there is no previously focused object oldFocus contains a null value TextField _parent Availability Flash Player 6 Usage my_txt _parent property _parent property Descriptio...

Page 697: ...ugh you can specify this property for a TextField object it is actually a global property and you can specify its value simply as _quality For more information see _quality TextField removeListener Av...

Page 698: ...Player 6 Usage my_txt replaceSel text Parameters text A string Returns Nothing Description Method replaces the current selection with the contents of the text parameter The text is inserted at the pos...

Page 699: ...ash This only restricts user interaction a script may put any text into the text field This property does not synchronize with the Embed Font Outlines check boxes in the Property inspector If the stri...

Page 700: ...lues from 0 to 180 represent counterclockwise rotation Values outside this range are added to or subtracted from 360 to obtain a value within the range For example the statement my_txt _rotation 450 i...

Page 701: ...rted with the replaceSel method or text entered by a user in a text field Each text field has a new text format When text is inserted the new text is assigned the new text format The text format is se...

Page 702: ...s both character and paragraph formatting information Character formatting information describes the appearance of individual characters for example font name point size color and associated URL Parag...

Page 703: ...fined by the style sheet object You can use text styles to define new formatting tags redefine built in HTML tags or create style classes that can be applied to certain HTML tags To apply styles to a...

Page 704: ...he style to retrieve Returns An object Description Method returns a copy of the style object associated with the style named styleName If there is no style object associated with styleName null is ret...

Page 705: ...tStyle TextField StyleSheet getStyleNames Availability Flash Player 7 Usage styleSheet getStyleNames Parameters None Returns An array Description Method returns an array that contains the names as str...

Page 706: ...Sheet onLoad callback handler to determine when the file has finished loading The CSS file must reside in exactly the same domain as the SWF file that is loading it For more information about restrict...

Page 707: ...e from the server the success parameter is false Example The following example loads the CSS file named styles css not shown into the style sheet object styleObj When the file has finished loading suc...

Page 708: ...exist in the style sheet it is added If the named style already exists in the style sheet it is replaced If the style parameter is null the named style is removed Flash Player creates a copy of the st...

Page 709: ..._txt tabEnabled Description Property specifies whether my_txt is included in automatic tab ordering It is undefined by default If the tabEnabled property is undefined or true the object is included in...

Page 710: ...ing is undefined The custom tab ordering defined by the tabIndex property is flat This means that no attention is paid to the hierarchical relationships of objects in the SWF file All objects in the S...

Page 711: ...rty indicates the height of the text TextField textWidth Availability Flash Player 6 Usage my_txt textWidth Description Property indicates the width of the text TextField type Availability Flash Playe...

Page 712: ...the variable that the text field is associated with The type of this property is String TextField _visible Availability Flash Player 6 Usage my_txt _visible Description Property a Boolean value that i...

Page 713: ...y_txt _x Description Property an integer that sets the x coordinate of a text field relative to the local coordinates of the parent movie clip If a text field is on the main Timeline then its coordina...

Page 714: ...tField _yscale TextField _y Availability Flash Player 6 Usage my_txt _y Description Property the y coordinate of a text field relative to the local coordinates of the parent movie clip If a text field...

Page 715: ..._x TextField _xscale TextField _y TextFormat class Availability Flash Player 6 Description The TextFormat class represents character formatting information You must use the constructor new TextFormat...

Page 716: ...ints TextFormat bold Indicates whether text is boldface TextFormat bullet Indicates whether text is in a bulleted list TextFormat color Indicates the color of text TextFormat font Indicates the font n...

Page 717: ...an empty string the text is displayed in the default target window _self If the url parameter is set to an empty string or to the value null you can get or set this property but the property will have...

Page 718: ...TextFormat blockIndent Availability Flash Player 6 Usage my_fmt blockIndent Description Property a number that indicates the block indentation in points Block indentation is applied to an entire bloc...

Page 719: ...r Availability Flash Player 6 Usage my_fmt color Description Property indicates the color of text A number containing three 8 bit RGB components for example 0xFF0000 is red 0x00FF00 is green TextForma...

Page 720: ...at which a text box shows all of the specified text The ascent and descent measurements provide respectively the distance above and below the baseline for a line of text The baseline for the first lin...

Page 721: ...e Assign the same text string and TextFormat object to the TextField object textField text text textField setTextFormat txt_fmt The following example creates a multiline 100 pixel wide text field that...

Page 722: ...fined See also TextFormat blockIndent TextFormat italic Availability Flash Player 6 Usage my_fmt italic Description Property a Boolean value that indicates whether text in this text format is italiciz...

Page 723: ...in points The default value is null which indicates that the property is undefined TextFormat size Availability Flash Player 6 Usage my_fmt size Description Property the point size of text in this tex...

Page 724: ...6 Usage my_fmt underline Description Property a Boolean value that indicates whether the text that uses this text format is underlined true or not false This underlining is similar to that produced by...

Page 725: ...e position of the first occurrence of specified text TextSnapshot getCount Returns the number of characters TextSnapshot getSelected Specifies whether any of the text in the specified range has been s...

Page 726: ...t in my_snap must match the case of the string in textToFind Returns The zero based index position of the first occurrence of the specified text or 1 Description Method searches the specified TextSnap...

Page 727: ...ue if at least one character in the given range has been selected by the corresponding TextSnapshot setSelected command false otherwise Description Method returns a Boolean value that specifies whethe...

Page 728: ...be examined Valid values for to are 0 through TextSnapshot getCount The character indexed by the to parameter is not included in the extracted string If this parameter is omitted TextSnapshot getCoun...

Page 729: ...ue of the character in my_snap that is nearest to the specified x y coordinates or 1 if no character is found Description Method lets you determine which character within a TextSnapshot object is on o...

Page 730: ...the to parameter is not included in the extracted string If this parameter is omitted TextSnapshot getCount is used If this value is less than or equal to the value of from from 1 is used select A Boo...

Page 731: ...contains it you can t use this in a script to refer to a variable defined in a class file in file applyThis as class applyThis var str String Defined in applyThis as function conctStr x String String...

Page 732: ...his _alpha 20 In the following statement inside an onClipEvent handler the keyword this references the current movie clip when the movie clip loads a startDrag operation is initiated for the current m...

Page 733: ...arameter If the string parameter does not contain a valid e mail address the error message is displayed in a text field error_txt try checkEmail Joe Smith catch e error_txt text e toString In this exa...

Page 734: ...F playback This action affects all SWF files in Flash Player Example The following code could be applied to a button that when clicked would toggle anti aliasing on and off on release toggleHighQualit...

Page 735: ...statement evaluates the _droptarget property and executes different actions depending on where my_mc is released The trace action is used at the end of the script to evaluate the location of the my_mc...

Page 736: ...n if the try block exits using a return statement A try block must be followed by a catch block a finally block or both A single try block can have multiple catch blocks but only one finally block You...

Page 737: ...ield using the Error toString method var account new Account try var returnVal account getAccountInfo if returnVal 0 throw new Error Error getting account information catch e status_txt text e toStrin...

Page 738: ...recordSetErrorCondition throw new RecordSetException if malFormedRecordCondition throw new MalformedRecord Finally in another AS file or FLA script the following code invokes the sortRows method on an...

Page 739: ...of operator causes the Flash interpreter to evaluate expression the result is a string specifying whether the expression is a string movie clip object function number or Boolean value The following ta...

Page 740: ...he special value null When null and undefined are compared with the equality operator they compare as equal Example In this example the variable x has not been declared and therefore has the value und...

Page 741: ...ing example illustrates the escape to unescape conversion process escape Hello World The escaped result is as follows Hello 7B 5BWorld 5D 7D Use unescape to return to the original format unescape Hell...

Page 742: ...aded into level 4 on press unloadMovieNum 4 See also loadMovie MovieClipLoader unloadClip unloadMovieNum Availability Flash Player 3 Usage unloadMovieNum level Parameters level The level _levelN of a...

Page 743: ...ableName value1 variableNameN valueN Parameters variableName An identifier value The value assigned to the variable Returns Nothing Description Statement used to declare local or Timeline variables If...

Page 744: ...e on the stage you can control various properties of Video objects For example you can move the Video object around on the stage by using its _x and _y properties you can change its size using its _he...

Page 745: ...automatically when the NetStream play command is issued If you want to control the audio associated with an FLV file you can use MovieClip attachAudio to route the audio to a movie clip you can then...

Page 746: ...locking my_video deblocking setting Description Property specifies the behavior for the deblocking filter that the video compressor applies as needed when streaming the video The following are accepta...

Page 747: ...If you call it when the code property is NetStream Play Start the height and width values will be 0 because the Video object doesn t yet have the height and width of the loaded FLV file Clip is the in...

Page 748: ...seeing the video at the same size at which it was captured regardless of the actual size of the Video object on the Stage Example See the examples for Video height void Availability Flash Player 5 Usa...

Page 749: ...ion of the loop The condition is retested at the beginning of each iteration as in the following steps 1 The expression condition is evaluated 2 If condition evaluates to true or a value that converts...

Page 750: ...ip containing the currently executing script The Global object built in objects such as Math and String To set a variable inside a with action the variable must have been declared outside the with act...

Page 751: ...hey resolve to the corresponding local variables function polar r var a x y with Math a PI r r x r cos PI y r sin PI 2 trace area a trace x x trace y y You can use nested with actions to access inform...

Page 752: ...de Removes the specified node from its parent XML send Sends the specified XML object to a URL XML sendAndLoad Sends the specified XML object to a URL and loads the server response into another XML ob...

Page 753: ...ious sibling in the parent node s child list XML status A numeric status code indicating the success or failure of an XML document parsing operation XML xmlDecl Specifies information about a document...

Page 754: ...r name headerValue The value associated with headerName Returns Nothing Description Method adds or changes HTTP request headers such as Content Type or SOAPAction sent with POST actions In the first u...

Page 755: ...0 my_xml addRequestHeader headers See also LoadVars addRequestHeader XML appendChild Availability Flash Player 5 Usage my_xml appendChild childNode Parameters childNode The child node to be added to...

Page 756: ...array containing all attributes of the specified XML object Example The following example writes the names of the XML attributes to the Output window str mytag name Val intem mytag doc new XML str y...

Page 757: ...ype XML cloneNode Availability Flash Player 5 Usage my_xml cloneNode deep Parameters deep Boolean value specifying whether the children of the specified XML object are recursively cloned Returns An XM...

Page 758: ...ad XML createElement Availability Flash Player 5 Usage my_xml createElement name Parameters name The tag name of the XML element being created Returns An XML element Description Method creates a new X...

Page 759: ...TypeDecl property of the XML object is set to the text of the XML document s DOCTYPE declaration For example DOCTYPE greeting SYSTEM hello dtd This property is set using a string representation of the...

Page 760: ...roperty and cannot be used to manipulate child nodes use appendChild insertBefore and removeNode to manipulate child nodes See also XML appendChild XML insertBefore XML removeNode XML getBytesLoaded A...

Page 761: ...See also XML getBytesLoaded XML hasChildNodes Availability Flash Player 5 Usage my_xml hasChildNodes Parameters None Returns A Boolean value Description Method returns true if the specified XML object...

Page 762: ...ividual XML objects as in the following code my_xml ignoreWhite true Usage 2 You can set the default ignoreWhite property for XML objects as in the following code XML prototype ignoreWhite true XML in...

Page 763: ...nd replaces the contents of the specified XML object with the downloaded XML data The URL is relative and is called via HTTP The load process is asynchronous it does not finish immediately after the l...

Page 764: ...my_xml loaded Description Property read only determines whether the document loading process initiated by the XML load call has completed If the process completes successfully the method returns true...

Page 765: ...Name is null See also XML nodeType XML nodeType Availability Flash Player 5 Usage my_xml nodeType Description Property read only takes or returns a nodeType value where 1 is an XML element and 3 is a...

Page 766: ...rser The XML onData method returns either the value undefined or a string that contains XML text downloaded from the server If the returned value is undefined an error occurred while downloading the X...

Page 767: ...default implementation of this method is not active To override the default implementation you must assign a function containing your own actions Example The following example creates a simple SWF fil...

Page 768: ...be parsed and passed to the specified XML object Returns Nothing Description Method parses the XML text specified in the source parameter and populates the specified XML object with the resulting XML...

Page 769: ...the specified XML object window The browser window to display data returned by the server _self specifies the current frame in the current window _blank specifies a new window _parent specifies the pa...

Page 770: ...layer 7 url must be in the same superdomain as the SWF file that is issuing this call For example a SWF file at www someDomain com can load variables from a SWF file at store someDomain com because bo...

Page 771: ...ly terminated 9 A start tag was not matched with an end tag 10 An end tag was encountered without a matching start tag XML toString Availability Flash Player 5 Usage my_xml toString Parameters None Re...

Page 772: ...text of the document s XML declaration This property is set using a string representation of the XML declaration not an XML node object If no XML declaration was encountered during a parse operation...

Page 773: ...lection Corresponding XML class entry appendChild XML appendChild attributes XML attributes childNodes XML childNodes cloneNode XML cloneNode firstChild XML firstChild hasChildNodes XML hasChildNodes...

Page 774: ...l to 1024 One consequence of this restriction is that the server daemons that communicate with the XMLSocket object must also be assigned to port numbers greater than or equal to 1024 Port numbers bel...

Page 775: ...cket close Closes an open socket connection XMLSocket connect Establishes a connection to the specified server XMLSocket send Sends an XML object to the server Event handler Description XMLSocket onCl...

Page 776: ...the same domain as the SWF file for details see Description below port The TCP port number on the host used to establish a connection The port number must be 1024 or higher Returns A Boolean value Des...

Page 777: ...ee About allowing cross domain data loading on page 190 When load is executed the XML object property loaded is set to false When the XML data finishes downloading the loaded property is set to true a...

Page 778: ...et onConnect XMLSocket onConnect Availability Flash Player 5 Usage myXMLSocket onConnect success your statements here Parameters success A Boolean value indicating whether a socket connection was succ...

Page 779: ...r method the script installs the onConnect method using the assignment operator socket new XMLSocket socket onConnect myOnConnect Finally the connection is initiated If connect returns false the SWF f...

Page 780: ...ct function your statements here Parameter object An XML object that contains a parsed XML document received from a server Returns Nothing Description Event handler invoked by Flash Player when the sp...

Page 781: ...transmits it to the server followed by a zero byte If object is an XML object the string is the XML textual representation of the XML object The send operation is asynchronous it returns immediately b...

Page 782: ...782 Chapter 12 ActionScript Dictionary...

Page 783: ...statement is not permitted in a class definition 1100 A class or interface has already been defined with this name 1101 Type mismatch 1102 There is no class with the name ClassName 1103 There is no pr...

Page 784: ...sed outside class 1129 A function with return type Void may not return a value 1130 The extends clause must appear before the implements clause 1131 A type identifier is expected after the 1132 Interf...

Page 785: ...is name 1161 Classes interfaces and built in types may not be deleted 1162 There is no class with this name 1163 The keyword keyword is reserved for ActionScript 2 0 and cannot be used here 1164 Custo...

Page 786: ...ready being resolved to the class that is being defined C B 1190 The class A B cannot be imported because its leaf name is already being resolved to imported class C B 1191 A class s instance variable...

Page 787: ...l NOT Right to left not Logical NOT Flash 4 style Right to left Post increment Left to right Post decrement Left to right Function call Left to right Array element Left to right Structure member Left...

Page 788: ...le Less than or equal to string version Left to right gt Greater than string version Left to right ge Greater than or equal to string version Left to right Equal Left to right Not equal Left to right...

Page 789: ...ee the Key class entry in Chapter 12 ActionScript Dictionary on page 205 Letters A to Z and standard numbers 0 to 9 The following table lists the keys on a standard keyboard for the letters A to Z and...

Page 790: ...ng ASCII key code values that are used to identify the keys in ActionScript R 82 S 83 T 84 U 85 V 86 W 87 X 88 Y 89 Z 90 0 48 1 49 2 50 3 51 4 52 5 53 6 54 7 55 8 56 9 57 Numeric keypad key Key code N...

Page 791: ...ing ASCII key code values that are used to identify the keys in ActionScript Numbpad 9 105 Multiply 106 Add 107 Enter 108 Subtract 109 Decimal 110 Divide 111 Function key Key code F1 112 F2 113 F3 114...

Page 792: ...keys with the corresponding ASCII key code values that are used to identify the keys in ActionScript Key Key code Backspace 8 Tab 9 Clear 12 Enter 13 Shift 16 Control 17 Alt 18 Caps Lock 20 Esc 27 Spa...

Page 793: ...Other keys 793 221 222 Key Key code...

Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...

Page 795: ...you want to use is supported by the Flash Player version you are targeting You can also determine which elements you can use by displaying the Actions toolbox elements that are not supported for your...

Page 796: ...break and continue actions The print and printAsBitmap actions The switch action For additional information see About targeting older versions of Flash Player on page 795 Using Flash MX 2004 to open F...

Page 797: ...when converting Flash 4 files by introducing Number functions in equality comparisons In the following example Number forces undefined to be converted to 0 so the comparison will succeed getProperty...

Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...

Page 799: ...rted only in Flash Player 6 and later don t use this method if you are targeting Flash Player 5 About ActionScript 1 ActionScript is an object oriented programming language Object oriented programming...

Page 800: ...ing to a specific order this is called inheritance You can use inheritance to extend or redefine the properties and methods of a class A class that inherits from another class is called a subclass A c...

Page 801: ...r function that created it Therefore if you assign methods to an object s prototype property they are available to any newly created instance of that object It s best to assign a method to the prototy...

Page 802: ...lips to have access to the methods and properties of the built in MovieClip object you ll need to make the new class inherit from the MovieClip class 3 Enter code like the following inherit from Movie...

Page 803: ...eritance in ActionScript All constructor functions have a prototype property that is created automatically when the function is defined The prototype property indicates the default property values for...

Page 804: ...ses it the new value as a parameter If a property with the given name already exists the new property overwrites it You can add getter setter properties to prototype objects If you add a getter setter...

Page 805: ...ll in Chapter 12 ActionScript Dictionary on page 205 To invoke a function using the Function call method Use the following syntax myFunction call thisObject parameter1 parameterN The method takes the...

Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...

Page 807: ...s 47 associativity of operators 45 787 asynchronous actions 178 attaching sounds 102 B balance sound controlling 104 bitwise operators 47 Boolean values 35 comparing 47 defined 26 braces See curly bra...

Page 808: ...nd document level 169 modifying 170 search order of 169 code displaying line numbers 67 formatting 67 selecting a line 75 stepping through lines 75 word wrapping 67 code hints 61 manually displaying 6...

Page 809: ...Object Model XML 181 domain names and security 188 dot operators 49 dot syntax 30 dragging movie clips 125 drawing lines and fills 107 shapes 131 duplicating movie clips 126 dynamic classes 173 E ECM...

Page 810: ...8 built in 51 calling 53 constructor 800 conversion 34 custom 51 defining 51 for controlling movie clips 122 local variables in 52 passing parameters to 52 returning values 53 sample 28 G get set meth...

Page 811: ...ontrols and Test Movie 68 to activate movie clips 98 keyboard shortcuts for pinned scripts 60 keyboard ASCII key code values 789 keypresses capturing 96 keywords 28 listed 33 L languages using multipl...

Page 812: ...nested defined 121 parent defined 121 properties 125 properties initializing at runtime 134 removing 126 sharing 127 starting and stopping 92 using as masks 132 See also SWF files moviename_DoFSComman...

Page 813: ...sing 49 constant 33 declaring 161 defined 28 initializing at runtime 134 of movie clips 125 of objects accessing 114 Properties tab Debugger 74 public attribute for class members 164 punctuation balan...

Page 814: ...yle sheets See cascading style sheets subclasses and class members 167 creating 162 creating for movie clips 133 suffixes 62 SWD file defined 69 SWF files controlling in Flash Player 187 creating soun...

Page 815: ...26 68 support 26 URL encoded format sending information 178 user event defined 83 UTF 8 Unicode 26 V values manipulating in expressions 45 variables about 40 and Debugger Variables tab 72 and Debugger...

Page 816: ...816 Index...

Reviews: