MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual

Summary of FLASH MX 2004 - ACTIONSCRIPT

  • Page 1

    Actionscript reference guide.

  • Page 2

    Trademarks add life to the web, afterburner, aftershock, andromedia, allaire, animation powerpack, aria, attain, authorware, authorware star, backstage, bright tiger, clustercats, coldfusion, contribute, design in motion, director, dream templates, dreamweaver, drumbeat 2000, edje, ejipt, extreme 3d...

  • Page 3: Contents

    3 contents introduction: getting started with actionscript . . . . . . . . . . . . . . . . . . . . . . . 9 intended audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 system requirements . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 4

    4 contents chapter 3: writing and debugging scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 controlling when actionscript runs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 using the actions panel and script window. . . . . . . . . . . . . . . . . . . . . ...

  • Page 5

    Contents 5 handling movie clip events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 assigning a class to a movie clip symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 initializing class properties. . . . . . . . . . . . . . . . . . . . ...

  • Page 6

    6 contents part v: reference chapter 12: actionscript dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 sample entry for most actionscript elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 sample entry for classes . . . . . . . . . . . . . . . . . . . . ...

  • Page 7

    Contents 7 appendix a: error messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 783 appendix b: operator precedence and associativity . . . . . . . . . . . . . . . . . . . 787 appendix c: keyboard keys and key code values . . . . . . . . . . . . . . . . . . . . . 78...

  • Page 8

    8 contents.

  • Page 9: Introduction

    9 introduction getting started with actionscript macromedia flash mx 2004 and flash mx professional 2004 are the professional standard authoring tools for producing high-impact web experiences. Actionscript is the language you use when you want to develop an application within flash. You don’t have ...

  • Page 10

    10 introduction: getting started with actionscript after you understand the basics, you are ready to use the information in the rest of this document as it applies to the specific effect you are trying to achieve. For example, if you want to learn how to write a script that performs a certain action...

  • Page 11: Part I

    Part i welcome to actionscript this part includes basic information on the actionscript language. Chapter 1 includes information on what is new or changed in actionscript and flash player 7. If you have used actionscript before, be sure to review this information carefully. If you are new to actions...

  • Page 13: Chapter 1

    13 chapter 1 what’s new in flash mx 2004 actionscript macromedia flash mx 2004 and macromedia flash mx professional 2004 provide several enhancements that make it easier for you to write more robust scripts using the actionscript language. These new features, which are discussed in this chapter, inc...

  • Page 14

    14 chapter 1: what’s new in flash mx 2004 actionscript • the movieclip.Getnexthighestdepth() method lets you create movieclip instances at runtime and be guaranteed that their objects render in front of the other objects in a parent movie clip’s z-order space. The movieclip.Getinstanceatdepth() meth...

  • Page 15

    Porting existing scripts to flash player 7 15 you might also need to implement a policy file if you are using runtime shared libraries. If either the loading or loaded swf file is published for flash player 7 and the loading and loaded files aren’t served from the exact same domain, use a policy fil...

  • Page 16

    16 chapter 1: what’s new in flash mx 2004 actionscript unlike the changes mentioned above, the changes listed in the following table (some of which also improve ecma compliance) may cause existing scripts to work differently than they did previously. If you used these features in existing scripts th...

  • Page 17

    Porting existing scripts to flash player 7 17 domain-name rules for settings and local data in flash player 6, superdomain matching rules are used by default when accessing local settings (such as camera or microphone access permissions) or locally persistent data (shared objects). That is, the sett...

  • Page 18

    18 chapter 1: what’s new in flash mx 2004 actionscript because flash player 7 implements exact-domain matching rules instead of superdomain matching rules, you might have to modify existing scripts if you want to access them from files that are published for flash player 7. (you can still publish th...

  • Page 19

    Porting existing scripts to flash player 7 19 you have to make the following changes: • if the called swf file is published for flash player 7, include system.Security.Allowdomain or localconnection.Allowdomain in the called swf file, using exact domain- name matching. • if the called swf file is pu...

  • Page 20

    20 chapter 1: what’s new in flash mx 2004 actionscript to summarize, you might have to modify your files to add or change statements if you publish files for flash player 7 that meet the following conditions: • you implemented cross-swf scripting (using loadmovie() , movieclip.Loadmovie() , moviecli...

  • Page 21

    Actionscript editor changes 21 if you are loading external data, you should create policy files even if you don’t plan to port any of your files to flash player 7. If you are using rsls, you should create policy files if either the calling or called file is published for flash player 7. For more inf...

  • Page 22

    22 chapter 1: what’s new in flash mx 2004 actionscript debugging changes this section describes changes that improve your ability to debug your scripts. Output window changed to output panel you can now move and dock the output panel in the same way as any other panel in flash. Improved error report...

  • Page 23

    New object-oriented programming model 23 key facts about actionscript 2.0 include the following points: • scripts that use actionscript 2.0 to define classes or interfaces must be stored as external script files, with a single class defined in each script; that is, classes and interfaces cannot be d...

  • Page 24

    24 chapter 1: what’s new in flash mx 2004 actionscript.

  • Page 25: Chapter 2

    25 chapter 2 actionscript basics actionscript has rules of grammar and punctuation that determine which characters and words are used to create meaning and in which order they can be written. For example, in english, a period ends a sentence. In actionscript, a semicolon ends a statement. The follow...

  • Page 26

    26 chapter 2: actionscript basics unicode support for actionscript macromedia flash mx 2004 and macromedia flash mx professional 2004 support unicode text encoding for actionscript. This means that you can include text in different languages in an actionscript file. For example, you could include te...

  • Page 27

    Terminology 27 constants are elements that don’t change. For example, the constant key.Tab always has the same meaning: it indicates the tab key on a keyboard. Constants are useful for comparing values. Constructors are functions that you use to define the properties and methods of a class. By defin...

  • Page 28

    28 chapter 2: actionscript basics instance names are unique names that let you target movie clip and button instances in scripts. You use the property inspector to assign instance names to instances on the stage. For example, a master symbol in the library could be called counter and the two instanc...

  • Page 29

    Syntax 29 target paths are hierarchical addresses of movie clip instance names, variables, and objects in a swf file. You name a movie clip instance in the movie clip property inspector. (the main timeline always has the name _root .) you can use a target path to direct an action at a movie clip or ...

  • Page 30

    30 chapter 2: actionscript basics in addition, case sensitivity is implemented for external scripts, such as actionscript 2.0 class files or scripts that you import using the #include command. If you are publishing files for flash player 7 and have previously created external files that you add to y...

  • Page 31

    Syntax 31 curly braces actionscript event handlers, class definitions, and functions are grouped together into blocks with curly braces ( {} ). You can put the opening brace on the same line as your declaration or on the next line, as shown in the following examples. To make your code easier to read...

  • Page 32

    32 chapter 2: actionscript basics parentheses when you define a function, place any parameters inside parentheses: function myfunction (name, age, reader){ // your code here } when you call a function, include any parameters passed to the function in parentheses, as shown here: myfunction ("steve", ...

  • Page 33

    Syntax 33 to create a comment block, place /* at the beginning of the commented lines and */ at the end. For example, when the following script runs, none of the code in the comment block is executed: // the code below runs var x:number = 15; var y:number = 20; // the code below doesn’t run /* on(re...

  • Page 34

    34 chapter 2: actionscript basics about data types a data type describes the kind of information a variable or actionscript element can hold. There are two kinds of data types built into flash: primitive and reference. The primitive data types— string, number, and boolean—have a constant value and t...

  • Page 35

    About data types 35 to include a quotation mark in a string, precede it with a backslash character (\). This is called escaping a character. There are other characters that cannot be represented in actionscript except by special escape sequences. The following table provides all the actionscript esc...

  • Page 36

    36 chapter 2: actionscript basics object an object is a collection of properties. Each property has a name and a value. The value of a property can be any flash data type, even the object data type. This allows you to arrange objects inside each other, or nest them. To specify objects and their prop...

  • Page 37

    Assigning data types to elements 37 determining an item’s data type while testing and debugging your programs, you may discover problems that seem to be related to the data types of different items. In these cases, you may want to determine an item’s data type. To do so, use the typeof operator, as ...

  • Page 38

    38 chapter 2: actionscript basics strict data typing actionscript 2.0 lets you explicitly declare the object type of a variable when you create it; this is called strict data typing. Because data type mismatches trigger compiler errors, strict data typing helps prevent you from assigning the wrong t...

  • Page 39

    Assigning data types to elements 39 the reason for this is that when you publish a file for actionscript 1, flash interprets a statement such as var x:string = "abc" as slash syntax rather than as strict typing. (actionscript 2.0 doesn’t support slash syntax.) this behavior can result in an object t...

  • Page 40

    40 chapter 2: actionscript basics the following example shows the results of casting built-in object types. As the first line in the with(results) block shows, an illegal cast—in this case, casting a string to a movie clip— returns null . As the last two lines show, casting to null or undefined retu...

  • Page 41

    About variables 41 to test the value of a variable, use the trace() action to send the value to the output panel. For example, trace(hoursworked) sends the value of the variable hoursworked to the output panel in test mode. You can also check and set the variable values in the debugger in test mode....

  • Page 42

    42 chapter 2: actionscript basics local variables to declare local variables, use the var statement inside the body of a function. A local variable is scoped to the block and expires at the end of the block. A local variable not declared within a block expires at the end of its script. For example, ...

  • Page 43

    About variables 43 global variables global variables and functions are visible to every timeline and scope in your document. To create a variable with global scope, use the _global identifier before the variable name, and do not use the var = syntax. For example, the following code creates the globa...

  • Page 44

    44 chapter 2: actionscript basics as another example, the variable invalue contains a primitive value, 3, so the actual value is passed to the sqrt() function and the returned value is 9: function sqrt(x){ return x * x; } var invalue = 3; var out = sqrt(invalue); the value of the variable invalue do...

  • Page 45

    Using operators to manipulate values in expressions 45 using operators to manipulate values in expressions an expression is any statement that flash can evaluate and that returns a value. You can create an expression by combining operators and values or by calling a function. Operators are character...

  • Page 46

    46 chapter 2: actionscript basics the following table lists the actionscript numeric operators: comparison operators comparison operators compare the values of expressions and return a boolean value ( true or false ). These operators are most commonly used in loops and in conditional statements. In ...

  • Page 47

    Using operators to manipulate values in expressions 47 logical operators logical operators compare boolean values ( true and false ) and return a third boolean value. For example, if both operands evaluate to true , the logical and operator ( && ) returns true . If one or both of the operands evalua...

  • Page 48

    48 chapter 2: actionscript basics the strict equality ( === ) operator is like the equality operator, with one important difference: the strict equality operator does not perform type conversion. If the two operands are of different types, the strict equality operator returns false . The strict ineq...

  • Page 49

    Using operators to manipulate values in expressions 49 dot and array access operators you can use the dot operator ( . ) and the array access operator ( [] ) to access built-in or custom actionscript object properties, including those of a movie clip. The dot operator uses the name of an object on i...

  • Page 50

    50 chapter 2: actionscript basics you create multidimensional arrays in actionscript by constructing an array, the elements of which are also arrays. To access elements of a multidimensional array, you can nest the array access operator with itself, as shown in the following example: var chessboard ...

  • Page 51

    Creating functions 51 using built-in functions a function is a block of actionscript code that can be reused anywhere in a swf file. If you pass values as parameters to a function, the function will operate on those values. A function can also return values. Flash has built-in functions that let you...

  • Page 52

    52 chapter 2: actionscript basics you can also define a function by creating a function literal—an unnamed function that is declared in an expression instead of in a statement. You can use a function literal to define a function, return its value, and assign it to a variable in one expression, as sh...

  • Page 53

    Creating functions 53 returning values from a function use the return statement to return values from functions. The return statement stops the function and replaces it with the value of the return action. The following rules govern the use of the return statement in functions: • if you specify a re...

  • Page 54

    54 chapter 2: actionscript basics.

  • Page 55: Chapter 3

    55 chapter 3 writing and debugging scripts in macromedia flash mx 2004 and macromedia flash mx professional 2004, you can write scripts that are embedded in your fla file or stored externally on your computer. (if you are writing actionscript 2.0 class files, you must store each class as an external...

  • Page 56

    56 chapter 3: writing and debugging scripts controlling when actionscript runs when you write a script, you use the actions panel to attach the script to a frame on a timeline, or to a button or movie clip on the stage. Scripts attached to a frame run, or execute, when the playhead enters that frame...

  • Page 57

    Controlling when actionscript runs 57 you can use the do..While statement to create the same kind of loop as a while loop. In a do..While loop, the expression is evaluated at the bottom of the code block so the loop always runs at least once, as shown in the following example: i = 4; do { my_mc.Dupl...

  • Page 58

    58 chapter 3: writing and debugging scripts using the actions panel and script window you can embed flash scripts in your fla file or store them as external files. It’s a good idea to store as much of your actionscript code in external files as possible. This makes it easier to reuse code in multipl...

  • Page 59

    Using the actions panel and script window 59 in the actions panel, the actions toolbox also contains a script navigator, which is a visual representation of the locations in the fla file that have associated actionscript; you can navigate through your fla file here to locate actionscript code. If yo...

  • Page 60

    60 chapter 3: writing and debugging scripts managing scripts in a fla file if you don’t centralize all your code within a fla file in one location, you can pin (lock in place) multiple scripts in the actions panel to make it easier to move among them. In the following figure, the script associated w...

  • Page 61

    Using the actionscript editor 61 using the actionscript editor flash mx 2004 and flash mx professional 2004 provide several tools to help you write syntactically correct code and lets you set preferences for code formatting and other options. These capabilities are discussed in this section. Syntax ...

  • Page 62

    62 chapter 3: writing and debugging scripts strictly typing objects to trigger code hints when you use actionscript 2.0, you can strictly type a variable that is based on a built-in class, such as button, array, and so on. If you do so, the actionscript editor displays code hints for the variable. F...

  • Page 63

    Using the actionscript editor 63 for information on using code hints when they appear, see “using code hints” on page 63 . Using comments to trigger code hints you can also use actionscript comments to specify an object’s class for code hinting. The following example tells actionscript that the clas...

  • Page 64

    64 chapter 3: writing and debugging scripts to specify settings for automatic code hints, do one of the following: • select edit > preferences, and then enable or disable code hints on the actionscript tab. • in the actions panel, select preferences from the options pop-up menu (at the upper right o...

  • Page 65

    Using the actionscript editor 65 to work with menu-style code hints: 1 display the code hint by typing a period after the variable or object name. The code hint menu appears. Note: if a code hint doesn’t appear, make sure you haven’t disabled code hints on the actionscript tab. If you want to displa...

  • Page 66

    66 chapter 3: writing and debugging scripts similarly, if you type escape+c+h, the following code is placed in your script, and the insertion point is placed between the parentheses, so you can begin typing your condition: catch () { } if you want to learn (or be reminded) which commands have escape...

  • Page 67

    Using the actionscript editor 67 to check for punctuation balance: 1 click between braces ( {}) , array access operators ( []) , or parentheses ( () ) in your script. 2 press control+' (windows) or command+' (macintosh) to highlight the text between braces, brackets, or parentheses. The highlighting...

  • Page 68

    68 chapter 3: writing and debugging scripts debugging your scripts flash provides several tools for testing actionscript in your swf files. The debugger, discussed in the rest of this section, lets you find errors in a swf file while it’s running in flash player. Flash also provides the following ad...

  • Page 69

    Debugging your scripts 69 to activate the debugger in test mode: • select control > debug movie. This opens the debugger. It also opens the swf file in test mode. Debugging a swf file from a remote location you can debug a remote swf file using the stand-alone, activex, or plug-in versions of flash ...

  • Page 70

    70 chapter 3: writing and debugging scripts to enable remote debugging of a flash movie: 1 select file > publish settings. 2 on the flash tab of the publish settings dialog box, select debugging permitted. 3 to set a password, enter a password in the password box. After you set this password, no one...

  • Page 71

    Debugging your scripts 71 to activate the debugger from a remote location: 1 open the flash authoring application. 2 in a browser or in the stand-alone player, open the published swf file from the remote location. The remote debug dialog box appears. If that dialog box doesn’t appear, flash can’t fi...

  • Page 72

    72 chapter 3: writing and debugging scripts displaying and modifying variables the variables tab in the debugger displays the names and values of any global and timeline variables in the swf file. If you change the value of a variable on the variables tab, you can see the change reflected in the swf...

  • Page 73

    Debugging your scripts 73 using the watch list to monitor a set of critical variables in a manageable way, you can mark variables to appear in the watch list. The watch list displays the absolute path to the variable and the value. You can also enter a new variable value in the watch list the same w...

  • Page 74

    74 chapter 3: writing and debugging scripts displaying movie clip properties and changing editable properties the debugger’s properties tab displays all the property values of any movie clip on the stage. You can change a value and see its effect in the swf file while it runs. Some movie clip proper...

  • Page 75

    Debugging your scripts 75 you can set breakpoints in the actions panel or in the debugger. (to set breakpoints in external scripts, you must use the debugger.) breakpoints set in the actions panel are saved with the flash document (fla file). Breakpoints set in the debugger are not saved in the fla ...

  • Page 76

    76 chapter 3: writing and debugging scripts as you step through lines of code, the values of variables and properties change in the watch list and in the variables, locals, and properties tabs. A yellow arrow along the left side of the debugger’s code view indicates the line at which the debugger st...

  • Page 77

    Using the output panel 77 using the output panel in test mode, the output panel displays information to help you troubleshoot your swf file. Some information, such as syntax errors, is displayed automatically. You can display other information by using the list objects and list variables commands. (...

  • Page 78

    78 chapter 3: writing and debugging scripts listing a swf file’s variables in test mode, the list variables command displays a list of all the variables currently in the swf file. This is especially useful for finding the correct variable target path and variable name. Unlike the debugger, the list ...

  • Page 79

    Updating flash player for testing 79 the debug > list objects command in test mode lists textfield objects. If an instance name is specified for a text field, the output panel displays the full target path including the instance name in the following form: target = "target path" using the trace stat...

  • Page 80

    80 chapter 3: writing and debugging scripts.

  • Page 81: Part II

    Part ii handling events and creating interaction events can be user-generated, such as mouse clicks or keypresses, or can occur as a result of some other process, such as an xml file loading over the network. The first chapter in this part describes the different types of events in macromedia flash ...

  • Page 83: Chapter 4

    83 chapter 4 handling events an event is a software or hardware occurrence that requires a response from a macromedia flash application. For example, an event such as a mouse click or a keypress is called a user event, since it occurs as a result of direct user interaction. An event generated automa...

  • Page 84

    84 chapter 4: handling events for example, suppose you have a button named next_btn on the stage. The following code assigns a function to the button’s onpress event handler; this function advances the playhead to the next frame in the timeline. Next_btn.Onpress = function () nextframe(); } in the a...

  • Page 85

    Using event listeners 85 using event listeners event listeners let an object, called a listener object, receive events generated by another object, called a broadcaster object. The broadcaster object registers the listener object to receive events generated by the broadcaster. For example, you could...

  • Page 86

    86 chapter 4: handling events to create a simple focus manager with event listeners: 1 using the text tool, create a text field on the stage. 2 select the text field and, in the property inspector, select input from the text type pop-up menu, and select the show border around text option. 3 create a...

  • Page 87

    Using button and movie clip event handlers 87 using button and movie clip event handlers you can attach event handlers directly to a button or movie clip instance by using the onclipevent() and on() handlers. The onclipevent() handler handles movie clip events, and the on() handler handles button ev...

  • Page 88

    88 chapter 4: handling events creating movie clips with button states when you attach an on() handler to a movie clip, or assign a function to one of the movieclip mouse event handlers for a movie clip instance, the movie clip responds to mouse events in the same way as a button does. You can also c...

  • Page 89

    Event handler scope 89 for instance, the following on() event handler will produce different results depending on whether it’s attached to a movie clip or button object. In the first case, the play() function call starts the playback head of the timeline that contains the button; in the second case,...

  • Page 90

    90 chapter 4: handling events scope of the “this” keyword the this keyword refers to the object in the currently executing scope. Depending on what type of event handler technique you’re using, this can refer to different objects. Within an event handler or event listener function , this refers to t...

  • Page 91: Chapter 5

    91 chapter 5 creating interaction with actionscript in simple animation, macromedia flash player plays the scenes and frames of a swf file sequentially. In an interactive swf file, your audience uses the keyboard and mouse to jump to different parts of a swf file, move objects, enter information in ...

  • Page 92

    92 chapter 5: creating interaction with actionscript controlling swf file playback the following actionscript functions let you control the playhead in the timeline and load a new web page into a browser window: • the gotoandplay() and gotoandstop() functions send the playhead to a frame or scene. T...

  • Page 93

    Controlling swf file playback 93 this same on() event handler code will produce a different result when attached to a movie clip object rather than a button. When attached to a button object, statements made within an on() handler are applied to the timeline that contains the button, by default. How...

  • Page 94

    94 chapter 5: creating interaction with actionscript creating interactivity and visual effects to create interactivity and other visual effects, you need to understand the following techniques: • creating a custom mouse pointer • getting the mouse position • capturing keypresses • setting color valu...

  • Page 95

    Creating interactivity and visual effects 95 buttons still function when you use a custom pointer. It’s a good idea to put the custom pointer on the top layer of the timeline so that it moves in front of buttons and other objects as you move the mouse in the swf file. Also, the tip of a custom mouse...

  • Page 96

    96 chapter 5: creating interaction with actionscript to get the current mouse position within a movie clip: 1 create a movie clip. 2 select the movie clip instance on the stage. Using the property inspector, name it mymovieclip . 3 select window > development panels > actions to open the actions pan...

  • Page 97

    Creating interactivity and visual effects 97 • assign the following onclipevent() handler to a movie clip, then select control > test movie and press the desired key. Onclipevent(keydown) { trace(key.Getcode()); } the key code of the desired key appears in the output panel. A common place to use key...

  • Page 98

    98 chapter 5: creating interaction with actionscript to create a keyboard-activated movie clip: 1 on the stage, create a movie clip that will move in response to keyboard arrow activity. In this example, the movie clip instance name is car . 2 on the stage, create a dynamic text box that will be upd...

  • Page 99

    Creating interactivity and visual effects 99 8 use similar code to check if the left arrow, up arrow, or down arrow key is being pressed. Your code should look like this: var distance = 10; car.Onenterframe = function() { with (car) { if (key.Isdown(key.Right)) { _x += distance; if (_x >= 400) { _x ...

  • Page 100

    100 chapter 5: creating interaction with actionscript setting color values you can use the methods of the built-in color class to adjust the color of a movie clip. The setrgb() method assigns hexadecimal rgb (red, green, blue) values to the movie clip. The following example uses setrgb() to change a...

  • Page 101

    Creating interactivity and visual effects 101 7 repeat step 6 for the other buttons (red, green, and black) to change the color of the movie clip to the corresponding color. Your code should now look like this: mycolor = new color(_root.Carcolor) _root.Blue.Onrelease = function(){ mycolor.Setrgb(0x0...

  • Page 102

    102 chapter 5: creating interaction with actionscript the sound class’s setvolume() method controls the volume, and the setpan() method adjusts the left and right balance of a sound. When the user drags the volume slider, the setvolume() method is called. The following procedures show how to create ...

  • Page 103

    Creating interactivity and visual effects 103 7 select frame 1 in the main timeline, and select window > development panels > actions. Add the following code to the actions panel: speaker.Stop(); song = new sound(); song.Onsoundcomplete = function() { speaker.Stop(); }; song.Attachsound("a_thousand_...

  • Page 104

    104 chapter 5: creating interaction with actionscript 8 enter the following actions: onclipevent (load) { top = _y; bottom = _y; left = _x; right = _x+100; _x += 100; } onclipevent (enterframe) { _parent.Song.Setvolume(_x-left); } 9 select control > test movie to use the volume slider. To create a s...

  • Page 105

    Creating interactivity and visual effects 105 detecting collisions the hittest() method of the movieclip class detects collisions in a swf file. It checks to see if an object has collided with a movie clip and returns a boolean value ( true or false ). There are two cases in which you would want to ...

  • Page 106

    106 chapter 5: creating interaction with actionscript the following procedures show how to detect collision using the car example. To perform collision detection between a movie clip and a point on the stage: 1 create a new movie clip on the stage, and enter box as the instance name in the property ...

  • Page 107

    Creating interactivity and visual effects 107 creating a simple line drawing tool you can use methods of the movieclip class to draw lines and fills on the stage as the swf file plays. This allows you to create drawing tools for users and to draw shapes in the swf file in response to events. The dra...

  • Page 108

    108 chapter 5: creating interaction with actionscript deconstructing a sample script in the sample swf file zapper.Swf (which you can view in using flash help), when a user drags the bug to the electrical outlet, the bug falls and the outlet shakes. The main timeline has only one frame and contains ...

  • Page 109

    Deconstructing a sample script 109 there are two onclipevent() handlers with two different events: load and enterframe . The actions in the onclipevent(load) statement execute only once, when the swf file loads. The actions in the onclipevent(enterframe) statement execute every time the playhead ent...

  • Page 110

    110 chapter 5: creating interaction with actionscript.

  • Page 111: Part III

    Part iii working with objects and classes this part discusses the macromedia flash runtime object model and its capabilities, 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 cla...

  • Page 113: Chapter 6

    113 chapter 6 using the built-in classes in addition to the actionscript core language elements and constructs ( for and while loops, for example) and primitive data types (numbers, strings, and arrays) described earlier (see “actionscript basics” on page 25 ), actionscript also provides a number of...

  • Page 114

    114 chapter 6: using the built-in classes about classes and instances in object-oriented programming, a class defines a category of object. A class describes the properties (data) and behavior (methods) for an object, much like an architectural blueprint describes the characteristics of a building. ...

  • Page 115

    Overview of built-in classes 115 overview of built-in classes this section lists all the actionscript classes, including a brief description of each class and cross- references to other relevant sections of the documentation. Core classes the core actionscript classes are those borrowed directly fro...

  • Page 116

    116 chapter 6: using the built-in classes classes specific to flash player the following tables list the classes that are specific to flash player and the flash runtime model. These classes are typically split into four categories: movie classes (which provide overall control of swf files and flash ...

  • Page 117

    Overview of built-in classes 117 localconnection the localconnection class lets two swf files running on the same computer communicate. See the localconnection class entry in chapter 12, “actionscript dictionary,” on page 205 . Mouse the mouse class provides control over the mouse in a swf file; for...

  • Page 118

    118 chapter 6: using the built-in classes media classes the media classes provide playback control of sound and video in a swf file, as well as access to the user’s microphone and camera, if they are installed. These classes are located in the built-in classes > media subfolder in the actions toolbo...

  • Page 119

    Overview of built-in classes 119 these classes are located in the built-in classes > client/server subfolder in the actions panel. Authoring classes the authoring classes are available only in the flash authoring environment. These classes are found in the built-in classes > authoring subfolder in t...

  • Page 120

    120 chapter 6: using the built-in classes.

  • Page 121: Chapter 7

    121 chapter 7 working with movie clips movie clips are self-contained miniature swf files that run independently of each other and the timeline that contains them. For example, if the main timeline has only one frame and a movie clip in that frame has ten frames, each frame in the movie clip plays w...

  • Page 122

    122 chapter 7: working with movie clips to use a method, invoke it by using the target path of the instance name, a dot, and then the method name and parameters, as in the following statements: mymovieclip.Play(); parentclip.Childclip.Gotoandplay(3); in the first statement, play() moves the playhead...

  • Page 123

    Specifying a root timeline for loaded swf files 123 the above code is also equivalent to the following: with (donut){ hole._alpha = 20; hole._xscale = 150; hole._yscale = 150; } loading and unloading additional swf files to play additional swf files without closing flash player, or to switch swf fil...

  • Page 124

    124 chapter 7: working with movie clips when contents.Swf loads into the movie clip in container.Swf, the value of username that’s attached to the root timeline of the hosting swf file (container.Swf ) would be set to "mary" . This could cause code in container.Swf (as well as contents.Swf ) to malf...

  • Page 125

    Dragging movie clips 125 changing movie clip position and appearance to change the properties of a movie clip as it plays, write a statement that assigns a value to a property or use the setproperty() function. For example, the following code sets the rotation of instance mc to 45: mc._rotation = 45...

  • Page 126

    126 chapter 7: working with movie clips creating movie clips at runtime not only can you create movie clip instances in the flash authoring environment, but you can also create them at runtime. Actionscript provides three ways to create new movie clips at runtime: • by creating a new, empty movie cl...

  • Page 127

    Creating movie clips at runtime 127 attaching a movie clip symbol to the stage the last way to create movie clip instances at runtime is to use attachmovie() . The attachmovie() method attaches an instance of a movie clip symbol in the swf file’s library to the stage. The new clip becomes a child cl...

  • Page 128

    128 chapter 7: working with movie clips to attach a movie clip to another movie clip: 1 assign a linkage identifier to a movie clip library symbol, as described above. 2 with the actions panel open (window > development panels > actions), select a frame in the timeline. 3 in the actions panel’s scri...

  • Page 129

    Managing movie clip depths 129 to populate a movie clip with parameters by using attachmovie() : 1 in a new flash document, create a movie clip symbol by selecting insert > new symbol. Type dynamic in the symbol name text box and select the movie clip behavior. 2 inside the symbol, create a dynamic ...

  • Page 130

    130 chapter 7: working with movie clips determining the next highest available depth to determine the next highest available depth within a movie clip, use movieclip.Getnexthighestdepth() . The integer value returned by this method indicates the next available depth that will render in front of all ...

  • Page 131

    Drawing shapes with actionscript 131 drawing shapes with actionscript you can use methods of the movieclip class to draw lines and fills on the stage. This allows you to create drawing tools for users and to draw shapes in the movie in response to events. The drawing methods are beginfill() , beging...

  • Page 132

    132 chapter 7: working with movie clips using movie clips as masks you can use a movie clip as a mask to create a hole through which the contents of another movie clip are visible. The mask movie clip plays all the frames in its timeline, just like a regular movie clip. You can make the mask movie c...

  • Page 133

    Assigning a class to a movie clip symbol 133 assigning a class to a movie clip symbol using actionscript 2.0, you can create your own class that extends the behavior of the built-in movieclip class, and then assign that class to a movie clip library symbol using the linkage properties dialog box. Wh...

  • Page 134

    134 chapter 7: working with movie clips initializing class properties in the example presented earlier, you added the instance of the ball symbol to the stage manually—that is, while authoring. As discussed previously (see “adding parameters to dynamically created movie clips” on page 128 ), you can...

  • Page 135: Chapter 8

    135 chapter 8 working with text a dynamic or input text field is a textfield object (an instance of the textfield class). When you create a text field, you can assign it an instance name in the property inspector. You can use the instance name in actionscript statements to set, change, and format th...

  • Page 136

    136 chapter 8: working with text to control a dynamic or input text field using actionscript, you must assign it an instance name in the property inspector. You can then reference the text field with the instance name, and use the methods and properties of the textfield class to control the contents...

  • Page 137

    Using the textformat class 137 creating text fields at runtime you can use the createtextfield() method of the movieclip class to create an empty text field on the stage at runtime. The new text field is attached to the timeline of the movie clip that calls the method. The createtextfield() method u...

  • Page 138

    138 chapter 8: working with text to format a text field with the textformat class: 1 in a new flash document, create a text field on the stage using the text tool. Type some text in the text field on the stage, like “bold, italic, 24 point text”. 2 in the property inspector, type mytext_txt in the i...

  • Page 139

    Formatting text with cascading style sheets 139 getting text metric information you can use the textformat.Gettextextent() method to obtain detailed text measurements for a text string with specific formatting applied. For example, suppose you need to create, at runtime, a new textfield object conta...

  • Page 140

    140 chapter 8: working with text supported css properties flash player supports a subset of properties in the original css1 specification ( www.W3.Org/tr/ rec-css1 ). The following table shows the supported css properties and values, and their corresponding actionscript property names. (each actions...

  • Page 141

    Formatting text with cascading style sheets 141 loading external css files you can define styles in an external css file and then load that file into a style sheet object. The styles defined in the css file are added to the style sheet object. To load an external css file, you use the load() method ...

  • Page 142

    142 chapter 8: working with text creating new styles with actionscript you can create new text styles with actionscript by using the setstyle() method of the textfield.Stylesheet class. This method takes two parameters: the name of the style and an object that defines that style’s properties. For ex...

  • Page 143

    Formatting text with cascading style sheets 143 using style classes you can create style “classes” that you can apply to a or tag using either tag’s class attribute. When applied to a tag, the style affects the entire paragraph. You can also style a span of text that uses a style class by using the ...

  • Page 144

    144 chapter 8: working with text an example of using styles with html this section presents an example of using styles with html tags. You’ll create a style sheet that styles some built-in tags and defines some style classes. You’ll then apply that style sheet to a textfield object that contains htm...

  • Page 145

    Formatting text with cascading style sheets 145 9 open the actions panel (window > development panels > actions) and add the following code to the actions panel: // create a new style sheet object var style_sheet = new textfield.Stylesheet(); // location of css file that defines styles var css_url =...

  • Page 146

    146 chapter 8: working with text you could then populate a text field associated with that style sheet with the following xml- formatted text: this is a section this is some main body text, with one emphatic word. An example of using styles with xml in this section, you’ll create the same fla file t...

  • Page 147

    Using html-formatted text 147 7 to create the xml text to assign to the text field, add the following code to the actions panel: var storytext = " title>san francisco, ca--macromedia inc. Announced today a new version of flash player that supports cascading style sheets (css) text styles. For more i...

  • Page 148

    148 chapter 8: working with text supported html tags this section lists the built-in html tags supported by flash player. You can also create new styles and tags using cascading style sheets; see “formatting text with cascading style sheets” on page 139 . Anchor tag () the tag creates a hyperlink an...

  • Page 149

    Using html-formatted text 149 image tag () the tag lets you embed external jpeg files, swf files, and movie clips inside text fields. Text automatically flows around images you embed in text fields. This tag is supported only in dynamic and input text fields that are multiline and wrap their text. T...

  • Page 150

    150 chapter 8: working with text list item tag ( the tag places a bullet in front of the text that it encloses. Grocery list: the above code would render as follows: grocery list: ■ apples ■ oranges ■ lemons paragraph tag ( ) the tag creates a new paragraph. It supports the following attributes: • a...

  • Page 151

    Using html-formatted text 151 • leading specifies the amount of leading (vertical space) between lines; corresponds to textformat.Leading . (see textformat.Leading on page 722 .) • leftmargin specifies the left margin of the paragraph, in points; corresponds to textformat.Leftmargin . (see textforma...

  • Page 152

    152 chapter 8: working with text embedding images, swf files, and movie clips in text fields in flash player 7 and later, you can use the tag to embed jpeg files, swf files, and movie clips inside dynamic and input text fields. (for a full list of attributes for the tag, see “image tag ()” on page 1...

  • Page 153

    Creating scrolling text 153 for example, the following code embeds a swf file named animation.Swf in the text field named textfield_txt on level 0 and assigns the instance name animation_mc to the movie clip that contains the swf file. _level0.Textfield_txt.Htmltext = "here’s an interesting animatio...

  • Page 154

    154 chapter 8: working with text to use the scroll property to create scrolling text: 1 do one of the following: ■ use the text tool to drag a text field on the stage. Assign the text field the instance name textfield in the property inspector. ■ use actionscript to create a text field dynamically w...

  • Page 155: Chapter 9

    155 chapter 9 creating classes with actionscript 2.0 actionscript 2.0 is a restructuring of the actionscript language that provides several powerful new programming features found in other programming languages, such as java. Actionscript 2.0 encourages program structures that are reusable, scalable...

  • Page 156

    156 chapter 9: creating classes with actionscript 2.0 principles of object-oriented programming this section provides a brief introduction to principles involved in developing object-oriented programs. These principles are described in more depth in the rest of this chapter, along with details on ho...

  • Page 157

    Using classes: a simple example 157 interfaces interfaces in object-oriented programming can be described as classes whose methods are not implemented (defined). Another class can implement the methods declared by the interface. An interface can also be thought of as a “programming contract” that ca...

  • Page 158

    158 chapter 9: creating classes with actionscript 2.0 to create the class file: 1 create a new directory on your hard disk and name it personfiles. This directory will contain all the files for this project. 2 do one of the following: ■ create a new file in your preferred text or code editor. ■ (fla...

  • Page 159

    Using classes: a simple example 159 6 next you’ll create the showinfo() method, which returns a preformatted string containing the values of the age and name properties. Add the showinfo() function definition to the class body, as shown below. Class person { var age:number; var name:string; // metho...

  • Page 160

    160 chapter 9: creating classes with actionscript 2.0 creating an instance of the person class the next step is to create an instance of the person class in another script, such as a frame script in a flash (fla) document or another as script, and assign it to a variable. To create an instance of a ...

  • Page 161

    Creating and using classes 161 creating and using classes as discussed previously, a class consists of two parts: the declaration and the body. The class declaration consists minimally of the class statement, followed by an identifier for the class name, then left and right curly braces. Everything ...

  • Page 162

    162 chapter 9: creating classes with actionscript 2.0 similarly, any function declared within a class is considered a method of the class. In the person class example, you created a single method called showinfo() . Class person { var age:number; var name:string; function showinfo() { // showinfo() ...

  • Page 163

    Creating and using classes 163 the class you specify in subclass inherits all the properties and methods defined by the superclass. For example, you might create a mammal class that defines properties and methods common to all mammals. To create a variation of the mammal class, such as a marsupial c...

  • Page 164

    164 chapter 9: creating classes with actionscript 2.0 if no constructor function is explicitly declared—that is, if you don’t create a function whose name matches that of the class—the compiler automatically creates an empty constructor function for you. A class can contain only one constructor func...

  • Page 165

    Instance and class members 165 instance and class members in object-oriented programming, members (properties or methods) of a class can be either instance members or class members. Instance members are created for, and copied into, each instance of the class; in contrast, class members are created ...

  • Page 166

    166 chapter 9: creating classes with actionscript 2.0 using class members: a simple example one use of class (static) members is to maintain state information about a class and its instances. For example, suppose you want to keep track of the number of instances that have been created from a particu...

  • Page 167

    Creating and using interfaces 167 class members and subclasses class members propagate to subclasses of the superclass that defines those members. In the previous example (see “using class members: a simple example” on page 166 ), you used a class property to keep track of the number of instances of...

  • Page 168

    168 chapter 9: creating classes with actionscript 2.0 for example, the following code declares an interface named myinterface that contains two methods, method_1() and method_2() . The first method takes no parameters and has no return type (specified as void ). The second method declaration takes a...

  • Page 169

    Understanding the classpath 169 for example, the following code first checks if the object name someobject implements the movable interface before calling the moveup() method on the object. If(movable(someobject) != null) { someobject.Moveup(); } understanding the classpath in order to use a class o...

  • Page 170

    170 chapter 9: creating classes with actionscript 2.0 modifying the classpath you can modify the global classpath using the preferences dialog box. To modify the document- level classpath setting, you use the publish settings dialog box for the fla file. You can add absolute directory paths (for exa...

  • Page 171

    Importing classes 171 using packages you can organize your actionscript class files in packages. A package is a directory that contains one or more class files, and that resides in a designated classpath directory. (see “understanding the classpath” on page 169 .) a package can, in turn, contain oth...

  • Page 172

    172 chapter 9: creating classes with actionscript 2.0 you can use the fully qualified class name to type your variables, as well: var datainstance:com.Network.Data = new data(); you can use the import statement to import packages into a script, which lets you use a class’s abbreviated name rather th...

  • Page 173

    Creating dynamic classes 173 as you can see, getusername returns the current value of username , and setusername sets the value of username to the string parameter passed to the method. An instance of the class would then use the following syntax to get or set the username property. // calling "get"...

  • Page 174

    174 chapter 9: creating classes with actionscript 2.0 in some cases, however, you might want to add and access properties or methods of a class at runtime that aren’t defined in the original class definition. The dynamic class modifier lets you do just that. For example, the following code adds the ...

  • Page 175: Part IV

    Part iv working with 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 exte...

  • Page 177: Chapter 10

    177 chapter 10 working with external data in macromedia flash mx 2004 and macromedia flash mx professional 2004, you can use actionscript to load data from external sources into a swf file. You can also send data from a swf file for processing by an application server (such as macromedia coldfusion ...

  • Page 178

    178 chapter 10: working with external data several actionscript functions and methods let you pass information into and out of a swf file. Each function or method uses a protocol to transfer information, and requires information to be formatted in a certain way. • the functions and movieclip methods...

  • Page 179

    Sending and loading variables to and from a remote source 179 for more information, see “using the xml class” on page 181 and “using the xmlsocket class” on page 184 . Using http to connect to server-side scripts the loadvariables() , loadvariablesnum() , geturl() , loadmovie() , and loadmovienum() ...

  • Page 180

    180 chapter 10: working with external data using the loadvars class you can use the loadvars class instead of loadvariables() to transfer variables between a swf file and a server. The loadvars class lets you send all the variables in an object to a specified url and load all the variables at a spec...

  • Page 181

    Sending and loading variables to and from a remote source 181 about xml xml (extensible markup language) is becoming the standard for the interchange of structured data in internet applications. You can integrate data in flash with servers that use xml technology to build sophisticated applications,...

  • Page 182

    182 chapter 10: working with external data the server-side script that passes information between flash and the database reads and writes the data in xml format. You can use actionscript to convert information collected in the swf file (for example, a user name and password) to an xml object and the...

  • Page 183

    Sending and loading variables to and from a remote source 183 the server receives the xml, generates an xml response, and sends it back to the swf file. If the password is accepted, the server responds with the following: this xml includes a session attribute that contains a unique, randomly generat...

  • Page 184

    184 chapter 10: working with external data the onloginreply() function is defined in the first frame of the swf file. (to understand this script, read the commented lines.) function onloginreply() { // get the first xml element var e = this.Firstchild; // if the first xml element is a loginreply ele...

  • Page 185

    Sending messages to and from flash player 185 you can use the connect() and send() methods of the xmlsocket class to transfer xml to and from a server over a socket connection. The connect() method establishes a socket connection with a web server port. The send() method passes an xml object to the ...

  • Page 186

    186 chapter 10: working with external data using fscommand() use the fscommand() function to send a message to whichever program is hosting flash player. The fscommand() function has two parameters: command and arguments . To send a message to the stand-alone version of flash player, you must use pr...

  • Page 187

    Sending messages to and from flash player 187 to use fscommand() to open a message box from a swf file in the html page through javascript: 1 in the html page that embeds the swf file, add the following javascript code: function themovie_dofscommand(command, args) { if (command == "messagebox") { al...

  • Page 188

    188 chapter 10: working with external data there are two different technologies that enable communication between the browser and flash player: liveconnect (netscape navigator 3.0 or later on windows 95/98/2000/nt or power macintosh) and activex (internet explorer 3.0 and later on windows 95/98/2000...

  • Page 189

    Flash player security features 189 for information on how to permit a swf file served from one domain to access data, objects, or variables from swf files that are served from another domain, see “about allowing data access between cross-domain swf files” on page 189 . For information on how to perm...

  • Page 190

    190 chapter 10: working with external data about allowing http to https protocol access between swf files as discussed in the previous section, you must use an allowdomain handler or method to permit a swf file in one domain to be accessed by a swf file in another domain. However, if the swf being a...

  • Page 191

    Flash player security features 191 an xml policy file contains a single tag, which in turn contains zero or more tags. Each tag contains one attribute, domain , which specifies either an exact ip address, an exact domain, or a wildcard domain (any domain). Wildcard domains are indicated by either a ...

  • Page 192

    192 chapter 10: working with external data.

  • Page 193: Chapter 11

    193 chapter 11 working with external media if you import an image or a sound while you author a document in macromedia flash mx 2004 or macromedia flash mx professional 2004, the image and sound are packaged and stored in the swf file when you publish it. In addition to importing media while authori...

  • Page 194

    194 chapter 11: working with external media flash video (flv) is the native video format used by flash player. You can play back flv files over http, or from the local file system. Playing external flv files provides several advantages over embedding video in a flash document, such as better perform...

  • Page 195

    Loading external mp3 files 195 about loaded swf files and the root timeline the actionscript property _root specifies or returns a reference to the root timeline of a swf file. If you load a swf file into a movie clip in another swf file, any references to _root in the loaded swf file resolve to the...

  • Page 196

    196 chapter 11: working with external media for example, suppose you’re creating an online game that uses different sounds depending on what level the user has reached in the game. The following code loads an mp3 file (blastoff.Mp3) into a sound object named gamesound , and then plays the sound when...

  • Page 197

    Playing back external flv files dynamically 197 playing back external flv files dynamically as an alternative to importing video into the flash authoring environment, you can use actionscript to dynamically play back external flv files in flash player. You can play back flv files from an http addres...

  • Page 198

    198 chapter 11: working with external media to play back an external flv file in a flash document: 1 with the document open in the flash authoring tool, in the library panel (window > library) select new video from the library options menu to create a video object. 2 drag a video object from the lib...

  • Page 199

    Preloading external media 199 preloading swf and jpeg files to preload swf and jpeg files into movie clip instances, you can use the moviecliploader class . This class provides an event listener mechanism to give notification about the status of file downloads into movie clips. Using a movieclipload...

  • Page 200

    200 chapter 11: working with external media to display download progress using the progressbar component: 1 in a new flash document, create a movie clip on the stage and name it target_mc . 2 open the components panel (window > development panels > components). 3 drag a progressbar component from th...

  • Page 201

    Preloading external media 201 preloading mp3 and flv files to preload mp3 and flv files, you can use the setinterval() function to create a “polling” mechanism that checks the bytes loaded for a sound or netstream object at predetermined intervals. To track the download progress of mp3 files, use th...

  • Page 202

    202 chapter 11: working with external media.

  • Page 203: Part V

    Part v reference this part contains the actionscript dictionary, which provides syntax and usage information for every element in the actionscript language. It also contains appendixes that provide reference material you may want to review as you write your scripts. Chapter 12: actionscript dictiona...

  • Page 205: Chapter 12

    205 chapter 12 actionscript dictionary this dictionary describes the syntax and use of actionscript elements in macromedia flash mx 2004 and macromedia flash mx professional 2004. To use examples in a script, copy the example code from this dictionary and paste it in the script pane or into an exter...

  • Page 206

    206 chapter 12: actionscript dictionary sample entry for most actionscript elements the following sample dictionary entry explains the conventions used for all actionscript elements that are not classes. Entry title all entries are listed alphabetically. The alphabetization ignores capitalization, l...

  • Page 207

    Contents of the dictionary 207 sample entry for classes the following sample dictionary entry explains the conventions used for built-in actionscript classes. Classes are listed alphabetically with all other elements in the dictionary. Entry title the entry title provides the name of the class. The ...

  • Page 208

    208 chapter 12: actionscript dictionary &= &= (bitwise and assignment) () () (parentheses) – – (minus) * * (multiplication) *= *= (multiplication assignment) , , (comma) . . (dot) : : (type) ?: ?: (conditional) / / (division) // // (comment delimiter) /* /* (comment delimiter) /= /= (division assign...

  • Page 209

    Contents of the dictionary 209 the following table lists all actionscript elements that are not symbolic operators. >= >= (greater than or equal to) >> >> (bitwise right shift) >>= >>= (bitwise right shift and assignment) >>> >>> (bitwise unsigned right shift) >>>= >>>= (bitwise unsigned right shift...

  • Page 210

    210 chapter 12: actionscript dictionary _width button._width , movieclip._width , textfield._width _x button._x , movieclip._x , textfield._x _xmouse button._xmouse , movieclip._xmouse , textfield._xmouse _xscale button._xscale , movieclip._xscale , textfield._xscale _y button._y , movieclip._y , te...

  • Page 211

    Contents of the dictionary 211 attachvideo video.Attachvideo() attributes xml.Attributes autosize textfield.Autosize avhardwaredisable system.Capabilities.Avhardwaredisable background textfield.Background backgroundcolor textfield.Backgroundcolor backspace key.Backspace bandwidth camera.Bandwidth be...

  • Page 212

    212 chapter 12: actionscript dictionary ceil math.Ceil() charat string.Charat() charcodeat string.Charcodeat() childnodes xml.Childnodes chr chr class class clear movieclip.Clear() , sharedobject.Clear() , video.Clear() clearinterval clearinterval() clonenode xml.Clonenode() close localconnection.Cl...

  • Page 213

    Contents of the dictionary 213 customitems contextmenu.Customitems data sharedobject.Data date date class deblocking video.Deblocking default default delete delete deletekey key.Deletekey do while do while doctypedecl xml.Doctypedecl domain localconnection.Domain() down key.Down duplicatemovieclip d...

  • Page 214

    214 chapter 12: actionscript dictionary firstchild xml.Firstchild floor math.Floor() flush sharedobject.Flush() focusenabled movieclip.Focusenabled font textformat.Font for for for..In for..In fps camera.Fps fromcharcode string.Fromcharcode() fscommand fscommand() function function , function class ...

  • Page 215

    Contents of the dictionary 215 getmilliseconds date.Getmilliseconds() getminutes date.Getminutes() getmonth date.Getmonth() getnewtextformat textfield.Getnewtextformat() getnexthighestdepth movieclip.Getnexthighestdepth() getpan sound.Getpan() getprogress moviecliploader.Getprogress() getproperty ge...

  • Page 216

    216 chapter 12: actionscript dictionary getversion getversion getvolume sound.Getvolume() getyear date.Getyear() globaltolocal movieclip.Globaltolocal() goto gotoandplay() , gotoandstop() gotoandplay gotoandplay() , movieclip.Gotoandplay() gotoandstop gotoandstop() , movieclip.Gotoandstop() gt gt (g...

  • Page 217

    Contents of the dictionary 217 ignorewhite xml.Ignorewhite implements implements import import indent textformat.Indent index camera.Index , microphone.Index indexof string.Indexof() infinity infinity -infinity -infinity insert key.Insert insertbefore xml.Insertbefore() install customactions.Install...

  • Page 218

    218 chapter 12: actionscript dictionary linestyle movieclip.Linestyle() lineto movieclip.Lineto() list customactions.List() ln10 math.Ln10 ln2 math.Ln2 load loadvars.Load() , textfield.Stylesheet.Load() , xml.Load() , loadclip moviecliploader.Loadclip() loaded loadvars.Loaded , xml.Loaded loadmovie ...

  • Page 219

    Contents of the dictionary 219 message error.Message microphone microphone class min math.Min() min_value number.Min_value mmexecute mmexecute() motionlevel camera.Motionlevel motiontimeout camera.Motiontimeout mouse mouse class mousewheelenabled textfield.Mousewheelenabled moveto movieclip.Moveto()...

  • Page 220

    220 chapter 12: actionscript dictionary on on() onactivity camera.Onactivity , microphone.Onactivity onchanged textfield.Onchanged onclipevent onclipevent() onclose xmlsocket.Onclose() onconnect xmlsocket.Onconnect() ondata loadvars.Ondata , movieclip.Ondata , xml.Ondata , xmlsocket.Ondata() ondrago...

  • Page 221

    Contents of the dictionary 221 onsetfocus button.Onsetfocus , movieclip.Onsetfocus , selection.Onsetfocus , textfield.Onsetfocus onsoundcomplete sound.Onsoundcomplete onstatus camera.Onstatus , localconnection.Onstatus , microphone.Onstatus , netstream.Onstatus , sharedobject.Onstatus , system.Onsta...

  • Page 222

    222 chapter 12: actionscript dictionary printjob printjob class printnum printnum() private private prototype function.Prototype public public push array.Push() quality camera.Quality random random , math.Random() rate microphone.Rate registerclass object.Registerclass() removelistener key.Removelis...

  • Page 223

    Contents of the dictionary 223 selection selection class send loadvars.Send() , localconnection.Send() , printjob.Send() , xml.Send() , xmlsocket.Send() sendandload loadvars.Sendandload() , xml.Sendandload() separatorbefore contextmenuitem.Separatorbefore serverstring system.Capabilities.Serverstrin...

  • Page 224

    224 chapter 12: actionscript dictionary setstyle textfield.Stylesheet.Setstyle() settextformat textfield.Settextformat() settime date.Settime() settransform color.Settransform() , sound.Settransform() setuseechosuppression microphone.Setuseechosuppression() setutcdate date.Setutcdate() setutcfullyea...

  • Page 225

    Contents of the dictionary 225 sqrt1_2 math.Sqrt1_2 sqrt2 math.Sqrt2 stage stage class start printjob.Start() , sound.Start() startdrag startdrag() , movieclip.Startdrag() static static status xml.Status stop stop() , movieclip.Stop() , sound.Stop() stopallsounds stopallsounds() stopdrag stopdrag() ...

  • Page 226

    226 chapter 12: actionscript dictionary textsnapshot textsnapshot object textwidth textfield.Textwidth this this throw throw time netstream.Time togglehighquality togglehighquality() tolowercase string.Tolowercase() tostring array.Tostring() , boolean.Tostring() , date.Tostring() , error.Tostring() ...

  • Page 227

    –– (decrement) 227 –– (decrement) availability flash player 4. Usage ––expression expression–– parameters none. Returns a number. Description operator (arithmetic); a pre-decrement and post-decrement unary operator that subtracts 1 from the expression . The pre-decrement form of the operator ( ––exp...

  • Page 228

    228 chapter 12: actionscript dictionary example the pre-decrement form of the operator decrements x to 2 ( x - 1 = 2 ), and returns the result as y : x = 3; y = --x; //y is equal to 2 the post-decrement form of the operator decrements x to 2 ( x - 1 = 2 ), and returns the original value of x as the ...

  • Page 229

    ! (logical not) 229 example the following example uses ++ as a post-increment operator to make a while loop run five times. I = 0; while(i++ trace("this is execution " + i); } this example uses ++ as a pre-increment operator. Var a = []; var i = 0; while (i a.Push(++i); } trace(a.Join()); this scrip...

  • Page 230

    230 chapter 12: actionscript dictionary example in the following example, the variable happy is set to false . The if condition evaluates the condition !Happy , and if the condition is true , the trace() action sends a string to the output panel. Happy = false; if (!Happy) { trace("don’t worry, be h...

  • Page 231

    !== (strict inequality) 231 !== (strict inequality) availability flash player 6. Usage expression1 !== expression2 description operator; tests for the exact opposite of the === operator. The strict inequality operator performs the same as the inequality operator except that data types are not conver...

  • Page 232

    232 chapter 12: actionscript dictionary % (modulo) availability flash player 4. In flash 4 files, the % operator is expanded in the swf file as x - int(x/y) * y , and may not be as fast or as accurate in later versions of flash player. Usage expression1 % expression2 parameters none. Returns nothing...

  • Page 233

    && (logical and) 233 example the following example assigns the value 4 to the variable x . X = 14; y = 5; trace(x %= y); // returns 4 see also % (modulo) & (bitwise and operator) availability flash player 5. In flash 4, the & operator was used for concatenating strings. In flash 5 and later, the & o...

  • Page 234

    234 chapter 12: actionscript dictionary description operator (logical); performs a boolean operation on the values of one or both of the expressions. Evaluates expression1 (the expression on the left side of the operator) and returns false if the expression evaluates to false . If expression1 evalua...

  • Page 235

    () (parentheses) 235 () (parentheses) availability flash player 4. Usage (expression1, expression2) function(parameter1,..., parametern) parameters expression1, expression2 numbers, strings, variables, or text. Function the function to be performed on the contents of the parentheses. Parameter1...Pa...

  • Page 236

    236 chapter 12: actionscript dictionary see also with – (minus) availability flash player 4. Usage (negation) - expression (subtraction) expression1 - expression2 parameters none. Returns nothing. Description operator (arithmetic); used for negating or subtracting. Usage 1: when used for negating, i...

  • Page 237

    *= (multiplication assignment) 237 * (multiplication) availability flash player 4. Usage expression1 * expression2 parameters none. Returns nothing. Description operator (arithmetic); multiplies two numerical expressions. If both expressions are integers, the product is an integer. If either or both...

  • Page 238

    238 chapter 12: actionscript dictionary example usage 1: the following example assigns the value 50 to the variable x . X = 5; y = 10; trace (x *= y); // returns 50 usage 2: the second and third lines of the following example calculate the expressions on the right-hand side of the equals sign and as...

  • Page 239

    : (type) 239 . (dot) availability flash player 4. Usage object.Property_or_method instancename.Variable instancename.Childinstance.Variable parameters object an instance of a class. The object can be an instance of any of the built-in actionscript classes or a custom class. This parameter is always ...

  • Page 240

    240 chapter 12: actionscript dictionary parameters variablename an identifier for a variable. Type a native data type, class name that you have defined, or interface name. Functionname an identifier for a function. Parameter an identifier for a function parameter. Description operator; specifies the...

  • Page 241

    / (division) 241 ?: (conditional) availability flash player 4. Usage expression1 ? Expression2 : expression3 parameters expression1 an expression that evaluates to a boolean value, usually a comparison expression, such as x . Expression2 , expression3 values of any type. Returns nothing. Description...

  • Page 242

    242 chapter 12: actionscript dictionary example the following statement divides the floating-point number 22.0 by 7.0 and then displays the result in the output panel. Trace(22.0 / 7.0); the result is 3.1429 , which is a floating-point number. // (comment delimiter) availability flash 1. Usage // co...

  • Page 243

    /* (comment delimiter) 243 /* (comment delimiter) availability flash player 5. Usage /* comment */ /* comment comment */ parameters comment any characters. Returns nothing. Description comment; indicates one or more lines of script comments. Any characters that appear between the opening comment tag...

  • Page 244

    244 chapter 12: actionscript dictionary /= (division assignment) availability flash player 4. Usage expression1 /= expression2 parameters expression1,expression2 a number or a variable that evaluates to a number. Returns nothing. Description operator (arithmetic compound assignment); assigns express...

  • Page 245

    [] (array access) 245 returns nothing. Description operator; initializes a new array or multidimensional array with the specified elements ( a0 , and so on), or accesses elements in an array. The array access operator lets you dynamically set and retrieve instance, variable, and object names. It als...

  • Page 246

    246 chapter 12: actionscript dictionary usage 1 and 2: the following example creates an array called employee_array and uses the trace() action to send the elements to the output panel. In the fourth line, an element in the array is changed and the fifth line sends the newly modified array to the ou...

  • Page 247

    ^= (bitwise xor assignment) 247 description operator (bitwise); converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression1 , but not both, are 1. Example the following example uses the bitwise xor ...

  • Page 248

    248 chapter 12: actionscript dictionary {} (object initializer) availability flash player 5. Usage object = {name1: value1, name2: value2,...Namen: valuen} parameters object the object to create. Name1,2,...N the names of the properties. Value1,2,...N the corresponding values for each name property....

  • Page 250

    250 chapter 12: actionscript dictionary description operator (logical); evaluates expression1 and expression2 . The result is true if either or both expressions evaluate to true ; the result is false only if both expressions evaluate to false . You can use the logical or operator with any number of ...

  • Page 252

    252 chapter 12: actionscript dictionary + (addition) availability flash player 4; flash player 5. In flash 5 and later, + is either a numeric operator or string concatenator depending on the data type of the parameter. In flash 4, + is only a numeric operator. Flash 4 files brought into the flash 5 ...

  • Page 253

    += (addition assignment) 253 usage 3: this statement adds the integers 2 and 3 and displays the resulting integer, 5, in the output panel: trace (2 + 3); this statement adds the floating-point numbers 2.5 and 3.25 and displays the result, 5.75 , a floating-point number, in the output panel: trace (2...

  • Page 254

    254 chapter 12: actionscript dictionary availability flash player 4; flash player 5. In flash 5 and later, the (less than) operator is a comparison operator capable of handling various data types. In flash 4, is an numeric operator. Flash 4 files brought into the flash 5 or later authoring environme...

  • Page 255

    255 availability flash player 5. Usage expression1 expression2 parameters expression1 a number or expression to be shifted left. Expression2 a number or expression that converts to an integer from 0 to 31. Returns nothing. Description operator (bitwise); converts expression1 and expression2 to 32-bi...

  • Page 256

    256 chapter 12: actionscript dictionary returns nothing. Description operator (bitwise compound assignment); this operator performs a bitwise left shift operation and stores the contents as a result in expression1 . The following two expressions are equivalent. A a = (a see also , >>= (bitwise right...

  • Page 257

    (inequality) 257 // true 2 // true 10 // false "allen" // true "jack" // false "11" //true "11" // numeric comparison // false "c" // false "a" // true (inequality) availability flash 2. Usage expression1 expression2 parameters expression1,expression2 a number, string, boolean value, variable, objec...

  • Page 258

    258 chapter 12: actionscript dictionary = (assignment) availability flash player 4. Flash 4 file: x = y converted flash 5 or later file: number(x) == number(y) usage expression1 = expression2 parameters expression1 a variable, element of an array, or property of an object. Expression2 a value of any...

  • Page 259

    -= (subtraction assignment) 259 -= (subtraction assignment) availability flash player 4. Usage expression1 -= expression2 parameters expression1,expression2 a number or expression that evaluates to a number. Returns nothing. Description operator (arithmetic compound assignment); assigns expression1 ...

  • Page 260

    260 chapter 12: actionscript dictionary == (equality) availability flash player 5. Usage expression1 == expression2 parameters expression1,expression2 a number, string, boolean value, variable, object, array, or function. Returns a boolean value. Description operator (equality); tests two expression...

  • Page 261

    === (strict equality) 261 === (strict equality) availability flash player 6. Usage expression1 === expression2 returns a boolean value. Description operator; tests two expressions for equality; the strict equality operator performs just like the equality operator except that data types are not conve...

  • Page 262

    262 chapter 12: actionscript dictionary > (greater than) availability flash player 4. Flash 4 file: x > y converted flash 5 or later file: number(x) > number(y) usage expression1 >expression2 parameters expression1,expression2 a number or string. Returns a boolean value. Description operator (compar...

  • Page 263

    >> (bitwise right shift) 263 description operator (comparison); compares two expressions and determines whether expression1 is greater than or equal to expression2 ( true ), or whether expression1 is less than expression2 ( false ). In flash 5 or later, greater than or equal to ( > ) is a comparison...

  • Page 264

    264 chapter 12: actionscript dictionary this is because -1 decimal equals 11111111111111111111111111111111 binary (thirty-two 1’s), shifting right by one bit causes the least significant (bit farthest to the right) to be discarded and the most significant bit to be filled in with 1. The result is 11...

  • Page 265

    >>> (bitwise unsigned right shift) 265 see also >>> (bitwise unsigned right shift) availability flash player 5. Usage expression1 >>> expression2 parameters expression1 a number or expression to be shifted right. Expression2 a number or expression that converts to an integer between 0 and 31. Return...

  • Page 266

    266 chapter 12: actionscript dictionary >>>= (bitwise unsigned right shift and assignment) availability flash player 5. Usage expression1 >>>= expression2 parameters expression1 a number or expression to be shifted left. Expression2 a number or expression that converts to an integer from 0 to 31. Re...

  • Page 267

    Accessibility.Updateproperties() 267 accessibility.Isactive() availability flash player 6 version 65. Usage accessibility.Isactive() parameters none. Returns a boolean value of true if there are active microsoft active accessibility (msaa) clients and the player is running in an environment that sup...

  • Page 268

    268 chapter 12: actionscript dictionary description method; causes flash player to reexamine all accessibility properties, update its description of objects for screen readers, and, if necessary, send events to screen readers to indicate that changes have occurred. For information on setting accessi...

  • Page 269

    _accprops 269 to determine whether the player is running in an environment that supports accessibility aids, use system.Capabilities.Hasaccessibility . The following table lists the name and data type of each _accprops property, its equivalent setting in the accessibility panel, and the kinds of obj...

  • Page 270

    270 chapter 12: actionscript dictionary if you are specifying several accessibility properties, make as many changes as you can before calling accessibility.Updateproperties() , instead of calling it after each property statement: _accprops.Name = "pet store"; animal_mc._accprops.Name = "animal"; an...

  • Page 271

    And 271 add availability flash player 4. Usage string1 add string2 parameters string1, string2 a string. Returns nothing. Description operator; concatenates (combines) two or more strings. The add operator replaces the flash 4 add ( & ) operator; flash player 4 files that use the & operator are auto...

  • Page 272

    272 chapter 12: actionscript dictionary arguments class availability flash player 5; property added in flash player 6. Description the arguments class is an array that contains the values that were passed as parameters to any function. Each time a function is called in actionscript, an arguments obj...

  • Page 273

    Array class 273 arguments.Caller availability flash player 6. Usage arguments.Caller description property; refers to the calling function. Arguments.Length availability flash player 5. Usage arguments.Length description property; the number of parameters actually passed to a function. Array class av...

  • Page 274

    274 chapter 12: actionscript dictionary method summary for the array class property summary for the array class constructor for the array class availability flash player 5. Usage new array() new array(length) new array(element0, element1, element2,...Elementn) parameters length an integer specifying...

  • Page 275

    Array class 275 description constructor; lets you create an array. You can use the constructor to create different types of arrays: an empty array, an array with a specific length but whose elements have no values, or an array whose elements have specific values. Usage 1: if you don’t specify any pa...

  • Page 276

    276 chapter 12: actionscript dictionary array.Concat() availability flash player 5. Usage my_array.Concat( [ value0, value1,...Valuen ]) parameters value0,...Valuen numbers, elements, or strings to be concatenated in a new array. If you don’t pass any values, a duplicate of my_array is created. Retu...

  • Page 277

    Array.Join() 277 array.Join() availability flash player 5. Usage my_array.Join([separator]) parameters separator a character or string that separates array elements in the returned string. If you omit this parameter, a comma is used as the default separator. Returns string. Description method; conve...

  • Page 278

    278 chapter 12: actionscript dictionary array.Length availability flash player 5. Usage my_array.Length description property; a nonzero-based integer specifying the number of elements in the array. This property is automatically updated when new elements are added to the array. When you assign a val...

  • Page 279

    Array.Reverse() 279 array.Push() availability flash player 5. Usage my_array.Push(value,...) parameters value one or more values to append to the array. Returns the length of the new array. Description method; adds one or more elements to the end of an array and returns the array’s new length. Examp...

  • Page 280

    280 chapter 12: actionscript dictionary array.Shift() availability flash player 5. Usage my_array.Shift() parameters none. Returns the first element in an array. Description method; removes the first element from an array and returns that element. Example the following code creates the array mypets ...

  • Page 281

    Array.Sort() 281 description method; extracts a slice or a substring of the array and returns it as a new array without modifying the original array. The returned array includes the start element and all elements up to, but not including, the end element. If you don’t pass any parameters, a duplicat...

  • Page 282

    282 chapter 12: actionscript dictionary description method; sorts the elements in an array. Flash sorts according to ascii (unicode) values. If either of the elements being compared does not contain the field specified in the fieldname parameter, the field is assumed to be undefined , and the elemen...

  • Page 283

    Array.Sorton() 283 } } trace ("unsorted:"); trace (passwords.Join()); passwords.Sort(order); trace ("sorted:"); trace (passwords.Join()); the output panel displays the following results: unsorted: mom:glam,ana:ring,jay:mag,anne:home,regina:silly sorted: ana:ring,anne:home,jay:mag,mom:glam,regina:sil...

  • Page 284

    284 chapter 12: actionscript dictionary returns the return value depends on whether you pass any parameters: • if you specify a value of 4 or array.Unique for option , and two or more elements being sorted have identical sort fields, flash returns a value of 0 and does not modify the array. • if you...

  • Page 285

    Array.Sorton() 285 performing a default sort on the password field produces the following results: my_array.Sorton("password") // bob // abcd // barb // catchy performing a case-insensitive sort on the password field produces the following results: my_array.Sorton("password", array.Caseinsensitive) ...

  • Page 286

    286 chapter 12: actionscript dictionary performing a sort that returns an index array doesn’t change the elements in the array: // before sorting // my_array[0].Age = 29; // my_array[1].Age = 3; // my_array[2].Age = 35; // my_array[3].Age = 4; // after a sort that returns an array containing index v...

  • Page 287

    Array.Tostring() 287 array.Splice() availability flash player 5. Usage my_array.Splice(start, deletecount [, value0, value1...Valuen]) parameters start the index of the element in the array where the insertion or deletion begins. Deletecount the number of elements to be deleted. This number includes...

  • Page 288

    288 chapter 12: actionscript dictionary example the following example creates my_array , converts it to a string, and displays 1,2,3,4,5 in the output panel. My_array = new array(); my_array[0] = 1; my_array[1] = 2; my_array[2] = 3; my_array[3] = 4; my_array[4] = 5; trace(my_array.Tostring()); array...

  • Page 289

    Boolean class 289 asfunction availability flash player 5. Usage asfunction:function,"parameter" parameters function an identifier for a function. Parameter a string that is passed to the function named in the function parameter. Returns nothing. Description protocol; a special protocol for urls in h...

  • Page 290

    290 chapter 12: actionscript dictionary method summary for the boolean class constructor for the boolean class availability flash player 5. Usage new boolean([x]) parameters x any expression. This parameter is optional. Returns nothing. Description constructor; creates a boolean object. If you omit ...

  • Page 291

    Boolean() 291 boolean.Valueof() availability flash player 5. Usage myboolean.Valueof() parameters none. Returns a boolean value. Description method; returns true if the primitive value type of the specified boolean object is true, false if it is false. Example var x:boolean = new boolean(); trace(x....

  • Page 292

    292 chapter 12: actionscript dictionary if expression is undefined, the return value is false . If expression is a movie clip or an object, the return value is true . See also boolean class break availability flash player 4. Usage break parameters none. Returns nothing. Description statement; appear...

  • Page 293

    Button class 293 button class availability flash player 6. Description all button symbols in a swf file are instances of the button object. You can give a button an instance name in the property inspector, and use the methods and properties of the button class to manipulate buttons with actionscript...

  • Page 294

    294 chapter 12: actionscript dictionary event handler summary for the button class button._visible a boolean value that indicates whether a button instance is hidden or visible. Button._width the width of a button instance, in pixels. Button._x the x coordinate of a button instance. Button._xmouse t...

  • Page 295

    Button._focusrect 295 button._alpha availability flash player 6. Usage my_btn._alpha description property; the alpha transparency value of the button specified by my_btn . Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Objects in a button with _alpha set to 0...

  • Page 296

    296 chapter 12: actionscript dictionary button.Getdepth() availability flash player 6. Usage my_btn.Getdepth() returns an integer. Description method; returns the depth of a button instance. Button._height availability flash player 6. Usage my_btn._height description property; the height of the butt...

  • Page 297

    Button._name 297 button.Menu availability flash player 7. Usage my_button.Menu = contextmenu parameters contextmenu a contextmenu object. Description property; associates the contextmenu object contextmenu with the button object my_button . The contextmenu class lets you modify the context menu that...

  • Page 298

    298 chapter 12: actionscript dictionary button.Ondragout availability flash player 6. Usage my_btn.Ondragout = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse button is pressed over the button and the pointer then rolls outsi...

  • Page 299

    Button.Onkeyup 299 see also button.Onkeyup button.Onkeydown availability flash player 6. Usage my_btn.Onkeydown = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a button has keyboard focus and a key is pressed. The onkeydown event han...

  • Page 300

    300 chapter 12: actionscript dictionary returns nothing. Description event handler; invoked when a button has input focus and a key is released. The onkeyup event handler is invoked with no parameters. You can use key.Getascii() and key.Getcode() to determine which key was pressed. You must define a...

  • Page 301

    Button.Onrelease 301 returns nothing. Description event handler; invoked when a button is pressed. You 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 onpress handl...

  • Page 302

    302 chapter 12: actionscript dictionary button.Onreleaseoutside availability flash player 6. Usage my_btn.Onreleaseoutside = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse is released while the pointer is outside the button ...

  • Page 303

    Button.Onsetfocus 303 example in the following example, a function that sends a trace() action to the output panel is defined for the onrollout handler. My_btn.Onrollout = function () { trace ("onrollout called"); }; button.Onrollover availability flash player 6. Usage my_btn.Onrollover = function()...

  • Page 304

    304 chapter 12: actionscript dictionary description event handler; invoked when a button receives keyboard focus. The oldfocus parameter is the object that loses the focus. For example, if the user presses the tab key to move the input focus from a text field to a button, oldfocus contains the text ...

  • Page 305

    Button.Tabenabled 305 button._rotation availability flash player 6. Usage my_btn._rotation description property; the rotation of the button, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values...

  • Page 306

    306 chapter 12: actionscript dictionary button.Tabindex availability flash player 6. Usage my_btn.Tabindex description property; lets you customize the tab ordering of objects in a swf file. You can set the tabindex property on a button, movie clip, or text field instance; it is undefined by default...

  • Page 307

    Button.Usehandcursor 307 button.Trackasmenu availability flash player 6. Usage my_btn.Trackasmenu description property; a boolean value that indicates whether other buttons or movie clips can receive mouse release events. This allows you to create menus. You can set the trackasmenu property on any b...

  • Page 308

    308 chapter 12: actionscript dictionary button._visible availability flash player 6. Usage my_btn._visible description property; a boolean value that indicates whether the button specified by my_btn is visible. Buttons that are not visible ( _visible property set to false ) are disabled. See also mo...

  • Page 309

    Button._xmouse 309 button._x availability flash player 6. Usage my_btn._x description property; an integer that sets the x coordinate of a button relative to the local coordinates of the parent movie clip. If a button is on the main timeline, then its coordinate system refers to the upper left corne...

  • Page 310

    310 chapter 12: actionscript dictionary button._xscale availability flash player 6. Usage my_btn._xscale description property; the horizontal scale of the button as applied from the registration point of the button, expressed as a percentage. The default registration point is (0,0). Scaling the loca...

  • Page 311

    Call() 311 button._ymouse availability flash player 6. Usage my_btn._ymouse description property (read-only); indicates the y coordinate of the mouse position relative to the button. See also button._xmouse button._yscale availability flash player 6. Usage my_btn._yscale description property; the ve...

  • Page 312

    312 chapter 12: actionscript dictionary see also function , function.Call() camera class availability flash player 6. Description the camera class is primarily for use with macromedia flash communication server, but can be used in a limited fashion without the server. The camera class lets you captu...

  • Page 313

    Camera.Activitylevel 313 event handler summary for the camera class constructor for the camera class see camera.Get() . Camera.Activitylevel availability flash player 6. Usage active_cam.Activitylevel description read-only property; a numeric value that specifies the amount of motion the camera is d...

  • Page 314

    314 chapter 12: actionscript dictionary camera.Bandwidth availability flash player 6. Usage active_cam.Bandwidth description read-only property; an integer that specifies the maximum amount of bandwidth the current outgoing video feed can use, in bytes. A value of 0 means that flash video can use as...

  • Page 315

    Camera.Get() 315 camera.Fps availability flash player 6. Usage active_cam.Fps description read-only property; the maximum rate at which you want the camera to capture data, in frames per second. The maximum rate possible depends on the capabilities of the camera; that is, if the camera doesn’t suppo...

  • Page 316

    316 chapter 12: actionscript dictionary returns • if index is not specified, this method returns a reference to the default camera or, if it is in use by another application, to the first available camera. (if there is more than one camera installed, the user may specify the default camera in the fl...

  • Page 317

    Camera.Get() 317 you can’t use actionscript to set the allow or deny value for a user, but you can display the privacy panel for the user by using system.Showsettings(0) . If the user selects remember, flash player no longer displays the privacy dialog box for movies from this domain. If camera.Get ...

  • Page 318

    318 chapter 12: actionscript dictionary camera.Height availability flash player 6. Usage active_cam.Height description read-only property; the current capture height, in pixels. To set a value for this property, use camera.Setmode() . Example the following line of code updates a text box in the user...

  • Page 319

    Camera.Motiontimeout 319 camera.Motionlevel availability flash player 6. Usage active_cam.Motionlevel description read-only property; a numeric value that specifies the amount of motion required to invoke camera.Onactivity(true) . Acceptable values range from 0 to 100. The default value is 50. Video...

  • Page 320

    320 chapter 12: actionscript dictionary camera.Muted availability flash player 6. Usage active_cam.Muted description read-only property; a boolean value that specifies whether the user has denied access to the camera ( true ) or allowed access ( false ) in the flash player privacy settings panel. Wh...

  • Page 321

    Camera.Onactivity 321 camera.Names availability flash player 6. Usage camera.Names note: the correct syntax is camera.Names . To assign the return value to a variable, use syntax like cam_array = camera.Names . To determine the name of the current camera, use active_cam.Name . Description read-only ...

  • Page 322

    322 chapter 12: actionscript dictionary description event handler; invoked when the camera starts or stops detecting motion. If you want to respond to this event handler, you must create a function to process its activity value. To specify the amount of motion required to invoke camera.Onactivity(tr...

  • Page 323

    Camera.Quality 323 • if the user allows access, the camera.Muted property is set to false , and this handler is invoked with an information object whose code property is "camera.Unmuted" and whose level property is "status" . • if the user denies access, the camera.Muted property is set to true , an...

  • Page 324

    324 chapter 12: actionscript dictionary camera.Setmode() availability flash player 6. Usage active_cam.Setmode(width, height, fps [,favorsize]) parameters width the requested capture width, in pixels. The default value is 160. Height the requested capture height, in pixels. The default value is 120....

  • Page 325

    Camera.Setmotionlevel() 325 on (press) { // sets width, height, and fps to user's input. _root.Mycam.Setmode(txt_width, my_txt._height, txt_fps); // update the user’s text fields with the new settings. _root.Txt_width = mycam.Width; _root.Txt_height = mycam.Height; _root.Txt_fps = mycam.Fps; } see a...

  • Page 326

    326 chapter 12: actionscript dictionary this method is similar in purpose to microphone.Setsilencelevel() ; both methods are used to specify when the onactivity event handler should be invoked. However, these methods have a significantly different impact on publishing streams: • microphone.Setsilenc...

  • Page 327

    Camera.Setquality() 327 description method; sets the maximum amount of bandwidth per second or the required picture quality of the current outgoing video feed. This method is generally applicable only if you are transmitting video using flash communication server. Use this method to specify which el...

  • Page 328

    328 chapter 12: actionscript dictionary camera.Width availability flash player 6. Usage active_cam.Width description read-only property; the current capture width, in pixels. To set a desired value for this property, use camera.Setmode() . Example the following line of code updates a text box in the...

  • Page 329

    Class 329 chr availability flash player 4. This function was deprecated in flash 5 in favor of string.Fromcharcode() . Usage chr(number) parameters number an ascii code number. Returns nothing. Description string function; converts ascii code numbers to characters. Example the following example conv...

  • Page 330

    330 chapter 12: actionscript dictionary description statement; defines a custom class, which lets you instantiate objects that share methods and properties that you define. For example, if you are developing an invoice-tracking system, you could create an invoice class that defines all the methods a...

  • Page 331

    Color class 331 in an external script file or in the actions panel, use the new operator to create a plant object. Var pinetree:plant = new plant("evergreen","n/a"); // confirm parameters were passed correctly trace(pinetree.Getleaftype()); trace(pinetree.Getbloomseason()); see also dynamic , extend...

  • Page 332

    332 chapter 12: actionscript dictionary method summary for the color class constructor for the color class availability flash player 5. Usage new color(target) parameters target the instance name of a movie clip. Returns nothing. Description constructor; creates a color object for the movie clip spe...

  • Page 333

    Color.Setrgb() 333 description method; returns the numeric values set by the last setrgb() call. Example the following code retrieves the rgb value for the color object my_color , converts it to a hexadecimal string, and assigns it to the value variable. Value = my_color.Getrgb().Tostring(16); see a...

  • Page 334

    334 chapter 12: actionscript dictionary returns nothing. Example this example sets the rgb color value for the movie clip my_mc . To see this code work, place a movie clip on the stage with the instance name my_mc . Then place the following code on frame 1 in the main timeline and choose control > t...

  • Page 335

    Contextmenu class 335 you create a colortransformobject parameter as follows: mycolortransform = new object(); mycolortransform.Ra = 50; mycolortransform.Rb = 244; mycolortransform.Ga = 40; mycolortransform.Gb = 112; mycolortransform.Ba = 12; mycolortransform.Bb = 90; mycolortransform.Aa = 40; mycol...

  • Page 336

    336 chapter 12: actionscript dictionary flash player has three types of context menus: the standard menu (which appears when you right- click in flash player), the edit menu (which appears when you right-click over a selectable or editable text field), and an error menu (which appears when a swf fil...

  • Page 337

    Contextmenu.Builtinitems 337 description constructor; creates a new contextmenu object. You can optionally specify an identifier for an event handler when you create the object. The specified function is called when the user invokes the context menu, but before the menu is actually displayed. This i...

  • Page 338

    338 chapter 12: actionscript dictionary example in this example, the built-in quality and print menu items are disabled for the contextmenu object my_cm , which is attached to the root timeline of the swf file. Var my_cm = new contextmenu (); my_cm.Builtinitems.Quality=false; my_cm.Builtinitems.Prin...

  • Page 339

    Contextmenu.Hidebuiltinitems() 339 contextmenu.Customitems availability flash player 7. Usage my_cm.Customitems description property; an array of contextmenuitem objects. Each object in the array represents a context menu item that you have defined. Use this property to add, remove, or modify these ...

  • Page 340

    340 chapter 12: actionscript dictionary this method hides only menu items that appear in the standard context menu; it does not affect items that appear in the edit or error menus. For more information about the different menu types, see the contextmenu class entry. This method works by setting all ...

  • Page 341

    Contextmenuitem class 341 example the following example determines over what type of object the context menu was invoked. My_cm = new contextmenu(); menuhandler = function (obj:object, menu:contextmenu) { if(obj instanceof movieclip) { trace("movie clip: " + obj); } if(obj instanceof textfield) { tr...

  • Page 342

    342 chapter 12: actionscript dictionary property summary for the contextmenuitem class event handler summary for the contextmenuitem class constructor for the contextmenuitem class availability flash player 7. Usage new contextmenuitem(caption, callbackfunction, [ separatorbefore, [ enabled, [ visib...

  • Page 343

    Contextmenuitem.Copy() 343 my_cm = new contextmenu(); my_cm.Customitems.Push(new contextmenuitem("start", starthandler)); my_cm.Customitems.Push(new contextmenuitem("stop", stophandler, true)); function stophandler(obj, item) { trace("stopping..."); } function starthandler(obj, item) { trace("starti...

  • Page 344

    344 chapter 12: actionscript dictionary example this example creates a new contextmenuitem object named original_cmi with the caption text pause and a callback handler set to the function onpause . The example then creates a copy of the contextmenuitem object and assigns it to the variable copy_cmi ...

  • Page 345

    Contextmenuitem.Separatorbefore 345 description event handler; invoked when the specified menu item is selected from the flash player context menu. The specified callback handler receives two parameters: obj , a reference to the object under the mouse when the user invoked the flash player context m...

  • Page 346

    346 chapter 12: actionscript dictionary contextmenuitem.Visible availability flash player 7. Usage menuitem_cmi.Visible description property; a boolean value that indicates whether the specified menu item is visible when the flash player context menu is displayed. By default, this property is true ....

  • Page 347

    Customactions.Get() 347 customactions class availability flash player 6. Description the methods of the customactions class allow a swf file playing in the flash authoring tool to manage any custom actions that are registered with the authoring tool. A swf file can install and uninstall custom actio...

  • Page 348

    348 chapter 12: actionscript dictionary customactions.Install() availability flash player 6. Usage customactions.Install(customactionsname, customxmldefinition) parameters customactionsname the name of the custom action definition to install. Customxmldefinition the text of the xml definition to ins...

  • Page 349

    Date class 349 customactions.Uninstall() availability flash player 6. Usage customactions.Uninstall(customactionsname) parameters customactionsname the name of the custom action definition to uninstall. Returns a boolean value of false if no custom actions are found with the name customactionsname ....

  • Page 350

    350 chapter 12: actionscript dictionary flash player 5 handles daylight saving time on the following operating systems as follows: • windows—the u.S. Rules for daylight saving time are always applied, which leads to incorrect transitions in europe and other areas that employ daylight saving time but...

  • Page 351

    Date class 351 constructor for the date class availability flash player 5. Usage new date() new date(year, month [, date [, hour [, minute [, second [, millisecond ]]]]]) parameters year a value of 0 to 99 indicates 1900 though 1999; otherwise all four digits of the year must be specified. Month an ...

  • Page 352

    352 chapter 12: actionscript dictionary date an integer from 1 to 31. This parameter is optional. Hour an integer from 0 (midnight) to 23 (11 p.M.). Minute an integer from 0 to 59. This parameter is optional. Second an integer from 0 to 59. This parameter is optional. Millisecond an integer from 0 t...

  • Page 353

    Date.Getfullyear() 353 date.Getday() availability flash player 5. Usage my_date.Getday() parameters none. Returns an integer. Description method; returns the day of the week (0 for sunday, 1 for monday, and so on) of the specified date object according to local time. Local time is determined by the ...

  • Page 354

    354 chapter 12: actionscript dictionary date.Gethours() availability flash player 5. Usage my_date.Gethours() parameters none. Returns an integer. Description method; returns the hour (an integer from 0 to 23) of the specified date object, according to local time. Local time is determined by the ope...

  • Page 355

    Date.Getseconds() 355 returns an integer. Description method; returns the minutes (an integer from 0 to 59) of the specified date object, according to local time. Local time is determined by the operating system on which flash player is running. Date.Getmonth() availability flash player 5. Usage my_...

  • Page 356

    356 chapter 12: actionscript dictionary date.Gettime() availability flash player 5. Usage my_date.Gettime() parameters none. Returns an integer. Description method; returns the number of milliseconds since midnight january 1, 1970, universal time, for the specified date object. Use this method to re...

  • Page 357

    Date.Getutcday() 357 date.Getutcdate() availability flash player 5. Usage my_date.Getutcdate() parameters none. Returns an integer. Description method; returns the day of the month (an integer from 1 to 31) in the specified date object, according to universal time. Date.Getutcday() availability flas...

  • Page 358

    358 chapter 12: actionscript dictionary date.Getutcfullyear() availability flash player 5. Usage my_date.Getutcfullyear() parameters none. Returns an integer. Description method; returns the four-digit year of the specified date object, according to universal time. Date.Getutchours() availability fl...

  • Page 359

    Date.Getutcminutes() 359 date.Getutcmilliseconds() availability flash player 5. Usage my_date.Getutcmilliseconds() parameters none. Returns an integer. Description method; returns the milliseconds of the specified date object, according to universal time. Date.Getutcminutes() availability flash play...

  • Page 360

    360 chapter 12: actionscript dictionary date.Getutcmonth() availability flash player 5. Usage my_date.Getutcmonth() parameters none. Returns an integer. Description method; returns the month (0 for january, 1 for february, and so on) of the specified date object, according to universal time. Date.Ge...

  • Page 361

    Date.Setfullyear() 361 description method; returns the year of the specified date object, according to local time. Local time is determined by the operating system on which flash player is running. The year is the full year minus 1900. For example, the year 2000 is represented as 100. See also date....

  • Page 362

    362 chapter 12: actionscript dictionary description method; sets the year of the specified date object, according to local time, and returns the new time in milliseconds. If the month and date parameters are specified, they are also set to local time. Local time is determined by the operating system...

  • Page 363

    Date.Setmonth() 363 date.Setminutes() availability flash player 5. Usage my_date.Setminutes(minute) parameters minute an integer from 0 to 59. Returns an integer. Description method; sets the minutes for a specified date object according to local time, and returns the new time in milliseconds. Local...

  • Page 364

    364 chapter 12: actionscript dictionary date.Setseconds() availability flash player 5. Usage my_date.Setseconds(second) parameters second an integer from 0 to 59. Returns an integer. Description method; sets the seconds for the specified date object in local time, and returns the new time in millise...

  • Page 365

    Date.Setutcfullyear() 365 date.Setutcdate() availability flash player 5. Usage my_date.Setutcdate(date) parameters date an integer from 1 to 31. Returns an integer. Description method; sets the date for the specified date object in universal time, and returns the new time in milliseconds. Calling th...

  • Page 366

    366 chapter 12: actionscript dictionary date.Setutchours() availability flash player 5. Usage my_date.Setutchours(hour [, minute [, second [, millisecond]]]) parameters hour an integer from 0 (midnight) to 23 (11 p.M.). Minute an integer from 0 to 59. This parameter is optional. Second an integer fr...

  • Page 367

    Date.Setutcmonth() 367 date.Setutcminutes() availability flash player 5. Usage my_date.Setutcminutes(minute [, second [, millisecond]]) parameters minute an integer from 0 to 59. Second an integer from 0 to 59. This parameter is optional. Millisecond an integer from 0 to 999. This parameter is optio...

  • Page 368

    368 chapter 12: actionscript dictionary date.Setutcseconds() availability flash player 5. Usage my_date.Setutcseconds(second [, millisecond])) parameters second an integer from 0 to 59. Millisecond an integer from 0 to 999. This parameter is optional. Returns an integer. Description method; sets the...

  • Page 369

    Date.Utc() 369 date.Tostring() availability flash player 5. Usage my_date.Tostring() parameters none. Returns a string. Description method; returns a string value for the specified date object in a readable format, and returns the new time in milliseconds. Example the following example returns the i...

  • Page 370

    370 chapter 12: actionscript dictionary description method; returns the number of milliseconds between midnight on january 1, 1970, universal time, and the time specified in the parameters. This is a static method that is invoked through the date object constructor, not through a specific date objec...

  • Page 371

    Delete 371 delete availability flash player 5. Usage delete reference parameters reference the name of the variable or object to eliminate. Returns a boolean value. Description operator; destroys the object or variable specified by the reference parameter, and returns true if the object was successf...

  • Page 372

    372 chapter 12: actionscript dictionary delete array[2]; trace(my_array.Length); usage 4: the following example illustrates the behavior of delete on object references. // create a new object, and assign the variable ref1 // to refer to the object ref1 = new object(); ref1.Name = "jody"; // copy the...

  • Page 373

    Dynamic 373 duplicatemovieclip() availability flash player 4. Usage duplicatemovieclip(target, newname, depth) parameters target the target path of the movie clip to duplicate. Newname a unique identifier for the duplicated movie clip. Depth a unique depth level for the duplicated movie clip. The de...

  • Page 374

    374 chapter 12: actionscript dictionary description keyword; specifies that objects based on the specified class can add and access dynamic properties at runtime. Type checking on dynamic classes is less strict than type-checking on nondynamic classes, because members accessed inside the class defin...

  • Page 375

    Else if 375 else availability flash player 4. Usage if (condition){ statement(s); } else (condition){ statement(s); } parameters condition an expression that evaluates to true or false . Statement(s) an alternative series of statements to run if the condition specified in the if statement is false ....

  • Page 376

    376 chapter 12: actionscript dictionary description statement; evaluates a condition and specifies the statements to run if the condition in the initial if statement returns false . If the else if condition returns true , the flash interpreter runs the statements that follow the condition inside cur...

  • Page 377

    Error class 377 see also #initclip eq (equal — string specific) availability flash player 4. This operator was deprecated in flash 5 in favor of the == (equality) operator. Usage expression1 eq expression2 parameters expression1, expression2 numbers, strings, or variables. Returns nothing. Descripti...

  • Page 378

    378 chapter 12: actionscript dictionary constructor for the error class availability flash player 7. Usage new error([message]) parameters message a string associated with the error object; this parameter is optional. Returns nothing. Description constructor; creates a new error object. If message i...

  • Page 379

    Escape 379 error.Name availability flash player 7. Usage myerror.Name description property; contains the name of the error object. By default, the value of this property is "error" . See also throw , try..Catch..Finally error.Tostring() availability flash player 7. Usage my_err.Tostring() returns a ...

  • Page 380

    380 chapter 12: actionscript dictionary example running the following code gives the result, hello%7b%5bworld%5d%7d . Escape("hello{[world]} " ); see also unescape eval() availability flash player 5 or later for full functionality. You can use the eval() function when exporting to flash player 4, bu...

  • Page 381

    Extends 381 example the following example uses eval() to determine the value of the expression "piece" + x . Because the result is a variable name, piece3 , eval() returns the value of the variable and assigns it to y : piece3 = "dangerous"; x = 3; y = eval("piece" + x); trace(y); // output: dangero...

  • Page 382

    382 chapter 12: actionscript dictionary example in class b as defined below, a call to class a’s constructor will automatically be inserted as the first statement of b’s constructor function, because a call does not already exist there. (that is, it is commented out in the example.) class b extends ...

  • Page 383

    For 383 for availability flash player 5. Usage for(init; condition; next) { statement(s); } parameters init an expression to evaluate before beginning the looping sequence, typically an assignment expression. A var statement is also permitted for this parameter. Condition an expression that evaluate...

  • Page 384

    384 chapter 12: actionscript dictionary the following is an example of using for to perform the same action repeatedly. In the following code, the for loop adds the numbers from 1 to 100: var sum = 0; for (var i=1; i sum = sum + i; } see also ++ (increment) , –– (decrement) , for..In , var for..In a...

  • Page 385

    Fscommand() 385 example the following is an example of using for..In to iterate over the properties of an object: myobject = { name:'tara', age:27, city:'san francisco' }; for (name in myobject) { trace ("myobject." + name + " = " + myobject[name]); } the output of this example is as follows: myobje...

  • Page 386

    386 chapter 12: actionscript dictionary usage 1: to send a message to flash player, you must use predefined commands and parameters. The following table shows the values you can specify for the command and parameters parameters of the fscommand action to control a swf file playing in flash player (i...

  • Page 387

    Fscommand() 387 example usage 1: in the following example, the fscommand action sets the flash player to scale the swf file to the full monitor screen size when the button is released. On(release){ fscommand("fullscreen", true); } usage 2: the following example uses the fscommand action applied to a...

  • Page 388

    388 chapter 12: actionscript dictionary function availability flash player 5. Usage function functionname ([parameter0, parameter1,...Parametern]){ statement(s) } function ([parameter0, parameter1,...Parametern]){ statement(s) } parameters functionname the name of the new function. Parameter an iden...

  • Page 389

    Function.Apply() 389 usage 2: the following function defines a circle object: function circle(radius) { this.Radius = radius; } the following statement defines an anonymous function that calculates the area of a circle and attaches it to the object circle as a method: circle.Prototype.Area = functio...

  • Page 390

    390 chapter 12: actionscript dictionary example the following function invocations are equivalent: math.Atan2(1, 0) math.Atan2.Apply(null, [1, 0]) you could construct a swf file that contains input entry fields that permit the user to enter the name of a function to invoke, and zero or more paramete...

  • Page 391

    Function.Prototype 391 in almost all cases, the function call operator ( () ) can be used instead of this method. The function call operator produces code that is concise and readable. This method is primarily useful when the this parameter of the function invocation needs to be explicitly controlle...

  • Page 392

    392 chapter 12: actionscript dictionary ge (greater than or equal to — string specific) availability flash player 4. This operator was deprecated in flash 5 in favor of the >= (greater than or equal to) operator. Usage expression1 ge expression2 parameters expression1 , expression2 numbers, strings,...

  • Page 393

    Gettimer 393 see also object.Addproperty() , set getproperty availability flash player 4. Usage getproperty(my_mc, property) parameters my_mc the instance name of a movie clip for which the property is being retrieved. Property a property of a movie clip. Returns the value of the specified property....

  • Page 394

    394 chapter 12: actionscript dictionary geturl() availability flash 2. The get and post options are only available to flash player 4 and later versions of the player. Usage geturl(url [, window [, "variables"]]) parameters url the url from which to obtain the document. Window an optional parameter s...

  • Page 395

    _global object 395 getversion availability flash player 5. Usage getversion() parameters none. Returns a string containing flash player version and platform information. Description function; returns a string containing flash player version and platform information. The getversion function only retu...

  • Page 396

    396 chapter 12: actionscript dictionary description identifier; creates global variables, objects, or classes. For example, you could create a library that is exposed as a global actionscript object, much like the math or date object. Unlike timeline- declared or locally declared variables and funct...

  • Page 397

    Gt (greater than — string specific) 397 gotoandstop() availability flash 2. Usage gotoandstop([scene,] frame) parameters scene an optional string specifying the name of the scene to which the playhead is sent. Frame a number representing the frame number, or a string representing the label of the fr...

  • Page 398

    398 chapter 12: actionscript dictionary _highquality availability flash player 4; deprecated in favor of _quality . Usage _highquality description deprecated property (global); specifies the level of anti-aliasing applied to the current swf file. Specify 2 (best quality) to apply high quality with b...

  • Page 399

    Ifframeloaded 399 the following example uses an if action to evaluate when a draggable object in the swf file is released by the user. If the object was released less than 300 milliseconds after dragging it, the condition evaluates to true and the statements inside the curly braces run. Those statem...

  • Page 400

    400 chapter 12: actionscript dictionary description deprecated action; checks whether the contents of a specific frame are available locally. Use ifframeloaded to start playing a simple animation while the rest of the swf file downloads to the local computer. The difference between using _framesload...

  • Page 401

    #include 401 description keyword; lets you access classes without specifying their fully qualified names. For example, if you want to use the class macr.Util.Users.Userclass.As in a script, you must either refer to it by its fully qualified name or import it; if you import it, you can then refer to ...

  • Page 402

    402 chapter 12: actionscript dictionary description compiler directive: includes the contents of the specified file, as if the commands in the file were part of the calling script itself. The #include directive is invoked at compile time. Therefore, if you make any changes to an external file, you m...

  • Page 403

    #initclip 403 infinity availability flash player 5. Usage infinity description constant; specifies the ieee-754 value representing positive infinity. The value of this constant is the same as number.Positive_infinity . -infinity availability flash player 5. Usage -infinity description constant; spec...

  • Page 404

    404 chapter 12: actionscript dictionary instanceof availability flash player 6. Usage object instanceof class parameters object an actionscript object. Class a reference to an actionscript constructor function, such as string or date. Returns if object is an instance of class , instanceof returns tr...

  • Page 405

    Interface 405 see also math.Floor() interface availability flash player 6. Usage interface interfacename {} interface interfacename [extends interfacename [, interfacename ...] {} note: to use this keyword, you must specify actionscript 2.0 and flash player 6 or later in the flash tab of your fla fi...

  • Page 406

    406 chapter 12: actionscript dictionary } // error: class must implement all interface methods // filename ib.As interface ib { function o():void; } class d implements ia, ib { function k():number {return 15;} function n(x:number):number {return x*x;} function o():void {trace("o");} } // external sc...

  • Page 407

    Isnan() 407 example the following are examples of return values for isfinite : isfinite(56) // returns true isfinite(number.Positive_infinity) // returns false isnan() availability flash player 5. Usage isnan(expression) parameters expression a boolean, variable, or other expression to be evaluated....

  • Page 408

    408 chapter 12: actionscript dictionary key class availability flash player 6. Description the key class is a top-level class whose methods and properties you can use without using a constructor. Use the methods of the key class to build an interface that can be controlled by a user with a standard ...

  • Page 409

    Key.Addlistener() 409 listener summary for the key class key.Addlistener() availability flash player 6. Usage key.Addlistener (newlistener) parameters newlistener an object with methods onkeydown and onkeyup . Returns nothing. Description method; registers an object to receive onkeydown and onkeyup ...

  • Page 410

    410 chapter 12: actionscript dictionary the following example assigns the keyboard shortcut control+7 to a button with an instance name of mybutton, and makes information about the shortcut available to screen readers (see _accprops ). In this example, when you press control+7 the myonpress function...

  • Page 411

    Key.End 411 key.Control availability flash player 5. Usage key.Control description property; constant associated with the key code value for the control key (17). Key.Deletekey availability flash player 5. Usage key.Deletekey description property; constant associated with the key code value for the ...

  • Page 412

    412 chapter 12: actionscript dictionary key.Enter availability flash player 5. Usage key.Enter description property; constant associated with the key code value for the enter key (13). Key.Escape availability flash player 5. Usage key.Escape description property; constant associated with the key cod...

  • Page 413

    Key.Insert 413 key.Getcode() availability flash player 5. Usage key.Getcode(); parameters none. Returns an integer that represents the key code of the last key pressed. Description method; returns the key code value of the last key pressed. To match the returned key code value with the key on a stan...

  • Page 414

    414 chapter 12: actionscript dictionary key.Isdown() availability flash player 5. Usage key.Isdown(keycode) parameters keycode the key code value assigned to a specific key, or a key class property associated with a specific key. To match the returned key code value with the key on a standard keyboa...

  • Page 415

    Key.Onkeyup 415 key.Left availability flash player 5. Usage key.Left description property; constant associated with the key code value for the left arrow key (37). Key.Onkeydown availability flash player 6. Usage somelistener.Onkeydown description listener; notified when a key is pressed. To use onk...

  • Page 416

    416 chapter 12: actionscript dictionary listeners enable different pieces of code to cooperate because multiple listeners can receive notification about a single event. See also key.Addlistener() key.Pgdn availability flash player 5. Usage key.Pgdn description property; constant associated with the ...

  • Page 417

    Key.Tab 417 key.Right availability flash player 5. Usage key.Right description property; constant associated with the key code value for the right arrow key (39). Key.Shift availability flash player 5. Usage key.Shift description property; constant associated with the key code value for the shift ke...

  • Page 418

    418 chapter 12: actionscript dictionary key.Up availability flash player 5. Usage key.Up description property; constant associated with the key code value for the up arrow key (38). Le (less than or equal to — string specific) availability flash player 4. This operator was deprecated in flash 5 in f...

  • Page 419

    _level 419 returns the length of the specified string or variable name. Description string function; returns the length of the specified string or variable name. Example the following example returns the value of the string "hello" . Length("hello"); the result is 5. See also " " (string delimiter) ...

  • Page 420

    420 chapter 12: actionscript dictionary loadmovie() availability flash player 3. Usage loadmovie("url",target [, method]) parameters url the absolute or relative url of the swf file or jpeg file to be loaded. A relative path must be relative to the swf file at level 0. Absolute urls must include the...

  • Page 421

    Loadmovienum() 421 example the following loadmovie() statement is attached to a navigation button labeled products. There is an invisible movie clip on the stage with the instance name dropzone . The loadmovie() function uses this movie clip as the target parameter to load the products in the swf fi...

  • Page 422

    422 chapter 12: actionscript dictionary if you want to specify a target instead of a level, use loadmovie() instead of loadmovienum() . Flash player has a stacking order of levels starting with level 0. These levels are like layers of acetate; they are transparent except for the objects on each leve...

  • Page 423

    Loadvariablesnum() 423 description function; reads data from an external file, such as a text file or text generated by a cgi script, active server pages (asp), or php, or perl script, and sets the values for variables in a target movie clip. This action can also be used to update variables in the a...

  • Page 424

    424 chapter 12: actionscript dictionary level an integer specifying the level in flash player to receive the variables. Variables an optional parameter specifying an http method for sending variables. The parameter must be the string get or post . If there are no variables to be sent, omit this para...

  • Page 425

    Loadvars class 425 loadvars class availability flash player 6. Description the loadvars class is an alternative to the loadvariables() function for transferring variables between a flash application and a server. You can use the loadvars class to obtain verification of successful data loading, progr...

  • Page 426

    426 chapter 12: actionscript dictionary constructor for the loadvars class availability flash player 6. Usage new loadvars() parameters none. Returns nothing. Description constructor; creates a loadvars object. You can then use the methods of that loadvars object to send and load data. Example the f...

  • Page 427

    Loadvars.Contenttype 427 the following standard http headers cannot be added or changed with this method: accept- ranges , age , allow , allowed , connection , content-length , content-location , content- range , etag , host , last-modified , locations , max-forwards , proxy-authenticate , proxy- au...

  • Page 428

    428 chapter 12: actionscript dictionary loadvars.Getbytesloaded() availability flash player 6. Usage my_lv.Getbytesloaded() parameters none. Returns an integer. Description method; returns the number of bytes downloaded by loadvars.Load() or loadvars.Sendandload() . This method returns undefined if ...

  • Page 429

    Loadvars.Load() 429 loadvars.Load() availability flash player 6; behavior changed in flash player 7. Usage my_lv.Load(url) parameters url the url from which to download the variables. If the swf file issuing this call is running in a web browser, url must be in the same domain as the swf file; for d...

  • Page 430

    430 chapter 12: actionscript dictionary loadvars.Loaded availability flash player 6. Usage my_lv.Loaded description property; undefined by default. When a loadvars.Load() or loadvars.Sendandload() operation is started, the loaded property is set to false ; when the operation completes, the loaded pr...

  • Page 431

    Loadvars.Onload 431 loadvars.Onload availability flash player 6. Usage my_lv.Onload = function(success) { // your statements here } parameters success the parameter indicates whether the load operation ended in success ( true ) or failure ( false ). Returns a boolean value. Description event handler...

  • Page 432

    432 chapter 12: actionscript dictionary loadvars.Send() availability flash player 6. Usage my_lv.Send(url [,target , method]) parameters url the url to upload variables to. Target the browser frame window in which any response will be displayed. Method the get or post method of the http protocol. Re...

  • Page 433

    Loadvars.Tostring() 433 description method; posts variables in the my_lv object to the specified url. The server response is downloaded, parsed as variable data, and the resulting variables are placed in the targetobject object. Variables are posted in the same manner as loadvars.Send() . Variables ...

  • Page 434

    434 chapter 12: actionscript dictionary localconnection class availability flash player 6. Description the localconnection class lets you develop swf files that can send instructions to each other without the use of fscommand() or javascript. Localconnection objects can communicate only between swf ...

  • Page 435

    Localconnection class 435 event handler summary for the localconnection class constructor for the localconnection class availability flash player 6. Usage new localconnection() parameters none. Returns nothing. Description constructor; creates a localconnection object. Example the following example ...

  • Page 436

    436 chapter 12: actionscript dictionary localconnection.Allowdomain availability flash player 6; behavior changed in flash player 7. Usage receiving_lc.Allowdomain = function([sendingdomain]) { // your statements here return true or false } parameters sendingdomain an optional parameter specifying t...

  • Page 437

    Localconnection.Allowinsecuredomain 437 example the following example shows how a localconnection object in a receiving swf file can permit swf files from any domain to invoke its methods. Compare this to the example in localconnection.Connect() , in which only swf files from the same domain can inv...

  • Page 438

    438 chapter 12: actionscript dictionary description event handler; invoked whenever receiving_lc , which is in a swf file hosted at a domain using a secure protocol (https), receives a request to invoke a method from a sending localconnection object that is in a swf file that is hosted at a nonsecur...

  • Page 439

    Localconnection.Connect() 439 localconnection.Connect() availability flash player 6. Usage receiving_lc.Connect(connectionname) parameters connectionname a string that corresponds to the connection name specified in the localconnection.Send() command that wants to communicate with receiving_lc . Ret...

  • Page 440

    440 chapter 12: actionscript dictionary example the following example shows how a swf file in a particular domain can invoke a method named trace in a receiving swf file in the same domain. The receiving swf file functions as a trace window for the sending swf file; it contains two methods that othe...

  • Page 441

    Localconnection.Domain() 441 localconnection.Domain() availability flash player 6; behavior changed in flash player 7. Usage my_lc.Domain() parameters none. Returns a string representing the domain of the location of the current swf file; for details, see “description,” below. Description method; re...

  • Page 442

    442 chapter 12: actionscript dictionary line numbers are included for reference purposes. The sequence of events is as follows: • the receiving swf file prepares to receive commands on a connection named "sum" (line 11). The flash player resolves the name of this connection to "mydomain.Com:sum" (se...

  • Page 443

    Localconnection.Onstatus 443 localconnection.Onstatus availability flash player 6. Usage sending_lc.Onstatus = function(infoobject) { // your statements here } parameters infoobject a parameter defined according to the status message. For details about this parameter, see “description,” below. Retur...

  • Page 444

    444 chapter 12: actionscript dictionary see also localconnection.Send() , system.Onstatus localconnection.Send() availability flash player 6. Usage sending_lc.Send (connectionname, method [, p1,...,pn]) parameters connectionname a string that corresponds to the connection name specified in the local...

  • Page 445

    Math class 445 • include the superdomain in connectionname in the sending localconnection object—for example, mydomain.Com:myconnectionname . In the receiving object, use localconnection.Allowdomain to specify that connections from the specified superdomain will be accepted (in this case, mydomain.C...

  • Page 446

    446 chapter 12: actionscript dictionary use the methods and properties of this class to access and manipulate mathematical constants and functions. All of the properties and methods of the math class are static, and must be called using the syntax math.Method(parameter) or math.Constant . In actions...

  • Page 447

    Math.Acos() 447 property summary for the math class all of the properties for the math class are constants. Math.Abs() availability flash player 5. In flash player 4, the methods and properties of the math class are emulated using approximations and may not be as accurate as the non-emulated math fu...

  • Page 448

    448 chapter 12: actionscript dictionary returns nothing. Description method; computes and returns the arc cosine of the number specified in the parameter x , in radians. Math.Asin() availability flash player 5. In flash player 4, the methods and properties of the math class are emulated using approx...

  • Page 449

    Math.Ceil() 449 math.Atan2() availability flash player 5. In flash player 4, the methods and 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.Atan2(y, x) parameters x a number specifyi...

  • Page 450

    450 chapter 12: actionscript dictionary math.Cos() availability flash player 5. In flash player 4, the methods and 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.Cos(x) parameters x ...

  • Page 451

    Math.Floor() 451 math.Exp() availability flash player 5. In flash player 4, the methods and 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.Exp(x) parameters x the exponent; a number ...

  • Page 452

    452 chapter 12: actionscript dictionary math.Log() availability flash player 5. In flash player 4, the methods and 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.Log(x) parameters x ...

  • Page 453

    Math.Log2e 453 math.Ln10 availability flash player 5. In flash player 4, the methods and 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.Ln10 parameters none. Returns nothing. Descrip...

  • Page 454

    454 chapter 12: actionscript dictionary math.Log10e availability flash player 5. In flash player 4, the methods and 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.Log10e parameters n...

  • Page 455

    Math.Pi 455 math.Min() availability flash player 5. In flash player 4, the methods and 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.Min(x , y) parameters x a number or expression. ...

  • Page 456

    456 chapter 12: actionscript dictionary math.Pow() availability flash player 5. In flash player 4, the methods and 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.Pow(x , y) parameter...

  • Page 457

    Math.Sqrt() 457 math.Round() availability flash player 5. In flash player 4, the methods and 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.Round(x) parameters x a number. Returns a ...

  • Page 458

    458 chapter 12: actionscript dictionary parameters x a number or expression greater than or equal to 0. Returns a number. Description method; computes and returns the square root of the specified number. Math.Sqrt1_2 availability flash player 5. In flash player 4, the methods and properties of the m...

  • Page 459

    Mbchr 459 math.Tan() availability flash player 5. In flash player 4, the methods and 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.Tan(x) parameters x an angle measured in radians. ...

  • Page 460

    460 chapter 12: actionscript dictionary returns a string. Description string function; converts an ascii code number to a multibyte character. See also string.Fromcharcode() mblength availability flash player 4. This function has been deprecated in favor of the string class . Usage mblength(string) ...

  • Page 461

    Microphone class 461 mbsubstring availability flash player 4. This function was deprecated in flash 5 in favor of string.Substr() . Usage mbsubstring(value, index, count) parameters value the multibyte string from which to extract a new multibyte string. Index the number of the first character to ex...

  • Page 462

    462 chapter 12: actionscript dictionary property summary for the microphone class event handler summary for the microphone class constructor for the microphone class see microphone.Get() . Microphone.Setsilencelevel() specifies the amount of sound required to activate the microphone. Microphone.Setu...

  • Page 463

    Microphone.Gain 463 microphone.Activitylevel availability flash player 6. Usage activemicrophone.Activitylevel description read-only property; a numeric value that specifies the amount of sound the microphone is detecting. Values range from 0 (no sound is being detected) to 100 (very loud sound is b...

  • Page 464

    464 chapter 12: actionscript dictionary top = this._y; bottom = top; } on (press) { startdrag(this, false, left, top, right, bottom); this._xscale = 100; this._yscale = 100; } on (release, releaseoutside) { stopdrag(); g = (this._x-50)*2; _root.Mymic.Setgain(g); _root.Txt_micgain = g; this._xscale =...

  • Page 465

    Microphone.Get() 465 in general, you shouldn’t pass a value for index ; simply use the microphone.Get() method to return a reference to the default microphone. By means of the microphone settings panel (discussed later in this section), the user can specify the default microphone flash should use. I...

  • Page 466

    466 chapter 12: actionscript dictionary example the following example lets the user specify the default microphone, then captures audio and plays it back locally. To avoid feedback, you may want to test this code while wearing headphones. System.Showsettings(2); mymic = microphone.Get(); _root.Attac...

  • Page 467

    Microphone.Names 467 // publish the microphone data by calling // the root function publive(). _root.Publive(); // play what is being published by calling // the root function playlive(). _root.Playlive(); } } see also microphone.Get() , microphone.Onstatus microphone.Name availability flash player ...

  • Page 468

    468 chapter 12: actionscript dictionary calling microphone.Names requires an extensive examination of the hardware, and it may take several seconds to build the array. In most cases, you can just use the default microphone. Example the following code returns information on the array of audio devices...

  • Page 469

    Microphone.Onstatus 469 trace(mode); }; see also microphone.Onactivity , microphone.Setsilencelevel() microphone.Onstatus availability flash player 6. Usage activemicrophone.Onstatus = function(infoobject) { // your statements here } parameters infoobject a parameter defined according to the status ...

  • Page 470

    470 chapter 12: actionscript dictionary microphone.Rate availability flash player 6. Usage activemicrophone.Rate description read-only property; the rate at which the microphone is capturing sound, in khz. The default value is 8 khz if your sound capture device supports this value. Otherwise, the de...

  • Page 471

    Microphone.Setrate() 471 var mymic = microphone.Get(); if (mymic.Gain > 55){ mymic.Setgain(55); } see also microphone.Gain , microphone.Setuseechosuppression() microphone.Setrate() availability flash player 6. Usage activemicrophone.Setrate(khz) parameters khz the rate at which the microphone should...

  • Page 472

    472 chapter 12: actionscript dictionary microphone.Setsilencelevel() availability flash player 6. Usage activemicrophone.Setsilencelevel(level [, timeout]) parameters level an integer that specifies the amount of sound required to activate the microphone and invoke microphone.Onactivity(true) . Acce...

  • Page 473

    Microphone.Setuseechosuppression() 473 example the following example changes the silence level based on the user’s input. The button has the following code attached: on (press) { this.Makesilencelevel(this.Silencelevel); } the makesilencelevel() function called by the button continues: function make...

  • Page 474

    474 chapter 12: actionscript dictionary example the following example turns on echo suppression. My_mic.Setuseechosuppression(true); see also microphone.Setgain() , microphone.Useechosuppression() microphone.Silencelevel() availability flash player 6. Usage activemicrophone.Silencelevel description ...

  • Page 475

    Mmexecute() 475 microphone.Useechosuppression() availability flash player 6. Usage activemicrophone.Useechosuppression description read-only property; a boolean value of true if echo suppression is enabled, false otherwise. The default value is false unless the user has selected reduce echo in the f...

  • Page 476

    476 chapter 12: actionscript dictionary in general, a user runs a jsapi script by selecting commands > run command. However, you can use this function in an actionscript script to call a jsapi command directly. If you use mmexecute() in a script on frame 1 of your file, the command executes when the...

  • Page 477

    Mouse.Hide() 477 mouse.Addlistener() availability flash player 6. Usage mouse.Addlistener (newlistener) parameters newlistener an object. Returns nothing. Description method; registers an object to receive notifications of the onmousedown , onmousemove , and onmouseup listeners. The newlistener para...

  • Page 478

    478 chapter 12: actionscript dictionary example the following code, attached to a movie clip on the main timeline, hides the standard pointer, and sets the x and y positions of the custompointer_mc movie clip instance to the x and y mouse positions in the main timeline. Onclipevent(enterframe){ mous...

  • Page 479

    Mouse.Onmouseup 479 mouse.Onmousemove availability flash player 6. Usage somelistener.Onmousemove parameters none. Returns nothing. Description listener; notified when the mouse moves. To use the onmousemove listener, you must create a listener object. You can then define a function for onmousemove ...

  • Page 480

    480 chapter 12: actionscript dictionary listeners enable different pieces of code to cooperate because multiple listeners can receive notification about a single event. See also mouse.Addlistener() mouse.Onmousewheel availability flash player 7 (windows only). Usage somelistener.Onmousewheel = funct...

  • Page 481

    Mouse.Show() 481 mouse.Removelistener() availability flash player 6. Usage mouse.Removelistener (listener) parameters listener an object. Returns if the listener object was successfully removed, the method returns true ; if the listener was not successfully removed (for example, if the listener was ...

  • Page 482

    482 chapter 12: actionscript dictionary movieclip class availability flash player 3. Description the methods for the movieclip class provide the same functionality as actions that target movie clips. There are also additional methods that do not have equivalent actions in the actions toolbox in the ...

  • Page 483

    Movieclip class 483 movieclip.Gotoandplay() sends the playhead to a specific frame in the movie clip and plays the swf file. Movieclip.Gotoandstop() sends the playhead to a specific frame in the movie clip and stops the swf file. Movieclip.Hittest() returns true if bounding box of the specified movi...

  • Page 484

    484 chapter 12: actionscript dictionary drawing method summary for the movieclip class property summary for the movieclip class method description movieclip.Beginfill() begins drawing a fill on the stage. Movieclip.Begingradientfill() begins drawing a gradient fill on the stage. Movieclip.Clear() re...

  • Page 485

    Movieclip class 485 movieclip.Tabenabled indicates whether a movie clip is included in tab ordering. Movieclip.Tabindex indicates the tab order of an object. Movieclip._target the target path of a movie clip instance. Movieclip._totalframes the total number of frames in a movie clip instance. Moviec...

  • Page 486

    486 chapter 12: actionscript dictionary event handler summary for the movieclip class event handler description movieclip.Ondata invoked when all the data is loaded into a movie clip. Movieclip.Ondragout invoked while the pointer is outside the button; the mouse button is pressed inside, and then ro...

  • Page 487

    Movieclip.Attachaudio() 487 movieclip._alpha availability flash player 4. Usage my_mc._alpha description property; the alpha transparency value of the movie clip specified by my_mc . Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 100. Objects in a movie clip with ...

  • Page 488

    488 chapter 12: actionscript dictionary example the following code attaches a microphone to a movie clip. My_mic = microphone.Get(); this.Attachaudio(my_mic); the following example shows how you can use a sound object to control the sound associated with an flv file. // clip is the instance name of ...

  • Page 489

    Movieclip.Beginfill() 489 example the following example attaches the symbol with the linkage identifier “circle” to the movie clip instance, which is on the stage in the swf file. On (release) { thing.Attachmovie( "circle", "circle1", 2 ); } see also movieclip.Removemovieclip() , movieclip.Unloadmov...

  • Page 490

    490 chapter 12: actionscript dictionary movieclip.Begingradientfill() availability flash player 6. Usage my_mc.Begingradientfill(filltype, colors, alphas, ratios, matrix) parameter filltype either the string "linear" or the string "radial" . Colors an array of rgb hex color values to be used in the ...

  • Page 491

    Movieclip.Begingradientfill() 491 if a matrixtype property does not exist then the remaining parameters are all required; the function fails if any of them are missing. This matrix scales, translates, rotates, and skews the unit gradient, which is defined at (-1,-1) and (1,1). • matrixtype , x , y ,...

  • Page 492

    492 chapter 12: actionscript dictionary returns nothing. Description method; indicates the beginning of a new drawing path. If the first parameter is undefined, or if no parameters are passed, the path has no fill. If an open path exists (that is if the current drawing position does not equal the pr...

  • Page 493

    Movieclip.Clear() 493 see also movieclip.Beginfill() , movieclip.Endfill() , movieclip.Linestyle() , movieclip.Lineto() , movieclip.Moveto() movieclip.Clear() availability flash player 6. Usage my_mc.Clear() parameters none. Returns nothing. Description method; removes all the graphics created durin...

  • Page 494

    494 chapter 12: actionscript dictionary movieclip.Createemptymovieclip() availability flash player 6. Usage my_mc.Createemptymovieclip(instancename, depth) parameters instancename a string that identifies the instance name of the new movie clip. Depth an integer that specifies the depth of the new m...

  • Page 495

    Movieclip.Createtextfield() 495 description method; creates a new, empty text field as a child of the movie clip specified by my_mc . You can use createtextfield() to create text fields while a swf file plays. The text field is positioned at ( x , y ) with dimensions width by height . The x and y pa...

  • Page 496

    496 chapter 12: actionscript dictionary movieclip._currentframe availability flash player 4. Usage my_mc._currentframe description property (read-only); returns the number of the frame in which the playhead is located in the timeline specified by my_mc . Example the following example uses the _curre...

  • Page 497

    Movieclip._droptarget 497 example the following example draws a circle with a hairline point, solid blue line, and a solid red fill. _root.Createemptymovieclip( "circle", 1 ); with ( _root.Circle ) { linestyle( 0, 0x0000ff, 100 ); beginfill( 0xff0000 ); moveto( 500, 500 ); curveto( 600, 500, 600, 40...

  • Page 498

    498 chapter 12: actionscript dictionary see also startdrag() movieclip.Duplicatemovieclip() availability flash player 5. Usage my_mc.Duplicatemovieclip(newname, depth [,initobject]) parameters newname a unique identifier for the duplicate movie clip. Depth a unique number specifying the depth at whi...

  • Page 499

    Movieclip.Endfill() 499 movieclip.Enabled availability flash player 6. Usage my_mc.Enabled description property; a boolean value that indicates whether a button movie clip is enabled. The default value of enabled is true . If enabled is set to false , the button movie clip’s callback methods and on ...

  • Page 500

    500 chapter 12: actionscript dictionary movieclip.Focusenabled availability flash player 6. Usage my_mc.Focusenabled description property; if the value is undefined or false , a movie clip cannot receive input focus unless it is a button movie clip. If the focusenabled property value is true , a mov...

  • Page 501

    Movieclip.Getbounds() 501 example the following example uses the _framesloaded property to start a swf file when all the frames are loaded. If all the frames aren’t loaded, the _xscale property of the movie clip instance loader is increased proportionally to create a progress bar. If (_framesloaded ...

  • Page 502

    502 chapter 12: actionscript dictionary movieclip.Getbytesloaded() availability flash player 5. Usage my_mc.Getbytesloaded() parameters none. Returns an integer indicating the number of bytes loaded. Description method; returns the number of bytes that have already loaded (streamed) for the movie cl...

  • Page 503

    Movieclip.Getinstanceatdepth() 503 movieclip.Getdepth() availability flash player 6. Usage my_mc.Getdepth() parameters none. Returns an integer. Description method; returns the depth of a movie clip instance. For more information, see “managing movie clip depths” on page 129 . See also movieclip.Get...

  • Page 504

    504 chapter 12: actionscript dictionary movieclip.Getnexthighestdepth() availability flash player 7. Usage my_mc.Getnexthighestdepth() parameters none. Returns an integer that reflects the next available depth index that would render above all other objects on the same level and layer within my_mc ....

  • Page 505

    Movieclip.Gettextsnapshot() 505 movieclip.Gettextsnapshot() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_mc.Gettextsnapshot(); parameters none. Returns a textsnapshot object that contains the static tex...

  • Page 506

    506 chapter 12: actionscript dictionary movieclip.Geturl() availability flash player 5. Usage my_mc.Geturl(url [,window, variables]) parameters url the url from which to obtain the document. Window an optional parameter specifying the name, frame, or expression that specifies the window or html fram...

  • Page 507

    Movieclip.Gotoandstop() 507 description method; converts the point object from stage (global) coordinates to the movie clip’s (local) coordinates. Example the following example converts the global x and y coordinates of the point object to the local coordinates of the movie clip. Onclipevent(mousemo...

  • Page 508

    508 chapter 12: actionscript dictionary returns nothing. Description method; brings the playhead to the specified frame of this movie clip and stops it there. See also gotoandstop() movieclip._height availability flash player 4. Usage my_mc._height description property; the height of the movie clip,...

  • Page 509

    Movieclip.Hittest() 509 movieclip.Hitarea availability flash player 6. Usage my_mc.Hitarea returns a reference to a movie clip. Description property; designates another movie clip to serve as the hit area for a button movie clip. If the hitarea property does not exist or is null or undefined , the b...

  • Page 510

    510 chapter 12: actionscript dictionary usage 1: compares the x and y coordinates to the shape or bounding box of the specified instance, according to the shapeflag setting. If shapeflag is set to true , only the area actually occupied by the instance on the stage is evaluated, and if x and y overla...

  • Page 511

    Movieclip.Lineto() 511 description method; specifies a line style that flash uses for subsequent calls to lineto() and curveto() until you call linestyle() with different parameters. You can call linestyle() in the middle of drawing a path to specify different styles for different line segments with...

  • Page 512

    512 chapter 12: actionscript dictionary example the following example draws a triangle with no lines and a partially transparent blue fill. _root.Createemptymovieclip ("triangle", 1); with (_root.Triangle){ beginfill (0x0000ff, 50); linestyle (5, 0xff00ff, 100); moveto (200, 200); lineto (300, 300);...

  • Page 513

    Movieclip.Loadvariables() 513 use the unloadmovie() method to remove swf files or images loaded with the loadmovie() method. Use the loadvariables() method to keep the active swf file, and update the variables with new values. See also loadmovie() , loadmovienum() , movieclip.Loadvariables() , movie...

  • Page 514

    514 chapter 12: actionscript dictionary see also loadmovie() , loadvariables() , loadvariablesnum() , movieclip.Unloadmovie() movieclip.Localtoglobal() availability flash player 5. Usage my_mc.Localtoglobal(point) parameters point the name or identifier of an object created with the object class , s...

  • Page 515

    Movieclip._lockroot 515 movieclip._lockroot availability flash player 7. Usage my_mc._lockroot description property; specifies what _root refers to when a swf file is loaded into a movie clip. The _lockroot property is undefined by default. You can set this property within the swf file that is being...

  • Page 516

    516 chapter 12: actionscript dictionary movieclip.Menu availability flash player 7. Usage my_mc.Menu = contextmenu parameters contextmenu a contextmenu object. Description property; associates the specified contextmenu object with the movie clip my_mc . The contextmenu class lets you modify the cont...

  • Page 517

    Movieclip.Nextframe() 517 description method; moves the current drawing position to ( x , y ). If any of the parameters are missing, this method fails and the current drawing position is not changed. Example this example draws a triangle with 5-point, solid magenta lines and no fill. The first line ...

  • Page 518

    518 chapter 12: actionscript dictionary movieclip.Ondata availability flash player 6. Usage my_mc.Ondata = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a movie clip receives data from a loadvariables() or loadmovie() call. You must ...

  • Page 519

    Movieclip.Ondragover 519 see also onclipevent() movieclip.Ondragout availability flash player 6. Usage my_mc.Ondragout = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse button is pressed and the pointer rolls outside the obje...

  • Page 520

    520 chapter 12: actionscript dictionary description event handler; invoked when the pointer is dragged outside and then over the movie clip. You must define a function that executes when the event handler is invoked. Example the following example defines a function for the ondragover method that sen...

  • Page 521

    Movieclip.Onkeydown 521 movieclip.Onkeydown availability flash player 6. Usage my_mc.Onkeydown = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a movie clip has input focus and a key is pressed. The onkeydown event handler is invoked ...

  • Page 522

    522 chapter 12: actionscript dictionary movieclip.Onkeyup availability flash player 6. Usage my_mc.Onkeyup = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when a key is released. The onkeyup event handler is invoked with no parameters. Yo...

  • Page 523

    Movieclip.Onload 523 movieclip.Onkillfocus availability flash player 6. Usage my_mc.Onkillfocus = function (newfocus) { // your statements here } parameters newfocus the object that is receiving the keyboard focus. Returns nothing. Description event handler; invoked when a movie clip loses keyboard ...

  • Page 524

    524 chapter 12: actionscript dictionary example the following example illustrates the correct use of movieclip.Onload() and onclipevent(load) . // symbol_mc is a movie clip symbol in the library. // it is linked to the movieclip class. // the following function is triggered for each instance of symb...

  • Page 525

    Movieclip.Onmousemove 525 example the following example defines a function for the onmousedown method that sends a trace() action to the output panel. My_mc.Onmousedown = function () { trace ("onmousedown called"); } movieclip.Onmousemove availability flash player 6. Usage my_mc.Onmousemove = functi...

  • Page 526

    526 chapter 12: actionscript dictionary movieclip.Onmouseup availability flash player 6. Usage my_mc.Onmouseup = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the mouse button is released. You must define a function that executes whe...

  • Page 527

    Movieclip.Onreleaseoutside 527 example the following example defines a function for the onpress method that sends a trace() action to the output panel. My_mc.Onpress = function () { trace ("onpress called"); }; movieclip.Onrelease availability flash player 6. Usage my_mc.Onrelease = function() { // ...

  • Page 528

    528 chapter 12: actionscript dictionary description event handler; invoked when the mouse is released while the pointer is outside the movie clip after the mouse button is pressed inside the movie clip. You must define a function that executes when the event handler is invoked. Example the following...

  • Page 529

    Movieclip.Onsetfocus 529 movieclip.Onrollover availability flash player 6. Usage my_mc.Onrollover = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked when the pointer moves over a movie clip area. You must define a function that executes when...

  • Page 530

    530 chapter 12: actionscript dictionary movieclip.Onunload availability flash player 6. Usage my_mc.Onunload = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked in the first frame after the movie clip is removed from the timeline. Flash proce...

  • Page 531

    Movieclip.Prevframe() 531 movieclip.Play() availability flash player 5. Usage my_mc.Play() parameters none. 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...

  • Page 532

    532 chapter 12: actionscript dictionary movieclip.Removemovieclip() availability flash player 5. Usage my_mc.Removemovieclip() parameters none. Returns nothing. Description method; removes a movie clip instance created with duplicatemovieclip() , movieclip.Duplicatemovieclip() , or movieclip.Attachm...

  • Page 533

    Movieclip._soundbuftime 533 movieclip.Setmask() availability flash player 6. Usage my_mc.Setmask(mask_mc) parameters my_mc the instance name of a movie clip to be masked. Mask_mc the instance name of a movie clip to be a mask. Returns nothing. Description method; makes the movie clip in the paramete...

  • Page 534

    534 chapter 12: actionscript dictionary movieclip.Startdrag() availability flash player 5. Usage my_mc.Startdrag([lock, [left, top, right, bottom]]) parameters lock a boolean value specifying whether the draggable movie clip is locked to the center of the mouse position ( true ), or locked to the po...

  • Page 535

    Movieclip.Swapdepths() 535 movieclip.Stopdrag() availability flash player 5. Usage my_mc.Stopdrag() parameters none. Returns nothing. Description method; ends a movieclip.Startdrag() method. A movie clip that was made draggable with that method remains draggable until a stopdrag() method is added, o...

  • Page 536

    536 chapter 12: actionscript dictionary see also _level , movieclip.Getdepth() , movieclip.Getinstanceatdepth() , movieclip.Getnexthighestdepth() movieclip.Tabchildren availability flash player 6. Usage my_mc.Tabchildren description property; undefined by default. If tabchildren is undefined or true...

  • Page 537

    Movieclip._target 537 see also button.Tabenabled , movieclip.Tabchildren , movieclip.Tabindex , textfield.Tabenabled movieclip.Tabindex availability flash player 6. Usage my_mc.Tabindex description property; lets you customize the tab ordering of objects in a movie. The tabindex property is undefine...

  • Page 538

    538 chapter 12: actionscript dictionary movieclip._totalframes availability flash player 4. Usage my_mc._totalframes description property (read-only); returns the total number of frames in the movie clip instance specified in the movieclip parameter. Movieclip.Trackasmenu availability flash player 6...

  • Page 539

    Movieclip.Usehandcursor 539 description method; removes the contents of a movie clip instance. The instance properties and clip handlers remain. To remove the instance, including its properties and clip handlers, use movieclip.Removemovieclip() . See also movieclip.Attachmovie() , movieclip.Loadmovi...

  • Page 540

    540 chapter 12: actionscript dictionary movieclip._visible availability flash player 4. Usage my_mc._visible description property; a boolean value that indicates whether the movie clip specified by my_mc is visible. Movie clips that are not visible ( _visible property set to false ) are disabled. Fo...

  • Page 541

    Movieclip._xmouse 541 movieclip._x availability flash player 3. Usage my_mc._x description property; an integer that sets the x coordinate of a movie clip relative to the local coordinates of the parent movie clip. If a movie clip is in the main timeline, then its coordinate system refers to the upp...

  • Page 542

    542 chapter 12: actionscript dictionary movieclip._xscale availability flash player 4. Usage my_mc._xscale description property; determines the horizontal scale ( percentage ) of the movie clip as applied from the registration point of the movie clip. The default registration point is (0,0). Scaling...

  • Page 543

    Movieclip._yscale 543 movieclip._ymouse availability flash player 5. Usage my_mc._ymouse description property (read-only); indicates the y coordinate of the mouse position. See also mouse class , movieclip._xmouse movieclip._yscale availability flash player 4. Usage my_mc._yscale description propert...

  • Page 544

    544 chapter 12: actionscript dictionary moviecliploader class availability flash player 7. Description this class lets you implement listener callbacks that provide status information while swf or jpeg files are being loaded (downloaded) into movie clips. To use moviecliploader features, use moviecl...

  • Page 545

    Moviecliploader class 545 listener summary for the moviecliploader class constructor for the moviecliploader class availability flash player 7. Usage new moviecliploader() parameters none. Returns nothing. Description constructor; creates a moviecliploader object that you can use to implement a numb...

  • Page 546

    546 chapter 12: actionscript dictionary moviecliploader.Addlistener() availability flash player 7. Usage my_mcl.Addlistener(listenerobject) parameters listenerobject an object that listens for a callback notification from the moviecliploader event handlers. Returns nothing. Description method; regis...

  • Page 547

    Moviecliploader.Loadclip() 547 example see moviecliploader.Loadclip() . See also moviecliploader.Onloadprogress() moviecliploader.Loadclip() availability flash player 7. Usage my_mcl.Loadmovie("url", target ) parameters url the absolute or relative url of the swf file or jpeg file to be loaded. A re...

  • Page 548

    548 chapter 12: actionscript dictionary example the following example illustrates the use of many of the moviecliploader methods and listeners. // first set of listeners var my_mcl = new moviecliploader(); mylistener = new object(); mylistener.Onloadstart = function (target_mc) { mytrace ("*********...

  • Page 549

    Moviecliploader.Loadclip() 549 //second set of listeners var another_mcl = new moviecliploader(); mylistener2 = new object(); mylistener2.Onloadstart = function (target_mc) { mytrace("*********second my_mcl instance*********"); mytrace ("your load has begun on movie clip22 . = " + target_mc); var lo...

  • Page 550

    550 chapter 12: actionscript dictionary moviecliploader.Onloadcomplete() availability flash player 7. Usage listenerobject.Onloadcomplete() = function(target_mc) { // your statements here } parameters listenerobject a listener object that was added using moviecliploader.Addlistener() . Target_mc the...

  • Page 551

    Moviecliploader.Onloadinit() 551 the string “urlnotfound” is returned if neither the moviecliploader.Onloadstart() or moviecliploader.Onloadcomplete() listener has been called. For example, if a server is down or the file is not found, these listeners are not called. The string “loadnevercompleted” ...

  • Page 552

    552 chapter 12: actionscript dictionary moviecliploader.Onloadprogress() availability flash player 7. Usage listenerobject.Onloadprogress() = function(target_mc [, loadedbytes [, totalbytes ] ] ) { // your statements here } parameters listenerobject a listener object that was added using moviecliplo...

  • Page 553

    Moviecliploader.Unloadclip() 553 description listener; invoked when a call to moviecliploader.Loadclip() has successfully begun to download a file. Example see moviecliploader.Loadclip() . See also moviecliploader.Onloaderror() , moviecliploader.Onloadinit() , moviecliploader.Onloadcomplete() moviec...

  • Page 554

    554 chapter 12: actionscript dictionary description method; removes a movie clip that was loaded by means of moviecliploader.Loadclip() . If you issue this command while a movie is loading, moviecliploader.Onloaderror() is invoked. See also moviecliploader.Loadclip() nan availability flash player 5....

  • Page 555

    Netconnection class 555 netconnection class availability flash player 7. Note: this class is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Description the netconnection class provides the means to ...

  • Page 556

    556 chapter 12: actionscript dictionary netconnection.Connect() flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Usage my_nc.Connect(null); parameters none (you mu...

  • Page 557

    Netstream class 557 method summary for the netstream class the following methods and properties of the netconnection and netstream classes are used to control flv playback. Property summary for the netstream class event handler summary for the netstream class method purpose netstream.Close() closes ...

  • Page 558

    558 chapter 12: actionscript dictionary constructor for the netstream class availability flash player 7. Note: this class is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Usage new netstream(my_nc)...

  • Page 559

    Netstream.Bytestotal 559 netstream.Buffertime availability flash player 7. Note: this property is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Usage mystream.Buffertime description read-only prope...

  • Page 560

    560 chapter 12: actionscript dictionary netstream.Close() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Usage my_ns.Close() parameters none. Return...

  • Page 561

    Netstream.Onstatus 561 netstream.Onstatus availability flash player 7. Note: this handler is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Usage my_ns.Onstatus = function(infoobject) { // your code...

  • Page 562

    562 chapter 12: actionscript dictionary example the following example writes data about the stream to a log file. My_ns.Onstatus = function(info) { _root.Log_stream += "stream status."; _root.Log_stream += "event: " + info.Code + ""; _root.Log_stream += "type: " + info.Level + ""; } see also s...

  • Page 563

    Netstream.Play() 563 netstream.Play() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Usage my_ns.Play("filename"); parameters filename the name of a...

  • Page 564

    564 chapter 12: actionscript dictionary netstream.Seek() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Usage my_ns.Seek(numberofseconds) parameters...

  • Page 565

    Netstream.Time 565 netstream.Setbuffertime() availability flash player 7. Note: this method is also supported in flash player 6 when used with flash communication server. For more information, see your flash communication server documentation. Usage my_ns.Setbuffertime(numberofseconds) parameters nu...

  • Page 566

    566 chapter 12: actionscript dictionary new availability flash player 5. Usage new constructor() parameters constructor a function followed by any optional parameters in parentheses. The function is usually the name of the object type (for example, array, number, or object) to be constructed. Return...

  • Page 567

    Nextframe() 567 newline availability flash player 4. Usage newline parameters none. Returns nothing. Description constant; inserts a carriage return character ( ) that generates a blank line in text output generated by your code. Use newline to make space for information that is retrieved by a fu...

  • Page 568

    568 chapter 12: actionscript dictionary nextscene() availability flash 2. Usage nextscene() parameters none. Returns nothing. Description function; sends the playhead to frame 1 of the next scene and stops it. Example in this example, when a user releases the button, the playhead is sent to frame 1 ...

  • Page 569

    Number class 569 null availability flash player 5. Usage null parameters none. Returns nothing. Description constant; a special value that can be assigned to variables, or returned by a function if no data was provided. You can use null to represent values that are missing or do not have a defined d...

  • Page 570

    570 chapter 12: actionscript dictionary method summary for the number class property summary for the number class constructor for the number class availability flash player 5. Usage new number(value) parameters value the numeric value of the number object being created, or a value to be converted to...

  • Page 571

    Number.Nan 571 number.Max_value availability flash player 5. Usage number.Max_value description property; the largest representable number (double-precision ieee-754). This number is approximately 1.79e+308. Number.Min_value availability flash player 5. Usage number.Min_value description property; t...

  • Page 572

    572 chapter 12: actionscript dictionary number.Negative_infinity availability flash player 5. Usage number.Negative_infinity description property; specifies the ieee-754 value representing negative infinity. The value of this property is the same as that of the constant -infinity . Negative infinity...

  • Page 573

    Number() 573 description method; returns the string representation of the specified number object ( mynumber ). If mynumber is undefined, the return value is as follows: • in files published for flash player 6 or earlier, the result is 0. • in files published for flash player 7 or later, the result ...

  • Page 574

    574 chapter 12: actionscript dictionary description function; converts the parameter expression to a number and returns a value as follows: • if expression is a number, the return value is expression . • if expression is a boolean value, the return value is 1 if expression is true , 0 if expression ...

  • Page 575

    Object.Addproperty() 575 constructor for the object class availability flash player 5. Usage new object([value]) parameters value a number, boolean value, or string to be converted to an object. This parameter is optional. If you do not specify value , the constructor creates a new object with no de...

  • Page 576

    576 chapter 12: actionscript dictionary you can add getter/setter properties to prototype objects. If you add a getter/setter property to a prototype object, all object instances that inherit the prototype object inherit the getter/setter property. This makes it possible to add a getter/setter prope...

  • Page 577

    Object.Addproperty() 577 usage 2: the above example of bookcount and bookname works, but the properties bookcount and bookname are added to every instance of the book object. That means that the cost of having the properties is two property slots for every instance of the object. If there are many p...

  • Page 578

    578 chapter 12: actionscript dictionary object.__proto__ availability flash player 5. Usage myobject.__proto__ parameters none. Description property; refers to the prototype property of the constructor function that created myobject . The __proto__ property is automatically assigned to all objects w...

  • Page 579

    Object.Tostring() 579 if a symbol is already registered to a class, this method replaces it with the new registration. When a movie clip instance is placed by the timeline or created using attachmovie() or duplicatemovieclip() , actionscript invokes the constructor for the appropriate class with the...

  • Page 580

    580 chapter 12: actionscript dictionary object.Unwatch() availability flash player 6. Usage myobject.Unwatch (prop) parameters prop the name of the object property that should no longer be watched, as a string. Returns a boolean value. Description method; removes a watchpoint that object.Watch() cre...

  • Page 581

    Object.Watch() 581 object.Watch() availability flash player 6. Usage myobject.Watch( prop, callback [, userdata] ) parameters prop a string indicating the name of the object property to watch. Callback the function to invoke when the watched property changes. This parameter is a function object, not...

  • Page 582

    582 chapter 12: actionscript dictionary example this example shows a checkbox component with methods that set the label or value of each check box instance: mycheckbox1.Setvalue(true); mycheckbox1.Setlabel("new label"); ... It’s convenient to think of the value and label of a check box as properties...

  • Page 583

    On() 583 on() availability flash 2. Not all events are supported in flash 2. Usage on(mouseevent) { // your statements here } parameters statement(s) the instructions to execute when the mouseevent takes place. A mouseevent is a trigger called an “event.” when the event takes place, the statements f...

  • Page 584

    584 chapter 12: actionscript dictionary onclipevent() availability flash player 5. Usage onclipevent(movieevent){ // your statements here } parameters a movieevent is a trigger called an event. When the event takes place, the statements following it within curly braces are executed. Any of the follo...

  • Page 585

    Onupdate 585 the following example uses onclipevent() with the keydown movie event. The keydown movie event is usually used in conjunction with one or more methods and properties of the key object. The following script uses key.Getcode() to find out which key the user has pressed; if the pressed key...

  • Page 586

    586 chapter 12: actionscript dictionary example the onupdate function gives the live preview movie an opportunity to update its visual appearance to match the new values of the component parameters. When the user changes a parameter value in the components property inspector or component parameters ...

  • Page 587

    _parent 587 ord availability flash player 4. This function has been deprecated in favor of the methods and properties of the string class. Usage ord(character) parameters character the character to convert to an ascii code number. Returns nothing. Description string function; converts characters to ...

  • Page 588

    588 chapter 12: actionscript dictionary parsefloat() availability flash player 5. Usage parsefloat(string) parameters string the string to read and convert to a floating-point number. Returns a number or nan . Description function; converts a string to a floating-point number. The function reads, or...

  • Page 589

    Parseint 589 parseint availability flash player 5. Usage parseint(expression [, radix]) parameters expression a string to convert to a integer. Radix optional; an integer representing the radix (base) of the number to parse. Legal values are from 2 to 36. Returns a number or nan . Description functi...

  • Page 590

    590 chapter 12: actionscript dictionary play() availability flash 2. Usage play() parameters none. Returns nothing. Description function; moves the playhead forward in the timeline. Example the following code uses an if statement to check the value of a name the user enters. If the user enters steve...

  • Page 591

    Print() 591 example when the user clicks a button that has the following handler attached to it, the playhead is sent to the previous frame. On(release) { prevframe(); } see also movieclip.Prevframe() prevscene() availability flash 2. Usage prevscene() parameters none. Returns nothing. Description f...

  • Page 592

    592 chapter 12: actionscript dictionary • bmovie designates the bounding box of a specific frame in a movie as the print area for all printable frames in the movie. Assign a #b frame label to the frame whose bounding box you want to use as the print area. • bmax designates a composite of all of the ...

  • Page 593

    Printasbitmap() 593 printasbitmap() availability flash player 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 class entry. Usage printasbitmap...

  • Page 594

    594 chapter 12: actionscript dictionary printasbitmapnum() availability flash player 5. 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 class entry....

  • Page 595

    Printjob class 595 printjob class availability flash player 7. Description the printjob class lets you create content and print it to one or more pages. This class, in addition to offering improvements to print functionality provided by the print() method, lets you render dynamic content offscreen, ...

  • Page 596

    596 chapter 12: actionscript dictionary description constructor; creates a printjob object that you can use to print one or more pages. To implement a print job, use these methods in the sequence shown: // create printjob object my_pj = new printjob(); // instantiate object // display print dialog b...

  • Page 597

    Printjob.Addpage() 597 the coordinates you specify for printarea represent screen pixels relative to the registration point of the _root movie (if target = 0) or of the level or movie clip specified by target . You must provide all four coordinates. The width ( xmax-xmin ) and height ( ymax-ymin ) m...

  • Page 598

    598 chapter 12: actionscript dictionary if this method returns false (for example, if you haven’t called printjob.Start() or the user canceled the print job), any subsequent calls to printjob.Addpage() will fail. However, if prior calls to printjob.Addpage() were successful, the concluding printjob....

  • Page 599

    Printjob.Send() 599 // starting at 0,0, print an area 400 pixels wide // and 400 pixels high of frame 3 of the "dance_mc" movie clip // in bitmap format if (my_pj.Addpage("dance_mc", {xmin:0,xmax:400,ymin:0,ymax:400},{printasbitmap:true}, 3)) { pagecount++; // starting at 0,0, print an area 400 pixe...

  • Page 600

    600 chapter 12: actionscript dictionary description method; is used following printjob.Start() and printjob.Addpage() to send spooled pages to the printer. Example see printjob.Addpage() . See also printjob.Addpage() , printjob.Start() printjob.Start() availability flash player 7. Usage my_pj.Start(...

  • Page 601

    Printnum() 601 if this method returns false (for example, if the user clicks cancel instead of ok), any subsequent calls to printjob.Addpage() and printjob.Send() will fail. However, if you test for this return value and don’t send printjob.Addpage() commands as a result, you should still delete the...

  • Page 602

    602 chapter 12: actionscript dictionary description function; prints the level in flash player according to the boundaries specified in the bounding box parameter ( "bmovie" , "bmax" , "bframe" ). If you want to print specific frames in the target movie, attach a #p frame label to those frames. Alth...

  • Page 603

    _quality 603 public flash player 6. Usage class someclassname{ public var name; public function name() { // your statements here } } note: to use this keyword, you must specify actionscript 2.0 and flash player 6 or later in the flash tab of your fla file’s publish settings dialog box. This keyword ...

  • Page 604

    604 chapter 12: actionscript dictionary the _quality property can be set to the following values: • "low" low rendering quality. Graphics are not anti-aliased, bitmaps are not smoothed. • "medium" medium rendering quality. Graphics are anti-aliased using a 2 x 2 grid, in pixels, but bitmaps are not ...

  • Page 605

    Return 605 removemovieclip() availability flash player 4. Usage removemovieclip(target) parameters target the target path of a movie clip instance created with duplicatemovieclip() , or the instance name of a movie clip created with movieclip.Attachmovie() or movieclip.Duplicatemovieclip() . Returns...

  • Page 606

    606 chapter 12: actionscript dictionary example the following example uses the return action inside the body of the sum() function to return the added value of the three parameters. The next line of code calls sum() and assigns the returned value to the variable newvalue . Function sum(a, b, c){ ret...

  • Page 607

    Selection class 607 scroll availability flash player 4. Usage textfieldvariablename.Scroll = x description property; a deprecated property that controls the display of information in a text field associated with a variable. The scroll property defines where the text field begins displaying content; ...

  • Page 608

    608 chapter 12: actionscript dictionary method summary for the selection class listener summary for the selection class selection.Addlistener() availability flash player 6. Usage selection.Addlistener(newlistener) parameters newlistener an object with an onsetfocus method. Returns none. Description ...

  • Page 609

    Selection.Getcaretindex() 609 selection.Getbeginindex() availability flash player 5. Usage selection.Getbeginindex() parameters none. Returns an integer. Description method; returns the index at the beginning of the selection span. If no index exists or no text field currently has focus, the method ...

  • Page 610

    610 chapter 12: actionscript dictionary selection.Getendindex() availability flash player 5. Usage selection.Getendindex() parameters none. Returns an integer. Description method; returns the ending index of the currently focused selection span. If no index exists, or if there is no currently focuse...

  • Page 611

    Selection.Removelistener() 611 selection.Onsetfocus availability flash player 6. Usage somelistener.Onsetfocus = function(oldfocus, newfocus){ statements; } description listener; notified when the input focus changes. To use onsetfocus , you must create a listener object. You can then define a funct...

  • Page 612

    612 chapter 12: actionscript dictionary selection.Setfocus() availability flash player 5. Instance names for buttons and movie clips work only in flash player 6 and later. Usage selection.Setfocus("instancename") parameters instancename a string specifying the path to the instance name of a button, ...

  • Page 613

    Set 613 returns nothing. Description method; sets the selection span of the currently focused text field. The new selection span will begin at the index specified in the start parameter, and end at the index specified in the end parameter. Selection span indexes are zero-based (for example, the firs...

  • Page 614

    614 chapter 12: actionscript dictionary set variable availability flash player 4. Usage set(variable, expression) parameters variable an identifier to hold the value of the expression parameter. Expression a value assigned to the variable. Returns nothing. Description statement; assigns a value to a...

  • Page 615

    Setinterval() 615 setinterval() availability flash player 6. Usage setinterval(functionname, interval [, param1, param2, ..., paramn]) parameters functionname a function name or a reference to an anonymous function. Interval the time in milliseconds between calls to the functionname parameter. Param...

  • Page 616

    616 chapter 12: actionscript dictionary usage 3: this example uses a method of an object. You must use this syntax when you want to call a method that is defined for an object. Obj = new object(); obj.Interval = function() { trace("interval function called"); } setinterval( obj, "interval", 1000 ); ...

  • Page 617

    Sharedobject class 617 sharedobject class availability flash player 6. Description shared objects are quite powerful: they offer real-time data sharing between objects that are persistent on the user’s computer. You can think of local shared objects as “cookies.” you can use local shared objects to ...

  • Page 618

    618 chapter 12: actionscript dictionary the following list summarizes how the user’s disk space choices interact with shared objects: • if the user selects never, objects are never saved locally, and all sharedobject.Flush() commands issued for the object return false . • if the user selects unlimit...

  • Page 619

    Sharedobject.Data 619 constructor for the sharedobject class for information on creating local shared objects, see sharedobject.Getlocal() . Sharedobject.Clear() availability flash player 7. Usage my_so.Clear() parameters none. Returns nothing. Description method; purges all of the data from the sha...

  • Page 620

    620 chapter 12: actionscript dictionary to create “private” values for a shared object—values that are available only to the client instance while the object is in use and are not stored with the object when it is closed—create properties that are not named data to store them, as shown in the follow...

  • Page 621

    Sharedobject.Flush() 621 if this method returns "pending" , the flash player displays a dialog box asking the user to increase the amount of disk space available to objects from this domain. To allow space for the shared object to “grow” when it is saved in the future, thus avoiding return values of...

  • Page 622

    622 chapter 12: actionscript dictionary sharedobject.Getlocal() availability flash player 6. Usage sharedobject.Getlocal(objectname [, localpath]) note: the correct syntax is sharedobject.Getlocal . To assign the object to a variable, use syntax like mylocalso = sharedobject.Getlocal . Parameters ob...

  • Page 623

    Sharedobject.Onstatus 623 sharedobject.Getsize() availability flash player 6. Usage mylocalsharedobject.Getsize() parameters none. Returns a numeric value specifying the size of the shared object, in bytes. Description method; gets the current size of the shared object, in bytes. Flash calculates th...

  • Page 624

    624 chapter 12: actionscript dictionary in addition to this onstatus handler, flash also provides a “super” function called system.Onstatus . If onstatus is invoked for a particular object and there is no function assigned to respond to it, flash processes a function assigned to system.Onstatus if i...

  • Page 625

    Sound class 625 property summary for the sound class event handler summary for the sound class constructor for the sound class availability flash player 5. Usage new sound([target]) parameters target the movie clip instance on which the sound object operates. This parameter is optional. Returns noth...

  • Page 626

    626 chapter 12: actionscript dictionary example the following example creates a new sound object called global_sound . The second line calls setvolume() and adjusts the volume on all sounds in the movie to 50%. Global_sound = new sound(); global_sound.Setvolume(50); the following example creates a n...

  • Page 627

    Sound.Getbytestotal() 627 sound.Getbytesloaded() availability flash player 6. Usage my_sound.Getbytesloaded() parameters none. Returns an integer indicating the number of bytes loaded. Description method; returns the number of bytes loaded (streamed) for the specified sound object. You can compare t...

  • Page 628

    628 chapter 12: actionscript dictionary sound.Getpan() availability flash player 5. Usage my_sound.Getpan(); parameters none. Returns an integer. Description method; returns the pan level set in the last setpan() call as an integer from -100 (left) to 100 (right). (0 sets the left and right channels...

  • Page 629

    Sound.Id3 629 sound.Getvolume() availability flash player 5. Usage my_sound.Getvolume() parameters none. Returns an integer. Description method; returns the sound volume level as an integer from 0 to 100, where 0 is off and 100 is full volume. The default setting is 100. See also sound.Setvolume() s...

  • Page 630

    630 chapter 12: actionscript dictionary tcom composer tcon content type tcop copyright message tdat date tdly playlist delay tenc encoded by text lyricist/text writer tflt file type time time tit1 content group description tit2 title/song name/content description tit3 subtitle/description refinement...

  • Page 631

    Sound.Loadsound() 631 flash player 6 supported several id31.0 tags. If these tags are in not in the mp3 file, but corresponding id3 2.0 tags are, the id3 2.0 tags are copied into the id3 1.0 properties, as shown in the following table. This process provides backward compatibility with scripts that y...

  • Page 632

    632 chapter 12: actionscript dictionary description method; loads an mp3 file into a sound object. You can use the isstreaming parameter to indicate whether the sound is an event or a streaming sound. Event sounds are completely loaded before they play. They are managed by the actionscript sound cla...

  • Page 633

    Sound.Onload 633 example the following example traces the id3 properties of song.Mp3 to the output panel. My_sound = new sound(); my_sound.Onid3 = function(){ for( var prop in my_sound.Id3 ){ trace( prop + " : "+ my_sound.Id3[prop] ); } } my_sound.Loadsound("song.Mp3", false); see also sound.Attachs...

  • Page 634

    634 chapter 12: actionscript dictionary sound.Onsoundcomplete availability flash player 6. Usage my_sound.Onsoundcomplete = function(){ // your statements here } parameters none. Returns nothing. Description event handler; invoked automatically when a sound finishes playing. You can use this handler...

  • Page 635

    Sound.Setpan() 635 sound.Position availability flash player 6. Usage my_sound.Position description property (read-only); the number of milliseconds a sound has been playing. If the sound is looped, the position will be reset to 0 at the beginning of each loop. Sound.Setpan() availability flash playe...

  • Page 636

    636 chapter 12: actionscript dictionary sound.Settransform() availability flash player 5. Usage my_sound.Settransform(soundtransformobject) parameters soundtransformobject an object created with the constructor for the generic object class. Returns nothing. Description method; sets the sound transfo...

  • Page 637

    Sound.Settransform() 637 mono sounds play all sound input in the left speaker and have the following transform settings by default: ll = 100 lr = 100 rr = 0 rl = 0 example the following example illustrates a setting that can be achieved by using settransform() , but cannot be achieved by using setvo...

  • Page 638

    638 chapter 12: actionscript dictionary sound.Setvolume() availability flash player 5. Usage my_sound.Setvolume(volume) parameters volume a number from 0 to 100 representing a volume level. 100 is full volume and 0 is no volume. The default setting is 100. Returns nothing. Description method; sets t...

  • Page 639

    _soundbuftime 639 returns nothing. Description method; starts playing the last attached sound from the beginning if no parameter is specified, or starting at the point in the sound specified by the secondoffset parameter. See also sound.Stop() sound.Stop() availability flash player 5. Usage my_sound...

  • Page 640

    640 chapter 12: actionscript dictionary stage class availability flash player 6. Description the stage class is a top-level class whose methods, properties, and handlers you can access without using a constructor. Use the methods and properties of this class to access and manipulate information abou...

  • Page 641

    Stage.Align 641 stage.Addlistener() availability flash player 6. Usage stage.Addlistener(mylistener) parameters mylistener an object that listens for a callback notification from the stage.Onresize event. Returns nothing. Description method; detects when a swf file is resized (but only if stage.Scal...

  • Page 642

    642 chapter 12: actionscript dictionary the following table lists the values for the align property. Any value not listed here centers the swf file in the player or browser area. Stage.Height availability flash player 6. Usage stage.Height description property (read-only); indicates the current heig...

  • Page 643

    Stage.Removelistener() 643 returns nothing. Description event handler; invoked when stage.Scalemode is set to "noscale" and the swf file is resized. You can use this event handler to write a function that lays out the objects on the stage when a swf file is resized. Example the following example dis...

  • Page 644

    644 chapter 12: actionscript dictionary stage.Scalemode availability flash player 6. Usage stage.Scalemode = "value" description property; indicates the current scaling of the swf file within the stage. The scalemode property forces the swf file into a specific scaling mode. By default, the swf file...

  • Page 645

    Startdrag() 645 startdrag() availability flash player 4. Usage startdrag(target,[lock, left, top, right, bottom]) parameters target the target path of the movie clip to drag. Lock a boolean value specifying whether the draggable movie clip is locked to the center of the mouse position ( true ), or l...

  • Page 646

    646 chapter 12: actionscript dictionary static availability flash player 6. Usage class someclassname{ static var name; static function name() { // your statements here } } note: to use this keyword, you must specify actionscript 2.0 and flash player 6 or later in the flash tab of your fla file’s pu...

  • Page 647

    Stopdrag() 647 stopallsounds() availability flash player 3. Usage stopallsounds() parameters none. Returns nothing. Description function; stops all sounds currently playing in a swf file without stopping the playhead. Sounds set to stream will resume playing as the playhead moves over the frames the...

  • Page 648

    648 chapter 12: actionscript dictionary example this code stops the drag action on the instance my_mc when the user releases the mouse button: on(press) { startdrag("my_mc"); } on(release) { stopdrag(); } see also movieclip._droptarget , movieclip.Stopdrag() , startdrag() " " (string delimiter) avai...

  • Page 649

    String class 649 string class availability flash player 5 (became a native object in flash player 6, which improved performance significantly). Description the string class is a wrapper for the string primitive data type, and provides methods and properties that let you manipulate primitive string v...

  • Page 650

    650 chapter 12: actionscript dictionary property summary for the string class constructor for the string class availability flash player 5. Usage new string(value) parameters value the initial value of the new string object. Returns nothing. Description constructor; creates a new string object. See ...

  • Page 651

    String.Charcodeat() 651 description method; returns the character in the position specified by the parameter index . If index is not a number from 0 to string.Length - 1, an empty string is returned. This method is similar to string.Charcodeat() except that the returned value is a character, not a 1...

  • Page 652

    652 chapter 12: actionscript dictionary string.Concat() availability flash player 5. Usage my_str.Concat(value1,...Valuen) parameters value1,...Valuen zero or more values to be concatenated. Returns a string. Description method; combines the value of the string object with the parameters and returns...

  • Page 653

    String.Lastindexof() 653 string.Indexof() availability flash player 5. Usage my_str.Indexof(substring, [startindex]) parameters substring an integer or string specifying the substring to be searched for within my_str . Startindex an optional integer specifying the starting point in my_str to search ...

  • Page 654

    654 chapter 12: actionscript dictionary string.Length availability flash player 5. Usage my_str.Length description property; a nonzero-based integer specifying the number of characters in the specified string object. Because all string indexes are zero-based, the index of the last character for any ...

  • Page 655

    String.Split() 655 see also string.Substr() , string.Substring() string.Split() availability flash player 5. Usage my_str.Split("delimiter", [limit]) parameters delimiter the character or string at which my_str splits. Limit the number of items to place into the array. This parameter is optional. Re...

  • Page 656

    656 chapter 12: actionscript dictionary string.Substr() availability flash player 5. Usage my_str.Substr(start, [length]) parameters start an integer that indicates the position of the first character in my_str to be used to create the substring. If start is a negative number, the starting position ...

  • Page 657

    String() 657 string.Tolowercase() availability flash player 5. Usage my_str.Tolowercase() parameters none. Returns a string. Description method; returns a copy of the string object, with all of the uppercase characters converted to lowercase. The original value is unchanged. String.Touppercase() ava...

  • Page 658

    658 chapter 12: actionscript dictionary description function; returns a string representation of the specified parameter as follows: if expression is a number, the return string is a text representation of the number. If expression is a string, the return string is expression . If expression is an o...

  • Page 659

    Switch 659 super availability flash player 6. Usage super.Method([arg1, ..., argn]) super([arg1, ..., argn]) parameters method the method to invoke in the superclass. Arg1 optional parameters that are passed to the superclass version of the method (syntax 1) or to the constructor function of the sup...

  • Page 660

    660 chapter 12: actionscript dictionary description statement; creates a branching structure for actionscript statements. Like the if action, the switch action tests a condition and executes statements if the condition returns a value of true . Example in the following example, if the number paramet...

  • Page 661

    System class 661 system class availability flash player 6. Description this is a top-level class that contains the capabilities object (see system.Capabilities object ), the security object (see system.Security object ), and the methods, properties, and event handlers listed below. Method summary fo...

  • Page 662

    662 chapter 12: actionscript dictionary system.Exactsettings availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage system.Exactsettings description property; specifies whether to use superdomain or exact-domain mat...

  • Page 663

    System.Onstatus 663 system.Onstatus availability flash player 6. Description event handler: provides a “super” event handler for certain objects. The localconnection, netstream, and sharedobject objects provide an onstatus event handler that uses an information object for providing information, stat...

  • Page 664

    664 chapter 12: actionscript dictionary system.Setclipboard() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage system.Setclipboard(string) parameters string a plain-text string of characters to place on the sy...

  • Page 665

    System.Usecodepage 665 description method; displays the specified flash player settings panel, which lets users do any of the following: • allow or deny access to the camera and microphone • specify the local disk space available for shared objects • select a default camera and microphone • specify ...

  • Page 666

    666 chapter 12: actionscript dictionary if you set system.Usecodepage to true , keep in mind that the traditional code page of the operating system running the player must include the characters used in your external text file in order for the text to display. For example, if you load an external te...

  • Page 667

    System.Capabilities object 667 system.Capabilities.Hasmp3 indicates whether the player is running on a system that has an mp3 decoder. Mp3 system.Capabilities.Hasprinting indicates whether the player is running on a system that supports printing. Pr system.Capabilities.Hasscreenbroadcast indicates w...

  • Page 668

    668 chapter 12: actionscript dictionary system.Capabilities.Avhardwaredisable availability flash player 7. Usage system.Capabilities.Avhardwaredisable description read-only property; a boolean value that specifies whether the user’s camera and microphone are enabled or disabled. See also camera.Get(...

  • Page 669

    System.Capabilities.Hasprinting 669 system.Capabilities.Hasaudioencoder availability flash player 6. Usage system.Capabilities.Hasaudioencoder description property; a boolean value that indicates whether the player can encode an audio stream, such as that coming from a microphone. The server string ...

  • Page 670

    670 chapter 12: actionscript dictionary system.Capabilities.Hasscreenbroadcast availability flash player 6. Usage system.Capabilities.Hasscreenbroadcast description property; a boolean value that indicates whether the player supports the development of screen broadcast applications to be run through...

  • Page 671

    System.Capabilities.Language 671 system.Capabilities.Hasvideoencoder availability flash player 6. Usage system.Capabilities.Hasvideoencoder description property; a boolean value that indicates whether the player can encode a video stream, such as that coming from a web camera. The server string is v...

  • Page 672

    672 chapter 12: actionscript dictionary system.Capabilities.Localfilereaddisable availability flash player 7. Usage system.Capabilities.Localfilereaddisable description read-only property; a boolean value that specifies whether flash player attempts to read anything (including the first swf file tha...

  • Page 673

    System.Capabilities.Screencolor 673 system.Capabilities.Os availability flash player 6. Usage system.Capabilities.Os description property; a string that indicates the current operating system. The os property can return the following strings: "windows xp" , "windows 2000" , "windows nt" , "windows 9...

  • Page 674

    674 chapter 12: actionscript dictionary system.Capabilities.Screendpi availability flash player 6. Usage system.Capabilities.Screendpi description property; indicates the dots-per-inch (dpi) resolution of the screen, in pixels. The server string is dp . System.Capabilities.Screenresolutionx availabi...

  • Page 675

    System.Security object 675 system.Capabilities.Serverstring availability flash player 6. Usage system.Capabilities.Serverstring description property; a url-encoded string that specifies values for each system.Capabilities property, as in this example: a=t&sa=t&sv=t&ev=t&mp3=t&ae=t&ve=t&acc=f&pr=t&sp...

  • Page 676

    676 chapter 12: actionscript dictionary system.Security.Allowdomain() availability flash player 6; behavior changed in flash player 7. Usage system.Security.Allowdomain("domain1", "domain2, ... Domainn") parameters domain1, domain2, ... Domainn strings that specify domains that can access objects an...

  • Page 677

    System.Security.Allowinsecuredomain() 677 system.Security.Allowinsecuredomain() availability flash player 7. Usage system.Security.Allowinsecuredomain("domain") parameters domain an exact domain name, such as “www.Mydomainname.Com” or “store.Mydomainname.Com”. Returns nothing. Description method; al...

  • Page 678

    678 chapter 12: actionscript dictionary targetpath availability flash player 5. Usage targetpath(movieclipobject) parameters movieclipobject reference (for example, _root or _parent ) to the movie clip for which the target path is being retrieved. Returns a string containing the target path of the s...

  • Page 679

    Telltarget 679 description deprecated action; applies the instructions specified in the statements parameter to the timeline specified in the target parameter. The telltarget action is useful for navigation controls. Assign telltarget to buttons that stop or start movie clips elsewhere on the stage....

  • Page 680

    680 chapter 12: actionscript dictionary textfield class availability flash player 6. Description all dynamic and input text fields in a swf file are instances of the textfield class. You can give a text field an instance name in the property inspector and use the methods and properties of the textfi...

  • Page 681

    Textfield class 681 textfield.Bottomscroll the bottommost visible line in a text field. Read-only. Textfield.Embedfonts indicates whether the text field uses embedded font outlines or device fonts. Textfield._height the height of a text field instance in pixels. This only affects the bounding box of...

  • Page 682

    682 chapter 12: actionscript dictionary event handler summary for the textfield class listener summary for the textfield class textfield.Textheight the height of the text field’s bounding box. Textfield.Textwidth the width of the text field’s bounding box. Textfield.Type indicates whether a text fie...

  • Page 683

    Textfield.Addlistener() 683 textfield.Addlistener() availability flash player 6. Usage my_txt.Addlistener(listener) parameters listener an object with an onchanged or onscroller event handler. Returns nothing. Description method; registers an object to receive notification when the onchanged and ons...

  • Page 684

    684 chapter 12: actionscript dictionary textfield._alpha availability flash player 6. Usage my_txt._alpha description property; sets or retrieves the alpha transparency value of the text field specified by my_txt . Valid values are 0 (fully transparent) to 100 (fully opaque). The default value is 10...

  • Page 685

    Textfield.Border 685 example the following sets the autosize property of the text field my_txt to "center" . My_txt.Autosize = "center"; textfield.Background availability flash player 6. Usage my_txt.Background description property; if true , the text field has a background fill. If false , the text...

  • Page 686

    686 chapter 12: actionscript dictionary textfield.Bordercolor availability flash player 6. Usage my_txt.Bordercolor description property; the color of the text field border, the default is 0x000000 (black). This property may be retrieved or set, even if there is currently no border. See also textfie...

  • Page 687

    Textfield.Getfontlist() 687 textfield.Embedfonts availability flash player 6. Usage my_txt.Embedfonts description property; a boolean value that, when true , renders the text field using embedded font outlines. If false , it renders the text field using device fonts. Textfield.Getdepth() availabilit...

  • Page 688

    688 chapter 12: actionscript dictionary example the following code displays a font list returned by getfontlist() . Font_array = textfield.Getfontlist(); for( i in font_array){ trace(font_array[i]); } textfield.Getnewtextformat() availability flash player 6. Usage my_txt.Getnewtextformat() parameter...

  • Page 689

    Textfield._highquality 689 description method; usage 1: returns a textformat object containing formatting information for all text in a text field. Only properties that are common to all text in the text field are set in the resulting textformat object. Any property which is mixed, meaning that it h...

  • Page 690

    690 chapter 12: actionscript dictionary textfield.Hscroll availability flash player 6. Usage my_txt.Hscroll returns an integer. Description property; indicates the current horizontal scrolling position. If the hscroll property is 0, the text is not horizontally scrolled. For more information on scro...

  • Page 691

    Textfield.Length 691 textfield.Htmltext availability flash player 6. Usage my_txt.Htmltext description property; if the text field is an html text field, this property contains the html representation of the text field’s contents. If the text field is not an html text field, it behaves identically t...

  • Page 692

    692 chapter 12: actionscript dictionary textfield.Maxchars availability flash player 6. Usage my_txt.Maxchars description property; indicates the maximum number of characters that the text field can contain. A script may insert more text than maxchars allows; the maxchars property only indicates how...

  • Page 693

    Textfield.Multiline 693 description property; associates the contextmenu object contextmenu with the text field my_txt . The contextmenu class lets you modify the context menu that appears when the user right-clicks (windows) or control-clicks (macintosh) in flash player. This property works only wi...

  • Page 694

    694 chapter 12: actionscript dictionary textfield._name availability flash player 6. Usage my_txt . _name description property; the instance name of the text field specified by my_txt . Textfield.Onchanged availability flash player 6. Usage my_txt.Onchanged = function(){ // your statements here } pa...

  • Page 695

    Textfield.Onscroller 695 textfield.Onkillfocus availability flash player 6. Usage my_txt.Onkillfocus = function(newfocus){ // your statements here } parameters newfocus the object that is receiving the focus. Returns nothing. Description event handler; invoked when a text field loses keyboard focus....

  • Page 696

    696 chapter 12: actionscript dictionary textfield.Onsetfocus availability flash player 6. Usage my_txt.Onsetfocus = function(oldfocus){ // your statements here } parameters oldfocus the object to lose focus. Returns nothing. Description event handler; invoked when a text field receives keyboard focu...

  • Page 697

    Textfield.Removelistener() 697 textfield.Password availability flash player 6. Usage my_txt.Password description property; if the value of password is true , the text field is a password text field and hides the input characters. If false , the text field is not a password text field. Textfield._qua...

  • Page 698

    698 chapter 12: actionscript dictionary textfield.Removetextfield() availability flash player 6. Usage my_txt.Removetextfield() description method; removes the text field specified by my_txt . This operation can only be performed on a text field that was created with movieclip.Createtextfield() . Wh...

  • Page 699

    Textfield.Restrict 699 textfield.Replacetext() availability flash player 7. Usage my_txt.Replacetext(beginindex, endindex, text) description method; replaces a range of characters, specified by the beginindex and endindex parameters, in the specified text field with the contents of the text paramete...

  • Page 700

    700 chapter 12: actionscript dictionary the ^ may be used anywhere in the string to toggle between including characters and excluding characters. The following code includes only uppercase letters, but excludes the uppercase letter q: my_txt.Restrict = "a-z^q"; you can use the \u escape sequence to ...

  • Page 701

    Textfield.Setnewtextformat() 701 textfield.Selectable availability flash player 6. Usage my_txt.Selectable description property; a boolean value that indicates whether the text field is selectable (editable). The value true indicates that the text is selectable. Textfield.Setnewtextformat() availabi...

  • Page 702

    702 chapter 12: actionscript dictionary textfield.Settextformat() availability flash player 6. Usage my_txt.Settextformat (textformat) my_txt.Settextformat (index, textformat) my_txt.Settextformat (beginindex, endindex, textformat) parameters textformat a textformat object, which contains character ...

  • Page 703

    Textfield.Stylesheet class 703 see also textfield.Setnewtextformat() , textformat class textfield._soundbuftime availability flash player 6. Usage my_txt._soundbuftime description property (global); an integer that specifies the number of seconds a sound prebuffers before it starts to stream. Textfi...

  • Page 704

    704 chapter 12: actionscript dictionary event handler summary for the textfield.Stylesheet class l constructor for the textfield.Stylesheet class availability flash player 7. Usage new textfield.Stylesheet() returns nothing. Description constructor; creates a textfield.Stylesheet object. Textfield.S...

  • Page 705

    Textfield.Stylesheet.Getstylenames() 705 the following code loads the styles from the css file, and then displays each property name and its value in the output panel. Var stylesheet = new textfield.Stylesheet(); stylesheet.Load("styles.Css"); var sectionstyle = stylesheet.Getstyle("heading"); for(p...

  • Page 706

    706 chapter 12: actionscript dictionary the following is displayed in the output panel: bodytext heading see also textfield.Stylesheet.Getstyle() textfield.Stylesheet.Load() availability flash player 7. Usage stylesheet.Load(url) parameters url the url of a css file to load. The url must be in the s...

  • Page 707

    Textfield.Stylesheet.Parsecss() 707 textfield.Stylesheet.Onload availability flash player 7. Usage stylesheet.Onload = function (success) {} parameters success a boolean value indicating whether the css file was successfully loaded. Returns nothing. Description callback handler; invoked when a textf...

  • Page 708

    708 chapter 12: actionscript dictionary description method; parses the css in csstext and loads the style sheet with it. If a style in csstext is already in stylesheet , the properties in stylesheet are retained, and only the ones in csstext are added or changed in stylesheet . To extend the native ...

  • Page 709

    Textfield.Tabindex 709 textfield.Stylesheet availability flash player 7. Usage my_txt.Stylesheet = textfield stylesheet description property; attaches a style sheet to the text field specified by my_txt . For information on creating style sheets, see the textfield.Stylesheet class entry and “formatt...

  • Page 710

    710 chapter 12: actionscript dictionary description property; lets you customize the tab ordering of objects in a swf file. You can set the tabindex property on a button, movie clip, or text field instance; it is undefined by default. If any currently displayed object in the swf file contains a tabi...

  • Page 711

    Textfield.Type 711 textfield.Textcolor availability flash player 6. Usage my_txt.Textcolor description property; indicates the color of the text in a text field. Textfield.Textheight availability flash player 6. Usage my_txt.Textheight description property; indicates the height of the text. Textfiel...

  • Page 712

    712 chapter 12: actionscript dictionary textfield._url availability flash player 6. Usage my_txt . _url description property (read only); retrieves the url of the swf file that created the text field. Textfield.Variable availability flash player 6. Usage my_txt . Variable description property; the n...

  • Page 713

    Textfield._x 713 example the following example sets the height and width properties of a text field: my_txt._width=200; my_txt._height=200; see also movieclip._height textfield.Wordwrap availability flash player 6. Usage my_txt.Wordwrap description property; a boolean value that indicates if the tex...

  • Page 714

    714 chapter 12: actionscript dictionary textfield._xmouse availability flash player 6. Usage my_txt._xmouse description property (read-only); returns the x coordinate of the mouse position relative to the text field. See also textfield._ymouse textfield._xscale availability flash player 6. Usage my_...

  • Page 715

    Textformat class 715 textfield._ymouse availability flash player 6. Usage my_txt._ymouse description property (read-only); indicates the y coordinate of the mouse position relative to the text field. See also textfield._xmouse textfield._yscale availability flash player 6. Usage my_txt._yscale descr...

  • Page 716

    716 chapter 12: actionscript dictionary the code my_txt.Settextformat(my_fmt) only changes the bold property of the text field’s default text format, because the bold property is the only one defined in my_fmt . All other aspects of the text field’s default text format remain unchanged. When textfie...

  • Page 717

    Textformat class 717 constructor for the textformat class availability flash player 6. Usage new textformat([font, [size, [color, [bold, [italic, [underline, [url, [target, [align, [leftmargin, [rightmargin, [indent, [leading]]]]]]]]]]]]]) parameters font the name of a font for text as a string. Siz...

  • Page 718

    718 chapter 12: actionscript dictionary textformat.Align availability flash player 6. Usage my_fmt.Align description property; indicates the alignment of the paragraph, represented as a string. The alignment of the paragraph, represented as a string. If "left" , the paragraph is left-aligned. If "ce...

  • Page 719

    Textformat.Gettextextent() 719 textformat.Bullet availability flash player 6. Usage my_fmt.Bullet description property; a boolean value that indicates that the text is part of a bulleted list. In a bulleted list, each paragraph of text is indented. To the left of the first line of each paragraph, a ...

  • Page 720

    720 chapter 12: actionscript dictionary parameters text a string. Width an optional number that represents the width, in pixels, at which the specified text should wrap. Returns an object with the properties width , height , ascent , descent , textfieldheight , textfieldwidth . Description method; r...

  • Page 721

    Textformat.Gettextextent() 721 when setting up your textformat object, set all the attributes exactly as they will be set for the creation of the text field, including font name, font size, and leading. The default value for leading is 2. Example this example creates a single-line text field that’s ...

  • Page 722

    722 chapter 12: actionscript dictionary textformat.Indent availability flash player 6. Usage my_fmt.Indent description property; an integer that indicates the indentation from the left margin to the first character in the paragraph. The default value is null , which indicates that the property is un...

  • Page 723

    Textformat.Tabstops 723 textformat.Leftmargin availability flash player 6. Usage my_fmt.Leftmargin description property; the left margin of the paragraph, in points. The default value is null , which indicates that the property is undefined. Textformat.Rightmargin availability flash player 6. Usage ...

  • Page 724

    724 chapter 12: actionscript dictionary textformat.Target availability flash player 6. Usage my_fmt.Target description property; indicates the target window where the hyperlink is displayed. If the target window is an empty string, the text is displayed in the default target window _self . If the te...

  • Page 725

    Textsnapshot object 725 textsnapshot object availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Description textsnapshot objects let you work with static text in a movie clip. You can use them, for example, to lay out ...

  • Page 726

    726 chapter 12: actionscript dictionary textsnapshot.Findtext() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Findtext( startindex, texttofind, casesensitive ) parameters startindex an integer speci...

  • Page 727

    Textsnapshot.Getselectedtext() 727 textsnapshot.Getselected() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Getselected(from, to) parameters from an integer that indicates the position of the first ...

  • Page 728

    728 chapter 12: actionscript dictionary description method; returns a string that contains all the characters specified by the corresponding textsnapshot.Setselected() command. If no characters are selected, an empty string is returned. If you pass a value of true for includelineendings , newline ch...

  • Page 729

    Textsnapshot.Setselectcolor() 729 textsnapshot.Hittesttextnearpos() availability authoring: flash mx 2004. Playback: swf files published for flash player 6 or later, playing in flash player 7 or later. Usage my_snap.Hittesttextnearpos(x, y [, maxdistance] ) parameters x a number that represents the ...

  • Page 730

    730 chapter 12: actionscript dictionary description method; specifies the color to use when highlighting characters that have been selected with the textsnapshot.Setselected() command. The color is always opaque; you can’t specify a transparency value. Textsnapshot.Setselected() availability authori...

  • Page 731

    This 731 this availability flash player 5. Usage this description identifier; references an object or movie clip instance. When a script executes, this references the movie clip instance that contains the script. When a method is called, this contains a reference to the object that contains the call...

  • Page 732

    732 chapter 12: actionscript dictionary // statements in fla file import simple; var obj:simple = new simple(); obj.Num = 0; obj.Func = function():boolean{ return true; } obj.Callfunc(); // syntax error with incorrect version of simple.As example in the following example, the keyword this references...

  • Page 733

    Throw 733 example in this example, a function named checkemail() checks whether the string that is passed to it is a properly formatted e-mail address. If the string does not contain an @ symbol, the function throws an error. Function checkemail(email:string) { if (email.Indexof("@") == -1) { throw ...

  • Page 734

    734 chapter 12: actionscript dictionary togglehighquality() availability flash 2; deprecated in favor of _quality . Usage togglehighquality() parameters none. Returns nothing. Description deprecated function; turns anti-aliasing on and off in flash player. Anti-aliasing smooths the edges of objects ...

  • Page 735

    True 735 description statement; evaluates the expression and displays the result in the output panel in test mode. Use this action to record programming notes or to display messages in the output panel while testing a movie. Use the expression parameter to check if a condition exists, or to display ...

  • Page 736

    736 chapter 12: actionscript dictionary try..Catch..Finally availability flash player 7. Usage try { // ... Try block ... } finally { // ... Finally block ... } try { // ... Try block ... } catch(error[:errortype1]) { // ... Catch block ... } [catch(error[:errortypen]) { // ... Catch block ... }] [f...

  • Page 737

    Try..Catch..Finally 737 example the following example shows how to create a try..Finally statement. Because code in the finally block is guaranteed to execute, it is typically used to perform any necessary “clean-up” code after a try block executes. In this example, the finally block is used to dele...

  • Page 738

    738 chapter 12: actionscript dictionary within the recordset class’s sortrows() method, one of these previously defined error objects are thrown depending on the type of exception that occurred. The following code snippet shows how this code might look. // within recordset.As class file... Function ...

  • Page 739

    Typeof 739 typeof availability flash player 5. Usage typeof(expression) parameters expression a string, movie clip, button, object, or function. Description operator; a unary operator placed before a single parameter. The typeof operator causes the flash interpreter to evaluate expression ; the resu...

  • Page 740

    740 chapter 12: actionscript dictionary undefined availability flash player 5. Usage undefined parameters none. Returns nothing. Description a special value, usually used to indicate that a variable has not yet been assigned a value. A reference to an undefined value returns the special value undefi...

  • Page 741

    Unloadmovie() 741 unescape availability flash player 5. Usage unescape(x) parameters x a string with hexadecimal sequences to escape. Returns a string decoded from a url-encoded parameter. Description function; evaluates the parameter x as a string, decodes the string from url-encoded format (conver...

  • Page 742

    742 chapter 12: actionscript dictionary example the following example unloads the movie clip draggable_mc on the main timeline, and loads movie.Swf into level 4. On (press) { unloadmovie ("_root.Draggable_mc"); loadmovienum ("movie.Swf", 4); } the following example unloads the movie loaded into leve...

  • Page 743

    Var 743 updateafterevent() availability flash player 5. Usage updateafterevent() parameters none. Returns nothing. Description function; updates the display (independent of the frames per second set for the movie) when you call it within an onclipevent() handler or as part of a function or method th...

  • Page 744

    744 chapter 12: actionscript dictionary you cannot declare a variable scoped to another object as a local variable: my_array.Length = 25; // ok var my_array.Length = 25; // syntax error when you use var , you can strictly type the variable; see “strict data typing” on page 38 note: classes defined i...

  • Page 745

    Video.Attachvideo() 745 video.Attachvideo() availability flash player 6; the ability to work with flash video (flv) files was added in flash player 7. Usage my_video.Attachvideo(source) parameters source a camera object that is capturing video data or a netstream object. To drop the connection to th...

  • Page 746

    746 chapter 12: actionscript dictionary video.Clear() availability flash player 6. Usage my_video.Clear() parameters none. Returns nothing. Description method; clears the image currently displayed in the video object. This is useful when, for example, you want to display standby information without ...

  • Page 747

    Video.Smoothing 747 video.Height availability flash player 6. Usage my_video.Height description read-only property; an integer specifying the height of the video stream, in pixels. For live streams, this value is the same as the camera.Height property of the camera object that is capturing the video...

  • Page 748

    748 chapter 12: actionscript dictionary video.Width availability flash player 6. Usage my_video.Width description read-only property; an integer specifying the width of the video stream, in pixels. For live streams, this value is the same as the camera.Width property of the camera object that is cap...

  • Page 749

    With 749 description statement; tests an expression and runs a statement or series of statements repeatedly in a loop as long as the expression is true . Before the statement block is run, the condition is tested; if the test returns true , the statement block is run. If the condition is false , the...

  • Page 750

    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 automatical...

  • Page 751

    Xml class 751 you could also write this code using the telltarget action. However, if someother_mc were not a movie clip, but an object, you could not use the with action. Telltarget ("someother_mc") { _x = 50; _y = 100; gotoandstop(3); } the with action is useful for accessing multiple items in a s...

  • Page 752

    752 chapter 12: actionscript dictionary method summary for the xml class property summary for the xml class method description xml.Addrequestheader() adds or changes http headers for post operations. Xml.Appendchild() appends a node to the end of the specified object’s child list. Xml.Clonenode() cl...

  • Page 753

    Xml class 753 collections summary for the xml class event handler summary for the xml class constructor for the xml class availability flash player 5. Usage new xml([source]) parameters source the xml text parsed to create the new xml object. Returns nothing. Description constructor; creates a new x...

  • Page 754

    754 chapter 12: actionscript dictionary example usage 1: the following example creates an new, empty xml object. My_xml = new xml(); usage 2: the following example creates an xml object by parsing the xml text specified in the source parameter, and populates the newly created xml object with the res...

  • Page 755

    Xml.Appendchild() 755 example this example adds a custom http header named soapaction with a value of foo to an xml object named my_xml . My_xml.Addrequestheader("soapaction", "'foo'"); this next example creates an array named headers that contains two alternating http headers and their associated v...

  • Page 756

    756 chapter 12: actionscript dictionary xml.Attributes availability flash player 5. Usage my_xml.Attributes parameters none. Returns an array. Description property; an associative array containing all attributes of the specified xml object. Example the following example writes the names of the xml a...

  • Page 757

    Xml.Clonenode() 757 xml.Childnodes availability flash player 5. Usage my_xml.Childnodes parameters none. Returns an array. Description property (read-only); an array of the specified xml object’s children. Each element in the array is a reference to an xml object that represents a child node. This i...

  • Page 758

    758 chapter 12: actionscript dictionary xml.Contenttype availability flash player 6. Usage my_xml.Contenttype description property; the mime type that is sent to the server when you call the xml.Send() or xml.Sendandload() method. The default is application/x-www-form-urlencoded. See also xml.Send()...

  • Page 759

    Xml.Doctypedecl 759 xml.Createtextnode() availability flash player 5. Usage my_xml.Createtextnode(text) parameters text the text used to create the new text node. Returns nothing. Description method; creates a new xml text node with the specified text. The new node initially has no parent, and text ...

  • Page 760

    760 chapter 12: actionscript dictionary xml.Firstchild availability flash player 5. Usage my_xml.Firstchild description property (read-only); evaluates the specified xml object and references the first child in the parent node’s children list. This property is null if the node does not have children...

  • Page 761

    Xml.Haschildnodes() 761 xml.Getbytestotal() availability flash player 6. Usage xml.Getbytestotal() parameters none. Returns an integer. Description method; returns the size, in bytes, of the xml document. See also xml.Getbytesloaded() xml.Haschildnodes() availability flash player 5. Usage my_xml.Has...

  • Page 762

    762 chapter 12: actionscript dictionary xml.Ignorewhite availability flash player 5. Usage my_xml.Ignorewhite = boolean xml.Prototype.Ignorewhite = boolean parameters boolean a boolean ( true or false ) value. Description property; default setting is false . When set to true , text nodes that contai...

  • Page 763

    Xml.Load() 763 xml.Lastchild availability flash player 5. Usage my_xml.Lastchild description property (read-only); evaluates the xml object and references the last child in the parent node’s child list. This method returns null if the node does not have children. This is a read-only property and can...

  • Page 764

    764 chapter 12: actionscript dictionary 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 , and the onload() method is invoked. The xml data is not parsed until it is completely downloaded. If the xml ...

  • Page 765

    Xml.Nodevalue 765 xml.Nodename availability flash player 5. Usage my_xml.Nodename description property; the node name of the xml object. If the xml object is an xml element ( nodetype == 1), nodename is the name of the tag representing the node in the xml file. For example, title is the nodename of ...

  • Page 766

    766 chapter 12: actionscript dictionary xml.Ondata availability flash player 5 usage my_xml.Ondata = function(src) { // your statements here } parameters src the raw data, usually in xml format, that is sent by the server. Returns nothing. Description event handler; invoked when xml text has been co...

  • Page 767

    Xml.Onload() 767 xml.Onload() availability flash player 5. Usage my_xml.Onload = function (success) { //your statements here } parameters success a boolean value indicating whether the xml object was successfully loaded with a xml.Load() or xml.Sendandload() operation. Returns nothing. Description e...

  • Page 768

    768 chapter 12: actionscript dictionary xml.Parentnode availability flash player 5. Usage my_xml.Parentnode description property (read-only); references the parent node of the specified xml object, or returns null if the node has no parent. This is a read-only property and cannot be used to manipula...

  • Page 769

    Xml.Send() 769 xml.Removenode() availability flash player 5. Usage my_xml.Removenode() parameters none. Returns nothing. Description method; removes the specified xml object from its parent. All descendants of the node are also deleted. Xml.Send() availability flash player 5. Usage my_xml.Send(url, ...

  • Page 770

    770 chapter 12: actionscript dictionary xml.Sendandload() availability flash player 5; behavior changed in flash player 7. Usage my_xml.Sendandload(url, targetxmlobject) parameters url the destination url for the specified xml object. If the swf file issuing this call is running in a web browser, ur...

  • Page 771

    Xml.Tostring() 771 xml.Status availability flash player 5. Usage my_xml.Status description property; automatically sets and returns a numeric value indicating whether an xml document was successfully parsed into an xml object. The numeric status codes and a description of each are listed as follows:...

  • Page 772

    772 chapter 12: actionscript dictionary example the following code is an example of xml.Tostring() that sends to the output panel. Node = new xml(" trace(node.Tostring()); see also xml.Doctypedecl , xml.Xmldecl xml.Xmldecl availability flash player 5. Usage my_xml.Xmldecl description property; speci...

  • Page 773

    Xmlnode class 773 xmlnode class availability flash player 5. Description the xmlnode class supports the following properties, methods, and collections; for information on their usage, see the corresponding xml class entries. See also xml class property, method, or collection corresponding xml class ...

  • Page 774

    774 chapter 12: actionscript dictionary xmlsocket class availability flash player 5. Description the xmlsocket class implements client sockets that allow the computer running flash player to communicate with a server computer identified by an ip address or domain name. The xmlsocket class is useful ...

  • Page 775

    Xmlsocket class 775 method summary for the xmlsocket class event handler summary for the xmlsocket class constructor for the xmlsocket class availability flash player 5. Usage new xmlsocket() parameters none. Returns nothing. Description constructor; creates a new xmlsocket object. The xmlsocket obj...

  • Page 776

    776 chapter 12: actionscript dictionary xmlsocket.Close() availability flash player 5. Usage myxmlsocket.Close() parameters none. Returns nothing. Description method; closes the connection specified by xmlsocket object. See also xmlsocket.Connect() xmlsocket.Connect() availability flash player 5; be...

  • Page 777

    Xmlsocket.Connect() 777 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 at www.Somedomain.Com can load variables from a swf file at store.Somedomain.Com, because both f...

  • Page 778

    778 chapter 12: actionscript dictionary xmlsocket.Onclose() availability flash player 5. Usage myxmlsocket.Onclose() = function() { // your statements here } parameters none. Returns nothing. Description event handler; invoked only when an open connection is closed by the server. The default impleme...

  • Page 779

    Xmlsocket.Ondata() 779 example the following example illustrates the process of specifying a replacement function for the onconnect method in a simple chat application. The function controls which screen users are taken to, depending on whether a connection is successfully established. If the connec...

  • Page 780

    780 chapter 12: actionscript dictionary description event handler; invoked when a message has been downloaded from the server, terminated by a zero byte. You can override xmlsocket.Ondata to intercept the data sent by the server without parsing it as xml. This is a useful if you’re transmitting arbi...

  • Page 781

    Xmlsocket.Send() 781 the onxml handler must first be installed in the xmlsocket object as follows: socket.Onxml = myonxml; the function displaymessage() is assumed to be a user-defined function that displays the message received by the user. Function myonxml(doc) { var e = doc.Firstchild; if (e != n...

  • Page 782

    782 chapter 12: actionscript dictionary.

  • Page 783: Appendix A

    783 appendix a error messages macromedia flash mx 2004 and macromedia flash mx professional 2004 provide enhanced compile-time error reporting if you specify actionscript 2.0 (the default) when you publish a file. The following table contains a list of error messages that the flash compiler can gene...

  • Page 784

    784 appendix a: error messages 1114 there is no interface defined with this name. 1115 a class may not extend an interface. 1116 an interface may not extend a class. 1117 an interface name is expected after the ‘implements’ keyword. 1118 a class may not implement a class, only interfaces. 1119 the c...

  • Page 785

    785 1146 the property being referenced does not have the static attribute. 1147 this call to super does not match the superconstructor. 1148 only the public attribute is allowed for interface methods. 1149 the import keyword cannot be used as a directive. 1150 you must export your movie as flash 7 t...

  • Page 786

    786 appendix a: error messages 1178 instance variables and functions may not be used to initialize static variables. 1179 runtime circularities were discovered between the following classes:%1 1180 the currently targeted flash player does not support debugging. 1181 the currently targeted flash play...

  • Page 787: Appendix B

    787 appendix b operator precedence and associativity this table lists all of the actionscript operators and their associativity, from highest to lowest precedence. Operator description associativity highest precedence + unary plus right to left - unary minus right to left ~ bitwise not right to left...

  • Page 788

    788 appendix b: operator precedence and associativity add string concatenation (formerly &) left to right - subtract left to right bitwise left shift left to right >> bitwise right shift left to right >>> bitwise right shift (unsigned) left to right less than left to right less than or equal to left...

  • Page 789: Appendix C

    789 appendix c keyboard keys and key code values the following tables list all of the keys on a standard keyboard and the corresponding ascii key code values that are used to identify the keys in actionscript. For more information, see the key class entry in chapter 12, “actionscript dictionary,” on...

  • Page 790

    790 appendix c: keyboard keys and key code values keys on the numeric keypad the following table lists the keys on a numeric keypad, with the corresponding 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 ...

  • Page 791

    Function keys 791 function keys the following table lists the function keys on a standard keyboard, with the corresponding 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 ...

  • Page 792

    792 appendix c: keyboard keys and key code values other keys the following table lists keys on a standard keyboard other than letters, numbers, numeric keypad keys, or function keys, with the corresponding ascii key code values that are used to identify the keys in actionscript. Key key code backspa...

  • Page 793

    Other keys 793 ] } 221 " ' 222 key key code.

  • Page 794

    794 appendix c: keyboard keys and key code values.

  • Page 795: Appendix D

    795 appendix d writing scripts for earlier versions of flash player actionscript has changed considerably with the release of macromedia flash mx 2004 and macromedia flash mx professional 2004. When you create content for flash player 7, you’ll take advantage of the full power of actionscript. You c...

  • Page 796

    796 appendix d: writing scripts for earlier versions of flash player using flash mx 2004 to create content for flash player 4 to use flash mx 2004 to create content for flash player 4, specify flash player 4 in the flash tab of the publish settings dialog box (file > publish settings). Flash player ...

  • Page 797

    Using flash mx 2004 to create content for flash player 4 797 • in flash 4, the escape sequence generated a carriage return character (ascii 13). In flash 5 and later, to comply with the ecma-262 standard, generates a line-feed character (ascii 10). An sequence in flash 4 fla files is automa...

  • Page 798

    798 appendix d: writing scripts for earlier versions of flash player.

  • Page 799: Appendix E

    799 appendix e object-oriented programming with actionscript 1 the information in this appendix was excerpted from the macromedia flash mx documentation and provides information on using the actionscript 1 object model to write scripts. It is included here for the following reasons: • if you want to...

  • Page 800

    800 appendix e: object-oriented programming with actionscript 1 objects in actionscript can be pure containers for data, or they can be graphically represented on the stage as movie clips, buttons, or text fields. All movie clips are instances of the built-in class movieclip, and all buttons are ins...

  • Page 801

    About actionscript 1 801 after you define the constructor function you must create an instance of the object. Use the new operator before the name of the constructor function and assign the new instance a variable name. For example, the following code uses the new operator to create a circle object ...

  • Page 802

    802 appendix e: object-oriented programming with actionscript 1 defining event handler methods in actionscript 1 you can create an actionscript class for movie clips and define the event handler methods in the prototype object of that new class. Defining the methods in the prototype object makes all...

  • Page 803

    About actionscript 1 803 function myclipclass(){} myclipclass.Prototype = new movieclip(); myclipclass.Prototype.Onload = function(){ trace("movie clip loaded"); } myclipclass.Prototype.Onpress = function(){ trace("pressed"); } myclipclass.Prototype.Onenterframe = function(){ trace("movie clip enter...

  • Page 804

    804 appendix e: object-oriented programming with actionscript 1 instead of adding roll() to the mountainbike class and the tricycle class, you can create the mountainbike class with bike as its superclass: mountainbike.Prototype = new bike(); now you can call the roll() method of mountainbike, as sh...

  • Page 805

    About actionscript 1 805 invoking a function using the function.Call() method in actionscript 1 the function.Call() method invokes the function represented by a function object. In almost all cases, the function call operator ( () ) can be used instead of the call() method. The function call operato...

  • Page 806

    806 appendix e: object-oriented programming with actionscript 1.

  • Page 807: Index

    807 index a accessing object properties 49 actions defined 26 repeating 56 actions panel 58 actions toolbox 58 yellow items in 61 actionscript actionscript 2.0 compiler error messages 783 assigning actionscript 2.0 class to movie clips 133 overview of actionscript 2.0 22, 155 strict data typing not ...

  • Page 808

    808 index child node 181 class files, creating 157 class members 114 and subclasses 167 created once per class 165 creating 165 example of using 166 classes about compiling and exporting 174 and object-oriented programming 156 assigning to movie clips 133 classpaths 169 creating and using 161 creati...

  • Page 809

    Index 809 strictly typing 38 string 34 undefined 36 data, external 177 access between cross-domain swfs 189 and loadvars object 180 and messages 185 and server-side scripts 179 and xml 181 and xmlsocket object 184 checking if loaded 178 security features 188 sending and loading 177 debug player 68 d...

  • Page 810

    810 index external class files creating 157 using classpaths to locate 169 external media 193–201 loading mp3 files 195 loading swf files and jpeg files 194 overview of loading 193 playing flv files 197 preloading 198, 199, 201 reasons for using 193 external sources, connecting flash with 177 f flas...

  • Page 811

    Index 811 inheritance 156 allowed from only one class 163 and subclasses 162 initializing movie clip properties 134 instance members 165 instance names assigning 50 compared with variable names 136 defined 28, 121 setting dynamically 49 instances defined 27, 114 example of creating 160 instantiating...

  • Page 812

    812 index movie clips activating with keyboard 98 adding parameters 128 adjusting color 100 and _root property 123 and with statement 122 assigning button states to 88 attaching on() and onclipevent() handlers 87 attaching to symbol on stage 127 calling multiple methods 122 changing properties in de...

  • Page 813

    Index 813 associativity 45, 787 bitwise 47 combining with values 45 comparison 46 dot 49 equality 47 logical 47 numeric 45 precedence 787 string 46 options pop-up menu in the actions panel 60, 61 in the debugger 70 in the output panel 77 output panel 77 and trace statement 79 list objects command 77...

  • Page 814

    814 index security 188–191 and policy files 190 and porting scripts to flash player 7 17, 19, 20 data access across domains 189, 190 semicolon 31 sending information in xml format 178 to remote files 177 url-encoded format 178 via tcp/ip 178 server-side scripts languages 177 xml format 182 servers, ...

  • Page 815

    Index 815 text fields 135 and html text 143 applying cascading style sheets 142 avoiding variable name conflicts 136 creating and removing at runtime 137 default properties 138 determining required size 139 displaying properties for debugging 78 flowing text around embedded images 147, 149 formattin...

  • Page 816

    816 index.