background image

750

Chapter 12:  ActionScript Dictionary

The 

object

 parameter becomes the context in which the properties, variables, and functions in 

the 

statement(s)

 parameter are read. For example, if 

object

 is 

my_array

, and two of the 

properties specified are 

length

 and 

concat

, those properties are automatically read as 

my_array

.

length

 and 

my_array.concat

. In another example, if 

object

 is 

state.california

any actions or statements inside the 

with

 action are called from inside the 

california

 instance.

To find the value of an identifier in the 

statement(s)

 parameter, ActionScript starts at the 

beginning of the scope chain specified by the 

object

 and searches for the identifier at each level 

of the scope chain, in a specific order. 

The scope chain used by the 

with

 action to resolve identifiers starts with the first item in the 

following list and continues to the last item:

The object specified in the 

object

 parameter in the innermost 

with

 action.

The object specified in the 

object

 parameter in the outermost 

with

 action.

The Activation object. (A temporary object that is automatically created when a function is 
called that holds the local variables called in the function.)

The movie clip 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

 

action or you must enter the full path to the Timeline on which you want the variable to live. If 
you set a variable in a 

with

 action without declaring it, the 

with

 action will look for the value 

according to the scope chain. If the variable doesn’t already exist, the new value will be set on the 
Timeline from which the 

with

 action was called.

In Flash 5 or later, the 

with

 action replaces the deprecated 

tellTarget

 action. You 

are encouraged to use 

with

 instead of 

tellTarget

 because it is a standard ActionScript extension 

to the ECMA-262 standard. The principal difference between the 

with

 and 

tellTarget

 actions 

is that 

with

 takes a reference to a movie clip or other object as its parameter, while 

tellTarget

 

takes a target path string that identifies a movie clip as its parameter, and cannot be used to 
target objects.

Example

The following example sets the 

_x

 and 

_y

 properties of the 

someOther_mc

 instance, and then 

instructs 

someOther_mc

 to go to Frame 3 and stop.

with (someOther_mc) {

_x = 50;
_y = 100;
gotoAndStop(3);

}

The following code snippet shows how to write the preceding code without using a 

with

 action. 

someOther_mc._x = 50;
someOther_mc._y = 100;
someOther_mc.gotoAndStop(3);

Содержание FLASH MX 2004 - ACTIONSCRIPT

Страница 1: ...ActionScript Reference Guide...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 8: ...8 Contents...

Страница 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...

Страница 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...

Страница 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...

Страница 12: ......

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 54: ...54 Chapter 2 ActionScript Basics...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...

Страница 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...

Страница 82: ......

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...

Страница 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...

Страница 112: ......

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 120: ...120 Chapter 6 Using the Built In Classes...

Страница 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...

Страница 122: ...nctions MovieClip attachMovie MovieClip createEmptyMovieClip MovieClip createTextField MovieClip getBounds MovieClip getBytesLoaded MovieClip getBytesTotal MovieClip getDepth MovieClip getInstanceAtDe...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 176: ......

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 192: ...192 Chapter 10 Working with External Data...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 199: ...ener object var loadListener Object new Object loadListener onLoadStart function loadTarget trace Loading into loadTarget has started loadListener onLoadProgress function loadTarget bytesLoaded bytesT...

Страница 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...

Страница 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...

Страница 202: ...202 Chapter 11 Working with External Media...

Страница 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...

Страница 204: ......

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 209: ...ovieClip _framesloaded _global _global object _height Button _height MovieClip _height TextField _height _highquality _highquality Button _highquality MovieClip _highquality TextField _highquality _lo...

Страница 210: ...er Key addListener Mouse addListener MovieClipLoader addListener Selection addListener Stage addListener TextField addListener addPage PrintJob addPage addProperty Object addProperty addRequestHeader...

Страница 211: ...Format bold Boolean Boolean Boolean class border TextField border borderColor TextField borderColor bottomScroll TextField bottomScroll break break bufferLength NetStream bufferLength bufferTime NetSt...

Страница 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...

Страница 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...

Страница 214: ...s MovieClip getBounds getBytesLoaded LoadVars getBytesLoaded MovieClip getBytesLoaded Sound getBytesLoaded XML getBytesLoaded getBytesTotal LoadVars getBytesTotal MovieClip getBytesTotal Sound getByte...

Страница 215: ...Style getStyleNames TextField StyleSheet getStyleNames getSWFVersion MovieClip getSWFVersion getText TextSnapshot getText getTextExtent TextFormat getTextExtent getTextFormat TextField getTextFormat g...

Страница 216: ...asMP3 System capabilities hasMP3 hasPrinting System capabilities hasPrinting hasScreenBroadcast System capabilities hasScreenBroadcast hasScreenPlayback System capabilities hasScreenPlayback hasStream...

Страница 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...

Страница 218: ...riablesNum loadVariablesNum LoadVars LoadVars class LocalConnection LocalConnection class localFileReadDisable System capabilities localFileReadDisable localToGlobal MovieClip localToGlobal log Math l...

Страница 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...

Страница 220: ...onLoad Sound onLoad TextField StyleSheet onLoad XML onLoad onLoadComplete MovieClipLoader onLoadComplete onLoadError MovieClipLoader onLoadError onLoadInit MovieClipLoader onLoadInit onLoadProgress M...

Страница 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...

Страница 222: ...L removeNode removeTextField TextField removeTextField replaceSel TextField replaceSel replaceText TextField replaceText resolutionX System capabilities screenResolutionX resolutionY System capabiliti...

Страница 223: ...Date setFullYear setGain Microphone setGain setHours Date setHours setInterval setInterval setMask MovieClip setMask setMilliseconds Date setMilliseconds setMinutes Date setMinutes setMode Camera setM...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 268: ...uivalent this iconImage this iconImages newIconNum if newTextEquivalent undefined if this _accProps undefined this _accProps new Object this _accProps name newTextEquivalent Accessibility updateProper...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 385: ...their respective Timelines The RadioButtonGroup movie clip is a parent with several children _RedRadioButton_ _GreenRadioButton_ and _BlueRadioButton for var name in RadioButtonGroup RadioButtonGroup...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 445: ...n LocalConnection objects located in specified domains see LocalConnection allowDomain and LocalConnection domain See also LocalConnection allowDomain LocalConnection connect LocalConnection domain Lo...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 474: ...ample See the example for Microphone silenceTimeout See also Microphone gain Microphone setSilenceLevel Microphone silenceTimeout Availability Flash Player 6 Usage activeMicrophone silenceTimeout Desc...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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 _...

Страница 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...

Страница 545: ...lso MovieClipLoader addListener Listener Description MovieClipLoader onLoadComplete Invoked when a file loaded with MovieClipLoader loadClip has completely downloaded MovieClipLoader onLoadError Invok...

Страница 546: ...adInit MovieClipLoader onLoadProgress MovieClipLoader onLoadStart MovieClipLoader removeListener MovieClipLoader getProgress Availability Flash Player 7 Usage my_mcl getProgress target_mc Parameters t...

Страница 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...

Страница 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...

Страница 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...

Страница 550: ...ded Example See MovieClipLoader loadClip See also MovieClipLoader addListener MovieClipLoader onLoadStart MovieClipLoader onLoadError MovieClipLoader onLoadError Availability Flash Player 7 Usage list...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 773: ...lection Corresponding XML class entry appendChild XML appendChild attributes XML attributes childNodes XML childNodes cloneNode XML cloneNode firstChild XML firstChild hasChildNodes XML hasChildNodes...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 782: ...782 Chapter 12 ActionScript Dictionary...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 793: ...Other keys 793 221 222 Key Key code...

Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...

Страница 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...

Страница 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...

Страница 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...

Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 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...

Страница 816: ...816 Index...

Отзывы: