MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

ActionScript 2.0 Language Reference

Advertisement

Table of Contents
loading

Summary of Contents for MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE

  • Page 1 ActionScript 2.0 Language Reference...
  • Page 2 If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
  • Page 3: Table Of Contents

    Contents Chapter 1: ActionScript language elements....31 Compiler Directives ..........31 #endinitclip directive .
  • Page 4 loadMovieNum function ........70 loadVariables function .
  • Page 5 _focusrect property ......... 117 _global property .
  • Page 6 <> inequality operator........167 instanceof operator.
  • Page 7 if statement ..........215 implements statement .
  • Page 8 toString (Array.toString method)......264 UNIQUESORT (Array.UNIQUESORT property) ....264 unshift (Array.unshift method) .
  • Page 9 noise (BitmapData.noise method) ......319 paletteMap (BitmapData.paletteMap method) ....320 perlinNoise (BitmapData.perlinNoise method) .
  • Page 10 onSetFocus (Button.onSetFocus handler)....366 _parent (Button._parent property) ......367 _quality (Button._quality property).
  • Page 11 hasEmbeddedVideo (capabilities.hasEmbeddedVideo property) ....409 hasIME (capabilities.hasIME property) ..... . . 409 hasMP3 (capabilities.hasMP3 property) .
  • Page 12 redOffset (ColorTransform.redOffset property) ....439 rgb (ColorTransform.rgb property) ......440 toString (ColorTransform.toString method) .
  • Page 13 getTime (Date.getTime method) ......486 getTimezoneOffset (Date.getTimezoneOffset method) ..487 getUTCDate (Date.getUTCDate method) .
  • Page 14 angle (DropShadowFilter.angle property).....532 blurX (DropShadowFilter.blurX property) .....533 blurY (DropShadowFilter.blurY property) .
  • Page 15 browse (FileReferenceList.browse method) ....588 fileList (FileReferenceList.fileList property) ....590 FileReferenceList constructor .
  • Page 16 ratios (GradientGlowFilter.ratios property) ....647 strength (GradientGlowFilter.strength property) ....650 type (GradientGlowFilter.type property) .
  • Page 17 onKeyDown (Key.onKeyDown event listener) ....686 onKeyUp (Key.onKeyUp event listener) ..... . 687 PGDN (Key.PGDN property) .
  • Page 18 loadStringEx (Locale.loadStringEx method) ....739 setDefaultLang (Locale.setDefaultLang method)....740 setLoadCallback (Locale.setLoadCallback method) ...740 setString (Locale.setString method) .
  • Page 19 rotate (Matrix.rotate method) ....... .777 scale (Matrix.scale method)....... . . 780 toString (Matrix.toString method) .
  • Page 20 cacheAsBitmap (MovieClip.cacheAsBitmap property) ..846 clear (MovieClip.clear method) ......847 createEmptyMovieClip (MovieClip.createEmptyMovieClip method) .
  • Page 21 onDragOver (MovieClip.onDragOver handler) ....902 onEnterFrame (MovieClip.onEnterFrame handler) ... . 903 onKeyDown (MovieClip.onKeyDown handler) ....903 onKeyUp (MovieClip.onKeyUp handler) .
  • Page 22 _y (MovieClip._y property) ........941 _ymouse (MovieClip._ymouse property) ..... 942 _yscale (MovieClip._yscale property) .
  • Page 23 valueOf (Number.valueOf method) ......990 Object ............990 addProperty (Object.addProperty method) .
  • Page 24 contains (Rectangle.contains method) ..... . 1037 containsPoint (Rectangle.containsPoint method)... . . 1038 containsRectangle (Rectangle.containsRectangle method) .
  • Page 25 onStatus (SharedObject.onStatus handler) ....1092 Sound ........... . . 1094 attachSound (Sound.attachSound method) .
  • Page 26 toUpperCase (String.toUpperCase method) ....1140 valueOf (String.valueOf method)......1141 StyleSheet (TextField.StyleSheet) .
  • Page 27 menu (TextField.menu property) ......1189 mouseWheelEnabled (TextField.mouseWheelEnabled property) ....1191 multiline (TextField.multiline property) .
  • Page 28 TextFormat ..........1228 align (TextFormat.align property) .
  • Page 29 Video ............1273 _alpha (Video._alpha property) .
  • Page 30 cloneNode (XMLNode.cloneNode method)....1318 firstChild (XMLNode.firstChild property) ..... 1320 getNamespaceForPrefix (XMLNode.getNamespaceForPrefix method) .
  • Page 31: Chapter 1: Actionscript Language Elements

    CHAPTER 1 ActionScript language elements This section provides syntax, usage information, and code samples for global functions and properties (those elements that do not belong to an ActionScript class); compiler directives; and for the constants, operators, statements, and keywords used in ActionScript and defined in the ECMAScript (ECMA-262) edition 4 draft language specification.
  • Page 32: Include Directive

    The global Include directory, which is one of the following: --Windows 2000 or Windows XP: C:\Documents and Settings\user \Local Settings\ Application Data\Macromedia\Flash 8\language\Configuration\Include --Macintosh OS X: Hard Drive/Users/Library/Application Support/Macromedia/Flash 8/language/Configuration/Include The Flash 8 program\language\First Run\Include directory; if you save a file here, it is copied to the global Include directory the next time you start Flash.
  • Page 33: Initclip Directive

    Parameters The filename and optional path for the script to [path]filename.as:String filename.as add to the Actions panel or to the current script; .as is the recommended filename extension. Example The following examples show various ways of specifying a path for a file to be included in your script: // Note that #include statements do not end with a semicolon (;) // AS file is in same directory as FLA file or script...
  • Page 34 Do not place a semicolon (;) at the end of the line that contains the #initclip directive. Availability: ActionScript 1.0; Flash Player 6.0 Parameters [optional] - A non-negative integer that specifies the execution order of blocks order:Number code. This is an optional parameter. You must specify the value by using an #initclip integer literal (only decimal values are allowed, not hexadecimal), and not by using a variable.
  • Page 35: Constants

    Constants A constant is a variable used to represent a property whose value never changes. This section describes global constants that are available to every script. Constants summary Modifiers Constant Description A unique Boolean value that represents the opposite false of true.
  • Page 36: Infinity Constant

    // converts it to a string trace("String: " + bool1); // outputs String: false Infinity constant Specifies the IEEE-754 value representing positive infinity. The value of this constant is the same as Number.POSITIVE_INFINITY Availability: ActionScript 1.0; Flash Player 5 See also POSITIVE_INFINITY (Number.POSITIVE_INFINITY property) -Infinity constant Specifies the IEEE-754 value representing negative infinity.
  • Page 37: Null Constant

    Example The following example shows how displays output from the statement on newline trace() multiple lines. var myName:String = "Lisa", myAge:Number = 30; trace(myName+myAge); trace("-----"); trace(myName+newline+myAge); // output: Lisa30 ----- Lisa See also trace function null constant A special value that can be assigned to variables or returned by a function if no data was provided.
  • Page 38: True Constant

    true constant A unique Boolean value that represents the opposite of . When automatic data typing false converts to a number, it becomes 1; when it converts to a string, it becomes true true "true" Availability: ActionScript 1.0; Flash Player 5 Example The following example shows the use of in an...
  • Page 39 In files published for Flash Player 6 or earlier, the value of . In files Number(undefined) published for Flash Player 7 or later, the value of Number(undefined) The value is similar to the special value . When undefined null null undefined compared with the equality ( ) operator, they compare as equal.
  • Page 40: Global Functions

    Global Functions This section contains a set of built-in functions that are available in any part of a SWF file where ActionScript is used. These global functions cover a wide variety of common programming tasks such as working with data types ( , and so on), Boolean() int()
  • Page 41 Deprecated since Flash Player 5. This function, along length(expression:St with all the string functions, has been deprecated. ring, Macromedia recommends that you use the methods variable:Object) of the String class and the String.length property to perform the same operations. Returns the length of the specified string or variable.
  • Page 42 Modifiers Signature Description Loads a SWF or JPEG file into Flash Player while the loadMovie(url:String original SWF file plays. , target:Object, [method:String]) Loads a SWF or JPEG file into a level in Flash Player loadMovieNum(url:Str while the originally loaded SWF file plays. ing, level:Number, [method:String]) Reads data from an external file, such as a text file or...
  • Page 43 Modifiers Signature Description Creates a new empty object or converts the specified Object([value:Object number, string, or Boolean value to an object. Specifies the mouse event or keypress that triggers on(mouseEvent:Object an action. Triggers actions defined for a specific instance of a onClipEvent(movieEve movie clip.
  • Page 44 Extracts part of a string. count:Number) Returns a string containing the target path of targetPath(targetObj movieClipObject. ect:Object) Deprecated since Flash Player 5. Macromedia tellTarget(target:St recommends that you use dot (.) notation and the ring, statement(s)) with statement. Applies the instructions specified in the statements parameter to the Timeline specified in the target parameter.
  • Page 45: Array Function

    Modifiers Signature Description Evaluates the expression and outputs the result. trace(expression:Obj ect) Evaluates the parameter x as a string, decodes the unescape(string:Stri string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string. Removes a movie clip that was loaded by means of unloadMovie(target:O loadMovie() from Flash Player.
  • Page 46: Asfunction Protocol

    Parameters [optional] - A positive integer that specifies the number of elements in numElements:Number the array. You can specify either or the list of elements, but not both. numElements [optional] - One or more parameters, elementN:Object element0, element1, ... , , the values of which can be of any type.
  • Page 47: Boolean Function

    Parameters - An identifier for a function. function:String - A string that is passed to the function named in the parameter:String function parameter. Example In the following example, the function is defined. The TextField object list_txt is playMP3() created and set so HTML text can be rendered. The text Track 1 and Track 2 are links inside the text field.
  • Page 48 is a string, the return value is as follows: expression In files published for Flash Player 6 and earlier, the string is first converted to a number. The value is if the number is not 0, otherwise the return value is true false In files published for Flash Player 7 and later, the result is...
  • Page 49: Call Function

    This example shows a significant difference between use of the function and the Boolean() Boolean class. The function creates a Boolean value, and the Boolean class creates Boolean() a Boolean object. Boolean values are compared by value, and Boolean objects are compared by reference.
  • Page 50: Chr Function

    chr function chr(number:Number) : String Deprecated since Flash Player 5. This function was deprecated in favor of String.fromCharCode() Converts ASCII code numbers to characters. Availability: ActionScript 1.0; Flash Player 4 Parameters - An ASCII code number. number:Number Returns - The character value of the specified ASCII code. String Example The following example converts the number 65 to the letter A and assigns it to the variable...
  • Page 51: Duplicatemovieclip Function

    You must clear the interval when you have finished using the function. Create a button called and use the following ActionScript to clear clearInt_btn setInterval() clearInt_btn.onRelease = function(){ clearInterval( intervalID ); trace("cleared interval"); See also setInterval function duplicateMovieClip function duplicateMovieClip(target:String, newname:String, depth:Number) : Void duplicateMovieClip(target:MovieClip, newname:String, depth:Number) : Void Creates an instance of a movie clip while the SWF file is playing.
  • Page 52: Escape Function

    Example In the following example, a new movie clip instance is created called An image is img_mc. loaded into the movie clip, and then the clip is duplicated. The duplicated clip is img_mc called , and this new clip is moved on the Stage so it does not overlap the original newImg_mc clip, and the same image is loaded into the second clip.
  • Page 53: Eval Function

    Example The following code produces the result someuser%40somedomain%2Ecom var email:String = "someuser@somedomain.com"; trace(escape(email)); In this example, the at symbol ( ) was replaced with and the dot symbol ( ) was replaced with . This is useful if you're trying to pass information to a remote server and the data has special characters in it (for example, ), as shown in the following code: &...
  • Page 54: Fscommand Function

    Lets the SWF file communicate with either Flash Player or the program that is hosting Flash Player, such as a web browser. You can also use the function to pass messages to fscommand() Macromedia Director, or to Visual Basic (VB), Visual C++, and other programs that can host ActiveX controls. ActionScript language elements...
  • Page 55 function lets a SWF file communicate with a script in a web page. fscommand() However, script access is controlled by the web page's setting. (You set allowScriptAccess this attribute in the HTML code that embeds the SWF file—for example, in the PARAM for Internet Explorer or the tag for Netscape.
  • Page 56 HTML page is in an untrusted sandbox. For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis ActionScript language elements...
  • Page 57 Director. For fscommand() more information, see the Director Support Center at www.macromedia.com/support/ director. Usage 4: In VisualBasic, Visual C++, and other programs that can host ActiveX controls, sends a VB event with two strings that can be handled in the environment's fscommand() programming language.
  • Page 58: Getproperty Function

    You must add a function to the web page that contains the SWF file. This function, , waits for an call. When myDocument_DoFSCommand() fscommand() fscommand() triggered in Flash (for example, when a user clicks the button), the command parameter strings are passed to the function.
  • Page 59: Gettimer Function

    Returns - The value of the specified property. Object Example The following example creates a new movie clip and shows the alpha value someClip_mc ) for the movie clip in the Output panel: _alpha someClip_mc this.createEmptyMovieClip("someClip_mc", 999); trace("The alpha of "+getProperty(someClip_mc, _name)+" is: "+getProperty(someClip_mc, _alpha));...
  • Page 60 This example loads an image into a movie clip. When the image is clicked, a new URL is loaded in a new browser window. var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc:MovieClip) { target_mc.onRelease = function() { getURL("http://www.macromedia.com/software/flash/flashpro/", "_blank"); var logo:MovieClipLoader = new MovieClipLoader(); logo.addListener(listenerObject); logo.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.createEmptyMovieClip("macromedia_mc", this.getNextHighestDepth()));...
  • Page 61: Getversion Function

    = "Gus"; var lastName:String = "Richardson"; var age:Number = 92; myBtn_btn.onRelease = function() { getURL("http://www.macromedia.com", "_blank", "GET"); The following ActionScript uses to send variables in the HTTP header. Make sure you POST test your documents in a browser window, because otherwise your variables are sent using var firstName:String = "Gus";...
  • Page 62: Gotoandplay Function

    See also os (capabilities.os property) version (capabilities.version property) gotoAndPlay function gotoAndPlay([scene:String], frame:Object) : Void Sends the playhead to the specified frame in a scene and plays from that frame. If no scene is specified, the playhead goes to the specified frame in the current scene. You can use the scene parameter only on the root Timeline, not within Timelines for movie clips or other objects in the document.
  • Page 63: Gotoandstop Function

    gotoAndStop function gotoAndStop([scene:String], frame:Object) : Void Sends the playhead to the specified frame in a scene and stops it. If no scene is specified, the playhead is sent to the frame in the current scene.You can use the parameter only on scene the root Timeline, not within Timelines for movie clips or other objects in the document.
  • Page 64: Ifframeloaded Function

    { statement(s); Deprecated since Flash Player 5. This function has been deprecated. Macromedia recommends that you use the property. MovieClip._framesloaded Checks whether the contents of a specific frame are available locally. Use ifFrameLoaded start playing a simple animation while the rest of the SWF file downloads to the local computer.
  • Page 65: Isfinite Function

    isFinite function isFinite(expression:Object) : Boolean Evaluates and returns if it is a finite number or if it is infinity or expression true false negative infinity. The presence of infinity or negative infinity indicates a mathematical error condition such as division by 0. Availability: ActionScript 1.0;...
  • Page 66: Length Function

    Deprecated since Flash Player 5. This function, along with all the string functions, has been deprecated. Macromedia recommends that you use the methods of the String class and the property to perform the same operations. String.length Returns the length of the specified string or variable.
  • Page 67: Loadmovie Function

    Returns - The length of the specified string or variable. Number Example The following example returns the length of the string "Hello": length("Hello"); result is 5. See also " string delimiter operator String length (String.length property) loadMovie function loadMovie(url:String, target:Object, [method:String]) : Void loadMovie(url:String, target:String, [method:String]) : Void Loads a SWF, JPEG, GIF, or PNG file into a movie clip in Flash Player while the original SWF file is playing.
  • Page 68 Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 3 - The ability to load JPEG files is available as of Flash Player 6.
  • Page 69 Example Usage 1: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called that already exists on the Stage: mySquare loadMovie("circle.swf", mySquare); // equivalent statement (Usage 1): loadMovie("circle.swf", _level0.mySquare); // equivalent statement (Usage 2): loadMovie("circle.swf", "mySquare"); The following example loads the SWF file circle.swf from the same directory, but replaces the main movie clip instead of the movie clip:...
  • Page 70: Loadmovienum Function

    loadMovieNum function loadMovieNum(url:String, level:Number, [method:String]) : Void Loads a SWF, JPEG, GIF, or PNG file into a level while the original SWF file is playing. Support for unanimated GIF files, PNG files, and progressive JPEG files is added in Flash Player 8.
  • Page 71 Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 4 - Flash 4 files opened in Flash 5 or later are converted to use the correct syntax.
  • Page 72: Loadvariables Function

    (a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables: company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103 In SWF files running in a version earlier than Flash Player 7, must be in the same superdomain as the SWF file that is issuing this call.
  • Page 73 Parameters - An absolute or relative URL where the variables are located. If the SWF file url:String issuing this call is running in a web browser, must be in the same domain as the SWF file; for details, see the Description section. - The target path to a movie clip that receives the loaded variables.
  • Page 74: Loadvariablesnum Function

    (a standard format used by CGI scripts). Any number of variables can be form-urlencoded specified. For example, the following phrase defines several variables: company=Macromedia&address=601+Townsend&city=San+Francisco&zip=94103 In SWF files running in a version of the player earlier than Flash Player 7, must be in the same superdomain as the SWF file that is issuing this call.
  • Page 75: Mbchr Function

    Example The following example loads information from a text file called params.txt into the main Timeline of the SWF at level 2 in Flash Player. The variable names of the text fields must match the variable names in the params.txt file. The function is used to setInterval() check the progress of the data being loaded into the SWF.
  • Page 76: Mblength Function

    See also fromCharCode (String.fromCharCode method) mblength function mblength(string:String) : Number Deprecated since Flash Player 5. This function was deprecated in favor of the methods and properties of the String class. Returns the length of the multibyte character string. Availability: ActionScript 1.0; Flash Player 4 Parameters - The string to measure.
  • Page 77: Mbsubstring Function

    ActionScript script to call a JSAPI command directly. If you in a script on Frame 1 of your file, the command executes when the SWF MMExecute() file is loaded. For more information on the JSAPI, see www.macromedia.com/go/jsapi_info_en. Global Functions...
  • Page 78 Availability: ActionScript 1.0; Flash Player 7 Parameters - Any command that you can use in a Flash JavaScript (JSFL) file. command:String Returns - A string representation of the result, if any, sent by the JavaScript statement. String Example The following command will output the number of items in the library of the current document to the trace window.
  • Page 79: Nextframe Function

    nextFrame function nextFrame() : Void Sends the playhead to the next frame. Availability: ActionScript 1.0; Flash Player 2 Example In the following example, when the user presses the Right or Down arrow key, the playhead goes to the next frame and stops. If the user presses the Left or Up arrow key, the playhead goes to the previous frame and stops.
  • Page 80: Number Function

    Example In the following example, when a user clicks the button that is created at runtime, the playhead is sent to Frame 1 of the next scene. Create two scenes, and enter the following ActionScript on Frame 1 of Scene 1. stop();...
  • Page 81 is a string, the function attempts to parse as a decimal expression expression number with an optional trailing exponent (that is, 1.57505e-3). , the return value is expression , the return value is as follows: expression undefined - In files published for Flash Player 6 or earlier, the result is 0. - In files published for Flash Player 7 or later, the result is Availability: ActionScript 1.0;...
  • Page 82: Object Function

    Example In the following example, a new empty object is created, and then the object is populated with values: var company:Object = new Object(); company.name = "Macromedia, Inc."; company.address = "600 Townsend Street"; company.city = "San Francisco"; company.state = "CA";...
  • Page 83 Parameters is a trigger called an event . When the event occurs, the mouseEvent:Object mouseEvent statements following it within curly braces ({ }) execute. Any of the following values can be specified for the parameter: mouseEvent The mouse button is pressed while the pointer is over the button. press The mouse button is released while the pointer is over the button.
  • Page 84: Onclipevent Handler

    onClipEvent handler onClipEvent(movieEvent:Object) { // your statements here Triggers actions defined for a specific instance of a movie clip. Availability: ActionScript 1.0; Flash Player 5 Parameters - The is a trigger called an event . When the event occurs, movieEvent:Object movieEvent the statements following it within curly braces ({}) are executed.
  • Page 85: Ord Function

    Example The following example uses with the movie event and is designed to onClipEvent() keyDown be attached to a movie clip or button. The movie event is usually used with one or keyDown more methods and properties of the Key object. The following script uses Key.getCode() find out which key the user has pressed;...
  • Page 86: Parsefloat Function

    Returns - The ASCII code number of the specified character. Number See also String charCodeAt (String.charCodeAt method) parseFloat function parseFloat(string:String) : Number Converts a string to a floating-point number. The function reads, or parses, and returns the numbers in a string until it reaches a character that is not a part of the initial number. If the string does not begin with a number that can be parsed, returns .
  • Page 87: Parseint Function

    parseInt function parseInt(expression:String, [radix:Number]) : Number Converts a string to an integer. If the specified string in the parameters cannot be converted to a number, the function returns . Strings beginning with 0x are interpreted as hexadecimal numbers. Integers beginning with 0 or specifying a radix of 8 are interpreted as octal numbers. White space preceding valid integers is ignored, as are trailing nonnumeric characters.
  • Page 88: Play Function

    See also parseFloat function play function play() : Void Moves the playhead forward in the Timeline. Availability: ActionScript 1.0; Flash Player 2 Example In the following example, there are two movie clip instances on the Stage with the instance names .
  • Page 89: Prevscene Function

    See also nextFrame function prevFrame (MovieClip.prevFrame method) prevScene function prevScene() : Void Sends the playhead to Frame 1 of the previous scene. Availability: ActionScript 1.0; Flash Player 2 See also nextScene function print function print(target:Object, boundingBox:String) : Void Prints the movie clip according to the boundaries specified in the parameter ( target bmovie...
  • Page 90 Parameters - The instance name of a movie clip to print. By default, all of the frames in target:Object the target instance can be printed. If you want to print specific frames in the movie clip, assign frame label to those frames. - A modifier that sets the print area of the movie clip.
  • Page 91: Printasbitmap Function

    If your movie clip does not contain alpha transparencies or color effects, Macromedia recommends that you use for better quality results.
  • Page 92: Printasbitmapnum Function

    Example The following example prints all of the printable frames in with a print area holder_mc defined by the bounding box of the frame: this.createEmptyMovieClip("holder_mc", 999); holder_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg"); this.myBtn_btn.onRelease = function() { printAsBitmap(this._parent.holder_mc, "bframe"); See also print function printAsBitmapNum function printNum function PrintJob printAsBitmapNum function printAsBitmapNum(level:Number, boundingBox:String) : Void...
  • Page 93: Printnum Function

    - A modifier that sets the print area of the movie clip. Enclose this boundingBox:String parameter in quotation marks (" or '), and specify one of the following values: Designates the bounding box of a specific frame in a movie clip as the print area bmovie for all of the printable frames in the movie clip.
  • Page 94: Random Function

    Availability: ActionScript 1.0; Flash Player 5 - 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. Parameters - The level in Flash Player to print.
  • Page 95: Removemovieclip Function

    Example The following use of returns a value of 0, 1, 2, 3, or 4: random() random(5); See also random (Math.random method) removeMovieClip function removeMovieClip(target:Object) Deletes the specified movie clip. Availability: ActionScript 1.0; Flash Player 4 Parameters - The target path of a movie clip instance created with target:Object or the instance name of a movie clip created with duplicateMovieClip()
  • Page 96: Setinterval Function

    setInterval function setInterval(functionReference:Function, interval:Number, [param1:Object, param2, ..., paramN]) : Number setInterval(objectReference:Object, methodName:String, interval:Number, [param1:Object, param2, ..., paramN]) : Number Calls a function or a method of an object at periodic intervals while a SWF file plays. You can to execute any function repetitively over time. setInterval() Use the following tips when working with setInterval()
  • Page 97 - The time in milliseconds between calls to the interval:Number functionReference function passed in. methodName is less than the SWF file's frame rate (for example, 10 frames per second [fps] is interval equal to 100 millisecond intervals), the interval function is called as close in time to the value as possible.
  • Page 98 Example 2: The following example is similar to the first, except that it calls before . This can help prevent unwanted loops and is clearInterval() setInterval() especially important in event-based systems where the initiating script can be executed multiple times before any particular interval has been cleared. var intervalId:Number;...
  • Page 99 "powder blue", "mint"); function executeCallback(param:String) { trace("executeCallback intervalId: " + intervalId + " count: " + count + " param: " + param); clearInterval(intervalId); if(count < maxCount) { count++; intervalId = setInterval(this, "executeCallback", duration, colors[count]); if(intervalId != null) { clearInterval(intervalId); intervalId = setInterval(this, "executeCallback", duration, colors[count]);...
  • Page 100: Setproperty Function

    count++; In a new document, instantiate a new instance of the new class: var custom:CustomClass = new CustomClass(); See also clearInterval function updateAfterEvent function class statement setProperty function setProperty(target:Object, property:Object, expression:Object) : Void Changes a property value of a movie clip as the movie clip plays. Availability: ActionScript 1.0;...
  • Page 101: Showredrawregions Function

    showRedrawRegions function showRedrawRegions(enable:Boolean, [color:Number]) : Void Provides the ability for the debugger player to outline the regions of the screen that are being redrawn (that is, dirty regions that are being updated). The outlines can also be turned on with the Show Redraw Regions menu option. Availability: ActionScript 1.0;...
  • Page 102: Startdrag Function

    startDrag function startDrag(target:Object, [lock:Boolean, left:Number, top:Number, right:Number, bottom:Number]) : Void Makes the movie clip draggable while the movie plays. Only one movie clip can be target dragged at a time. After a operation is executed, the movie clip remains startDrag() draggable until it is explicitly stopped by or until a action for...
  • Page 103: Stop Function

    stop function stop() : Void Stops the SWF file that is currently playing. The most common use of this action is to control movie clips with buttons. Availability: ActionScript 1.0; Flash Player 2 See also gotoAndStop function gotoAndStop (MovieClip.gotoAndStop method) stopAllSounds function stopAllSounds() : Void Stops all sounds currently playing in a SWF file without stopping the playhead.
  • Page 104: Stopdrag Function

    this.stop_mc.onRelease = function() { stopAllSounds(); See also Sound stopDrag function stopDrag() : Void Stops the current drag operation. Availability: ActionScript 1.0; Flash Player 4 Example The following code, placed in the main Timeline, stops the drag action on the movie clip instance when the user releases the mouse button: my_mc...
  • Page 105: String Function

    String function String(expression:Object) : String Returns a string representation of the specified parameter, as described in the following list: is a number, the return string is a text representation of the number. expression is a string, the return string is expression expression is an object, the return value is a string representation of the object...
  • Page 106: Substring Function

    substring function substring(string:String, index:Number, count:Number) : String Deprecated since Flash Player 5. This function was deprecated in favor of String.substr() Extracts part of a string. This function is one-based, whereas the String object methods are zero-based. Availability: ActionScript 1.0; Flash Player 4 Parameters - The string from which to extract the new string.
  • Page 107: Telltarget Function

    // _level0.myClip_mc See also eval function tellTarget function tellTarget(target:String) { statement(s); Deprecated since Flash Player 5. Macromedia recommends that you use dot (.) notation and statement. with Applies the instructions specified in the parameter to the Timeline specified in statements parameter.
  • Page 108: Togglehighquality Function

    The following example uses dot (.) notation to achieve the same results: on(release) { _parent.ball.gotoAndPlay(2); If you need to issue multiple commands to the ball instance, you can use the with action, as shown in the following statement: on(release) { with(_parent.ball) { gotoAndPlay(2);...
  • Page 109: Trace Function

    trace function trace(expression:Object) You can use Flash Debug Player to capture output from the function and display the trace() result. Use this statement to record programming notes or to display messages in the Output panel while testing a SWF file. Use the parameter to check whether a condition exists, expression or to display values in the Output panel.
  • Page 110: Unescape Function

    unescape function unescape(string:String) : String Evaluates the parameter as a string, decodes the string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string. Availability: ActionScript 1.0; Flash Player 5 Parameters - A string with hexadecimal sequences to escape. string:String Returns - A string decoded from a URL-encoded parameter.
  • Page 111: Unloadmovienum Function

    Example The following example creates a new movie clip called and loads an image into that pic_mc clip. It is loaded using the MovieClipLoader class. When you click the image, the movie clip unloads from the SWF file: var pic_mcl:MovieClipLoader = new MovieClipLoader(); pic_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth()));...
  • Page 112: Updateafterevent Function

    See also loadMovieNum function unloadMovie function loadMovie (MovieClip.loadMovie method) updateAfterEvent function updateAfterEvent() : Void Updates the display (independent of the frames per second set for the movie) when you call it within an handler or as part of a function or method that you pass to onClipEvent() setInterval().
  • Page 113 Global Properties summary Modifiers Property Description Lets you control screen reader accessibility options for _accProps SWF files, movie clips, buttons, dynamic text fields, and input text fields at runtime. Property (global); specifies whether a yellow rectangle _focusrect appears around the button or movie clip that has keyboard focus.
  • Page 114: Accprops Property

    _accProps property _accProps.propertyName instanceName._accProps.propertyName Lets you control screen reader accessibilityoptions for SWF files, movie clips, buttons, dynamic text fields, and input textfields at runtime. Theseproperties override the corresponding settings available in the Accessibilitypanel during authoring. For changes to these properties to take effect,you must call Accessibility.updateProperties(). For information on the Accessibility panel, see "The Flash Accessibility panel"...
  • Page 115 To specify settings that correspond to the Tab index setting in the Accessibility panel, use the Button.tabIndex, MovieClip.tabIndex, or TextField.tabIndex properties. There is no way to specify an Auto Label setting at runtime. To refer to the object that represents the entire Flash document, omit the _accProps parameter.
  • Page 116 After you specify an accessibility property, you can't revert its value to avalue set in the Accessibility panel. However, you can set the property to itsdefault value ( for Boolean false values; empty strings for stringvalues) by deleting the property from the object, as _accProps shownin the following example:...
  • Page 117: Focusrect Property

    _focusrect property _focusrect = Boolean; Specifies whether a yellow rectangle appears around the button or movie clip that has keyboard focus. If is set to its default value of , then a yellow rectangle _focusrect true appears around the currently focused button or movie clip as the user presses the Tab key to navigate through objects in a SWF file.
  • Page 118: Global Property

    _global property _global.identifier A reference to the global object that holds the core ActionScript classes, such as String, Object, Math, and Array. For example, you could create a library that is exposed as a global ActionScript object, similar to the Math or Date object. Unlike Timeline-declared or locally declared variables and functions, global variables and functions are visible to every Timeline and scope in the SWF file, provided they are not obscured by identifiers with the same names in inner scopes.
  • Page 119: Highquality Property

    See also var statement set variable statement _highquality property _highquality Deprecated since Flash Player 5. This property was deprecated in favor of _quality Specifies the level of anti-aliasing applied to the current SWF file. Specify 2 (best quality) to apply high quality with bitmap smoothing always on. Specify 1 (high quality) to apply anti- aliasing;...
  • Page 120: Maxscroll Property

    Example The following example stops the playhead in the main Timeline of the SWF file sub.swf that is loaded into . The sub.swf file contains animation and is in the same directory as _level9 the document that contains the following ActionScript: loadMovieNum("sub.swf", 9);...
  • Page 121: Quality Property

    Example In the following example, there is a movie clip on the Stage with the instance name . Within that movie clip is another movie clip with an instance name square_mc circle_mc The following ActionScript lets you modify the parent instance (which is circle_mc ) when the circle is clicked.
  • Page 122 Value Description Graphic Anti- Bitmap Smoothing Aliasing " " High rendering quality. Graphics are anti- Flash Player 8: Bitmaps are HIGH This setting is the aliased using a 4 x 4 smoothed based on the default rendering pixel grid. parameter used in smoothing quality setting that MovieClip.attachBitmap()
  • Page 123: Root Property

    _root property _root.movieClip _root.action _root.property Specifies or returns a reference to the root movie clip Timeline. If a movie clip has multiple levels, the root movie clip Timeline is on the level containing the currently executing script. For example, if a script in level 1 evaluates is returned.
  • Page 124: Scroll Property

    scroll property textFieldVariableName.scroll = x Deprecated since Flash Player 5. This property was deprecated in favor of TextField.scroll Controls the display of information in a text field associated with a variable. The scroll property defines where the text field begins displaying content; after you set it, Flash Player updates it as the user scrolls through the text field.
  • Page 125: This Property

    Example The following example streams an MP3 file and buffers the sound before it plays for the user. Two text fields are created at runtime to hold a timer and debugging information. The property is set to buffer the MP3 for 10 seconds. A new Sound object _soundbuftime instance is created for the MP3.
  • Page 126 Example Create an ActionsScript file named ApplyThis.as and then enter the following code: class ApplyThis { var str:String = "Defined in ApplyThis.as"; function conctStr(x:String):String { return x+x; function addStr():String { return str; Then, in a FLA or a separate ActionScript file, add the following code var obj:ApplyThis = new ApplyThis();...
  • Page 127: Operators

    In the following example, the keyword references the Circle object: this function Circle(radius:Number):Void { this.radius = radius; this.area = Math.PI*Math.pow(radius, 2); var myCircle = new Circle(4); trace(myCircle.area); In the following statement assigned to a frame inside a movie clip, the keyword this references the current movie clip.
  • Page 128 Operator Description Converts expression1 and expression2 to 32-bit unsigned & (bitwise AND) integers, and performs a Boolean AND operation on each bit of the integer parameters. Assigns expression1 the value of expression1& expression2. &= (bitwise AND assignment) Converts expression1 and expression2 to 32-bit integers, and <<...
  • Page 129 Evaluates expression1 , then expression2 , and so on. , (comma) Deprecated since Flash Player 5. Macromedia recommends that you (concatenation use the add (+) operator when creating content for Flash Player 5 or (strings)) later. This operator is not supported in Flash Player 8 or later.
  • Page 130 Performs a Boolean operation on the values of both expressions. && (logical AND) Deprecated since Flash Player 5. Macromedia recommends that you (logical AND) use the logical AND (&&) operator. Performs a logical AND (&&) operation in Flash Player 4.
  • Page 131 Operator Description Assigns expression1 the value of expression1 % expression2. (modulo assignment) Multiplies two numerical expressions. * (multiplication) Assigns expression1 the value of expression1 * expression2. (multiplication assignment) Creates a new, initially anonymous, object and calls the function identified by the constructor parameter. Deprecated since Flash Player 5.
  • Page 132: Addition Operator

    + addition operator expression1 + expression2 Adds numeric expressions or concatenates (combines) strings. If one expression is a string, all other expressions are converted to strings and concatenated. If both expressions are integers, the sum is an integer; if either or both expressions are floating-point numbers, the sum is a floating-point number.
  • Page 133: Addition Assignment Operator

    Usage 3: Variables associated with dynamic and input text fields have the data type String. In the following example, the variable is an input text field on the Stage. After a user deposit enters a deposit amount, the script attempts to add .
  • Page 134: [] Array Access Operator

    Example Usage 1: This example uses the operator with a string expression and sends "My name is Gilbert" to the Output panel. var x1:String = "My name is "; x1 += "Gilbert"; trace(x1); // output: My name is Gilbert Usage 2: The following example shows a numeric use of the addition assignment ( operator: var x:Number = 5;...
  • Page 135 Usage 2: Surround the index of each element with brackets ([]) to access it directly; you can add a new element to an array, or you can change or retrieve the value of an existing element. The first index in an array is always 0, as shown in the following example: var my_array:Array = new Array();...
  • Page 136 Example The following example shows two ways to create a new empty Array object; the first line uses brackets ([]): var my_array:Array = []; var my_array:Array = new Array(); The following example creates an array called and uses the trace() statement employee_array to send the elements to the Output panel.
  • Page 137: Assignment Operator

    = assignment operator expression1 = expression2 Assigns the value of (the parameter on the right) to the variable, array element, expression2 or property in . Assignment can be either by value or by reference. Assignment expression1 by value copies the actual value of and stores it in .
  • Page 138: Bitwise And Operator

    The following example uses assignment by reference to create a new object, and assign a reference to that object to the variable . Assignment by value is then used to assign mercury the value of to the property of the object: 3030 diameter...
  • Page 139: Bitwise And Assignment Operator

    Operands - A number. expression1 : Number - A number. expression2 : Number Returns - The result of the bitwise operation. Number Example The following example compares the bit representation of the numbers and returns 1 only if both bits at the same position are 1. In this ActionScript, you add 13 (binary 1101) and 11 (binary 1011) and return 1 only in the position where both numbers have a 1.
  • Page 140: Bitwise Left Shift Operator

    Operands - A number. expression1 : Number - A number. expression2 : Number Returns - The value of Number expression1 & expression2 Example The following example assigns the value var x:Number = 15; var y:Number = 9; trace(x &= y); // output: 9 See also &...
  • Page 141: Bitwise Left Shift And Assignment Operator

    Operands - A number or expression to be shifted left. expression1 : Number - A number or expression that converts to an integer from 0 to 31. expression2 : Number Returns - The result of the bitwise operation. Number Example In the following example, the integer 1 is shifted 10 bits to the left: The result x = 1 <<...
  • Page 142: Bitwise Not Operator

    Returns - The result of the bitwise operation. Number Example In the following example, you use the bitwise left shift and assignment ( ) operator to shift <<= all bits one space to the left: var x:Number = 4; // shift all bits one slot to the left. x <<= 1;...
  • Page 143 Floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value via the two's complement notation, with the minimum being -2147483648 or 0x800000000;...
  • Page 144: Bitwise Or Operator

    | bitwise OR operator expression1 | expression2 Converts to 32-bit unsigned integers, and returns a 1 in each expression1 expression2 bit position where the corresponding bits of either are 1. expression1 expression2 Floating-point numbers are converted to integers by discarding any digits after the decimal point.
  • Page 145: Bitwise Or Assignment Operator

    |= bitwise OR assignment operator expression1 |= expression2 Assigns the value of . For example, the following expression1 expression1 | expression2 two statements are equivalent: x |= y; x = x | y; Availability: ActionScript 1.0; Flash Player 5 Operands - A number or variable.
  • Page 146: Bitwise Right Shift Operator

    >> bitwise right shift operator expression1 >> expression2 Converts to 32-bit integers, and shifts all the bits in expression1 expression2 to the right by the number of places specified by the integer that results from expression1 the conversion of . Bits that are shifted off the right end are discarded. To expression2 preserve the sign of the original , the bits on the left are filled in with 0 if the...
  • Page 147: Bitwise Right Shift And Assignment Operator

    The following example shows the result of the previous example: var x:Number = 255; This is because 65535 decimal equals 1111111111111111 binary (sixteen 1s), 1111111111111111 binary shifted right by 8 bits is 11111111 binary, and 11111111 binary is 255 decimal. The most significant bit is 0 because the integers are 32-bit, so the fill bit is 0. The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right: var x:Number = -1 >>...
  • Page 148: Bitwise Unsigned Right Shift Operator

    Example The following commented code uses the bitwise right shift and assignment ( ) operator. >>= function convertToBinary(numberToConvert:Number):String { var result:String = ""; for (var i = 0; i<32; i++) { // Extract least significant bit using bitwise AND var lsb:Number = numberToConvert & 1; // Add this bit to the result string result = (lsb ? "1"...
  • Page 149: Bitwise Unsigned Right Shift And Assignment Operator

    Returns - The result of the bitwise operation. Number Example The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right: var x:Number = -1 >>> 1; trace(x); // output: 2147483647 This is because -1 decimal is 11111111111111111111111111111111 binary (thirty-two 1s), and when you shift right (unsigned) by 1 bit, the least significant (rightmost) bit is discarded, and the most significant (leftmost) bit is filled with a 0.
  • Page 150: Bitwise Xor Operator

    Example See also >>> bitwise unsigned right shift operator >>= bitwise right shift and assignment operator ^ bitwise XOR operator expression1 ^ expression2 Converts to 32-bit unsigned integers, and returns a 1 in each expression1 expression2 bit position where the corresponding bits in , but not both, are expression1 expression2...
  • Page 151: Bitwise Xor Assignment Operator

    // 1111 ^ 1001 = 0110 // returns 6 decimal (0110 binary) See also & bitwise AND operator &= bitwise AND assignment operator ^= bitwise XOR assignment operator | bitwise OR operator |= bitwise OR assignment operator ~ bitwise NOT operator ^= bitwise XOR assignment operator expression1 ^= expression2 Assigns...
  • Page 152: Block Comment Delimiter Operator

    /*..*/ block comment delimiter operator /* comment */ /* comment comment */ Indicates one or more lines of script comments. Any characters that appear between the opening comment tag ( ) and the closing comment tag ( ), are interpreted as a comment and ignored by the ActionScript interpreter.
  • Page 153: Comma Operator

    , comma operator (expression1 , expression2 [, expressionN... ]) Evaluates , then , and so on. This operator is primarily used with expression1 expression2 loop statement and is often used with the parentheses () operator. Availability: ActionScript 1.0; Flash Player 4 Operands - An expression to be evaluated.
  • Page 154: Add Concatenation (Strings) Operator

    () parentheses operator add concatenation (strings) operator string1 add string2 Deprecated since Flash Player 5. Macromedia recommends that you use the add ( ) operator when creating content for Flash Player 5 or later. This operator is not supported in Flash Player 8 or later.
  • Page 155: Conditional Operator

    Returns - The concatenated string. String See also + addition operator ?: conditional operator expression1 ? expression2 : expression3 Instructs Flash to evaluate , and if the value of , it returns expression1 expression1 true the value of ; otherwise it returns the value of expression2 expression3 Availability: ActionScript 1.0;...
  • Page 156: Decrement Operator

    -- decrement operator --expression expression-- A pre-decrement and post-decrement unary operator that subtracts 1 from the expression . The can be a variable, element in an array, or property of an object. The pre- expression decrement form of the operator ( ) subtracts 1 from and returns --expression...
  • Page 157: Division Assignment Operator

    Operands - A number or a variable that evaluates to a number. expression : Number Returns - The floating-point result of the operation. Number Example The following statement divides the current width and height of the Stage, and then displays the result in the Output panel.
  • Page 158: Dot Operator

    See also / division operator . dot operator object.property_or_methodinstancename.variable instancename.childinstanceinstancename.childinstance.variable Used to navigate movie clip hierarchies to access nested (child) movie clips, variables, or properties. The dot operator is also used to test or set the properties of an object or top-level class, execute a method of an object or top-level class, or create a data structure.
  • Page 159: Equality Operator

    The following example creates a new movie clip within the scope. Then a text field is _root created inside the movie clip called . The text field's property is set container_mc autoSize and then populated with the current date. true this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());...
  • Page 160: Eq Equality (Strings) Operator

    Example The following example uses the equality ( operator with an statement: var a:String = "David", b:String = "David"; if (a == b) { trace("David is David"); The following examples show the results of operations that compare mixed types: var x:Number = 5; var y:String = "5";...
  • Page 161: Greater Than Operator

    Compares two expressions for equality and returns a value of if the string representation true is equal to the string representation of otherwise. expression1 expression2 false Availability: ActionScript 1.0; Flash Player 4 Operands - Numbers, strings, or variables. expression1 : Object - Numbers, strings, or variables.
  • Page 162: Gt Greater Than (Strings) Operator

    Example In the following example, the greater than ( ) operator is used to determine whether the value > of the text field is greater than 90: score_txt if (score_txt.text>90) { trace("Congratulations, you win!"); } else { trace("sorry, try again"); gt greater than (strings) operator expression1 gt expression2 Deprecated since Flash Player 5.
  • Page 163: Ge Greater Than Or Equal To (Strings) Operator

    Availability: ActionScript 1.0; Flash Player 4 - In Flash 4, is a numeric operator. In Flash 5 > or later, the greater than or equal to ( ) operator is a comparison operator capable of >= handling various data types. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity.
  • Page 164: Increment Operator

    Returns - The result of the comparison. Boolean See also >= greater than or equal to operator ++ increment operator ++expression expression++ A pre-increment and post-increment unary operator that adds 1 to . The expression can be a variable, element in an array, or property of an object. The pre- expression increment form of the operator ( ) adds 1 to...
  • Page 165 Example The following example uses ++ as a post-increment operator to make a loop run five while times: var i:Number = 0; while (i++ < 5) { trace("this is execution " + i); /* output: this is execution 1 this is execution 2 this is execution 3 this is execution 4 this is execution 5...
  • Page 166: Inequality Operator

    != inequality operator expression1 != expression2 Tests for the exact opposite of the equality ( ) operator. If is equal to expression1 , the result is . As with the equality ( ) operator, the definition of equal expression2 false depends on the data types being compared, as illustrated in the following list: Numbers, strings, and Boolean values are compared by value.
  • Page 167: Inequality Operator

    == equality operator === strict equality operator <> inequality operator expression1 <> expression2 Deprecated since Flash Player 5. This operator has been deprecated. Macromedia recommends that you use the operator. != (inequality) Tests for the exact opposite of the equality ( ) operator.
  • Page 168: Instanceof Operator

    Operands - A number, string, Boolean value, variable, object, array, or expression1 : Object function. - A number, string, Boolean value, variable, object, array, or expression2 : Object function. Returns - The Boolean result of the comparison. Boolean See also != inequality operator instanceof operator object instanceof classConstructor...
  • Page 169: Less Than Operator

    < less than operator expression1 < expression2 Compares two expressions and determines whether is less than ; if expression1 expression2 so, the operator returns . If is greater than or equal to , the true expression1 expression2 operator returns . String expressions are evaluated using alphabetical order; all capital false letters come before lowercase letters.
  • Page 170: Lt Less Than (Strings) Operator

    lt less than (strings) operator expression1 lt expression2 Deprecated since Flash Player 5. This operator was deprecated in favor of the (less than) < operator. Compares and returns is less than expression1 expression2 true expression1 otherwise. expression2 false Availability: ActionScript 1.0; Flash Player 4 Operands - Numbers, strings, or variables.
  • Page 171: Le Less Than Or Equal To (Strings) Operator

    Returns - The Boolean result of the comparison. Boolean Example The following examples show results for both numeric and string true false comparisons: trace(5 <= 10); // true trace(2 <= 2); // true trace(10 <= 3); // false trace("Allen" <= "Jack"); // true trace("Jack"...
  • Page 172: Line Comment Delimiter Operator

    // line comment delimiter operator // comment Indicates the beginning of a script comment. Any characters that appear between the comment delimiter ( and the end-of-line character are interpreted as a comment and ignored by the ActionScript interpreter. Availability: ActionScript 1.0; Flash Player 1.0 Operands - Any characters.
  • Page 173: And Logical And Operator

    === strict equality operator and logical AND operator condition1 and condition2 Deprecated since Flash Player 5. Macromedia recommends that you use the logical AND operator. &&) Performs a logical AND ( operation in Flash Player 4. If both expressions evaluate to &&)
  • Page 174: Logical Not Operator

    Returns - A Boolean result of the logical operation. Boolean See also && logical AND operator ! logical NOT operator ! expression Inverts the Boolean value of a variable or expression. If is a variable with the expression absolute or converted value , the value of .
  • Page 175: Not Logical Not Operator

    not logical NOT operator not expression Deprecated since Flash Player 5. This operator was deprecated in favor of the ! (logical operator. NOT) Performs a logical NOT (!) operation in Flash Player 4. Availability: ActionScript 1.0; Flash Player 4 Operands - A variable or other expression that converts to a Boolean value.
  • Page 176: Or Logical Or Operator

    Example The following example uses the logical OR ( ) operator in an statement. The second expression evaluates to so the final result is true, true var x:Number = 10; var y:Number = 250; var start:Boolean = false; if ((x > 25) || (y > 200) || (start)) { trace("the logical OR test passed");...
  • Page 177: Modulo Operator

    Availability: ActionScript 1.0; Flash Player 4 Operands - An expression that evaluates to condition1 : Boolean true false - An expression that evaluates to condition2 : Boolean true false Returns - The result of the logical operation. Boolean See also || logical OR operator | bitwise OR operator % modulo operator...
  • Page 178: Modulo Assignment Operator

    The first trace returns 2, rather than 12/5 or 2.4, because the modulo ( ) operator returns only the remainder. The second trace returns 0.0999999999999996 instead of the expected 0.1 because of the limitations of floating-point accuracy in binary computing. See also / division operator round (Math.round method)
  • Page 179: Multiplication Operator

    * multiplication operator expression1 * expression2 Multiplies two numerical expressions. If both expressions are integers, the product is an integer. If either or both expressions are floating-point numbers, the product is a floating- point number. Availability: ActionScript 1.0; Flash Player 4 Operands - A number or expression that evaluates to a number.
  • Page 180: New Operator

    Returns - The value of . If an expression cannot be converted Number expression1 * expression2 to a numeric value, it returns (not a number). Example Usage 1: The following example assigns the value 50 to the variable var x:Number = 5; var y:Number = 10;...
  • Page 181: Ne Not Equal (Strings) Operator

    book1 = new Book("Confederacy of Dunces", 19.95); book2 = new Book("The Floating Opera", 10.95); The following example uses the operator to create an object with 18 elements: Array golfCourse_array = new Array(18); See also [] array access operator {} object initializer operator ne not equal (strings) operator expression1 ne expression2 Deprecated since Flash Player 5.
  • Page 182 = {name:"Macromedia, Inc.", address:"600 Townsend Street", city:"San Francisco", state:"California", zip:"94103", balance:"1000"}; for (i in account) { trace("account." + i + " = " + account[i]); The following example shows how array and object initializers can be nested within each other: var person:Object = {name:"Gina Vechio", children:["Ruby", "Chickie",...
  • Page 183: () Parentheses Operator

    The previous ActionScript example can also be written in the following format: var person:Object = new Object(); person.name = "Gina Vechio"; person.children = new Array("Ruby", "Chickie", "Puppa"); See also Object () parentheses operator (expression1 [, expression2]) ( expression1, expression2 ) function ( parameter1,..., parameterN ) Performs a grouping operation on one or more parameters, performs sequential evaluation of expressions, or surrounds one or more parameters and passes them as parameters to a function...
  • Page 184: Strict Equality Operator

    trace((2 + 3) * (4 + 5)); // Output: 45trace(2 + (3 * (4 + 5))); // // writes 29 trace(2 + (3 * (4 + 5))); // Output: 29trace(2+(3*4)+5); // writes 19 trace(2 + (3 * 4) + 5); // Output: 19 Usage 2: The following example evaluates the function , and then the function foo()
  • Page 185 - A number, string, Boolean value, variable, object, array, or expression2 : Object function. Returns - The Boolean result of the comparison. Boolean Example The comments in the following code show the returned value of operations that use the equality and strict equality operators: // Both return true because no conversion is done var string1:String = "5";...
  • Page 186: Strict Inequality Operator

    See also ! logical NOT operator != inequality operator !== strict inequality operator && logical AND operator || logical OR operator == equality operator !== strict inequality operator expression1 !== expression2 Tests for the exact opposite of the strict equality ( )operator.
  • Page 187: String Delimiter Operator

    trace(s1 === s2); // true trace(s1 === s3); // false trace(s1 === n); // false trace(s1 === b); // false trace(s1 !== s2); // false trace(s1 !== s3); // true trace(s1 !== n); // true trace(s1 !== b); // true See also ! logical NOT operator != inequality operator...
  • Page 188: Subtraction Operator

    - subtraction operator (Negation) -expression (Subtraction) expression1 - expression2 Used for negating or subtracting. Usage 1: When used for negating, it reverses the sign of the numerical . Usage 2: expression When used for subtracting, it performs an arithmetic subtraction on two numerical expressions, subtracting from .
  • Page 189: Type Operator

    Operands - A number or expression that evaluates to a number. expression1 : Number - A number or expression that evaluates to a number. expression2 : Number Returns - The result of the arithmetic operation. Number Example The following example uses the subtraction assignment ( operator to subtract 10 from 5 and assign the result to the variable var x:Number = 5;...
  • Page 190: Typeof Operator

    Availability: ActionScript 1.0; Flash Player 6 Operands - An identifier for a variable. A native data type, class name variableName : Object type that you have defined, or interface name. An identifier for a function. functionName An identifier for a function parameter. parameter Example Usage 1: The following example declares a public variable named...
  • Page 191: Void Operator

    Returns representation of the type of . The following table shows the String String expression results of the operator on each type of typeof expression Expression Type Result String string Movie clip movieclip Button object Text field object Number number Boolean boolean Object...
  • Page 192: Statements

    Statements Statements are language elements that perform or specify an action. For example, the return statement returns a result as a value of the function in which it executes. The if statement evaluates a condition to determine the next action that should be taken. The switch statement creates a branching structure for ActionScript statements.
  • Page 193 Statement Description Comprises a set of statements that you define to perform a certain function task. Permits implicit getting of properties associated with objects based on classes you have defined in external class files. Evaluates a condition to determine the next action in a SWF file. Specifies that a class must define all the methods declared in the implements interface (or interfaces) being implemented.
  • Page 194: Break Statement

    break statement break Appears within a loop ( ) or within a block of statements for..in do..while while associated with a particular case within a statement. When used in a loop, the switch break statement instructs Flash to skip the rest of the loop body, stop the looping action, and execute the statement following the loop statement.
  • Page 195: Case Statement

    case statement case expression : statement(s) Defines a condition for the statement. If the parameter equals the switch expression parameter of the statement using strict equality ( ), then Flash Player expression switch will execute statements in the parameter until it encounters a statement statement(s) break...
  • Page 196: Class Statement

    class statement [dynamic] class className [ extends superClass ] [ implements interfaceName[, interfaceName... ] ] { // class definition here 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 and properties that each invoice should have.
  • Page 197 Example The following example creates a class called Plant. The Plant constructor takes two parameters. // Filename Plant.as class Plant { // Define property names and types var leafType:String; var bloomSeason:String; // Following line is constructor // because it has the same name as the class function Plant(param_leafType:String, param_bloomSeason:String) { // Assign passed values to properties when new Plant object is created this.leafType = param_leafType;...
  • Page 198: Continue Statement

    In an external script file or in the Actions panel, use the operator to create an ImageLoader object. var jakob_mc:MovieClip = this.createEmptyMovieClip("jakob_mc", this.getNextHighestDepth()); var jakob:ImageLoader = new ImageLoader("http://www.helpexamples.com/flash/ images/image1.jpg", jakob_mc, {_x:10, _y:10, _alpha:70, _rotation:-5}); See also dynamic statement continue statement continue Jumps past all remaining statements in the innermost loop and starts the next iteration of the loop as if control had passed through to the end of the loop normally.
  • Page 199 In the following loop, causes the Flash interpreter to skip the rest of the do..while continue loop body and jump to the bottom of the loop, where the condition is tested: trace("example 2"); var i:Number = 0; do { if (i % 3 == 0) { i++;...
  • Page 200: Default Statement

    default statement default: statements Defines the default case for a statement. The statements execute if the switch expression parameter of the statement doesn't equal (using the strict equality [ ] operation) switch any of the parameters that follow the keywords for a given expression case switch...
  • Page 201: Delete Statement

    delete statement delete reference Destroys the object reference specified by the parameter, and returns if the reference true reference is successfully deleted; otherwise. This operator is useful for freeing memory false used by scripts. You can use the operator to remove references to objects. After all delete references to an object are removed, Flash Player removes the object and frees the memory used by that object.
  • Page 202: Do..while Statement

    Usage 3: The following example deletes an object property: var my_array:Array = new Array(); my_array[0] = "abc"; // my_array.length == 1 my_array[1] = "def"; // my_array.length == 2 my_array[2] = "ghi"; // my_array.length == 3 // my_array[2] is deleted, but Array.length is not changed delete my_array[2];...
  • Page 203: Dynamic Statement

    Availability: ActionScript 1.0; Flash Player 4 Parameters - The condition to evaluate. The within the block of condition:Boolean statement(s) code are executed as long as the parameter evaluates to condition true Example The following example uses a loop to evaluate whether a condition is do..while true, traces...
  • Page 204 Subclasses of dynamic classes are also dynamic. Be sure to specify the type when declaring an object, as in the following: var x:MyClass = new MyClass(); If you do not specify the type when declaring an object (as in the following) then the object is considered dynamic: var x = new MyClass();...
  • Page 205: Else Statement

    If you add an undeclared function, , an error is generated, as shown in the following dance example: trace(""); craig.dance = true; for (i in craig) { trace("craig." + i + " = " + craig[i]); /* output: **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 14: There is no property with the name 'dance'.
  • Page 206: Else If Statement

    Example In the following example, the condition is used to check whether the variable is else age_txt greater than or less than 18: if (age_txt.text>=18) { trace("welcome, user"); else { trace("sorry, junior"); userObject.minor = true; userObject.accessAllowed = false; In the following example, curly braces are not necessary because only one statement ({}) follows the...
  • Page 207: Extends Statement

    Example The following example uses statements to compare to a specified value: else if score_txt if (score_txt.text>90) { trace("A"); else if (score_txt.text>75) { trace("B"); else if (score_txt.text>60) { trace("C"); else { trace("F"); See also if statement extends statement class className extends otherClassName {} interface interfaceName extends otherInterfaceName {} Defines a class that is a subclass of another class;...
  • Page 208 Example In the following example, the Car class extends the Vehicle class so that all of its methods, properties, and functions are inherited. If your script instantiates a Car object, methods from both the Car class and the Vehicle class can be used. The following example shows the contents of a file called Vehicle.as, which defines the Vehicle class: class Vehicle {...
  • Page 209 The following example instantiates a Car object, calls a method that is defined in the Vehicle class ( ), then calls the method that is overridden by the Car class ( ), and start() stop() finally calls a method from the Car class ( activateCarAlarm() var myNewCar:Car = new Car(2, "Red", true);...
  • Page 210: For Statement

    for statement for(init; condition; next) { statement(s); Evaluates the (initialize) expression once and then starts a looping sequence. The init looping sequence begins by evaluating the expression. If the condition condition expression evaluates to true, is executed and the expression is evaluated. The statement next looping sequence then begins again with the evaluation of the...
  • Page 211: For..in Statement

    for..in statement for (variableIterant in object) { statement(s); Iterates over the properties of an object or elements in an array and executes the statement for each property or element. Methods of an object are not enumerated by the for..in action. Some properties cannot be enumerated by the action.
  • Page 212: Function Statement

    The following example uses to iterate over the elements of an array: for..in var myArray:Array = new Array("one", "two", "three"); for (var index in myArray) trace("myArray["+index+"] = " + myArray[index]); // output: myArray[2] = three myArray[1] = two myArray[0] = one The following example uses the operator with to iterate over a particular...
  • Page 213 You can use this statement to define a with the specified function functionname , and . When a script calls a function, the statements in the parameters statement(s) function's definition are executed. Forward referencing is permitted; within the same script, a function may be declared after it is called.
  • Page 214: Get Statement

    The following function creates a LoadVars object and loads params.txt into the SWF file. When the file successfully loads, traces: variables loaded var myLV:LoadVars = new LoadVars(); myLV.load("params.txt"); myLV.onLoad = function(success:Boolean) { trace("variables loaded"); get statement function get property () { // your statements here Permits implicit getting of properties associated with objects based on classes you have defined in external class files.
  • Page 215: If Statement

    Enter the following ActionScript in a frame on the Timeline: var giants:Team = new Team("San Fran", "SFO"); trace(giants.name); giants.name = "San Francisco"; trace(giants.name); /* output: San Fran San Francisco */ When you trace giants.name, you use the method to return the value of the property. See also addProperty (Object.addProperty method) if statement...
  • Page 216: Implements Statement

    The following example uses an statement to evaluate how long it takes a user to click the instance in a SWF file. If a user clicks the button more than 10 seconds after the submit_btn SWF file plays, the condition evaluates to and the message inside the curly braces ( true appears in a text field that's created at runtime (using...
  • Page 217: Import Statement

    import statement import className import packageName.* Lets you access classes without specifying their fully qualified names. For example, if you want to use a custom class macr.util.users.UserClass in a script, you must refer to it by its fully qualified name or import it; if you import it, you can refer to it by the class name: // before importing var myUser:macr.util.users.UserClass = new macr.util.users.UserClass();...
  • Page 218: Interface Statement

    interface statement interface InterfaceName [extends InterfaceName ] {} Defines an interface. An interface is similar to a class, with the following important differences: Interfaces contain only declarations of methods, not their implementation. That is, every class that implements an interface must provide an implementation for each method declared in the interface.
  • Page 219: Intrinsic Statement

    return 15; function n(x:Number):Number { return x * x; function o():Void { trace("o"); } // external script or Actions panel // script file mvar = new D(); trace(mvar.k()); // 15 trace(mvar.n(7)); // 49 trace(mvar.o()); // "o" interface Ic extends Ia { function p():Void;...
  • Page 220 keyword was created specifically to enable compile-time type checking for intrinsic built-in classes and objects, and global variables and functions. This keyword was not meant for general purpose use, but may be of some value to developers seeking to enable compile- time type checking with previously defined classes, especially if the classes are defined using ActionScript 1.0.
  • Page 221: Private Statement

    trace(myCircle.radius); trace(myCircle.getArea()); trace(myCircle.getDiameter()); See also class statement private statement class someClassName{ private var name; private function name() { // your statements here Specifies that a variable or function is available only to the class that declares or defines it or to subclasses of that class.
  • Page 222: Public Statement

    As the following code demonstrates, the constructor for the Beta class is able to access the property that is inherited from the Alpha class: privateProperty var myBeta:Beta = new Beta(); // Output: privateProperty is visible only within class and subclasses Attempts to access the variable from outside the Alpha class or a class that privateProperty...
  • Page 223: Return Statement

    jimmy.age = 27; jimmy.name = "jimmy"; If you change one of the public variables in the User class to a private variable, an error is generated when trying to access the property. See also private statement return statement return[expression] Specifies the value returned by a function. The statement evaluates return expression...
  • Page 224: Set Statement

    See also function statement set statement function set property(varName) { // your statements here Permits implicit setting of properties associated with objects based on classes you have defined in external class files. Using implicit set methods lets you modify the value of an object's property without accessing the property directly.
  • Page 225: Set Variable Statement

    gus.username = "Rupert"; trace(gus.username); // output: Rupert In the following example, the function executes when the value is traced. The function triggers only when you pass it a value, as shown in the line: gus.username = "Rupert"; See also get statement set variable statement set("variableString",expression) Assigns a value to a variable.
  • Page 226: Static Statement

    Parameters - A string that names a variable to hold the value of the variableString:String parameter. expression Example In the following example, you assign a value to a variable. You are assigning the value of to the variable. "Jakob" name set("name", "Jakob");...
  • Page 227: Super Statement

    Example The following example demonstrates how you can use the keyword to create a static counter that tracks how many instances of the class have been created. Because the variable is static, it will be created only once for the entire class, not for every numInstances single instance.
  • Page 228: Switch Statement

    Returns Both forms invoke a function. The function may return any value. Parameters - The method to invoke in the superclass. method:Function - Optional parameters that are passed to the superclass version of the method (syntax 1) argN or to the constructor function of the superclass (syntax 2). switch statement switch (expression){ caseClause:...
  • Page 229: Throw Statement

    trace("you pressed E or e"); break; case "I" : case "i" : trace("you pressed I or i"); break; default : trace("you pressed some other key"); break; Key.addListener(listenerObj); See also === strict equality operator throw statement throw expression Generates, or throws, an error that can be handled, or caught, by a code block.
  • Page 230: Try..catch..finally Statement

    try { checkEmail("Joe Smith"); catch (e) { error_txt.text = e.toString(); In the following example, a subclass of the Error class is thrown. The function checkEmail() is modified to throw an instance of that subclass. // Define Error subclass InvalidEmailError // In InvalidEmailError.as: class InvalidEmailAddress extends Error { var message = "Invalid email address.";...
  • Page 231 Encloses a block of code in which an error can occur, and then respond to the error. If any code in the code block throws an error (using the statement), control passes to the throw block, if one exists, and then to the code block, if one exists.
  • Page 232 myFunction = function () { trace("this is myFunction"); try { myInterval = setInterval(this, "myFunction", 1000); throw new Error("my error"); catch (myError:Error) { trace("error caught: "+myError); finally { clearInterval(myInterval); trace("error is cleared"); In the following example, the block is used to delete an ActionScript object, finally regardless of whether or not an error occurred.
  • Page 233 var returnVal = account.getAccountInfo(); if (returnVal != 0) { throw new Error("Error getting account information."); trace("success"); catch (e) { this.createTextField("status_txt", this.getNextHighestDepth(), 0, 0, 100, 22); status_txt.autoSize = true; status_txt.text = e.toString(); The following example shows a code block with multiple, typed code blocks.
  • Page 234: Var Statement

    Finally, in another AS file or FLA script, the following code invokes the method sortRows() on an instance of the RecordSet class. It defines blocks for each type of error that is catch thrown by sortRows() import RecordSet; var myRecordSet:RecordSet = new RecordSet(); try { myRecordSet.sortRows();...
  • Page 235: While Statement

    Parameters - An identifier. variableName:String Example The following ActionScript creates a new array of product names. adds an Array.push element onto the end of the array. If you want to use strict typing, it is essential that you use keyword. Without before , you get errors when you try to use product_array...
  • Page 236: With Statement

    Parameters - An expression that evaluates to condition:Boolean true false Example In the following example, the statement is used to test an expression. When the value while is less than 20, the value of is traced. When the condition is no longer , the loop true exits.
  • Page 237 To find the value of an identifier in the parameter, ActionScript starts at the statement(s) beginning of the scope chain specified by the and searches for the identifier at each object level of the scope chain, in a specific order. The scope chain used by the statement to resolve identifiers starts with the first item in with...
  • Page 238 The following code snippet shows how to write the preceding code without using a with statement. someOther_mc._x = 50; someOther_mc._y = 100; someOther_mc.gotoAndStop(3); statement is useful for accessing multiple items in a scope chain list simultaneously. with In the following example, the built-in object is placed at the front of the scope chain.
  • Page 239: Chapter 2: Actionscript Classes

    CHAPTER 2 ActionScript classes Documentation for ActionScript classes includes syntax, usage information, and code samples for methods, properties, and event handlers and listeners that belong to a specific class in ActionScript (as opposed to global functions or properties). The classes are listed alphabetically and include new classes in Flash Player 8 that are found in the flash.* packages.
  • Page 240: Isactive (Accessibility.isactive Method)

    Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Indicates whether an accessibility aid is currently static isActive() : Boolean active and the player is communicating with it. Causes all changes to _accProps (accessibility static updateProperties() :...
  • Page 241: Updateproperties (Accessibility.updateproperties Method)

    Returns - A Boolean value: if the Flash Player is communicating with an accessibility Boolean true aid (usually a screen reader); otherwise. false Example The following example checks whether an accessibility aid is currently active: if (Accessibility.isActive()) { trace ("An accessibility aid is currently active"); } else { trace ("There is currently no active accessibility aid");...
  • Page 242: Arguments

    See also isActive (Accessibility.isActive method) _accProps property hasAccessibility (capabilities.hasAccessibility property) arguments Object +-arguments public class arguments extends Object object is used to store and access a function's arguments. While inside the arguments function's body it can be accessed with the local variable.
  • Page 243: Callee (Arguments.callee Property)

    Method summary Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method) callee (arguments.callee property) public callee : Object A reference to the currently executing function.
  • Page 244: Array

    Array Object +-Array public dynamic class Array extends Object The Array class lets you access and manipulate indexed arrays. An indexed array is an object whose properties are identified by a number representing their position in the array. This number is referred to as the index. All indexed arrays are zero-based, which means that the first element in the array is [0], the second element is [1], and so on.
  • Page 245 Availability: ActionScript 1.0; Flash Player 5 - Became a native object in Flash Player 6, which improved performance significantly. Example In the following example, my_array contains four months of the year: var my_array:Array = new Array(); my_array[0] = "January"; my_array[1] = "February"; my_array[2] = "March";...
  • Page 246 Method summary Modifiers Signature Description Concatenates the elements specified in the concat([value:Object parameters with the elements in an array and creates ]) : Array a new array. Converts the elements in an array to strings, inserts join([delimiter:Stri the specified separator between the elements, ng]) : String concatenates them, and returns the resulting string.
  • Page 247: Array Constructor

    Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method) Array constructor public Array([value:Object]) 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 undefined values, or an array whose elements have specific values.
  • Page 248: Caseinsensitive (Array.caseinsensitive Property)

    if (my_array[0] == undefined) { // No quotation marks around undefined. trace("undefined is a special value, not a string"); } // Traces: undefined is a special value, not a string. Usage 3: The following example creates the new Array object with an initial go_gos_array length of 5:...
  • Page 249: Concat (Array.concat Method)

    concat (Array.concat method) public concat([value:Object]) : Array Concatenates the elements specified in the parameters with the elements in an array and creates a new array. If the parameters specify an array, the elements of that array are value concatenated, rather than the array itself. The array is left unchanged.
  • Page 250: Descending (Array.descending Property)

    trace(x_array[3]); // 1 trace(x_array[4]); // 2, 3 trace(x_array[5]); // 4 DESCENDING (Array.DESCENDING property) public static DESCENDING : Number In the sorting methods, this constant specifies descending sort order. You can use this constant for the parameter in the method. options sort() sortOn() The value of this constant is 2.
  • Page 251: Length (Array.length Property)

    trace(a_array.join(" + ")); // Displays Earth + Moon + Sun. The following example creates a nested array that contains two arrays. The first array has three elements: Europa, Io, and Callisto. The second array has two elements: Titan and Rhea. It joins the array by using a plus sign (+), but the elements within each nested array remain separated by commas (,).
  • Page 252: Numeric (Array.numeric Property)

    a,b,undefined,undefined,undefined,undefined,undefined,undefined,undefine // if the length property is now set to 5, the array will be truncated my_array.length = 5; trace(my_array.length); // my_array.length is updated to 5 trace(my_array); // outputs: a,b,undefined,undefined,undefined NUMERIC (Array.NUMERIC property) public static NUMERIC : Number In the sorting methods, this constant specifies numeric (instead of character-string) sorting. Including it in the parameter causes the methods to sort...
  • Page 253: Push (Array.push Method)

    Example The following code creates the array array containing four elements, and then myPets_array removes its last element: var myPets_array:Array = new Array("cat", "dog", "bird", "fish"); var popped:Object = myPets_array.pop(); trace(popped); // Displays fish. trace(myPets_array); // Displays cat,dog,bird. See also push (Array.push method) shift (Array.shift method) unshift (Array.unshift...
  • Page 254: Returnindexedarray

    RETURNINDEXEDARRAY (Array.RETURNINDEXEDARRAY property) public static RETURNINDEXEDARRAY : Number Specifies that a sort returns an indexed array as a result of calling the sort() sortOn() method. You can use this constant for the parameter in the options sort() sortOn() method. This provides preview or copy functionality by returning an array that represents the results of the sort and leaves the original array unmodified.
  • Page 255: Slice (Array.slice Method)

    Example The following code creates the array and then removes the first element from myPets_array the array and assigns it to the variable shifted var myPets_array:Array = new Array("cat", "dog", "bird", "fish"); var shifted:Object = myPets_array.shift(); trace(shifted); // Displays "cat". trace(myPets_array);...
  • Page 256: Sort (Array.sort Method)

    Example The following example creates an array of five pets and uses to populate a new array slice() that contains only four-legged pets: var myPets_array:Array = new Array("cat", "dog", "fish", "canary", "parrot"); var myFourLeggedPets_array:Array = new Array(); var myFourLeggedPets_array = myPets_array.slice(0, 2); trace(myFourLeggedPets_array);...
  • Page 257 Availability: ActionScript 1.0; Flash Player 5 - Array sorting option added in Flash Player 7. Parameters [optional] - A comparison function used to determine the sorting compareFunction:Object order of elements in an array. Given the elements A and B, the result of compareFunction can have one of the following three values: -1, if A should appear before B in the sorted sequence...
  • Page 258 Example Usage 1: The following example shows the use of with and without a value Array.sort() passed for options var fruits_array:Array = new Array("oranges", "apples", "strawberries", "pineapples", "cherries"); trace(fruits_array); // Displays oranges,apples,strawberries,pineapples,cherries. fruits_array.sort(); trace(fruits_array); // Displays apples,cherries,oranges,pineapples,strawberries. trace(fruits_array); // Writes apples,cherries,oranges,pineapples,strawberries.
  • Page 259: Sorton (Array.sorton Method)

    sortOn (Array.sortOn method) public sortOn(fieldName:Object, [options:Object]) : Array Sorts the elements in an array according to one or more fields in the array. The array should have the following characteristics: The array is an indexed array, not an associative array. Each element of the array holds an object with one or more properties.
  • Page 260 Availability: ActionScript 1.0; Flash Player 6 - The options parameter was added in Flash Player 7. The ability to use different options parameters on multiple sort fields was added in Flash Player 8. Parameters - A string that identifies a field to be used as the sort value, or an array in fieldName:Object which the first element represents the primary sort field, the second represents the secondary sort field, and so on.
  • Page 261 // Results: // john, omaha // john, kansas city // bob, omaha rec_array.sortOn(["name", "city"]); for(i=0; i<rec_array.length; i++){ trace(rec_array[i].name + ", " + rec_array[i].city); // Results: // bob, omaha // john, kansas city // john, omaha rec_array.sortOn(["city", "name" ]); for(i=0; i<rec_array.length; i++){ trace(rec_array[i].name + ", "...
  • Page 262: Splice (Array.splice Method)

    Performing a case-insensitive, descending sort on the password field produces the following results: my_array.sortOn("password", Array.CASEINSENSITIVE | Array.DESCENDING); // catchy // Bob // barb // abcd Performing a default sort on the age field produces the following results: my_array.sortOn("age"); // 29 // 3 // 35 // 4...
  • Page 263 Parameters - An integer that specifies the index of the element in the array where startIndex:Number the insertion or deletion begins. You can specify a negative integer to specify a position relative to the end of the array (for example, -1 is the last element of the array). [optional] - An integer that specifies the number of elements to be deleteCount:Number deleted.
  • Page 264: Tostring (Array.tostring Method)

    toString (Array.toString method) public toString() : String Returns a string value representing the elements in the specified Array object. Every element in the array, starting with index 0 and ending with the highest index, is converted to a concatenated string and separated by commas. To specify a custom separator, use the method.
  • Page 265: Unshift (Array.unshift Method)

    unshift (Array.unshift method) public unshift(value:Object) : Number Adds one or more elements to the beginning of an array and returns the new length of the array. Availability: ActionScript 1.0; Flash Player 5 Parameters - One or more numbers, elements, or variables to be inserted at the beginning value:Object of the array.
  • Page 266: Addlistener (Asbroadcaster.addlistener Method)

    Property summary Modifiers Property Description A list of references to all registered listener objects. _listeners:Array [read-only] Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Registers an object to receive event notification addListener(listener messages.
  • Page 267: Broadcastmessage (Asbroadcaster.broadcastmessage Method)

    Parameters - The name of the listener object that receives event notification. listenerObj:Object Returns - Although this method technically returns a Boolean value, in practical terms it Boolean returns because it always returns the value Void true Example The following example is an excerpt from the full example provided in the entry for the method.
  • Page 268: Initialize (Asbroadcaster.initialize Method)

    Parameters - The name of the event to broadcast. The name of any listener methods eventName:String must match this parameter in order to receive the broadcast event. You can pass arguments to the listener methods by including additional arguments after eventName Example The following example is an excerpt from the first full example provided in the entry for the...
  • Page 269 Parameters - An object to serve as a broadcasting object. obj:Object Example The following example creates a generic object, , and turns it into an event someObject broadcaster. The output should be the strings shown in the two statements: trace() var someObject:Object = new Object();...
  • Page 270: Listeners (Asbroadcaster._Listeners Property)

    _listeners (AsBroadcaster._listeners property) A list of references to all registered listener objects. This property is intended for internal use, and is not intended for direct manipulation. Objects are added to and removed from this array by calls to the methods. addListener() removelistener() You can call this property only from an object that was initialized by using the...
  • Page 271: Removelistener (Asbroadcaster.removelistener Method)

    // cycle through all listener objects, listing all properties of each listener object for (var i:Number = 0; i < numListeners; i++) { trace("Listener " + i + " listens for these events:"); for (item in someObject._listeners[i]) { trace (" " + item + ": " + someObject._listeners[i][item]); See also initialize (AsBroadcaster.initialize method) removeListener (AsBroadcaster.removeListener...
  • Page 272: Bevelfilter (Flash.filters.bevelfilter)

    See also addListener (AsBroadcaster.addListener method) initialize (AsBroadcaster.initialize method) BevelFilter (flash.filters.BevelFilter) Object +-flash.filters.BitmapFilter +-flash.filters.BevelFilter public class BevelFilter extends BitmapFilter The BevelFilter class lets you add a bevel effect to a variety of objects in Flash. A bevel effect gives objects such as buttons a three-dimensional look. You can customize the look of the bevel with different highlight and shadow colors, the amount of blur on the bevel, the angle of the bevel, the placement of the bevel, and a knockout effect.
  • Page 273 See also filters (MovieClip.filters property) cacheAsBitmap (MovieClip.cacheAsBitmap property) filters (Button.filters property) cacheAsBitmap (Button.cacheAsBitmap property) filters (TextField.filters property) applyFilter (BitmapData.applyFilter method) MovieClip Property summary Modifiers Property Description The angle of the bevel. angle:Number The amount of horizontal blur in pixels. blurX:Number The amount of vertical blur in pixels.
  • Page 274 Constructor summary Signature Description Initializes a new BevelFilter instance with the specified parameters. BevelFilter([distanc e:Number], [angle:Number], [highlightColor:Numb er], [highlightAlpha:Numb er], [shadowColor:Number] [shadowAlpha:Number] , [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [type:String], [knockout:Boolean]) Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : BevelFilter Methods inherited from class BitmapFilter...
  • Page 275: Angle (Bevelfilter.angle Property)

    angle (BevelFilter.angle property) public angle : Number The angle of the bevel. Valid values are from 0 to 360 degrees. The default value is 45. The angle value represents the angle of the theoretical light source falling on the object and determines the placement of the effect relative to the object.
  • Page 276: Bevelfilter Constructor

    BevelFilter constructor public BevelFilter([distance:Number], [angle:Number], [highlightColor:Number], [highlightAlpha:Number], [shadowColor:Number], [shadowAlpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [type:String], [knockout:Boolean]) Initializes a new BevelFilter instance with the specified parameters. Availability: ActionScript 1.0; Flash Player 8 Parameters [optional] - The offset distance of the bevel, in pixels (floating point). The distance:Number default value is 4.
  • Page 277 [optional] - The type of bevel. Valid values are , and type:String "inner" "outer" "full" The default value is "inner" [optional] - Applies a knockout effect ( ), which effectively makes the knockout:Boolean true object's fill transparent and reveals the background color of the document. The default value (no knockout).
  • Page 278: Blurx (Bevelfilter.blurx Property)

    rect.lineTo(w, h); rect.lineTo(0, h); rect.lineTo(0, 0); rect._x = 20; rect._y = 20; return rect; blurX (BevelFilter.blurX property) public blurX : Number The amount of horizontal blur in pixels. Valid values are from 0 to 255 (floating point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16, and 32) are optimized to render more quickly than other values.
  • Page 279: Blury (Bevelfilter.blury Property)

    var filter:BevelFilter = new BevelFilter(5, 45, 0xFFFF00, .8, 0x0000FF, .8, 20, 20, 1, 3, "inner", false); rect.filters = new Array(filter); return rect; blurY (BevelFilter.blurY property) public blurY : Number The amount of vertical blur in pixels. Valid values are from 0 to 255 (floating point). The default value is 4.
  • Page 280: Clone (Bevelfilter.clone Method)

    var filter:BevelFilter = new BevelFilter(5, 45, 0xFFFF00, .8, 0x0000FF, .8, 20, 20, 1, 3, "inner", false); rect.filters = new Array(filter); return rect; clone (BevelFilter.clone method) public clone() : BevelFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A new BevelFilter instance with all the same properties as flash.filters.BevelFilter...
  • Page 281 // >> highlightAlpha: 0.8 // >> highlightColor: 16776960 // >> angle: 45 // >> distance: 5 for(var i in clonedFilter) { trace(">> " + i + ": " + clonedFilter[i]); // >> clone: [type Function] // >> type: inner // >> blurY: 20 // >>...
  • Page 282: Distance (Bevelfilter.distance Property)

    distance (BevelFilter.distance property) public distance : Number The offset distance of the bevel. Valid values are in pixels (floating point). The default value is Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip instance distance ) when a user clicks it: rect...
  • Page 283: Highlightalpha (Bevelfilter.highlightalpha Property)

    highlightAlpha (BevelFilter.highlightAlpha property) public highlightAlpha : Number The alpha transparency value of the highlight color. The value is specified as a normalized value from 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. Availability: ActionScript 1.0;...
  • Page 284: Highlightcolor (Bevelfilter.highlightcolor Property)

    highlightColor (BevelFilter.highlightColor property) public highlightColor : Number The highlight color of the bevel. Valid values are in hexadecimal format, 0xRRGGBB. The default value is 0xFFFFFF. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip highlightColor instance ( ) when a user clicks it:...
  • Page 285: Knockout (Bevelfilter.knockout Property)

    knockout (BevelFilter.knockout property) public knockout : Boolean Applies a knockout effect ( ), which effectively makes the object's fill transparent and true reveals the background color of the document. The default value is (no knockout). false Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip instance...
  • Page 286: Quality (Bevelfilter.quality Property)

    quality (BevelFilter.quality property) public quality : Number The number of times to apply the filter. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality, and a value of 3 is high quality. Filters with lower values are rendered more quickly.
  • Page 287: Shadowalpha (Bevelfilter.shadowalpha Property)

    shadowAlpha (BevelFilter.shadowAlpha property) public shadowAlpha : Number The alpha transparency value of the shadow color. This value is specified as a normalized value from 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. Availability: ActionScript 1.0;...
  • Page 288: Shadowcolor (Bevelfilter.shadowcolor Property)

    shadowColor (BevelFilter.shadowColor property) public shadowColor : Number The shadow color of the bevel. Valid values are in hexadecimal format, 0xRRGGBB. The default value is 0x000000. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip shadowColor instance ( ) when a user clicks it:...
  • Page 289: Strength (Bevelfilter.strength Property)

    strength (BevelFilter.strength property) public strength : Number The strength of the imprint or spread. Valid values are from 0 to 255. The larger the value, the more color is imprinted and the stronger the contrast between the bevel and the background.
  • Page 290: Type (Bevelfilter.type Property)

    type (BevelFilter.type property) public type : String The type of bevel. Valid values are , and "inner" "outer" "full" Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip instance ( type rect when a user clicks it: import flash.filters.BevelFilter;...
  • Page 291: Bitmapdata (Flash.display.bitmapdata)

    BitmapData (flash.display.BitmapData) Object +-flash.display.BitmapData public class BitmapData extends Object The BitmapData class lets you create arbitrarily sized transparent or opaque bitmap images and manipulate them in various ways at runtime. This class lets you separate bitmap rendering operations from the Flash Player internal display updating routines.
  • Page 292 See also attachBitmap (MovieClip.attachBitmap method) beginBitmapFill (MovieClip.beginBitmapFill method) Property summary Modifiers Property Description [read- The height of the bitmap image in pixels. height:Number only] The rectangle that defines the size and location of the rectangle:Rectangle [read-only] bitmap image. Defines whether the bitmap image supports per-pixel transparent:Boolean [read-only] transparency.
  • Page 293 Method summary Modifiers Signature Description Takes a source image and a filter object and applyFilter(sourceBi generates the filtered image. tmap:BitmapData, sourceRect:Rectangle , destPoint:Point, filter:BitmapFilter) : Number Returns a new BitmapData object that is a clone of clone() : BitmapData the original instance with an exact copy of the contained bitmap.
  • Page 294 Modifiers Signature Description Draws a source image or movie clip onto a destination draw(source:Object, image, using the Flash Player vector renderer. [matrix:Matrix], [colorTransform:Colo rTransform], [blendMode:Object], [clipRect:Rectangle] , [smooth:Boolean]) : Void Fills a rectangular area of pixels with a specified fillRect(rect:Rectan ARGB color.
  • Page 295 Modifiers Signature Description Performs per-channel blending from a source image merge(sourceBitmap:B to a destination image. itmapData, sourceRect:Rectangle , destPoint:Point, redMult:Number, greenMult:Number, blueMult:Number, alphaMult:Number) : Void Fills an image with pixels representing random noise. noise(randomSeed:Num ber, [low:Number], [high:Number], [channelOptions:Numb er], [grayScale:Boolean]) : Void Remaps the color channel values in an image that has paletteMap(sourceBit...
  • Page 296 Modifiers Signature Description Performs a pixel dissolve either from a source image pixelDissolve(source to a destination image or by using the same image. Bitmap:BitmapData, sourceRect:Rectangle , destPoint:Point, [randomSeed:Number], [numberOfPixels:Numb er], [fillColor:Number]) : Number Scrolls an image by a certain (x, y) pixel amount. scroll(x:Number, y:Number) : Void Sets the color of a single pixel of a BitmapData object.
  • Page 297: Applyfilter (Bitmapdata.applyfilter Method)

    applyFilter (BitmapData.applyFilter method) public applyFilter(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, filter:BitmapFilter) : Number Takes a source image and a filter object and generates the filtered image. This method relies on the behavior of built-in filter objects, which have code to determine the destination rectangle that is affected by an input source rectangle. After a filter is applied, the resulting image can be larger than the input image.
  • Page 298 ColorMatrixFilter — This filter can use source and destination images that are either opaque or transparent. DisplacementMapFilter — This filter can use source and destination images that are either opaque or transparent, but the source and destination image formats must be the same.
  • Page 299: Bitmapdata Constructor

    BitmapData constructor public BitmapData(width:Number, height:Number, [transparent:Boolean], [fillColor:Number]) Creates a BitmapData object with a specified width and height. If you specify a value for the parameter, every pixel in the bitmap is set to that color. fillColor By default, the bitmap is created as opaque, unless you pass the value for the true parameter.
  • Page 300: Clone (Bitmapdata.clone Method)

    trace(bitmap_1.width); // 100 trace(bitmap_1.height); // 80 trace(bitmap_1.transparent); // true var bitmap_2:BitmapData = new BitmapData(width, height); trace(bitmap_2.width); // 100 trace(bitmap_2.height); // 80 trace(bitmap_2.transparent); // true clone (BitmapData.clone method) public clone() : BitmapData Returns a new BitmapData object that is a clone of the original instance with an exact copy of the contained bitmap.
  • Page 301 // >> paletteMap: [type Function] // >> hitTest: [type Function] // >> colorTransform: [type Function] // >> perlinNoise: [type Function] // >> getColorBoundsRect: [type Function] // >> floodFill: [type Function] // >> setPixel32: [type Function] // >> getPixel32: [type Function] // >>...
  • Page 302: Colortransform (Bitmapdata.colortransform Method)

    // >> height: 80 // >> width: 100 To further demonstrate the relationships between , and bitmap_1 bitmap_2 clonedBitmap the following example modifies the pixel value at (1, 1) of . Modifying pixel value at bitmap_1 (1, 1) demonstrates that the method creates an instance based on values of the clone() instance instead instead of refering to the values.
  • Page 303: Copychannel (Bitmapdata.copychannel Method)

    Example The following example shows how to apply a color transform operation to a BitmapData instance. import flash.display.BitmapData; import flash.geom.ColorTransform; var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC); var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); mc.onPress = function() { myBitmapData.colorTransform(myBitmapData.rectangle, new ColorTransform(1, 0, 0, 1, 255, 0, 0, 0));...
  • Page 304 Parameters - The input bitmap image to use. The source sourceBitmap:flash.display.BitmapData image can be a different BitmapData object or it can refer to the current BitmapData object. - The source Rectangle object. If you only want to sourceRect:flash.geom.Rectangle copy channel data from a smaller area within the bitmap, specify a source rectangle that is smaller than the overall size of the BitmapData object.
  • Page 305: Copypixels (Bitmapdata.copypixels Method)

    copyPixels (BitmapData.copyPixels method) public copyPixels(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, [alphaBitmap:BitmapData], [alphaPoint:Point], [mergeAlpha:Boolean]) : Void Provides a fast routine to perform pixel manipulation between images with no stretching, rotation, or color effects. This method copies a rectangular area of a source image to a rectangular area of the same size at the destination point of the destination BitmapData object.
  • Page 306: Dispose (Bitmapdata.dispose Method)

    Example The following example shows how to copy pixels from one BitmapData instance to another. import flash.display.BitmapData; import flash.geom.Rectangle; import flash.geom.Point; var bitmapData_1:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC); var bitmapData_2:BitmapData = new BitmapData(100, 80, false, 0x00FF0000); var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());...
  • Page 307: Draw (Bitmapdata.draw Method)

    var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); mc.onPress = function() { myBitmapData.dispose(); trace(myBitmapData.width); // -1 trace(myBitmapData.height); // -1 trace(myBitmapData.transparent); // -1 draw (BitmapData.draw method) public draw(source:Object, [matrix:Matrix], [colorTransform:ColorTransform], [blendMode:Object], [clipRect:Rectangle], [smooth:Boolean]) : Void Draws a source image or movie clip onto a destination image, using the Flash Player vector renderer.
  • Page 308 [optional] - A ColorTransform object that colorTransform:flash.geom.ColorTransform you use to adjust the color values of the bitmap. If no object is supplied, the bitmap image's colors will not be transformed. Set this parameter to a ColorTransform object created using the default constructor, if you must pass this parameter but you do new ColorTransform() not want to transform the image.
  • Page 309: Fillrect (Bitmapdata.fillrect Method)

    mc_1.onPress = function() { myBitmapData.draw(mc_2, myMatrix, myColorTransform, blendMode, myRectangle, smooth); function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; fillRect (BitmapData.fillRect method) public fillRect(rect:Rectangle, color:Number) : Void Fills a rectangular area of pixels with a specified ARGB color.
  • Page 310: Floodfill (Bitmapdata.floodfill Method)

    See also Rectangle (flash.geom.Rectangle) floodFill (BitmapData.floodFill method) public floodFill(x:Number, y:Number, color:Number) : Void Performs a flood fill operation on an image starting at an (x, y) coordinate and filling with a certain color. The method is similar to the paint bucket tool in various painting floodFill() programs.
  • Page 311: Generatefilterrect (Bitmapdata.generatefilterrect Method)

    generateFilterRect (BitmapData.generateFilterRect method) public generateFilterRect(sourceRect:Rectangle, filter:BitmapFilter) : Rectangle Determines the destination rectangle that the method call affects, given a applyFilter() BitmapData object, a source rectangle, and a filter object. For example, a blur filter normally affects an area larger than the size of the original image. A 100 x 200 pixel image that is being filtered by a default BlurFilter instance, where blurX = generates a destination rectangle of...
  • Page 312: Getcolorboundsrect (Bitmapdata.getcolorboundsrect Method)

    var filterRect:Rectangle = myBitmapData.generateFilterRect(myBitmapData.rectangle, filter); trace(filterRect); // (x=-31, y=-31, w=162, h=142) getColorBoundsRect (BitmapData.getColorBoundsRect method) public getColorBoundsRect(mask:Number, color:Number, [findColor:Boolean]) : Rectangle Determines a rectangular region that fully encloses all pixels of a specified color within the bitmap image. For example, if you have a source image and you want to determine the rectangle of the image that contains a nonzero alpha channel, you pass {mask: 0xFF000000, color: as parameters.
  • Page 313: Getpixel (Bitmapdata.getpixel Method)

    mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); myBitmapData.fillRect(new Rectangle(0, 0, 50, 40), 0x00FF0000); mc.onPress = function() { var colorBoundsRect:Rectangle = myBitmapData.getColorBoundsRect(0x00FFFFFF, 0x00FF0000, true); trace(colorBoundsRect); // (x=0, y=0, w=50, h=40) getPixel (BitmapData.getPixel method) public getPixel(x:Number, y:Number) : Number Returns an integer that reresents an RGB pixel value from a BitmapData object at a specific point (x, y).
  • Page 314: Getpixel32 (Bitmapdata.getpixel32 Method)

    var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); trace("0x" + myBitmapData.getPixel(0, 0).toString(16)); // 0xcccccc See also getPixel32 (BitmapData.getPixel32 method) getPixel32 (BitmapData.getPixel32 method) public getPixel32(x:Number, y:Number) : Number Returns an ARGB color value that contains alpha channel data and RGB data. This method is similar to the method, which returns an RGB color without alpha channel data.
  • Page 315: Height (Bitmapdata.height Property)

    var green:String = (myBitmapData.getPixel32(0, 0) >> 8 & 0xFF).toString(16); trace(">> green: " + green); // cc var blue:String = (myBitmapData.getPixel32(0, 0) & 0xFF).toString(16); trace(">> blue: " + blue); // ee trace("0x" + alpha + red + green + blue); // 0xffaaccee See also getPixel (BitmapData.getPixel method) height (BitmapData.height property)
  • Page 316 If an image is an opaque image, it is considered a fully opaque rectangle for this method. Both images must be transparent images to perform pixel-level hit testing that considers transparency. When you are testing two transparent images, the alpha threshold parameters control what alpha channel values, from 0 to 255, are considered opaque.
  • Page 317: Loadbitmap (Bitmapdata.loadbitmap Method)

    currPoint.x = mc_2._x; currPoint.y = mc_2._y; if(myBitmapData.hitTest(destPoint, 255, currPoint)) { trace(">> Collision at x:" + currPoint.x + " and y:" + currPoint.y); mc_2.startDrag(true); function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height);...
  • Page 318: Merge (Bitmapdata.merge Method)

    var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); merge (BitmapData.merge method) public merge(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, redMult:Number, greenMult:Number, blueMult:Number, alphaMult:Number) : Void Performs per-channel blending from a source image to a destination image. The following formula is used for each channel: new red dest = (red source * redMult) + (red dest * (256 - redMult) / 256; , and values are the multipliers used for each redMult...
  • Page 319: Noise (Bitmapdata.noise Method)

    var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth()); mc_2._x = 101; mc_1.onPress = function() { bitmapData_1.merge(bitmapData_2, new Rectangle(0, 0, 50, 40), new Point(25, 20), 128, 0, 0, 0); noise (BitmapData.noise method) public noise(randomSeed:Number, [low:Number], [high:Number], [channelOptions:Number], [grayScale:Boolean]) : Void Fills an image with pixels representing random noise. Availability: ActionScript 1.0;...
  • Page 320: Palettemap (Bitmapdata.palettemap Method)

    var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc_1.attachBitmap(bitmapData_1, this.getNextHighestDepth()); var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth()); mc_2._x = 101; mc_1.onPress = function() { bitmapData_1.merge(bitmapData_2, new Rectangle(0, 0, 50, 40), new Point(25, 20), 128, 0, 0, 0); mc_1.onPress = function() { bitmapData_1.noise(128, 0, 255, 1, true); mc_2.onPress = function() { bitmapData_2.noise(128);...
  • Page 321 You can use this method for a variety of effects such as general palette mapping (taking one channel and converting it to a false color image). You can also use this method for a variety of advanced color manipulation algorithms, such as gamma, curves, levels, and quantizing. Availability: ActionScript 1.0;...
  • Page 322: Perlinnoise (Bitmapdata.perlinnoise Method)

    for(var i = 0; i < 255; i++) { redArray[i] = 0x00000000; greenArray[i] = 0x00000000; redArray[0xFF] = 0x0000FF00; greenArray[0xFF] = 0x00FF0000; myBitmapData.paletteMap(myBitmapData, new Rectangle(0, 0, 100, 40), new Point(0, 0), redArray, greenArray, null, null); perlinNoise (BitmapData.perlinNoise method) public perlinNoise(baseX:Number, baseY:Number, numOctaves:Number, randomSeed:Number, stitch:Boolean, fractalNoise:Boolean, [channelOptions:Number], [grayScale:Boolean], [offsets:Object]) : Void Generates a Perlin noise image.
  • Page 323 - Frequency to use in the y direction. For example, to generate a noise that is baseY:Number sized for a 64 x 128 image, pass 128 for the value. baseY - Number of octaves or individual noise functions to combine to create numOctaves:Number this noise.
  • Page 324: Pixeldissolve (Bitmapdata.pixeldissolve Method)

    var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth()); mc_2._x = 101; mc_1.onPress = function() { var randomNum:Number = Math.floor(Math.random() * 10); bitmapData_1.perlinNoise(100, 80, 6, randomNum, false, true, 1, true, null); mc_2.onPress = function() { var randomNum:Number = Math.floor(Math.random() * 10); bitmapData_2.perlinNoise(100, 80, 4, randomNum, false, false, 15, false, null);...
  • Page 325 [optional] - The random seed to use to start the pixel dissolve. The randomSeed:Number default value is 0. [optional] - The default is 1/30 of the source area (width x height). numberOfPixels:Number [optional] - An ARGB color value that you use to fill pixels whose source fillColor:Number value equals its destination value.
  • Page 326: Rectangle (Bitmapdata.rectangle Property)

    rectangle (BitmapData.rectangle property) public rectangle : Rectangle [read-only] The rectangle that defines the size and location of the bitmap image. The top and left of the rectangle are 0; the width and height are equal to the width and height in pixels of the BitmapData object.
  • Page 327: Setpixel (Bitmapdata.setpixel Method)

    var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); myBitmapData.fillRect(new Rectangle(0, 0, 25, 80), 0x00FF0000); mc.onPress = function() { myBitmapData.scroll(25, 0); setPixel (BitmapData.setPixel method) public setPixel(x:Number, y:Number, color:Number) : Void Sets the color of a single pixel of a BitmapData object. The current alpha channel value of the image pixel is preserved during this operation.
  • Page 328: Setpixel32 (Bitmapdata.setpixel32 Method)

    function sketch() { myBitmapData.setPixel(_xmouse, _ymouse, 0x000000); See also getPixel (BitmapData.getPixel method) setPixel32 (BitmapData.setPixel32 method) setPixel32 (BitmapData.setPixel32 method) public setPixel32(x:Number, y:Number, color:Number) : Void Sets the color and alpha transparency values of a single pixel of a BitmapData object. This method is similar to the method;...
  • Page 329: Threshold (Bitmapdata.threshold Method)

    function sketch() { myBitmapData.setPixel32(_xmouse, _ymouse, 0x00000000); See also getPixel32 (BitmapData.getPixel32 method) setPixel (BitmapData.setPixel method) threshold (BitmapData.threshold method) public threshold(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, operation:String, threshold:Number, [color:Number], [mask:Number], [copySource:Boolean]) : Number Tests pixel values in an image against a specified threshold and sets pixels that pass the test to new color values.
  • Page 330 - A rectangle that defnes the area of the source image sourceRect:flash.geom.Rectangle to use as input. - The point within the destination image (the current destPoint:flash.geom.Point BitmapData instance) that corresponds to upper-left corner of the source rectangle. - One of the following comparison operators, passed as a String: "<", operation:String "<=", ">", ">=", "==", "!="...
  • Page 331: Transparent (Bitmapdata.transparent Property)

    transparent (BitmapData.transparent property) public transparent : Boolean [read-only] Defines whether the bitmap image supports per-pixel transparency. You can set this value only when you construct a BitmapData object by passing in for the parameter. true transparent After you create a BitmapData object, you can check whether it supports per-pixel transparency by seeing if the value of the property is transparent...
  • Page 332: Bitmapfilter (Flash.filters.bitmapfilter)

    BitmapFilter (flash.filters.BitmapFilter) Object +-flash.filters.BitmapFilter public class BitmapFilter extends Object The BitmapFilter base class for all image filter effects. The BevelFilter, BlurFilter, ColorMatrixFilter, ConvolutionFilter, DisplacementMapFilter, DropShadowFilter, GlowFilter, GradientBevelFilter, and GradientGlowFilter classes all extend the BitmapFilter class. You can apply these filter effects to bitmaps or MovieClip instances. You can create subclasses only for the preceding subclasses of the BitmapFilter class.
  • Page 333: Clone (Bitmapfilter.clone Method)

    clone (BitmapFilter.clone method) public clone() : BitmapFilter Returns a BitmapFilter object that is an exact copy of the original BitmapFilter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A BitmapFilter object. flash.filters.BitmapFilter BlurFilter (flash.filters.BlurFilter) Object +-flash.filters.BitmapFilter +-flash.filters.BlurFilter public class BlurFilter extends BitmapFilter The BlurFilter class lets you apply a blur visual effect to a variety of objects in Flash.
  • Page 334 A filter is not applied if the resulting image exceeds 2880 pixels in width or height. If, for example, you zoom in on a large movie clip with a filter applied, the filter is turned off if the resulting image exceeds the limit of 2880 pixels. Availability: ActionScript 1.0;...
  • Page 335: Blurfilter Constructor

    Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : BlurFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString...
  • Page 336: Blurx (Blurfilter.blurx Property)

    Example The following example instantiates a new constructor and applies it to a flat, BlurFilter rectangular shape: import flash.filters.BlurFilter; var rect:MovieClip = createRectangle(100, 100, 0x003366, "BlurFilterExample"); var blurX:Number = 30; var blurY:Number = 30; var quality:Number = 3; var filter:BlurFilter = new BlurFilter(blurX, blurY, quality); var filterArray:Array = new Array();...
  • Page 337: Blury (Blurfilter.blury Property)

    filter.blurX = 200; this.filters = new Array(filter); function createBlurFilterRectangle(name:String):MovieClip { var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); var w:Number = 100; var h:Number = 100; rect.beginFill(0x003366); rect.lineTo(w, 0); rect.lineTo(w, h); rect.lineTo(0, h); rect.lineTo(0, 0); rect._x = 20; rect._y = 20; var filter:BlurFilter = new BlurFilter(30, 30, 2); var filterArray:Array = new Array();...
  • Page 338: Clone (Blurfilter.clone Method)

    var w:Number = 100; var h:Number = 100; rect.beginFill(0x003366); rect.lineTo(w, 0); rect.lineTo(w, h); rect.lineTo(0, h); rect.lineTo(0, 0); rect._x = 20; rect._y = 20; var filter:BlurFilter = new BlurFilter(30, 30, 2); var filterArray:Array = new Array(); filterArray.push(filter); rect.filters = filterArray; return rect; clone (BlurFilter.clone method) public clone() : BlurFilter Returns a copy of this filter object.
  • Page 339 // >> clone: [type Function] // >> quality: 2 // >> blurY: 30 // >> blurX: 30 for(var i in clonedFilter) { trace(">> " + i + ": " + clonedFilter[i]); // >> clone: [type Function] // >> quality: 2 // >>...
  • Page 340: Quality (Blurfilter.quality Property)

    quality (BlurFilter.quality property) public quality : Number The number of times to perform the blur. Valid values are from 0-15. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality. A value of 3 is high quality and approximates a Gaussian blur.
  • Page 341: Boolean

    Boolean Object +-Boolean public class Boolean extends Object The Boolean class is a wrapper object with the same functionality as the standard JavaScript Boolean object. Use the Boolean class to retrieve the primitive data type or string representation of a Boolean object. You must use the constructor new to create a Boolean object before calling its Boolean()
  • Page 342: Boolean Constructor

    Method summary Modifiers Signature Description Returns the string representation ("true" or toString() : String "false") of the Boolean object. Returns true if the primitive value type of the valueOf() : Boolean specified Boolean object is true; false otherwise. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty...
  • Page 343: Tostring (Boolean.tostring Method)

    toString (Boolean.toString method) public toString() : String Returns the string representation ( ) of the Boolean object. "true" "false" Availability: ActionScript 1.0; Flash Player 5 Returns - A string; String "true" "false" Example This example creates a variable of type Boolean and uses to convert the value to a toString() string for use in the trace statement:...
  • Page 344: Button

    Button Object +-Button public class Button extends Object All button symbols in a SWF file are instances of the object. You can give a button an Button instance name in the Property inspector, and use the methods and properties of the Button class to manipulate buttons with ActionScript.
  • Page 345 Modifiers Property Description Instance name of the button specified by my_btn. _name:String A reference to the movie clip or object that contains _parent:MovieClip the current movie clip or object. Property (global); sets or retrieves the rendering _quality:String quality used for a SWF file. The rotation of the button, in degrees, from its original _rotation:Number orientation.
  • Page 346 Modifiers Property Description The y coordinate of the button relative to the local _y:Number coordinates of the parent movie clip. [read- Indicates the y coordinate of the mouse position _ymouse:Number only] relative to the button. The vertical scale of the button as applied from the _yscale:Number registration point of the button, expressed as a percentage.
  • Page 347: Alpha (Button._Alpha Property)

    Event Description Invoked when the pointer moves over a button area. onRollOver function() {} Invoked when a button receives keyboard focus. onSetFocus function(oldFocu s:Object) {} Method summary Modifiers Signature Description Returns the depth of the button instance. getDepth() : Number Methods inherited from class Object addProperty (Object.addProperty method),...
  • Page 348: Blendmode (Button.blendmode Property)

    blendMode (Button.blendMode property) public blendMode : Object The blend mode for the button. The blend mode affects the appearance of the button when it is in a layer above another object onscreen. Flash Player applies the property on each pixel of the button. Each pixel is blendMode composed of three constituent colors (red, green, and blue), and each constituent color has a value between 0x00 and 0xFF.
  • Page 349 Integer value String value Illustration Description Multiplies the values of the "multiply" button constituent colors by those of the background color, and then normalizes by dividing by 0xFF, resulting in darker colors. This is commonly used for shadows and depth effects. For example, if a constituent color (such as red) of one pixel in the button and the...
  • Page 350 Integer value String value Illustration Description Selects the darker of the "darken" constituent colors of the button and those of the background (the ones with the smaller values). This setting is commonly used for superimposing type. For example, if the button has a pixel with an RGB value of 0xFFCC33, and the background pixel has an RGB value of...
  • Page 351 Integer value String value Illustration Description Adds the values of the "add" constituent colors of the button to those of its background, and applies a ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects. For example, if the button has a pixel with an RGB value of 0xAAA633, and the background...
  • Page 352 Integer value String value Illustration Description Applies the alpha value of each "alpha" pixel of the button to the background. This requires the "layer" to be applied to blendMode a parent button. For example, in the illustration, the parent button, which is a white background, has blendMode = "layer"...
  • Page 353: Cacheasbitmap (Button.cacheasbitmap Property)

    If you attempt to set the property to any other value, Flash Player sets it to blendMode "normal" Availability: ActionScript 1.0; Flash Player 8 Example In the following example you can see that if you set the property to an integer, Flash Player converts the value to the corresponding string version: my_button.blendMode = 8;...
  • Page 354: Enabled (Button.enabled Property)

    In the following cases a button does not use a bitmap, even if the property is cacheAsBitmap set to and instead renders from vector data: true When the bitmap is too large, that is, greater than 2880 pixels in either direction When the bitmap fails to allocate memory (due to an out of memory error) property is best used with buttons that have mostly static content and cacheAsBitmap...
  • Page 355: Filters (Button.filters Property)

    //button code // the following function will not get called // because myBtn2_btn.enabled was set to false myBtn1_btn.onRelease = function() { trace( "you clicked : " + this._name ); myBtn2_btn.onRelease = function() { trace( "you clicked : " + this._name ); filters (Button.filters property) public filters : Array An indexed array containing each filter object currently associated with the button.
  • Page 356 To clear the filters for a button, set to an empty array ( filters At load time, if a button has an associated filter, it is marked to cache itself as a transparent bitmap. From this point forward, as long as the button has a valid filter list, the player caches the button as a bitmap.
  • Page 357: Focusrect (Button._Focusrect Property)

    _focusrect (Button._focusrect property) public _focusrect : Boolean A Boolean value that specifies whether a button has a yellow rectangle around it when it has keyboard focus. This property can override the global property. By default, the _focusrect property of a button instance is null; meaning, the button instance does not _focusrect override the global property.
  • Page 358: Height (Button._Height Property)

    Returns - The depth of the button instance. Number Example If you create on the Stage, you can trace their depth using the myBtn1_btn myBtn2_btn following ActionScript: trace(myBtn1_btn.getDepth()); trace(myBtn2_btn.getDepth()); If you load a SWF file called buttonMovie.swf into this document, you could trace the depth of a button, , inside that SWF file using another button in the main SWF file: myBtn4_btn...
  • Page 359: Highquality (Button._Highquality Property)

    _highquality (Button._highquality property) public _highquality : Number Deprecated since Flash Player 7. This property was deprecated in favor of Button._quality Specifies the level of anti-aliasing applied to the current SWF file. Specify 2 (best quality) to apply high quality with bitmap smoothing always on. Specify 1 (high quality) to apply anti- aliasing;...
  • Page 360: Name (Button._Name Property)

    Example The following example assigns a ContextMenu object to a button instance named . The ContextMenu object contains a single menu item (labeled "Save...") with an myBtn_btn associated callback handler function named doSave Add the button instance to the Stage and name it myBtn_btn. var menu_cm:ContextMenu = new ContextMenu();...
  • Page 361: Ondragout (Button.ondragout Handler)

    onDragOut (Button.onDragOut handler) onDragOut = function() {} Invoked when the mouse button is clicked over the button and the pointer then dragged outside of the button. You must define a function that executes when the event handler is invoked. Availability: ActionScript 1.0; Flash Player 6 Example The following example demonstrates how you can execute statements when the pointer is dragged off a button.
  • Page 362: Onkeydown (Button.onkeydown Handler)

    See also onDragOut (Button.onDragOut handler) onKeyDown (Button.onKeyDown handler) onKeyDown = function() {} Invoked when a button has keyboard focus and a key is pressed. The event onKeyDown handler is invoked with no parameters. You can use the Key.getAscii() methods to determine which key was pressed. You must define a function Key.getCode() that executes when the event handler is invoked.
  • Page 363: Onkeyup (Button.onkeyup Handler)

    onKeyUp (Button.onKeyUp handler) onKeyUp = function() {} Invoked when a button has input focus and a key is released. The event handler is onKeyUp invoked with no parameters. You can use the methods Key.getAscii() Key.getCode() to determine which key was pressed. Availability: ActionScript 1.0;...
  • Page 364: Onkillfocus (Button.onkillfocus Handler)

    onKillFocus (Button.onKillFocus handler) onKillFocus = function(newFocus:Object) {} Invoked when a button loses keyboard focus. The handler receives one onKillFocus parameter, , which is an object representing the new object receiving the focus. If no newFocus object receives the focus, contains the value newFocus null Availability: ActionScript 1.0;...
  • Page 365: Onrelease (Button.onrelease Handler)

    Example In the following example, a function that sends a trace() statement to the Output panel is defined for the handler: onPress my_btn.onPress = function () { trace ("onPress called"); onRelease (Button.onRelease handler) onRelease = function() {} Invoked when a button is released. You must define a function that executes when the event handler is invoked.
  • Page 366: Onrollout (Button.onrollout Handler)

    onRollOut (Button.onRollOut handler) onRollOut = function() {} Invoked when the pointer moves outside a button area. You must define a function that executes when the event handler is invoked. Availability: ActionScript 1.0; Flash Player 6 Example In the following example, a function that sends a trace() statement to the Output panel is defined for the handler: onRollOut...
  • Page 367: Parent (Button._Parent Property)

    Example The following example demonstrates how you can execute statements when the user of a SWF file moves focus from one button to another. Create two buttons, btn1_btn btn2_btn and enter the following ActionScript in Frame 1 of the Timeline: Selection.setFocus(btn1_btn);...
  • Page 368: Quality (Button._Quality Property)

    _quality (Button._quality property) public _quality : String Property (global); sets or retrieves the rendering quality used for a SWF file. Device fonts are always aliased and therefore are unaffected by the property. _quality property can be set to the following values: _quality "...
  • Page 369: Scale9Grid (Button.scale9Grid Property)

    Example The following example rotates two buttons on the Stage. Create two buttons on the Stage called . Make sure that is not perfectly round, so you can control_btn my_btn my_btn see it rotating. Then enter the following ActionScript in Frame 1 of the Timeline: var control_btn:Button;...
  • Page 370: Soundbuftime (Button._Soundbuftime Property)

    The area below the rectangle The area in the lower-right corner outside the rectangle You can think of the eight regions outside of the center (defined by the rectangle) as a picture frame that has special rules applied to it when the button is scaled. When the property is set and a button is scaled, all text and gradients are scaled scale9Grid...
  • Page 371: Tabenabled (Button.tabenabled Property)

    tabEnabled (Button.tabEnabled property) public tabEnabled : Boolean Specifies whether is included in automatic tab ordering. It is by default. my_btn undefined If the property is , the object is included in automatic tab tabEnabled undefined true ordering. If the property is also set to a value, the object is included in custom tab tabIndex ordering as well.
  • Page 372: Target (Button._Target Property)

    property may be a non-negative integer. The objects are ordered according to tabIndex their properties, in ascending order. An object with a value of precedes tabIndex tabIndex an object with a value of . If two objects have the same value, the one tabIndex tabIndex...
  • Page 373: Trackasmenu (Button.trackasmenu Property)

    Example Add a button instance to the Stage with an instance name and add the following code my_btn to Frame 1 of the Timeline: trace(my_btn._target); //displays /my_btn Select my_btn and convert it to a movie clip. Give the new movie clip an instance name .
  • Page 374: Url (Button._Url Property)

    Example The following example demonstrates how to track two buttons as a menu. Place two button instances on the Stage called . Enter the following ActionScript in the one_btn two_btn Timeline: var one_btn:Button; var two_btn:Button; one_btn.trackAsMenu = true; two_btn.trackAsMenu = true one_btn.onRelease = function() { trace("clicked one_btn");...
  • Page 375: Usehandcursor (Button.usehandcursor Property)

    var my_str:String = String(url_array.pop()); output_txt.text = unescape(my_str); When you click each button, the file name of the SWF containing the buttons displays in the Output panel. useHandCursor (Button.useHandCursor property) public useHandCursor : Boolean A Boolean value that, when set to (the default), indicates whether a pointing hand (hand true cursor) displays when the mouse rolls over a button.
  • Page 376: Width (Button._Width Property)

    Example Create two buttons on the Stage with the instance names myBtn1_btn myBtn2_btn Enter the following ActionScript in Frame 1 of the Timeline: myBtn1_btn.onRelease = function() { this._visible = false; trace("clicked "+this._name); myBtn2_btn.onRelease = function() { this._alpha = 0; trace("clicked "+this._name); Notice how you can still click after the alpha is set to 0.
  • Page 377: X (Button._X Property)

    _x (Button._x property) public _x : Number 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 corner of the Stage as (0, 0).
  • Page 378: Xscale (Button._Xscale Property)

    table_str += "<b>Stage</b>\t"+"x:"+_xmouse+"\t"+"y:"+_ymouse+newline; table_str += "<b>Button</ b>\t"+"x:"+my_btn._xmouse+"\t"+"y:"+my_btn._ymouse+newline; table_str += "</textformat>"; mouse_txt.htmlText = table_str; Mouse.addListener(mouseListener); See also _ymouse (Button._ymouse property) _xscale (Button._xscale property) public _xscale : Number The horizontal scale of the button as applied from the registration point of the button, expressed as a percentage.
  • Page 379: Ymouse (Button._Ymouse Property)

    The y coordinate of the button relative to the local coordinates of the parent movie clip. If a button is in the main Timeline, its coordinate system refers to the upper left corner of the Stage as (0, 0). If the button is inside another movie clip that has transformations, the button is in the local coordinate system of the enclosing movie clip.
  • Page 380: Yscale (Button._Yscale Property)

    mouse_txt.htmlText = table_str; Mouse.addListener(mouseListener); See also _xmouse (Button._xmouse property) _yscale (Button._yscale property) public _yscale : Number The vertical scale of the button as applied from the registration point of the button, expressed as a percentage. The default registration point is (0,0). Availability: ActionScript 1.0;...
  • Page 381: Camera

    Camera extends Object The Camera class is primarily for use with Macromedia Flash Communication Server, but can be used in a limited way without the server. The Camera class lets you capture video from a video camera attached to the computer that is running Macromedia Flash Player—for example, to monitor a video feed from a web camera...
  • Page 382 Modifiers Property Description A numeric value that specifies the amount of motion motionLevel:Number [read-only] required to invoke Camera.onActivity(true). The number of milliseconds between the time the motionTimeOut:Number [read-only] camera stops detecting motion and the time Camera.onActivity (false) is invoked. [read- A Boolean value that specifies whether the user has muted:Boolean only]...
  • Page 383: Activitylevel (Camera.activitylevel Property)

    Method summary Modifiers Signature Description Returns a reference to a Camera object for capturing static get([index:Number]) video. : Camera Sets the camera capture mode to the native mode that setMode([width:Numbe best meets the specified requirements. r], [height:Number], [fps:Number], [favorArea:Boolean]) : Void Specifies how much motion is required to invoke setMotionLevel([moti Camera.onActivity(true).
  • Page 384: Bandwidth (Camera.bandwidth Property)

    Example This example detects the amount of motion the camera detects using the activityLevel property and a ProgressBar instance. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
  • Page 385: Currentfps (Camera.currentfps Property)

    Example The following example changes the maximum amount of bandwidth used by the camera feed. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
  • Page 386: Fps (Camera.fps Property)

    Example The following example detects the rate in frames per second that the camera captures data, using the property and a ProgressBar instance. Create a new video instance by currentFps selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
  • Page 387: Get (Camera.get Method)

    Example The following example detects the rate in frames per second that the camera captures data, using the property and a ProgressBar instance. Create a new video instance by currentFps selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
  • Page 388 When a SWF file tries to access the camera returned by , Flash Player displays a Camera.get() Privacy dialog box that lets the user choose whether to allow or deny access to the camera. (Make sure your Stage size is at least 215 x 138 pixels; this is the minimum size Flash requires to display the dialog box.) When the user responds to this dialog box, the event handler returns an...
  • Page 389: Height (Camera.height Property)

    Returns - If is not specified, this method returns a reference to the default camera or, if Camera index 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 Flash Player Camera Settings panel.) If no cameras are available or installed, the method returns .
  • Page 390: Index (Camera.index Property)

    Example The following code displays the current width, height and FPS of a video instance in a Label component instance on the Stage. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
  • Page 391: Motionlevel (Camera.motionlevel Property)

    cameras_txt.html = true; cameras_txt.border = true; cameras_txt.wordWrap = true; cameras_txt.multiline = true; for (var i = 0; i<Camera.names.length; i++) { cameras_txt.htmlText += "<li><u><a href=\"asfunction:changeCamera,"+i+"\">"+Camera.names[i]+"</a></u></ li>"; function changeCamera(index:Number) { my_cam = Camera.get(index); my_video.attachVideo(my_cam); camera_lbl.text = my_cam.index+". "+my_cam.name; method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later.
  • Page 392 var motion_pb:mx.controls.ProgressBar; motion_pb.mode = "manual"; motion_pb.label = "Motion: %3%%"; var motionLevel_lbl:mx.controls.Label; // configure the NumericStepper component instance var motionLevel_nstep:mx.controls.NumericStepper; motionLevel_nstep.minimum = 0; motionLevel_nstep.maximum = 100; motionLevel_nstep.stepSize = 5; motionLevel_nstep.value = my_cam.motionLevel; // Continuously update the progress of the ProgressBar component instance to the activityLevel // of the current Camera instance, which is defined in my_cam this.onEnterFrame = function() {...
  • Page 393: Motiontimeout (Camera.motiontimeout Property)

    motionTimeOut (Camera.motionTimeOut property) public motionTimeOut : Number [read-only] The number of milliseconds between the time the camera stops detecting motion and the time is invoked. The default value is 2000 (2 seconds). Camera.onActivity (false) To set this value, use Camera.setMotionLevel() Availability: ActionScript 1.0;...
  • Page 394: Muted (Camera.muted Property)

    See also setMotionLevel (Camera.setMotionLevel method) onActivity (Camera.onActivity handler) muted (Camera.muted property) public muted : Boolean [read-only] A Boolean value that specifies whether the user has denied access to the camera ( ) or true allowed access ( ) in the Flash Player Privacy Settings panel. When this value changes, false is invoked.
  • Page 395: Name (Camera.name Property)

    name (Camera.name property) public name : String [read-only] A string that specifies the name of the current camera, as returned by the camera hardware. Availability: ActionScript 1.0; Flash Player 6 Example The following example displays the name of the default camera in a text field. In Windows, this name is the same as the device name listed in the Scanners and Cameras Control Panel.
  • Page 396: Onactivity (Camera.onactivity Handler)

    Calling the property requires an extensive examination of the hardware, and it Camera.names may take several seconds to build the array. In most cases, you can just use the default camera. The correct syntax is . To assign the return value to a variable, use syntax Camera.names like .
  • Page 397: Onstatus (Camera.onstatus Handler)

    Example The following example displays true or false in the Output panel when the camera starts or stops detecting motion: // Assumes a Video object named "myVideoObject" is on the Stage active_cam = Camera.get(); myVideoObject.attachVideo(active_cam); active_cam.setMotionLevel(10, 500); active_cam.onActivity = function(mode) trace(mode);...
  • Page 398: Quality (Camera.quality Property)

    Example The following ActionScript is used to display a message whenever the user allows or denies access to the camera: var my_cam:Camera = Camera.get(); var my_video:Video; my_video.attachVideo(my_cam); my_cam.onStatus = function(infoObj:Object) { switch (infoObj.code) { case 'Camera.Muted' : trace("Camera access is denied"); break;...
  • Page 399: Setmode (Camera.setmode Method)

    quality_nstep.minimum = 0; quality_nstep.maximum = 100; quality_nstep.stepSize = 5; quality_nstep.value = my_cam.quality; function changeQuality() { my_cam.setQuality(my_cam.bandwidth, quality_nstep.value); quality_nstep.addEventListener("change", changeQuality); See also setQuality (Camera.setQuality method) setMode (Camera.setMode method) public setMode([width:Number], [height:Number], [fps:Number], [favorArea:Boolean]) : Void Sets the camera capture mode to the native mode that best meets the specified requirements. If the camera does not have a native mode that matches all the parameters you pass, Flash selects a capture mode that most closely synthesizes the requested mode.
  • Page 400 [optional] - A Boolean value that specifies how to manipulate the width, favorArea:Boolean height, and frame rate if the camera does not have a native mode that meets the specified requirements. The default value is , which means that maintaining capture size is true favored;...
  • Page 401: Setmotionlevel (Camera.setmotionlevel Method)

    setMotionLevel (Camera.setMotionLevel method) public setMotionLevel([motionLevel:Number], [timeOut:Number]) : Void Specifies how much motion is required to invoke . Optionally Camera.onActivity(true) sets the number of milliseconds that must elapse without activity before Flash considers motion to have stopped and invokes Camera.onActivity(false) Video can be displayed regardless of the value of the sensitivity parameter. This parameter determines only when and under waht circumstances Camera.onActivity invoked -- not whether video is actually being captured or displayed.
  • Page 402: Setquality (Camera.setquality Method)

    Example The following example sends messages to the Output panel when video activity starts or stops. Change the motion sensitivity value of 30 to a higher or lower number to see how different values affect motion detection. // Assumes a Video object named "myVideoObject" is on the Stage active_cam = Camera.get();...
  • Page 403: Width (Camera.width Property)

    To specify that both bandwidth and quality are equally important, pass numeric values for both parameters. Flash will transmit video that achieves the specified quality and that doesn't exceed the specified bandwidth. If necessary, Flash will reduce the frame rate to maintain picture quality without exceeding the specified bandwidth.
  • Page 404: Capabilities (System.capabilities)

    You can send capabilities information using a HTTP method. The following POST example shows a server string for a computer that has MP3 support, 1600 x 1200 pixel resolution, is running Windows XP, and Flash Player 8 (8.0.0.0): A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=f&PR=t&SP=t& SB=f&DEB=t&V=WIN%208%2C0%2C0%2C0&M=Macromedia%20Windows& ActionScript classes...
  • Page 405 R=1600x1200&DP=72&COL=color&AR=1.0&OS=Windows%20XP& L=en&PT=External&AVD=f&LFD=f&WD=f" All properties of the object are read-only. System.capabilities Availability: ActionScript 1.0; Flash Player 6 Property summary Modifiers Property Description A Boolean value that specifies whether access to the static avHardwareDisable:Bo [read-only] user's camera and microphone has been olean administratively prohibited (true) or allowed (false).
  • Page 406 (true) or allowed (false). A string that indicates the manufacturer of Flash static manufacturer:String [read-only] Player, in the format "Macromedia OSName" (OSName could be "Windows", "Macintosh", "Linux", or "Other OS Name"). [read-only] A string that indicates the current operating system. static...
  • Page 407: Avhardwaredisable (Capabilities.avhardwaredisable Property)

    Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch...
  • Page 408: Hasaudio (Capabilities.hasaudio Property)

    Availability: ActionScript 1.0; Flash Player 6 Example The following example traces the value of this read-only property: trace(System.capabilities.hasAccessibility); See also isActive (Accessibility.isActive method) updateProperties (Accessibility.updateProperties method) hasAudio (capabilities.hasAudio property) public static hasAudio : Boolean [read-only] Specifies if the system has audio capabilities. A Boolean value that is if the player is true running on a system that has audio capabilities;...
  • Page 409: Hasembeddedvideo (Capabilities.hasembeddedvideo Property)

    hasEmbeddedVideo (capabilities.hasEmbeddedVideo property) public static hasEmbeddedVideo : Boolean [read-only] A Boolean value that is if the player is running on a system that supports embedded true video; otherwise. The server string is false Availability: ActionScript 1.0; Flash Player 6,0,65,0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasEmbeddedVideo);...
  • Page 410: Hasprinting (Capabilities.hasprinting Property)

    hasPrinting (capabilities.hasPrinting property) public static hasPrinting : Boolean [read-only] A Boolean value that is if the player is running on a system that supports printing; true otherwise. The server string is false Availability: ActionScript 1.0; Flash Player 6,0,65,0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasPrinting);...
  • Page 411: Hasstreamingaudio (Capabilities.hasstreamingaudio Property)

    hasStreamingAudio (capabilities.hasStreamingAudio property) public static hasStreamingAudio : Boolean [read-only] A Boolean value that is if the player can play streaming audio; otherwise. The true false server string is Availability: ActionScript 1.0; Flash Player 6,0,65,0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasStreamingAudio);...
  • Page 412: Isdebugger (Capabilities.isdebugger Property)

    isDebugger (capabilities.isDebugger property) public static isDebugger : Boolean [read-only] A Boolean value that indicates whether the player is an officially released version ( ) or a false special debugging version ( ). The server string is true Availability: ActionScript 1.0; Flash Player 6 Example The following example traces the value of this read-only property: trace(System.capabilities.isDebugger);...
  • Page 413: Localfilereaddisable (Capabilities.localfilereaddisable Property)

    Language German Hungarian Italian Japanese Korean Norwegian Other/unknown Polish Portuguese Russian Simplified Chinese zh-CN Spanish Swedish Traditional Chinese zh-TW Turkish Availability: ActionScript 1.0; Flash Player 6 - Behavior changed in Flash Player 7. Example The following example traces the value of this read-only property: trace(System.capabilities.language);...
  • Page 414: Manufacturer (Capabilities.manufacturer Property)

    The following example traces the value of this read-only property: trace(System.capabilities.localFileReadDisable); manufacturer (capabilities.manufacturer property) public static manufacturer : String [read-only] A string that indicates the manufacturer of Flash Player, in the format " " Macromedia OSName could be " ", " ", , or " "). The server...
  • Page 415: Playertype (Capabilities.playertype Property)

    Example The following example traces the value of this read-only property: trace(System.capabilities.pixelAspectRatio); playerType (capabilities.playerType property) public static playerType : String [read-only] A string that indicates the type of player. This property can have one of the following values: for the Flash StandAlone Player "StandAlone"...
  • Page 416: Screenresolutionx (Capabilities.screenresolutionx Property)

    The following example traces the value of this read-only property: trace(System.capabilities.screenResolutionY); serverString (capabilities.serverString property) public static serverString : String [read-only] A URL-encoded string that specifies values for each property. System.capabilities The following example shows a URL-encoded string: A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=f&PR=t&SP=t& SB=f&DEB=t&V=WIN%208%2C0%2C0%2C0&M=Macromedia%20Windows& R=1600x1200&DP=72&COL=color&AR=1.0&OS=Windows%20XP& ActionScript classes...
  • Page 417: Version (Capabilities.version Property)

    L=en&PT=External&AVD=f&LFD=f&WD=f Availability: ActionScript 1.0; Flash Player 6 Example The following example traces the value of this read-only property: trace(System.capabilities.serverString); version (capabilities.version property) public static version : String [read-only] A string containing the Flash Player platform and version information (for example, "WIN ).
  • Page 418 Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Constructor summary Signature Description Class Deprecated. Color(target:Object) Creates a Color object for the movie clip specified by the target_mc parameter. Method summary Modifiers Signature Description...
  • Page 419: Color Constructor

    Color constructor public Color(target:Object) Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class. Creates a Color object for the movie clip specified by the parameter. You can then target_mc use the methods of that Color object to change the color of the entire target movie clip. Availability: ActionScript 1.0;...
  • Page 420: Gettransform (Color.gettransform Method)

    Example The following code retrieves the RGB value for the Color object , converts the value my_color to a hexadecimal string, and assigns it to the variable. To see this code work, add a myValue movie clip instance to the Stage, and give it the instance name my_mc var my_color:Color = new Color(my_mc);...
  • Page 421: Setrgb (Color.setrgb Method)

    setRGB (Color.setRGB method) public setRGB(offset:Number) : Void Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class. Specifies an RGB color for a Color object. Calling this method overrides any previous settings. Color.setTransform() Availability: ActionScript 1.0;...
  • Page 422 is the offset for the green component (-255 to 255). is the percentage for the blue component (-100 to 100). is the offset for the blue component (-255 to 255). is the percentage for alpha (-100 to 100). is the offset for alpha (-255 to 255). You create a parameter as follows: colorTransformObject...
  • Page 423: Colormatrixfilter (Flash.filters.colormatrixfilter)

    See also Object ColorMatrixFilter (flash.filters.ColorMatrixFilter) Object +-flash.filters.BitmapFilter +-flash.filters.ColorMatrixFilter public class ColorMatrixFilter extends BitmapFilter The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel on the input image to produce a result with a new set of RGBA color and alpha values.
  • Page 424 This filter separates each source pixel into its red, green, blue, and alpha components as srcR, srcG, srcB, srcA. As a final step, it combines each color component back into a single pixel and writes out the result. The calculations are performed on unmultiplied color values. If the input graphic consists of premultiplied color values, those values are automatically converted into unmultiplied color values for this operation.
  • Page 425 listener.image = image; listener.onMouseMove = function() { var xPercent:Number = 1 - (_xmouse/Stage.width); var yPercent:Number = 1 - (_ymouse/Stage.height); var matrix:Array = new Array(); matrix = matrix.concat([yPercent, 0, 0, 0, 0]); // red matrix = matrix.concat([0, xPercent, 0, 0, 0]); // green matrix = matrix.concat([0, 0, xPercent, 0, 0]);...
  • Page 426: Clone (Colormatrixfilter.clone Method)

    Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : ColorMatrixFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString...
  • Page 427: Colormatrixfilter Constructor

    var filter:ColorMatrixFilter = new ColorMatrixFilter(matrix); trace("filter: " + filter.matrix); var clonedFilter:ColorMatrixFilter = filter.clone(); matrix = clonedFilter.matrix; matrix[2] = 1; clonedFilter.matrix = matrix; trace("clonedFilter: " + clonedFilter.matrix); ColorMatrixFilter constructor public ColorMatrixFilter(matrix:Array) Initializes a new ColorMatrixFilter instance with the specified parameters. Availability: ActionScript 1.0; Flash Player 8 Parameters - An array of 20 elements arranged in a 4 x 5 matrix.
  • Page 428: Colortransform (Flash.geom.colortransform)

    ColorTransform (flash.geom.ColorTransform) Object +-flash.geom.ColorTransform public class ColorTransform extends Object The ColorTransform class lets you mathematically adjust all of the color values in a movie clip. The color adjustment function or color transformation can be applied to all four channels: red, green, blue, and alpha transparency. When a ColorTransform object is applied to a movie clip, a new value for each color channel is calculated like this: New red value = (old red value *...
  • Page 429 Property summary Modifiers Property Description A decimal value that is multiplied by the alpha alphaMultiplier:Numb transparency channel value. A number from -255 to 255 that is added to the alpha alphaOffset:Number transparency channel value after it has been multiplied by the alphaMultiplier value. A decimal value that is multiplied by the blue channel blueMultiplier:Numbe value.
  • Page 430 Constructor summary Signature Description Creates a ColorTransform object for a display object with the ColorTransform([redM specified color channel values and alpha values. ultiplier:Number], [greenMultiplier:Num ber], [blueMultiplier:Numb er], [alphaMultiplier:Num ber], [redOffset:Number], [greenOffset:Number] [blueOffset:Number], [alphaOffset:Number] Method summary Modifiers Signature Description Applies a second, additive color transformation to the concat(second:ColorT movie clip.
  • Page 431: Alphamultiplier (Colortransform.alphamultiplier Property)

    alphaMultiplier (ColorTransform.alphaMultiplier property) public alphaMultiplier : Number A decimal value that is multiplied by the alpha transparency channel value. If you set the alpha transparency value of a movie clip directly by using the property, it affects the value of the property of that MovieClip._alpha alphaMultiplier...
  • Page 432: Alphaoffset (Colortransform.alphaoffset Property)

    alphaOffset (ColorTransform.alphaOffset property) public alphaOffset : Number A number from -255 to 255 that is added to the alpha transparency channel value after it has been multiplied by the value. alphaMultiplier Availability: ActionScript 1.0; Flash Player 8 Example The following example creates the ColorTransform object and adjusts its colorTrans value from 0 to -128.
  • Page 433: Blueoffset (Colortransform.blueoffset Property)

    Example The following example creates the ColorTransform object and adjusts its colorTrans value from 1 to .5. blueMultiplier import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans:ColorTransform = new ColorTransform(); trace(colorTrans.blueMultiplier); // 1 colorTrans.blueMultiplier = .5; trace(colorTrans.blueMultiplier); // .5 var rect:MovieClip = createRectangle(20, 80, 0x0000FF); var trans:Transform = new Transform(rect);...
  • Page 434: Colortransform Constructor

    colorTrans.blueOffset = 255; trace(colorTrans.blueOffset); // 255 var rect:MovieClip = createRectangle(20, 80, 0x000000); var trans:Transform = new Transform(rect); trans.colorTransform = colorTrans; function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip { scope = (scope == undefined) ? this : scope; var depth:Number = scope.getNextHighestDepth(); var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color);...
  • Page 435: Concat (Colortransform.concat Method)

    [optional] - The offset for the green color channel value (-255 to 255). greenOffset:Number The default value is 0. [optional] - The offset for the blue color channel value (-255 to 255). blueOffset:Number The default value is 0. [optional] - The offset for alpha transparency channel value (-255 to alphaOffset:Number 255).
  • Page 436 Example The following example concatenates the ColorTransform object colorTrans_2 resulting in a full red offset combined with a .5 alpha multiplier. colorTrans_1 import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans_1:ColorTransform = new ColorTransform(1, 1, 1, 1, 255, 0, 0, trace(colorTrans_1); // (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=255, greenOffset=0, blueOffset=0, alphaOffset=0) var colorTrans_2:ColorTransform = new ColorTransform(1, 1, 1, .5, 0, 0, 0,...
  • Page 437: Greenmultiplier (Colortransform.greenmultiplier Property)

    greenMultiplier (ColorTransform.greenMultiplier property) public greenMultiplier : Number A decimal value that is multiplied by the green channel value. Availability: ActionScript 1.0; Flash Player 8 Example The following example creates the ColorTransform object and adjusts its colorTrans from 1 to .5. greenMultiplier import flash.geom.ColorTransform;...
  • Page 438: Redmultiplier (Colortransform.redmultiplier Property)

    Example The following example creates the ColorTransform object and adjusts its colorTrans value from 0 to 255. greenOffset import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans:ColorTransform = new ColorTransform(); trace(colorTrans.greenOffset); // 0 colorTrans.greenOffset = 255; trace(colorTrans.greenOffset); // 255 var rect:MovieClip = createRectangle(20, 80, 0x000000); var trans:Transform = new Transform(rect);...
  • Page 439: Redoffset (Colortransform.redoffset Property)

    colorTrans.redMultiplier = .5; trace(colorTrans.redMultiplier); // .5 var rect:MovieClip = createRectangle(20, 80, 0xFF0000); var trans:Transform = new Transform(rect); trans.colorTransform = colorTrans; function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip { scope = (scope == undefined) ? this : scope; var depth:Number = scope.getNextHighestDepth(); var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color);...
  • Page 440: Rgb (Colortransform.rgb Property)

    scope = (scope == undefined) ? this : scope; var depth:Number = scope.getNextHighestDepth(); var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; rgb (ColorTransform.rgb property) public rgb : Number The RGB color value for a ColorTransform object. When you set this property, it changes the three color offset values ( redOffset , and...
  • Page 441: Tostring (Colortransform.tostring Method)

    var depth:Number = scope.getNextHighestDepth(); var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; toString (ColorTransform.toString method) public toString() : String Formats and returns a string that describes all of the properties of the ColorTransform object. Availability: ActionScript 1.0;...
  • Page 442: Contextmenu

    ContextMenu Object +-ContextMenu public dynamic class ContextMenu extends Object The ContextMenu class provides runtime control over the items in the Flash Player context menu, which appears when a user right-clicks (Windows) or Control-clicks (Macintosh) on Flash Player. You can use the methods and properties of the ContextMenu class to add custom menu items, control the display of the built-in context menu items (for example, Zoom In and Print), or create copies of menus.
  • Page 443 See also ContextMenuItem menu (Button.menu property) menu (MovieClip.menu property) menu (TextField.menu property) Property summary Modifiers Property Description An object that has the following Boolean properties: builtInItems:Object zoom, quality, play, loop, rewind, forward_back, and print. An array of ContextMenuItem objects. customItems:Array Properties inherited from class Object constructor (Object.constructor property),...
  • Page 444: Builtinitems (Contextmenu.builtinitems Property)

    Method summary Modifiers Signature Description Creates a copy of the specified ContextMenu object. copy() : ContextMenu Hides all built-in menu items (except Settings) in the hideBuiltInItems() : specified ContextMenu object. Void Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable...
  • Page 445: Contextmenu Constructor

    In the next example, a loop enumerates through all names and values of the built-in for..in menu items of the ContextMenu object, my_cm var my_cm:ContextMenu = new ContextMenu(); for(eachProp in my_cm.builtInItems) { var propName = eachProp; var propValue = my_cm.builtInItems[propName]; trace(propName + ": "...
  • Page 446: Copy (Contextmenu.copy Method)

    function itemHandler(obj, item) { //...put code here... trace("selected!"); this.menu = my_cm; When the user right-clicks or Control-clicks the Stage, the custom menu is displayed. See also menu (Button.menu property) onSelect (ContextMenu.onSelect handler) customItems (ContextMenu.customItems property) hideBuiltInItems (ContextMenu.hideBuiltInItems method) menu (MovieClip.menu property) menu (TextField.menu property) copy (ContextMenu.copy method)
  • Page 447: Customitems (Contextmenu.customitems Property)

    for (var i in my_cm.customItems) { trace("my_cm-> "+my_cm.customItems[i].caption); customItems (ContextMenu.customItems property) public customItems : Array 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 custom menu items.
  • Page 448: Hidebuiltinitems (Contextmenu.hidebuiltinitems Method)

    hideBuiltInItems (ContextMenu.hideBuiltInItems method) public hideBuiltInItems() : Void Hides all built-in menu items (except Settings) in the specified ContextMenu object. If the Flash Debug Player is running, the Debugging menu item shows, although it is dimmed for SWF files that don't have remote debugging enabled. This method hides only menu items that appear in the standard context menu;...
  • Page 449: Contextmenuitem

    Parameters - A reference to the object (movie clip, button, or selectable text field) that was item:Object under the mouse pointer when the Flash Player context menu was invoked and whose menu property is set to a valid ContextMenu object. - A reference to the ContextMenu object assigned to the property of item_menu:Object...
  • Page 450 Menu items are compared without regard to case, punctuation, or white space. None of the following words can appear in a custom item: Macromedia, Flash Player, or Settings.
  • Page 451: Caption (Contextmenuitem.caption Property)

    Constructor summary Signature Description Creates a new ContextMenuItem object that can be added to ContextMenuItem(caption:Str the ContextMenu.customItems array. ing, callbackFunction:Function, [separatorBefore:Boolean], [enabled:Boolean], [visible:Boolean]) Method summary Modifiers Signature Description Creates and returns a copy of the specified copy() : ContextMenuItem object. ContextMenuItem Methods inherited from class Object addProperty (Object.addProperty...
  • Page 452: Contextmenuitem Constructor

    ContextMenuItem constructor public ContextMenuItem(caption:String, callbackFunction:Function, [separatorBefore:Boolean], [enabled:Boolean], [visible:Boolean]) Creates a new ContextMenuItem object that can be added to the array. ContextMenu.customItems Availability: ActionScript 1.0; Flash Player 7 Parameters - A string that specifies the text associated with the menu item. caption:String - A function that you define, which is called when the menu callbackFunction:Function...
  • Page 453: Copy (Contextmenuitem.copy Method)

    copy (ContextMenuItem.copy method) public copy() : ContextMenuItem Creates and returns a copy of the specified ContextMenuItem object. The copy includes all properties of the original object. Availability: ActionScript 1.0; Flash Player 7 Returns - A ContextMenuItem object. ContextMenuItem Example This example creates a new ContextMenuItem object named with the caption original_cmi Pause and a callback handler set to the function...
  • Page 454: Onselect (Contextmenuitem.onselect Handler)

    Example The following example creates two new context menu items: Start and Stop. When the user selects Start, the number of milliseconds from when the SWF file started is traced. Start is then disabled in the menu. When Stop is selected, the number of milliseconds that have elapsed since the SWF file started is traced.
  • Page 455: Separatorbefore (Contextmenuitem.separatorbefore Property)

    Parameters - A reference to the object (movie clip, Timeline, button, or selectable text field) obj:Object on which the user right or Control clicked. - A reference to the selected ContextMenuItem object. menuItem:Object Example The following example determines over what type of object the context menu was invoked. var my_cmi:ContextMenu = new ContextMenu();...
  • Page 456: Visible (Contextmenuitem.visible Property)

    Example This example creates three menu items, labeled Open, Save, and Print. A separator bar divides the Save and Print items. The menu items are then added to the ContextMenu object's array. Finally, the menu is attached to the current Timeline of the SWF file. customItems var my_cm:ContextMenu = new ContextMenu();...
  • Page 457: Convolutionfilter (Flash.filters.convolutionfilter)

    stopMenuItem.visible = false; function startHandler(obj, item) { trace("Starting... "+getTimer()+"ms"); startMenuItem.visible = false; stopMenuItem.visible = true; this.menu = my_cm; ConvolutionFilter (flash.filters.ConvolutionFilter) Object +-flash.filters.BitmapFilter +-flash.filters.ConvolutionFilter public class ConvolutionFilter extends BitmapFilter The ConvolutionFilter class applies a matrix convolution filter effect. A convolution combines pixels in the input image with neighboring pixels to produce an image. A wide variety of imaging operations can be achieved through convolutions, including blurring, edge detection, sharpening, embossing, and beveling.
  • Page 458 A matrix convolution is based on an n x m matrix, which describes how a given pixel value in the input image is combined with its neighboring pixel values to produce a resulting pixel value. Each result pixel is determined by applying the matrix to the corresponding source pixel and its neighboring pixels.
  • Page 459 Property summary Modifiers Property Description The alpha transparency value of the substitute color. alpha:Number Bias to add to the result of the matrix transformation. bias:Number Indicates whether the image should be clamped. clamp:Boolean The hexadecimal color to substitute for pixels that are color:Number off the source image.
  • Page 460: Alpha (Convolutionfilter.alpha Property)

    Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : ConvolutionFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString...
  • Page 461: Bias (Convolutionfilter.bias Property)

    myBitmapData.noise(128, 0, 255, 1 | 2 | 4 | 8, false); mc.onPress = function() { myBitmapData.applyFilter(myBitmapData, new Rectangle(0, 0, 98, 78), new Point(2, 2), filter); bias (ConvolutionFilter.bias property) public bias : Number Bias to add to the result of the matrix transformation. The default is 0. Availability: ActionScript 1.0;...
  • Page 462: Clone (Convolutionfilter.clone Method)

    Example The following example changes the property of from its default value of clamp filter true false import flash.filters.ConvolutionFilter; import flash.display.BitmapData; import flash.geom.Rectangle; import flash.geom.Point; var clamp:Boolean = false; var filter:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 0, true, clamp, 0x00FF00, 1);...
  • Page 463 var filter_1:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9); var filter_2:ConvolutionFilter = filter_1; var clonedFilter:ConvolutionFilter = filter_1.clone(); trace(filter_1 == filter_2); // true trace(filter_1 == clonedFilter); // false for(var i in filter_1) { trace(">> " + i + ": " + filter_1[i]); // >>...
  • Page 464: Color (Convolutionfilter.color Property)

    filter_1.bias = 20; trace(filter_1.bias); // 20 trace(filter_2.bias); // 20 trace(clonedFilter.bias); // 0 color (ConvolutionFilter.color property) public color : Number The hexadecimal color to substitute for pixels that are off the source image. This is an RGB value with no alpha component. The default is 0. Availability: ActionScript 1.0;...
  • Page 465: Convolutionfilter Constructor

    ConvolutionFilter constructor public ConvolutionFilter(matrixX:Number, matrixY:Number, matrix:Array, [divisor:Number], [bias:Number], [preserveAlpha:Boolean], [clamp:Boolean], [color:Number], [alpha:Number]) Initializes a ConvolutionFilter instance with the specified parameters. Availability: ActionScript 1.0; Flash Player 8 Parameters - The x dimension of the matrix (the number of columns in the matrix). matrixX:Number The default value is 0.
  • Page 466: Divisor (Convolutionfilter.divisor Property)

    The following example creates a ConvolutionFilter object with the four required parameters , and matrixX matrixY matrix divisor import flash.filters.ConvolutionFilter; import flash.display.BitmapData; var matrixX:Number = 3; var matrixY:Number = 3; var matrix:Array = [1, 1, 1, 1, 1, 1, 1, 1, 1]; var divisor:Number = 9;...
  • Page 467: Matrix (Convolutionfilter.matrix Property)

    mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); myBitmapData.noise(128); mc.onPress = function() { var newDivisor:Number = 6; filter.divisor = newDivisor; myBitmapData.applyFilter(myBitmapData, myBitmapData.rectangle, new Point(0, 0), filter); matrix (ConvolutionFilter.matrix property) public matrix : Array An array of values used for matrix transformation; returns a copy. The number of items in the array must equal matrixX*matrixY property cannot be changed by directly modifying the values (for example,...
  • Page 468: Matrixx (Convolutionfilter.matrixx Property)

    matrixX (ConvolutionFilter.matrixX property) public matrixX : Number The x dimension of the matrix (the number of columns in the matrix). The default value is 0. Availability: ActionScript 1.0; Flash Player 8 Example The following example displays the property of matrixX filter import flash.filters.ConvolutionFilter;...
  • Page 469: Customactions

    Example The following example changes the property of from its default value preserveAlpha filter true false import flash.filters.ConvolutionFilter; import flash.display.BitmapData; var preserveAlpha:Boolean = false; var filter:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 0, preserveAlpha); var myBitmapData:BitmapData = new BitmapData(100, 80, true, 0xCCFF0000);...
  • Page 470: Get (Customactions.get Method)

    Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Reads the contents of the custom action XML static get(name:String) : definition file named name. String Installs a new custom action XML definition file static install(name:String,...
  • Page 471: Install (Customactions.install Method)

    Parameters - The name of the custom action definition to retrieve. name:String Returns - If the custom action XML definition is located, returns a string; otherwise, returns String undefined Example The following example lists the custom actions in a ComboBox instance, and gets the custom action when a Button instance is clicked.
  • Page 472 Parameters - The name of the custom action definition to install. name:String - The text of the XML definition to install. data:String Returns - A Boolean value of if an error occurs during installation; otherwise, a value Boolean false is returned to indicate that the custom action has been successfully installed. true Example The following example installs information into the Actions panel from an XML file.
  • Page 473: List (Customactions.list Method)

    list (CustomActions.list method) public static list() : Array Returns an Array object containing the names of all the custom actions that are registered with the Flash authoring tool. The elements of the array are simple names, without the .xml file extension, and without any directory separators (for example, ":", "/", or "\"). If there are no registered custom actions, returns a zero-length array.
  • Page 474: Uninstall (Customactions.uninstall Method)

    uninstall (CustomActions.uninstall method) public static uninstall(name:String) : Boolean Removes the Custom Actions XML definition file named name The name of the definition file must be a simple filename, without the .xml file extension, and without any directory separators (':', '/' or '\'). Availability: ActionScript 1.0;...
  • Page 475: Date

    Date Object +-Date public class Date extends Object The Date class lets you retrieve date and time values relative to universal time (Greenwich mean time, now called universal time or UTC) or relative to the operating system on which Flash Player is running. The methods of the Date class are not static but apply only to the individual Date object specified when the method is called.
  • Page 476 Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Constructor summary Signature Description Constructs a new Date object that holds the specified date and time. Date([yearOrTimevalu e:Number], [month:Number], [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number]...
  • Page 477 Method summary Modifiers Signature Description Returns the day of the month (an integer from 1 to 31) getDate() : Number of the specified Date object according to local time. Returns the day of the week (0 for Sunday, 1 for getDay() : Number Monday, and so on) of the specified Date object according to local time.
  • Page 478 Modifiers Signature Description Returns the minutes (an integer from 0 to 59) of the getUTCMinutes() : specified Date object, according to universal time. Number Returns the month (0 [January] to 11 [December]) of getUTCMonth() : the specified Date object, according to universal time. Number Returns the seconds (an integer from 0 to 59) of the getUTCSeconds() :...
  • Page 479 Modifiers Signature Description Sets the year for the specified Date object (my_date) setUTCFullYear(year: in universal time and returns the new time in Number, milliseconds. [month:Number], [date:Number]) : Number Sets the hour for the specified Date object in universal setUTCHours(hour:Num time and returns the new time in milliseconds. ber, [minute:Number], [second:Number],...
  • Page 480: Date Constructor

    Modifiers Signature Description Returns the number of milliseconds between midnight static UTC(year:Number, on January 1, 1970, universal time, and the time month:Number, specified in the parameters. [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number] ) : Number Returns the number of milliseconds since midnight valueOf() : Number January 1, 1970, universal time, for this Date.
  • Page 481 In the third line, a Date object is created with year, month, and date parameters passed to it, resulting in the time 09:30:15 GMT (+ 0 milliseconds) March 6, 1965. Note that since the year parameter is specified as a two-digit integer, it is interpreted as 1965. In the fourth line, only one parameter is passed, which is a time value representing the number of milliseconds before or after 0:00:00 GMT January 1, 1970;...
  • Page 482: Getdate (Date.getdate Method)

    See also getMonth (Date.getMonth method) getDate (Date.getDate method) getFullYear (Date.getFullYear method) getDate (Date.getDate method) public getDate() : Number Returns the day of the month (an integer from 1 to 31) of the specified Date object according to local time. Local time is determined by the operating system on which Flash Player is running.
  • Page 483: Getfullyear (Date.getfullyear Method)

    Example The following example creates a new Date object and uses to determine the current getDay() day of the week var dayOfWeek_array:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); var today_date:Date = new Date(); var day_str:String = dayOfWeek_array[today_date.getDay()]; trace("Today is "+day_str);...
  • Page 484: Getmilliseconds (Date.getmilliseconds Method)

    Example The following example uses the constructor to create a Date object based on the current time and uses the method to display hour values from that object: getHours() var my_date:Date = new Date(); trace(my_date.getHours()); var my_date:Date = new Date(); var hourObj:Object = getHoursAmPm(my_date.getHours());...
  • Page 485: Getminutes (Date.getminutes Method)

    getMinutes (Date.getMinutes method) public getMinutes() : Number 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. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer.
  • Page 486: Getseconds (Date.getseconds Method)

    var monthNames_array:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); return monthNames_array[month]; getSeconds (Date.getSeconds method) public getSeconds() : Number Returns the seconds (an integer from 0 to 59) of the specified Date object, according to local time.
  • Page 487: Gettimezoneoffset (Date.gettimezoneoffset Method)

    getTimezoneOffset (Date.getTimezoneOffset method) public getTimezoneOffset() : Number Returns the difference, in minutes, between the computer's local time and universal time. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer. Number Example The following example returns the difference between the local daylight saving time for San Francisco and universal time.
  • Page 488: Getutcday (Date.getutcday Method)

    See also getDate (Date.getDate method) getUTCDay (Date.getUTCDay method) public getUTCDay() : Number Returns the day of the week (0 for Sunday, 1 for Monday, and so on) of the specified Date object, according to universal time. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer.
  • Page 489: Getutchours (Date.getutchours Method)

    Example The following example creates a new Date object and uses Date.getUTCFullYear() . The value returned by may differ from the Date.getFullYear() Date.getUTCFullYear() value returned by if today's date is December 31 or January 1 Date.getFullYear() depending on the relationship between your local time zone and universal time. var today_date:Date = new Date();...
  • Page 490: Getutcmilliseconds (Date.getutcmilliseconds Method)

    getUTCMilliseconds (Date.getUTCMilliseconds method) public getUTCMilliseconds() : Number Returns the milliseconds (an integer from 0 to 999) of the specified Date object, according to universal time. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer. Number Example The following example creates a new Date object and uses to return getUTCMilliseconds() the milliseconds value from the Date object.
  • Page 491: Getutcseconds (Date.getutcseconds Method)

    Returns - An integer. Number Example The following example creates a new Date object and uses Date.getUTCMonth() . The value returned by can differ from the value Date.getMonth() Date.getUTCMonth() returned by if today's date is the first or last day of a month depending on Date.getMonth() the relationship between your local time zone and universal time.
  • Page 492: Getyear (Date.getyear Method)

    Returns - An integer. Number Example The following example creates a new Date object and uses Date.getUTCFullYear() . The value returned by may differ from the Date.getFullYear() Date.getUTCFullYear() value returned by if today's date is December 31 or January 1 Date.getFullYear() depending on the relationship between your local time zone and universal time.
  • Page 493: Setdate (Date.setdate Method)

    setDate (Date.setDate method) public setDate(date:Number) : Number Sets the day of the month for the specified Date object, according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running. Availability: ActionScript 1.0;...
  • Page 494: Sethours (Date.sethours Method)

    [optional] - A number from 1 to 31. If you omit this parameter, the date field date:Number of the specified Date object will not be modified. Returns - An integer. Number Example The following example initially creates a new Date object, setting the date to May 15, 2004, and uses to change the date to May 15, 2002: Date.setFullYear()
  • Page 495: Setmilliseconds (Date.setmilliseconds Method)

    setMilliseconds (Date.setMilliseconds method) public setMilliseconds(millisecond:Number) : Number Sets the milliseconds for the specified Date object according to local time and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running. Availability: ActionScript 1.0;...
  • Page 496: Setmonth (Date.setmonth Method)

    Example The following example initially creates a new Date object, setting the time and date to 8:00 a.m. on May 15, 2004, and then uses to change the time to 8:30 a.m.: Date.setMinutes() var my_date:Date = new Date(2004,4,15,8,0); trace(my_date.getMinutes()); // output: 0 my_date.setMinutes(30);...
  • Page 497: Settime (Date.settime Method)

    Parameters - An integer from 0 to 59. second:Number Returns - An integer. Number Example The following example initially creates a new Date object, setting the time and date to 8:00:00 a.m. on May 15, 2004, and uses to change the time to 8:00:45 Date.setSeconds() a.m.: var my_date:Date = new Date(2004,4,15,8,0,0);...
  • Page 498: Setutcdate (Date.setutcdate Method)

    setUTCDate (Date.setUTCDate method) public setUTCDate(date:Number) : Number Sets the date for the specified Date object in universal time and returns the new time in milliseconds. Calling this method does not modify the other fields of the specified Date object, but can report a new value if the day of the Date.getUTCDay() Date.getDay()
  • Page 499: Setutchours (Date.setutchours Method)

    Parameters - An integer that represents the year specified as a full four-digit year, such as year:Number 2000. [optional] - An integer from 0 (January) to 11 (December). If you omit this month:Number parameter, the month field of the specified Date object will not be modified. [optional] - An integer from 1 to 31.
  • Page 500: Setutcmilliseconds (Date.setutcmilliseconds Method)

    [optional] - A number; an integer from 0 to 59. If you omit this parameter, second:Number the seconds field of the specified Date object will not be modified. [optional] - A number; an integer from 0 to 999. If you omit this millisecond:Number parameter, the milliseconds field of the specified Date object will not be modified.
  • Page 501: Setutcminutes (Date.setutcminutes Method)

    Example The following example initially creates a new Date object, setting the date to 8:30 a.m. on May 15, 2004 with the milliseconds value set to 250, and uses Date.setUTCMilliseconds() to change the milliseconds value to 575: var my_date:Date = new Date(2004,4,15,8,30,0,250); trace(my_date.getUTCMilliseconds());...
  • Page 502: Setutcmonth (Date.setutcmonth Method)

    setUTCMonth (Date.setUTCMonth method) public setUTCMonth(month:Number, [date:Number]) : Number Sets the month, and optionally the day, for the specified Date object in universal time and returns the new time in milliseconds. Calling this method does not modify the other fields of the specified Date object, but might report a new Date.getUTCDay()
  • Page 503: Setyear (Date.setyear Method)

    [optional] - An integer from 0 to 999. If you omit this parameter, the millisecond:Number milliseconds field of the specified Date object will not be modified. Returns - An integer. Number Example The following example initially creates a new Date object, setting the time and date to 8:00:00 a.m.
  • Page 504: Tostring (Date.tostring Method)

    trace(my_date.getYear()); // output: 103 trace(my_date.getFullYear()); // output: 2003 toString (Date.toString method) public toString() : String Returns a string value for the specified date object in a readable format. Availability: ActionScript 1.0; Flash Player 5 Returns - A string. String Example The following example returns the information in the Date object as a dateOfBirth_date...
  • Page 505: Valueof (Date.valueof Method)

    Returns - An integer. Number Example The following example creates a new Date object defined in universal maryBirthday_date time. This is the universal time variation of the example used for the constructor new Date method. The output is in local time and varies accordingly. For Pacific Daylight Time the output is seven hours earlier than UTC: Sun Aug 11 17:00:00 GMT-0700 1974.
  • Page 506 To apply filters to movie clips at runtime, use the property. Setting the filters filters property of an object does not modify the object and can be undone by clearing the filters property. To apply filters to BitmapData instances, use the method.
  • Page 507 Property summary Modifiers Property Description Specifies the alpha transparency value to use for out- alpha:Number of-bounds displacements. Specifies what color to use for out-of-bounds color:Number displacements. Describes which color channel to use in the map componentX:Number image to displace the x result. Describes which color channel to use in the map componentY:Number image to displace the y result.
  • Page 508: Alpha (Displacementmapfilter.alpha Property)

    Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : DisplacementMapFilte Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString...
  • Page 509 filter.alpha = .25; this.filters = new Array(filter); function createDisplacementMapRectangle():MovieClip { var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial"); var filter:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000); var txtBlock:MovieClip = createTextBlock(); txtBlock._x = 30; txtBlock._y = 30; txtBlock.filters = new Array(filter);...
  • Page 510: Clone (Displacementmapfilter.clone Method)

    clone (DisplacementMapFilter.clone method) public clone() : DisplacementMapFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A new DisplacementMapFilter instance with all flash.filters.DisplacementMapFilter the same properties as the original one. Example The following example creates three DisplacementMapFilter objects and compares them: is created by using the constructor;...
  • Page 511 for(var i in clonedFilter) { trace(">> " + i + ": " + clonedFilter[i]); // >> clone: [type Function] // >> alpha: 0 // >> color: 0 // >> mode: wrap // >> scaleY: 10 // >> scaleX: 10 // >> componentY: 1 // >>...
  • Page 512: Color (Displacementmapfilter.color Property)

    var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial", true); var filter_1:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000); var filter_2:DisplacementMapFilter = filter_1; var clonedFilter:DisplacementMapFilter = filter_1.clone(); trace(filter_1.mode); // wrap trace(filter_2.mode); // wrap trace(clonedFilter.mode); // wrap filter_1.mode = "ignore";...
  • Page 513 Example The following example modifies the out-of-range property on the existing MovieClip color when a user clicks it. filteredMc 0x00FF00 import flash.filters.DisplacementMapFilter; import flash.display.BitmapData; import flash.geom.Point; import flash.geom.Matrix; import flash.geom.ColorTransform; var filteredMc:MovieClip = createDisplacementMapRectangle(); filteredMc.onPress = function() { var filter:DisplacementMapFilter = this.filters[0]; filter.scaleY = 25;...
  • Page 514: Componentx (Displacementmapfilter.componentx Property)

    var bmp:BitmapData = new BitmapData(w, h, true, bgColor); bmp.draw(mc, new Matrix(), new ColorTransform(), "normal", bmp.rectangle, true); mc.attachBitmap(bmp, this.getNextHighestDepth()); return bmp; function createTextBlock():MovieClip { var txtBlock:MovieClip = this.createEmptyMovieClip("txtBlock", this.getNextHighestDepth()); txtBlock.createTextField("txt", this.getNextHighestDepth(), 0, 0, 300, 80); txtBlock.txt.text = "watch the text bend with the displacement map"; return txtBlock;...
  • Page 515 function createDisplacementMapRectangle():MovieClip { var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial"); var filter:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000); var txtBlock:MovieClip = createTextBlock(); txtBlock._x = 30; txtBlock._y = 30; txtBlock.filters = new Array(filter); return txtBlock; function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1);...
  • Page 516: Componenty (Displacementmapfilter.componenty Property)

    componentY (DisplacementMapFilter.componentY property) public componentY : Number Describes which color channel to use in the map image to displace the y result. Possible values are 1 (red), 2 (green), 4 (blue), and 8 (alpha). Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip...
  • Page 517: Displacementmapfilter Constructor

    mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.endFill(); (hide == true) ? mc._alpha = 0 : mc._alpha = 100; var bmp:BitmapData = new BitmapData(w, h, true, bgColor); bmp.draw(mc, new Matrix(), new ColorTransform(), "normal", bmp.rectangle, true);...
  • Page 518 - Describes which color channel to use in the map image to displace the componentX:Number x result. Possible values are the following: (red) (green) (blue) (alpha) - Describes which color channel to use in the map image to displace the componentY:Number y result.
  • Page 519 import flash.filters.DisplacementMapFilter; import flash.display.BitmapData; import flash.geom.Point; import flash.geom.Matrix; import flash.geom.ColorTransform; var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial"); var mapPoint:Point = new Point(-30, -30); var componentX:Number = 1; var componentY:Number = 1; var scaleX:Number = 10; var scaleY:Number = 10; var mode:String = "wrap"; var color:Number = 0x000000;...
  • Page 520: Mapbitmap (Displacementmapfilter.mapbitmap Property)

    function createTextBlock():MovieClip { var txtBlock:MovieClip = this.createEmptyMovieClip("txtBlock", this.getNextHighestDepth()); txtBlock.createTextField("txt", this.getNextHighestDepth(), 0, 0, 300, 80); txtBlock.txt.text = "watch the text bend with the displacement map"; return txtBlock; mapBitmap (DisplacementMapFilter.mapBitmap property) public mapBitmap : BitmapData A BitmapData object containing the displacement map data. property cannot be changed by directly modifying its value.
  • Page 521 txtBlock._x = 30; txtBlock._y = 30; txtBlock.filters = new Array(filter); return txtBlock; function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1); var matrix:Matrix = new Matrix(); matrix.createGradientBox(w, h, 0, 0, 0); mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad");...
  • Page 522: Mappoint (Displacementmapfilter.mappoint Property)

    mapPoint (DisplacementMapFilter.mapPoint property) public mapPoint : Point value that contains the offset of the upper-left corner of the target flash.geom.Point movie clip from the upper-left corner of the map image. property cannot be changed by directly modifying its value. Instead, you must mapPoint get a reference to , make the change to the reference, and then set...
  • Page 523 function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1); var matrix:Matrix = new Matrix(); matrix.createGradientBox(w, h, 0, 0, 0); mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.endFill(); (hide == true) ? mc._alpha = 0 : mc._alpha = 100;...
  • Page 524: Mode (Displacementmapfilter.mode Property)

    mode (DisplacementMapFilter.mode property) public mode : String The mode for the filter. Possible values are the following: — Wraps the displacement value to the other side of the source image. This is the "wrap" default value. — Clamps the displacement value to the edge of the source image. "clamp"...
  • Page 525: Scalex (Displacementmapfilter.scalex Property)

    return txtBlock; function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1); var matrix:Matrix = new Matrix(); matrix.createGradientBox(w, h, 0, 0, 0); mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.endFill();...
  • Page 526 import flash.geom.Point; import flash.geom.Matrix; import flash.geom.ColorTransform; var filteredMc:MovieClip = createDisplacementMapRectangle(); filteredMc.onPress = function() { var filter:DisplacementMapFilter = this.filters[0]; filter.scaleX = 5; this.filters = new Array(filter); function createDisplacementMapRectangle():MovieClip { var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial"); var filter:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000);...
  • Page 527: Scaley (Displacementmapfilter.scaley Property)

    function createTextBlock():MovieClip { var txtBlock:MovieClip = this.createEmptyMovieClip("txtBlock", this.getNextHighestDepth()); txtBlock.createTextField("txt", this.getNextHighestDepth(), 0, 0, 300, 80); txtBlock.txt.text = "watch the text bend with the displacement map"; return txtBlock; scaleY (DisplacementMapFilter.scaleY property) public scaleY : Number The multiplier to use to scale the y displacement result from the map calculation. Availability: ActionScript 1.0;...
  • Page 528: Dropshadowfilter (Flash.filters.dropshadowfilter)

    function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1); var matrix:Matrix = new Matrix(); matrix.createGradientBox(w, h, 0, 0, 0); mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.endFill(); (hide == true) ? mc._alpha = 0 : mc._alpha = 100;...
  • Page 529 The use of filters depends on the object to which you apply the filter: To apply filters to movie clips, text fields, and buttons at runtime, use the filters property. Setting the property of an object does not modify the object and can be filters undone by clearing the property.
  • Page 530 Property summary Modifiers Property Description The alpha transparency value for the shadow color. alpha:Number The angle of the shadow. angle:Number The amount of horizontal blur. blurX:Number The amount of vertical blur. blurY:Number The color of the shadow. color:Number The offset distance for the shadow, in pixels. distance:Number Indicates whether or not the object is hidden.
  • Page 531: Alpha (Dropshadowfilter.alpha Property)

    Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : DropShadowFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString...
  • Page 532: Angle (Dropshadowfilter.angle Property)

    art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; angle (DropShadowFilter.angle property) public angle : Number The angle of the shadow.
  • Page 533: Blurx (Dropshadowfilter.blurx Property)

    var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; blurX (DropShadowFilter.blurX property) public blurX : Number The amount of horizontal blur. Valid values are 0 to 255 (floating point). The default value is 4.
  • Page 534: Blury (Dropshadowfilter.blury Property)

    return art; blurY (DropShadowFilter.blurY property) public blurY : Number The amount of vertical blur. Valid values are 0 to 255 (floating point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values.
  • Page 535: Clone (Dropshadowfilter.clone Method)

    clone (DropShadowFilter.clone method) public clone() : DropShadowFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A new DropShadowFilter instance with all the flash.filters.DropShadowFilter properties of the original one. Example The following example creates three DropShadowFilter objects and compares them; is created by using the DropShadowFilter constructor;...
  • Page 536: Color (Dropshadowfilter.color Property)

    // >> hideObject: false // >> strength: 1 // >> blurY: 16 // >> blurX: 16 // >> knockout: false // >> inner: false // >> quality: 3 // >> alpha: 0.8 // >> color: 0 // >> angle: 45 // >>...
  • Page 537: Distance (Dropshadowfilter.distance Property)

    var mc:MovieClip = createDropShadowRectangle("DropShadowColor"); mc.onRelease = function() { var filter:DropShadowFilter = this.filters[0]; filter.color = 0xFF0000; this.filters = new Array(filter); function createDropShadowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); var w:Number = 100; var h:Number = 100; art.beginFill(0x003366); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h);...
  • Page 538: Dropshadowfilter Constructor

    var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); var w:Number = 100; var h:Number = 100; art.beginFill(0x003366); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array();...
  • Page 539 [optional] - The amount of vertical blur. Valid values are 0 to 255 (floating blurY:Number point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values. [optional] - The strength of the imprint or spread.
  • Page 540: Hideobject (Dropshadowfilter.hideobject Property)

    blurY, strength, quality, inner, knockout, hideObject); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; function createRectangle(w:Number, h:Number, bgColor:Number, name:String):MovieClip { var mc:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); mc.beginFill(bgColor); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc._x = 20; mc._y = 20; return mc;...
  • Page 541: Inner (Dropshadowfilter.inner Property)

    var h:Number = 100; art.beginFill(0x003366); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray;...
  • Page 542: Knockout (Dropshadowfilter.knockout Property)

    art._x = 20; art._y = 20; var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; knockout (DropShadowFilter.knockout property) public knockout : Boolean Applies a knockout effect ( ), which effectively makes the object's fill transparent and true reveals the background color of the document.
  • Page 543: Quality (Dropshadowfilter.quality Property)

    var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; quality (DropShadowFilter.quality property) public quality : Number The number of times to apply the filter. Valid values are 0 to 15. The default value is 1, which is equivalent to low quality.
  • Page 544: Strength (Dropshadowfilter.strength Property)

    var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; strength (DropShadowFilter.strength property) public strength : Number The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the shadow and the background.
  • Page 545: Error

    return art; Error Object +-Error public class Error extends Object Contains information about an error that occurred in a script. You create an Error object using the constructor function. Typically, you a new Error object from within a Error throw code block that is then caught by a code block.
  • Page 546: Error Constructor

    Method summary Modifiers Signature Description Returns the string "Error" by default or the value toString() : String contained in Error.message, if defined. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString...
  • Page 547: Message (Error.message Property)

    message (Error.message property) public message : String Contains the message associated with the Error object. By default, the value of this property is " ". You can specify a property when you create an Error object by passing the Error message error string to the constructor function.
  • Page 548: Tostring (Error.tostring Method)

    Example In the following example, a function throws a specified error depending on the two numbers that you try to divide. Add the following ActionScript to Frame 1 of the Timeline: function divideNumber(numerator:Number, denominator:Number):Number { if (isNaN(numerator) || isNaN(denominator)) { throw new Error("divideNum function requires two numeric parameters.");...
  • Page 549: Externalinterface (Flash.external.externalinterface)

    Example In the following example, a function throws an error (with a specified message) if the two strings that are passed to it are not identical: function compareStrings(str1_str:String, str2_str:String):Void { if (str1_str != str2_str) { throw new Error("Strings do not match."); try { compareStrings("Dog", "dog");...
  • Page 550 ExternalInterface is supported in the following combinations of browser and operating system: Browser Operating System Internet Explorer 5.0 Windows and higher Netscape 8.0 and Windows Macintosh higher Mozilla 1.7.5 and Windows Macintosh higher Firefox 1.0 and higher Windows Macintosh Safari 1.3 and higher Macintosh ExternalInterface requires the user's web browser to support either ActiveX or the NPRuntime API that is exposed by some browsers for plugin scripting.
  • Page 551: Addcallback (Externalinterface.addcallback Method)

    Method summary Modifiers Signature Description Registers an ActionScript method as callable from static addCallback(methodNa the container. me:String, instance:Object, method:Function) : Boolean Calls a function exposed by the Flash Player static call(methodName:Stri container, passing 0 or more arguments. [parameter1:Object]) : Object Methods inherited from class Object addProperty (Object.addProperty method),...
  • Page 552 0, 0, 200, 50); txtField.border = true; txtField.text = wasSuccessful.toString(); function goToMacromedia() { txtField.text = "http://www.macromedia.com"; getURL("http://www.macromedia.com", "_self"); For the previous example to work properly, you should copy and paste the following code into the containing HTML page. This code relies on the...
  • Page 553: Available (Externalinterface.available Property)

    </form> <script> function callExternalInterface() { thisMovie("externalInterfaceExample").goHome(); function thisMovie(movieName) { if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName] else { return document[movieName] </script> available (ExternalInterface.available property) public static available : Boolean [read-only] Indicates whether this player is in a container that offers an external interface. If the external interface is available, this property is ;...
  • Page 554 If the container is hosting the Netscape plug-in, you can either write custom support for the new NPRuntime interface or embed an HTML control and embed Flash Player within the HTML control. If you embed an HTML control, you can communicate with Flash Player through a JavaScript interface that talks to the native container application.
  • Page 555: Filereference (Flash.net.filereference)

    mc.lineTo(0, 0); mcFmt = new TextFormat(); mcFmt.align = "center"; mcFmt.bold = true; mc.createTextField("mcTxt", depth, 0, 0, width, height); mc.mcTxt.text = "Call JS Function"; mc.mcTxt.setTextFormat(mcFmt); return mc; For the previous example to work properly, you should be copy and paste the following code into the containing HTML page.
  • Page 556 During an upload operation, all of the properties of a FileReference object are populated by calls to . During a download FileReference.browse() FileReferenceList.browse() operation, the property is populated when has been invoked; all other name onSelect properties are populated when has been invoked.
  • Page 557 Example The following example creates a FileReference object that prompts the user to select an image or text file to be uploaded. It also listens for any possible event. import flash.net.FileReference; var allTypes:Array = new Array(); var imageTypes:Object = new Object(); imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)";...
  • Page 558 trace("onIOError: " + file.name); listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse(allTypes); See also FileReferenceList (flash.net.FileReferenceList) Property summary Modifiers Property Description The creation date of the file on the local disk. creationDate:Date [read-only] [read-...
  • Page 559 Event summary Event Description Invoked when the user dismisses the file-browsing dialog box. onCancel function(fileRef :FileReference) Invoked when the upload or download operation has successfully onComplete completed. function(fileRef :FileReference) Invoked when an upload fails because of an HTTP error. onHTTPError function(fileRef :FileReference, httpError:Number...
  • Page 560: Addlistener (Filereference.addlistener Method)

    Constructor summary Signature Description Creates a new FileReference object. FileReference() Method summary Modifiers Signature Description Registers an object to receive notification when a addListener(listener FileReference event listener is invoked. :Object) : Void Displays a file-browsing dialog box in which the user browse([typelist:Arr can select a local file to upload.
  • Page 561: Browse (Filereference.browse Method)

    = function(file:FileReference):Void { trace("onComplete: " + file.name); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); browse (FileReference.browse method) public browse([typelist:Array]) : Boolean Displays a file-browsing dialog box in which the user can select a local file to upload. The dialog box is native to the user's operating system.
  • Page 562 Parameters [optional] - An array of file types used to filter the files displayed in the typelist:Array dialog box. If you omit this parameter, all files are displayed. If you include this parameter, the array must contain one or more elements enclosed in curly braces { }. You can use one of two formats for the array: A list of file type descriptions followed by their Windows file extensions only.
  • Page 563: Cancel (Filereference.cancel Method)

    Returns - Returns if the parameters are valid and the file-browsing dialog box is Boolean true displayed. Returns if the dialog box is not displayed, if another browse session is already false in progress, or if you use the parameter but fail to provide a description or typelist extension string in any element in the array.
  • Page 564: Creationdate (Filereference.creationdate Property)

    >= (bytesTotal / 2)) { file.cancel(); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); creationDate (FileReference.creationDate property) public creationDate : Date [read-only] The creation date of the file on the local disk. If the FileReference object has not been...
  • Page 565: Creator (Filereference.creator Property)

    See also browse (FileReference.browse method) creator (FileReference.creator property) public creator : String [read-only] The Macintosh creator type of the file. In Windows, this property is . If the null FileReference object has not been populated, a call to get the value of this property returns null Availability: ActionScript 1.0;...
  • Page 566 For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 8 Parameters - The URL of the file to download to the local computer.
  • Page 567 Returns - A value of if the dialog box in which a user can select a file is displayed. If the Boolean true dialog box is not displayed, the method returns . The dialog box could fail to be false displayed for any of the following reasons: You did not pass a value for the parameter.
  • Page 568: Filereference Constructor

    = function(file:FileReference):Void { trace("onIOError: " + file.name); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; if(!fileRef.download(url, "FlashPlatform.pdf")) { trace("dialog box failed to open."); See also browse (FileReference.browse method) browse (FileReferenceList.browse method) upload (FileReference.upload method) FileReference constructor public FileReference() Creates a new FileReference object.
  • Page 569: Modificationdate (Filereference.modificationdate Property)

    modificationDate (FileReference.modificationDate property) public modificationDate : Date [read-only] The date that the file on the local disk was last modified. If the FileReference object has not been populated, a call to get the value of this property returns null Availability: ActionScript 1.0; Flash Player 8 Example The following example retrieves the of a file selected by the user.
  • Page 570: Oncancel (Filereference.oncancel Event Listener)

    Cancel or presses the Escape key after the dialog box is displayed. import flash.net.FileReference; var listener:Object = new Object(); listener.onCancel = function(file:FileReference):Void { trace("onCancel"); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; if(!fileRef.download(url, "FlashPlatform.pdf")) { trace("dialog box failed to open."); ActionScript classes...
  • Page 571: Oncomplete (Filereference.oncomplete Event Listener)

    = new Object(); listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); onHTTPError (FileReference.onHTTPError event listener) onHTTPError = function(fileRef:FileReference, httpError:Number) {} Invoked when an upload fails because of an HTTP error.
  • Page 572 Parameters - The File Reference object that initiated the fileRef:flash.net.FileReference operation. - The HTTP error that caused this upload to fail. For example, an httpError:Number of 404 indicates that a page is not found. HTTP error values can be found in httpError sections 10.4 and 10.5 of the HTTP specification at ftp://ftp.isi.edu/in-notes/rfc2616.txt.
  • Page 573: Onioerror (Filereference.onioerror Event Listener)

    trace("onIOError: " + file.name); listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse(); onIOError (FileReference.onIOError event listener) onIOError = function(fileRef:FileReference) {} Invoked when an input/output error occurs. This listener is invoked when the upload or download fails for any of the following reasons: An input/output error occurs while the player is reading, writing, or transmitting the file.
  • Page 574: Onopen (Filereference.onopen Event Listener)

    The following example traces a message when the event is triggered. onOpen import flash.net.FileReference; var listener:Object = new Object(); listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); ActionScript classes...
  • Page 575: Onprogress (Filereference.onprogress Event Listener)

    = new Object(); listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress: " + file.name + " with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); FileReference (flash.net.FileReference)
  • Page 576: Onsecurityerror (Filereference.onsecurityerror Event Listener)

    See also onSecurityError (FileReference.onSecurityError event listener) onSecurityError = function(fileRef:FileReference, errorString:String) {} Invoked when an upload or download fails because of a security error. The calling SWF file may have tried to access a SWF file outside its domain and does not have permission to do so. You can try to remedy this error by using a cross-domain policy file.
  • Page 577: Onselect (Filereference.onselect Event Listener)

    trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); listener.onHTTPError = function(file:FileReference):Void { trace("onHTTPError: " + file.name); listener.onIOError = function(file:FileReference):Void { trace("onIOError: " + file.name); listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: "...
  • Page 578: Removelistener (Filereference.removelistener Method)

    Parameters - The FileReference object that initiated the operation. fileRef:flash.net.FileReference Example The following example traces a message within the event listener. onSelect import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("onSelect: " + file.name); if(!file.upload("http://www.yourdomain.com/ yourUploadHandlerScript.cfm")) { trace("Upload dialog failed to open.");...
  • Page 579: Size (Filereference.size Property)

    = new Object(); listener.onCancel = function(file:FileReference):Void { trace(file.removeListener(this)); // true var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); size (FileReference.size property) public size : Number [read-only] The size of the file on the local disk, in bytes. If the FileReference object has not been...
  • Page 580: Type (Filereference.type Property)

    type (FileReference.type property) public type : String [read-only] The file type. In Windows, this property is the file extension. On the Macintosh, this property is the four-character file type. If the FileReference object has not been populated, a call to get the value of this property returns null Availability: ActionScript 1.0;...
  • Page 581 For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 8...
  • Page 582 You can send data to the server with the call by appending parameters to the URL; upload() for example, http://www.myserver.com/upload.cgi?userID=jdoe On some browsers, URL strings are limited in length. Lengths greater than 256 characters may fail on some browsers or servers. Returns - A value of in any of the following situations:...
  • Page 583 listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); listener.onHTTPError = function(file:FileReference):Void { trace("onHTTPError: " + file.name); listener.onIOError = function(file:FileReference):Void { trace("onIOError: "...
  • Page 584: Filereferencelist (Flash.net.filereferencelist)

    FileReferenceList (flash.net.FileReferenceList) Object +-flash.net.FileReferenceList public class FileReferenceList extends Object The FileReferenceList class provides a means to let users select one or more files for uploading. A FileReferenceList object represents a group of one or more local files on the user's disk as an array of FileReference objects.
  • Page 585 trace(item.addListener(this)); item.upload("http://www.yourdomain.com/"); listener.onCancel = function():Void { trace("onCancel"); listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void { trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal); listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); listener.onHTTPError = function(file:FileReference, httpError:Number):Void trace("onHTTPError: "...
  • Page 586 Property summary Modifiers Property Description An array of FileReference objects. fileList:Array Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Event summary Event Description Invoked when the user dismisses the file-browsing dialog box. onCancel function(fileRef List:FileReferen...
  • Page 587: Addlistener (Filereferencelist.addlistener Method)

    Method summary Modifiers Signature Description Registers an object to receive notification when a addListener(listener FileReferenceList event listener is invoked. :Object) : Void Displays a file-browsing dialog box in which the user browse([typelist:Arr can select one or more local files to upload. ay]) : Boolean Removes an object from the list of objects that receive removeListener(liste...
  • Page 588: Browse (Filereferencelist.browse Method)

    var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); browse (FileReferenceList.browse method) public browse([typelist:Array]) : Boolean Displays a file-browsing dialog box in which the user can select one or more local files to upload. The dialog box is native to the user's operating system. When you call this method and the user successfully selects files, the property of this FileReferenceList object is fileList...
  • Page 589 A list of file type descriptions followed by their Windows file extensions and their Macintosh file types. Each element in the array must contain a string that describes the file type; a semicolon- delimited list of Windows file extensions, with a wildcard (*) character preceding each extension;...
  • Page 590: Filelist (Filereferencelist.filelist Property)

    textTypes.extension = "*.txt; *.rtf"; allTypes.push(textTypes); var fileRef:FileReferenceList = new FileReferenceList(); fileRef.browse(allTypes); See also browse (FileReference.browse method) FileReference (flash.net.FileReference) fileList (FileReferenceList.fileList property) public fileList : Array An array of FileReference objects. When the method has been called and the user has selected FileReferenceList.browse() one or more files from the dialog box opened by , this property is populated with an...
  • Page 591: Filereferencelist Constructor

    var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); See also FileReference (flash.net.FileReference) upload (FileReference.upload method) browse (FileReferenceList.browse method) FileReferenceList constructor public FileReferenceList() Creates a new FileReferenceList object. This object contains nothing until you call browse() on it. When you call on the FileReference object, the property of the browse() fileList...
  • Page 592: Oncancel (Filereferencelist.oncancel Event Listener)

    onCancel (FileReferenceList.onCancel event listener) onCancel = function(fileRefList:FileReferenceList) {} Invoked when the user dismisses the file-browsing dialog box. (This dialog box is displayed when you call the , or FileReferenceList.browse() FileReference.browse() methods.) FileReference.download() Availability: ActionScript 1.0; Flash Player 8 Parameters - The FileReferenceList object that initiated fileRefList:flash.net.FileReferenceList the operation.
  • Page 593: Removelistener (Filereferencelist.removelistener Method)

    Parameters - The FileReferenceList object that initiated fileRefList:flash.net.FileReferenceList the operation. Example The following example demonstrates the listener. onSelect import flash.net.FileReferenceList; import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(fileRefList:FileReferenceList) { trace("onSelect"); var list:Array = fileRefList.fileList; var item:FileReference; for(var i:Number = 0; i < list.length; i++) { item = list[i];...
  • Page 594: Function

    Parameters - An object that listens for a callback notification from the listener:Object FileReferenceList event listeners. Returns - Returns if the object is removed. Otherwise, this method returns Boolean true false Example The following example demonstrates the method. removeListener import flash.net.FileReferenceList; var listener:Object = new Object();...
  • Page 595: Apply (Function.apply Method)

    Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Specifies the value of thisObject to be used within apply(thisObject:Obj any function that ActionScript calls. ect, [argArray:Array]) : Void Invokes the function represented by a Function...
  • Page 596 Parameters - The object to which myFunction is applied. thisObject:Object [optional] - An array whose elements are passed to myFunction as argArray:Array parameters. Example The following function invocations are equivalent: Math.atan2(1, 0) Math.atan2.apply(null, [1, 0]) The following simple example shows how passes an array of parameters: apply() function theFunction() {...
  • Page 597: Call (Function.call Method)

    // use apply() to set the value of this to be myObj and send secondArray theFunction.apply(myObj,secondArray); // output: // this == myObj? true // arguments: a,b,c See also call (Function.call method) call (Function.call method) public call(thisObject:Object, [parameter1:Object]) : Object Invokes the function represented by a Function object. Every function in ActionScript is represented by a Function object, so all functions support this method.
  • Page 598: Glowfilter (Flash.filters.glowfilter)

    Returns Object Example The following example uses to make a function behave as a method of Function.call() another object, without storing the function in the object: function myObject() { function myMethod(obj) { trace("this == obj? " + (this == obj)); var obj:Object = new myObject();...
  • Page 599 You can also apply filter effects to images and video during authoring. For more information, see your authoring documentation. If you apply a filter to a movie clip or button, the property of the movie clip cacheAsBitmap or button is set to .
  • Page 600: Alpha (Glowfilter.alpha Property)

    Constructor summary Signature Description Initializes a new GlowFilter instance with the specified parameters. GlowFilter([color:Nu mber], [alpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [inner:Boolean], [knockout:Boolean]) Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : GlowFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty...
  • Page 601: Blurx (Glowfilter.blurx Property)

    Example The following example changes the property on an existing movie clip when a user alpha clicks it. import flash.filters.GlowFilter; var mc:MovieClip = createGlowFilterRectangle("GlowFilterAlpha"); mc.onRelease = function() { var filter:GlowFilter = this.filters[0]; filter.alpha = .4; this.filters = new Array(filter); function createGlowFilterRectangle(name:String):MovieClip { var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 602: Blury (Glowfilter.blury Property)

    Example The following example changes the property on an existing movie clip when a user blurX clicks it. import flash.filters.GlowFilter; var mc:MovieClip = createGlowFilterRectangle("GlowFilterBlurX"); mc.onRelease = function() { var filter:GlowFilter = this.filters[0]; filter.blurX = 20; this.filters = new Array(filter); function createGlowFilterRectangle(name:String):MovieClip { var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 603: Clone (Glowfilter.clone Method)

    Example The following example changes the property on an existing movie clip when a user blurY clicks it. import flash.filters.GlowFilter; var mc:MovieClip = createGlowFilterRectangle("GlowFilterBlurY"); mc.onRelease = function() { var filter:GlowFilter = this.filters[0]; filter.blurY = 20; this.filters = new Array(filter); function createGlowFilterRectangle(name:String):MovieClip { var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 604 Example The following example creates three GlowFilter objects and compares them: filter_1 created by using the GlowFilter constructor; is created by setting it equal to filter_2 ; and is created by cloning . Notice that although filter_1 clonedFilter filter_1 evaluates as being equal to , even though it contains the filter_2 filter_1...
  • Page 605: Color (Glowfilter.color Property)

    To further demonstrate the relationships between , and filter_1 filter_2 clonedFilter the following example modifies the property of . Modifying knockout filter_1 knockout demonstrates that the method creates a new instance based on the values of clone() instead of pointing to them in reference. filter_1 import flash.filters.GlowFilter;...
  • Page 606: Glowfilter Constructor

    rect.beginFill(0x003366); rect.lineTo(w, 0); rect.lineTo(w, h); rect.lineTo(0, h); rect.lineTo(0, 0); rect._x = 20; rect._y = 20; var filter:GlowFilter = new GlowFilter(0x000000, .8, 16, 16, 1, 3, false, false); var filterArray:Array = new Array(); filterArray.push(filter); rect.filters = filterArray; return rect; GlowFilter constructor public GlowFilter([color:Number], [alpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [inner:Boolean], [knockout:Boolean])
  • Page 607 [optional] - Specifies whether the glow is an inner glow. The value inner:Boolean true indicates an inner glow. The default is , an outer glow (a glow around the outer edges of false the object). [optional] - Specifies whether the object has a knockout effect. The value knockout:Boolean makes the object's fill transparent and reveals the background color of the document.
  • Page 608: Inner (Glowfilter.inner Property)

    mc._y = 20; return mc; inner (GlowFilter.inner property) public inner : Boolean Specifies whether the glow is an inner glow. The value indicates an inner glow. The true default is , an outer glow (a glow around the outer edges of the object). false Availability: ActionScript 1.0;...
  • Page 609: Knockout (Glowfilter.knockout Property)

    knockout (GlowFilter.knockout property) public knockout : Boolean Specifies whether the object has a knockout effect. A value of makes the object's fill true transparent and reveals the background color of the document. The default is false knockout effect). Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on an existing movie clip when a user...
  • Page 610: Quality (Glowfilter.quality Property)

    quality (GlowFilter.quality property) public quality : Number The number of times to apply the filter. Valid values are 0 to 15. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality, and a value of 3 is high quality. Filters with lower values are rendered more quickly.
  • Page 611: Strength (Glowfilter.strength Property)

    strength (GlowFilter.strength property) public strength : Number The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. The default is 2.
  • Page 612: Gradientbevelfilter (Flash.filters.gradientbevelfilter)

    GradientBevelFilter (flash.filters.GradientBevelFilter) Object +-flash.filters.BitmapFilter +-flash.filters.GradientBevelFilter public class GradientBevelFilter extends BitmapFilter The GradientBevelFilter class lets you apply a gradient bevel effect to various objects in Flash. A gradient bevel is a beveled edge, enhanced with gradient color, on the outside, inside, or top of an object.
  • Page 613 See also ratios (GradientBevelFilter.ratios property) applyFilter (BitmapData.applyFilter method) BevelFilter (flash.filters.BevelFilter) filters (Button.filters property) cacheAsBitmap (Button.cacheAsBitmap property) cacheAsBitmap (MovieClip.cacheAsBitmap property) filters (MovieClip.filters property) filters (TextField.filters property) Property summary Modifiers Property Description An array of alpha transparency values for the alphas:Array corresponding colors in the colors array. The angle, in degrees.
  • Page 614 Constructor summary Signature Description Initializes the filter with the specified parameters. GradientBevelFilter( [distance:Number], [angle:Number], [colors:Array], [alphas:Array], [ratios:Array], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [type:String], [knockout:Boolean]) Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : GradientBevelFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty...
  • Page 615: Alphas (Gradientbevelfilter.alphas Property)

    alphas (GradientBevelFilter.alphas property) public alphas : Array An array of alpha transparency values for the corresponding colors in the array. Valid colors values for each element in the array are 0 to 1. For example, .25 sets a transparency value of 25%.
  • Page 616: Angle (Gradientbevelfilter.angle Property)

    var filter:GradientBevelFilter = new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 2, "inner", false); art.filters = new Array(filter); return art; See also colors (GradientBevelFilter.colors property) ratios (GradientBevelFilter.ratios property) angle (GradientBevelFilter.angle property) public angle : Number The angle, in degrees. Valid values are 0 to 360. The default is 45. The angle value represents the angle of the theoretical light source falling on the object.
  • Page 617: Blurx (Gradientbevelfilter.blurx Property)

    var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; var filter:GradientBevelFilter = new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 3, "inner", false); art.filters = new Array(filter); return art; See also ratios (GradientBevelFilter.ratios property) blurX (GradientBevelFilter.blurX property) public blurX : Number...
  • Page 618: Blury (Gradientbevelfilter.blury Property)

    var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; var filter:GradientBevelFilter = new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 3, "inner", false); art.filters = new Array(filter); return art; blurY (GradientBevelFilter.blurY property) public blurY : Number The amount of vertical blur.
  • Page 619: Clone (Gradientbevelfilter.clone Method)

    art.filters = new Array(filter); return art; clone (GradientBevelFilter.clone method) public clone() : GradientBevelFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A new GradientBevelFilter instance with all the flash.filters.GradientBevelFilter same properties as the original GradientBevelFilter instance. Example The following example creates two rectangle shapes.
  • Page 620: Colors (Gradientbevelfilter.colors Property)

    function getNewFilter():GradientBevelFilter { var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; return new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 2, "inner", false); colors (GradientBevelFilter.colors property) public colors : Array An array of RGB hexadecimal color values to use in the gradient.
  • Page 621: Distance (Gradientbevelfilter.distance Property)

    var w:Number = 150; var h:Number = 150; art.beginFill(0xCCCCCC); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; var filter:GradientBevelFilter = new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 2, "inner", false);...
  • Page 622: Gradientbevelfilter Constructor

    art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; var filter:GradientBevelFilter = new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 3, "inner", false); art.filters = new Array(filter); return art;...
  • Page 623 [optional] - The strength of the imprint or spread. The higher the value, strength:Number the more color is imprinted and the stronger the contrast between the bevel and the background. Valid values are 0 to 255. A value of 0 means that the filter is not applied. The default value is 1.
  • Page 624: Knockout (Gradientbevelfilter.knockout Property)

    var filter:GradientBevelFilter = new GradientBevelFilter(distance, angleInDegrees, colors, alphas, ratios, blurX, blurY, strength, quality, type, knockout); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; function setUpFlatRectangle(w:Number, h:Number, bgColor:Number, name:String):MovieClip { var mc:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); mc.beginFill(bgColor); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h);...
  • Page 625: Quality (Gradientbevelfilter.quality Property)

    Example The following example demonstrates how to set the property on an existing object. knockout import flash.filters.GradientBevelFilter; var mc:MovieClip = setUpFilter("knockoutExample"); mc.onRelease = function() { var arr:Array = this.filters; arr[0].knockout = true; this.filters = arr; function setUpFilter(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 626 Example The following example demonstrates how to set the property on an existing object. quality import flash.filters.GradientBevelFilter; var mc:MovieClip = setUpFilter("qualityExample"); mc.onRelease = function() { var arr:Array = this.filters; arr[0].quality = 1; // low quality this.filters = arr; function setUpFilter(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 627: Ratios (Gradientbevelfilter.ratios Property)

    ratios (GradientBevelFilter.ratios property) public ratios : Array An array of color distribution ratios for the corresponding colors in the array. Valid colors values for each element in the array are 0 to 255. property cannot be changed by directly modifying its values. Instead, you must ratios get a reference to , make the change to the reference, and then set...
  • Page 628 Keep in mind that the spread of the colors in the gradient varies based on the values of the , and properties, as well as the values. blurX blurY strength quality ratios Availability: ActionScript 1.0; Flash Player 8 Example The following example demonstrates how to set the property on an existing entity.
  • Page 629: Strength (Gradientbevelfilter.strength Property)

    art.beginFill(0xCCCCCC); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; var filter:GradientBevelFilter = new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 2, "inner", false); art.filters = new Array(filter);...
  • Page 630: Type (Gradientbevelfilter.type Property)

    Example The following example demonstrates how to set the property on an existing object. strength import flash.filters.GradientBevelFilter; var mc:MovieClip = setUpFilter("strengthExample"); mc.onRelease = function() { var arr:Array = this.filters; arr[0].strength = 1; this.filters = arr; function setUpFilter(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 631: Gradientglowfilter (Flash.filters.gradientglowfilter)

    Example The following example demonstrates how to set the property on an existing object. type import flash.filters.GradientBevelFilter; var mc:MovieClip = setUpFilter("typeExample"); mc.onRelease = function() { var arr:Array = this.filters; arr[0].type = "outer"; this.filters = arr; function setUpFilter(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 632 The GradientGlowFilter class lets you apply a gradient glow effect to a variety of objects in Flash. A gradient glow is a realistic-looking glow with a color gradient that you can control. You can apply a gradient glow around the inner or outer edge of an object or on top of an object.
  • Page 633 Property summary Modifiers Property Description An array of alpha transparency values for the alphas:Array corresponding colors in the colors array. The angle, in degrees. angle:Number The amount of horizontal blur. blurX:Number The amount of vertical blur. blurY:Number An array of colors that defines a gradient. colors:Array The offset distance of the glow.
  • Page 634: Alphas (Gradientglowfilter.alphas Property)

    Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : GradientGlowFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString...
  • Page 635: Angle (Gradientglowfilter.angle Property)

    alphas.pop(); alphas.push(.3); alphas.push(1); filter.alphas = alphas; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); var w:Number = 100; var h:Number = 100; art.beginFill(0x003366); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var colors:Array = [0xFFFFFF, 0xFF0000, 0xFFFF00, 0x00CCFF];...
  • Page 636: Blurx (Gradientglowfilter.blurx Property)

    Example The following example changes the property on an existing movie clip when a user angle clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowAngle"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.distance = 50; filter.angle = 90; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 637: Blury (Gradientglowfilter.blury Property)

    Example The following example changes the property on an existing movie clip when a user blurX clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowBlurX"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.blurX = 255; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 638: Clone (Gradientglowfilter.clone Method)

    Example The following example changes the property on an existing movie clip when a user blurY clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowBlurY"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.blurY = 255; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 639 Example The following example creates three GradientGlowFilter objects and compares them; is created by using the GradientGlowFilter construtor; is created by filter_1 filter_2 setting it equal to ; and, is created by cloning . Notice that filter_1 clonedFilter filter_1 although evaluates as being equal to , even though it filter_2...
  • Page 640: Colors (Gradientglowfilter.colors Property)

    // >> distance: 0 To further demonstrate the relationships between , and filter_1 filter_2 clonedFilter the following example below modifies the property of . Modifying knockout filter_1 demonstrates that the method creates a new instance based on the values knockout clone() instead of pointing to them in reference.
  • Page 641 Example The following example changes the property on an existing movie clip when a user colors clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowColors"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; var colors:Array = filter.colors; colors.pop(); colors.push(0xFF00FF); filter.colors = colors; this.filters = new Array(filter);...
  • Page 642: Distance (Gradientglowfilter.distance Property)

    distance (GradientGlowFilter.distance property) public distance : Number The offset distance of the glow. The default value is 4. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on an existing movie clip when a user distance clicks it.
  • Page 643: Gradientglowfilter Constructor

    GradientGlowFilter constructor public GradientGlowFilter([distance:Number], [angle:Number], [colors:Array], [alphas:Array], [ratios:Array], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [type:String], [knockout:Boolean]) Initializes the filter with the specified parameters. Availability: ActionScript 1.0; Flash Player 8 Parameters [optional] - The offset distance of the glow. The default is 4. distance:Number [optional] - The angle, in degrees.
  • Page 644 [optional] - The placement of the filter effect. Possible values are: type:String : Glow on the outer edge of the object "outer" : Glow on the inner edge of the object; the default "inner" : Glow on top of the object "full"...
  • Page 645: Knockout (Gradientglowfilter.knockout Property)

    function createRectangle(w:Number, h:Number, bgColor:Number, name:String):MovieClip { var mc:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); mc.beginFill(bgColor); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc._x = 20; mc._y = 20; return mc; knockout (GradientGlowFilter.knockout property) public knockout : Boolean Specifies whether the object has a knockout effect. A knockout effect makes the object's fill transparent and reveals the background color of the document.
  • Page 646: Quality (Gradientglowfilter.quality Property)

    var colors:Array = [0xFFFFFF, 0xFF0000, 0xFFFF00, 0x00CCFF]; var alphas:Array = [0, 1, 1, 1]; var ratios:Array = [0, 63, 126, 255]; var filter:GradientGlowFilter = new GradientGlowFilter(0, 45, colors, alphas, ratios, 55, 55, 2.5, 2, "outer", false); var filterArray:Array = new Array(); filterArray.push(filter);...
  • Page 647: Ratios (Gradientglowfilter.ratios Property)

    art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var colors:Array = [0xFFFFFF, 0xFF0000, 0xFFFF00, 0x00CCFF]; var alphas:Array = [0, 1, 1, 1]; var ratios:Array = [0, 63, 126, 255]; var filter:GradientGlowFilter = new GradientGlowFilter(0, 45, colors, alphas, ratios, 55, 55, 2.5, 2, "outer", false); var filterArray:Array = new Array();...
  • Page 648 In the following code and image, a filter is applied to a black circle movie clip, with the type set to . For instructional purposes, the first color in the array, pink, has an "full" colors value of 1, so it shows against the white document background. (In practice, you alpha probably would not want the first color showing in this way.) Note the last color in the array, yellow, obscures the black circle to which the filter is applied:...
  • Page 649 If you make two small changes in the code, the effect of the glow can be very different, even with the same arrays. Set the alpha value of the first color in the array to ratios colors 0, to make the filter blend in with the document's white background; and set the type property to .
  • Page 650: Strength (Gradientglowfilter.strength Property)

    function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); var w:Number = 100; var h:Number = 100; art.beginFill(0x003366); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var colors:Array = [0xFFFFFF, 0xFF0000, 0xFFFF00, 0x00CCFF]; var alphas:Array = [0, 1, 1, 1]; var ratios:Array = [0, 63, 126, 255];...
  • Page 651: Type (Gradientglowfilter.type Property)

    Example The following example changes the property on an existing movie clip when a user strength clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowStrength"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.strength = 1; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 652 Example The following example changes the property on an existing movie clip when a user clicks type import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowType"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.type = "inner"; filter.strength = 1; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
  • Page 653: Ime (System.ime)

    IME (System.IME) Object +-System.IME public class IME extends Object The IME class lets you directly manipulate the operating system's input method editor (IME) in the Flash Player application that is running on a client computer. You can determine whether an IME is installed, whether or not the IME is enabled, and which IME is enabled. You can disable or enable the IME in the Flash Player application, and you can perform other limited functions, depending on the operating system.
  • Page 654 Capability Windows Macintosh OSX Macintosh Classic Linux/Solaris XIM Get IME conversion Yes ** mode System.IME.getConver sionMode() Send IME the string to be Yes * converted System.IME. setCompositionString() Get from IME the original Yes * string before conversion System.IME.addListen er() listener.onIMECompos ition() System.IME.removeLis tener()
  • Page 655 Property summary Modifiers Property Description A string with the value "ALPHANUMERIC_FULL" for use static ALPHANUMERIC_FULL:St with setConversionMode() and ring getConversionMode(). A string with the value "ALPHANUMERIC_HALF" for use static ALPHANUMERIC_HALF:St with setConversionMode() and ring getConversionMode(). A string with the value "CHINESE" for use with static CHINESE:String setConversionMode() and getConversionMode().
  • Page 656: Addlistener (Ime.addlistener Method)

    Method summary Modifiers Signature Description Registers an object to receive notification when an static addListener(listener IME event handler is invoked by the :Object) : Void onIMEComposition event. Instructs the IME to select the first candidate for the static doConversion() : current composition string.
  • Page 657: Alphanumeric_Full

    Parameters - An object, with an (readingString) method, that listener:Object onIMEComposition listens for a callback notification from the IME event handlers. The reading string passed to this method is in the composition mode of the IME. For example, if the user enters text in Hiragana and then selects a Kanji candidate, the reading string is the original Hiragana.
  • Page 658: Alphanumeric_Half

    Example The following example sets the IME to if the system has an Input ALPHANUMERIC_FULL Method Editor (IME) installed ( System.capabilities.hasIME if(System.capabilities.hasIME) { trace(System.IME.getConversionMode()); System.IME.setConversionMode(System.IME.ALPHANUMERIC_FULL); trace(System.IME.getConversionMode()); See also setConversionMode (IME.setConversionMode method) getConversionMode (IME.getConversionMode method) hasIME (capabilities.hasIME property) ALPHANUMERIC_HALF (IME.ALPHANUMERIC_HALF property) public static ALPHANUMERIC_HALF : String A string with the value for use with...
  • Page 659: Chinese (Ime.chinese Property)

    CHINESE (IME.CHINESE property) public static CHINESE : String A string with the value for use with "CHINESE" setConversionMode() . This constant is used with simplified and traditional Chinese IMEs. getConversionMode() Availability: ActionScript 1.0; Flash Player 8 Example The following example sets the IME to if the system has an Input Method Editor CHINESE (IME) installed (...
  • Page 660: Getconversionmode (Ime.getconversionmode Method)

    mc.onPress = function() { if(System.capabilities.hasIME) { Selection.setFocus(mc.txt); System.IME.setCompositionString(mc.txt.text); trace(System.IME.doConversion()); getConversionMode (IME.getConversionMode method) public static getConversionMode() : String Indicates the conversion mode of the current IME. Availability: ActionScript 1.0; Flash Player 8 Returns - The conversion mode. Possible values are IME mode string constants that indicate String the conversion mode: ALPHANUMERIC_FULL...
  • Page 661: Getenabled (Ime.getenabled Method)

    See also ALPHANUMERIC_FULL (IME.ALPHANUMERIC_FULL property) ALPHANUMERIC_HALF (IME.ALPHANUMERIC_HALF property) CHINESE (IME.CHINESE property) JAPANESE_HIRAGANA (IME.JAPANESE_HIRAGANA property) JAPANESE_KATAKANA_FULL (IME.JAPANESE_KATAKANA_FULL property) JAPANESE_KATAKANA_HALF (IME.JAPANESE_KATAKANA_HALF property) KOREAN (IME.KOREAN property) UNKNOWN (IME.UNKNOWN property) getEnabled (IME.getEnabled method) public static getEnabled() : Boolean Indicates whether the system IME is enabled. An enabled IME performs multibyte input; a disabled IME performs alphanumeric input.
  • Page 662: Japanese_Katakana_Full

    Example The following example sets the IME to if the system has an Input JAPANESE_HIRAGANA Method Editor (IME) installed ( System.capabilities.hasIME if(System.capabilities.hasIME) { trace(System.IME.getConversionMode()); System.IME.setConversionMode(System.IME.JAPANESE_HIRAGANA); trace(System.IME.getConversionMode()); See also setConversionMode (IME.setConversionMode method) getConversionMode (IME.getConversionMode method) JAPANESE_KATAKANA_FULL (IME.JAPANESE_KATAKANA_FULL property) public static JAPANESE_KATAKANA_FULL : String A string with the value for use with "JAPANESE_KATAKANA_FULL"...
  • Page 663: Japanese_Katakana_Half

    JAPANESE_KATAKANA_HALF (IME.JAPANESE_KATAKANA_HALF property) public static JAPANESE_KATAKANA_HALF : String A string with the value for use with "JAPANESE_KATAKANA_HALF" setConversionMode() . This constant is used with Japanese IMEs. getConversionMode() Availability: ActionScript 1.0; Flash Player 8 Example The following example sets the IME to if the system has an Input JAPANESE_KATAKANA_HALF Method Editor (IME) installed (...
  • Page 664: Onimecomposition (Ime.onimecomposition Event Listener)

    See also setConversionMode (IME.setConversionMode method) getConversionMode (IME.getConversionMode method) onIMEComposition (IME.onIMEComposition event listener) onIMEComposition = function([readingString:String]) {} Notified when the IME composition string is being set. To use this listener, you must create a listener object. You can then define a function for this listener and use IME.addListener() to register the listener with the IME object, as in the following code: var someListener:Object = new Object();...
  • Page 665: Removelistener (Ime.removelistener Method)

    mc.txt.text = "Click this text to add a listener."; mc.onPress = function() { if(System.capabilities.hasIME) { Selection.setFocus(mc.txt); System.IME.setCompositionString(mc.txt.text); See also addListener (IME.addListener method) setCompositionString (IME.setCompositionString method) removeListener (IME.removeListener method) public static removeListener(listener:Object) : Boolean Removes a listener object that was previously registered to an instance with IME.addListener() Availability: ActionScript 1.0;...
  • Page 666: Setcompositionstring (Ime.setcompositionstring Method)

    mc.txt.border = true; mc.txt.background = true; mc.txt.autoSize = "left"; mc.txt.text = "Click this text to add and remove a listener."; mc.onPress = function() { if(System.capabilities.hasIME) { Selection.setFocus(mc.txt); System.IME.setCompositionString(mc.txt.text); setCompositionString (IME.setCompositionString method) public static setCompositionString(composition:String) : Boolean Sets the IME composition string. When this string is set, the user can select IME candidates before committing the result to the text field that currently has focus.
  • Page 667: Setconversionmode (Ime.setconversionmode Method)

    setConversionMode (IME.setConversionMode method) public static setConversionMode(mode:String) : Boolean Sets the conversion mode of the current IME. Availability: ActionScript 1.0; Flash Player 8 Parameters - The conversion mode. Possible values are the IME mode string constants: mode:String ALPHANUMERIC_FULL ALPHANUMERIC_HALF CHINESE JAPANESE_HIRAGANA JAPANESE_KATAKANA_FULL JAPANESE_KATAKANA_HALF KOREAN...
  • Page 668: Setenabled (Ime.setenabled Method)

    setEnabled (IME.setEnabled method) public static setEnabled(enabled:Boolean) : Boolean Enables or disables the system IME. An enabled IME performs multibyte input; a disabled IME performs alphanumeric input. Availability: ActionScript 1.0; Flash Player 8 Parameters - Set to to enable the system IME, to disable it.
  • Page 669: Key

    Example The following example sets the IME to if the system has an Input Method Editor UNKNOWN (IME) installed ( System.capabilities.hasIME if(System.capabilities.hasIME) { trace(System.IME.getConversionMode()); System.IME.setConversionMode(System.IME.UNKNOWN); trace(System.IME.getConversionMode()); See also getConversionMode (IME.getConversionMode method) Object +-Key public class Key extends Object The Key class is a top-level class whose methods and properties you can use without a constructor.
  • Page 670 Property summary Modifiers Property Description The key code value for the Backspace key (8). static BACKSPACE:Number The key code value for the Caps Lock key (20). static CAPSLOCK:Number The key code value for the Control key (17). static CONTROL:Number The key code value for the Delete key (46). static DELETEKEY:Number The key code value for the Down Arrow key (40).
  • Page 671 Event summary Event Description Notified when a key is pressed. onKeyDown function() {} Notified when a key is released. onKeyUp function() {} Method summary Modifiers Signature Description Registers an object to receive onKeyDown and static addListener(listener onKeyUp notification. :Object) : Void Returns the ASCII code of the last key pressed or static getAscii() : Number...
  • Page 672: Addlistener (Key.addlistener Method)

    addListener (Key.addListener method) public static addListener(listener:Object) : Void Registers an object to receive notification. When a key is pressed or onKeyDown onKeyUp released, regardless of the input focus, all listening objects registered with addListener() have either their method or method invoked. Multiple objects can listen onKeyDown onKeyUp for keyboard notifications.
  • Page 673: Backspace (Key.backspace Property)

    Key.addListener(myListener); my_btn.onPress = myOnPress; my_btn._accProps.shortcut = "Ctrl+7"; Accessibility.updateProperties(); See also getCode (Key.getCode method) isDown (Key.isDown method) onKeyDown (Key.onKeyDown event listener) onKeyUp (Key.onKeyUp event listener) removeListener (Key.removeListener method) BACKSPACE (Key.BACKSPACE property) public static BACKSPACE : Number The key code value for the Backspace key (8). Availability: ActionScript 1.0;...
  • Page 674: Control (Key.control Property)

    Example The following example creates a new listener object and defines a function for onKeyDown The last line uses to register the listener with the Key object so that it can addListener() receive notification from the key down event. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.CAPSLOCK)) { trace("you pressed the Caps Lock key.");...
  • Page 675: Deletekey (Key.deletekey Property)

    DELETEKEY (Key.DELETEKEY property) public static DELETEKEY : Number The key code value for the Delete key (46). Availability: ActionScript 1.0; Flash Player 5 Example The following example lets you draw lines with the mouse pointer using the Drawing API and listener objects.
  • Page 676: Down (Key.down Property)

    DOWN (Key.DOWN property) public static DOWN : Number The key code value for the Down Arrow key (40). Availability: ActionScript 1.0; Flash Player 5 Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key.
  • Page 677: Enter (Key.enter Property)

    ENTER (Key.ENTER property) public static ENTER : Number The key code value for the Enter key (13). Availability: ActionScript 1.0; Flash Player 5 Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key. The instance stops when you press Enter and deletes the car_mc event.
  • Page 678: Escape (Key.escape Property)

    ESCAPE (Key.ESCAPE property) public static ESCAPE : Number The key code value for the Escape key (27). Availability: ActionScript 1.0; Flash Player 5 Example The following example sets a timer. When you press Escape, the Output panel displays information that includes how long it took you to press the key. var keyListener:Object = new Object();...
  • Page 679: Getcode (Key.getcode Method)

    Example The following example calls the method any time a key is pressed. The example getAscii() creates a listener object named and defines a function that responds to the keyListener event by calling .The object is then registered to onKeyDown Key.getAscii() keyListener object, which broadcasts the...
  • Page 680 Returns - The key code of the last key pressed. This method returns 0 if no key was pressed or Number released, or if the key code is not accessible for security reasons. Example The following example calls the method any time a key is pressed. The example getCode() creates a listener object named and defines a function that responds to the...
  • Page 681: Home (Key.home Property)

    HOME (Key.HOME property) public static HOME : Number The key code value for the Home key (36). Availability: ActionScript 1.0; Flash Player 5 Example The following example attaches a draggable movie clip called at the x and y car_mc coordinates of 0,0. When you press the Home key, returns to 0,0.
  • Page 682: Isaccessible (Key.isaccessible Method)

    Example The following example creates a new listener object and defines a function for onKeyDown The last line uses to register the listener with the Key object so that it can addListener() receive notification from the key down event and display information in the Output panel. var keyListener:Object = new Object();...
  • Page 683: Istoggled (Key.istoggled Method)

    Returns - The value if the key specified in is pressed; otherwise. Boolean true keycode false Example The following script lets the user control a movie clip's ( ) location: car_mc car_mc.onEnterFrame = function() { if (Key.isDown(Key.RIGHT)) { this._x += 10; } else if (Key.isDown(Key.LEFT)) { this._x -= 10;...
  • Page 684 Example The following example calls the method any time a key is pressed and executes isToggled() a trace statement any time the Caps Lock key is toggled to an active state. The example creates a listener object named and defines a function that responds to the keyListener onKeyDown event by calling...
  • Page 685: Left (Key.left Property)

    LEFT (Key.LEFT property) public static LEFT : Number The key code value for the Left Arrow key (37). Availability: ActionScript 1.0; Flash Player 5 Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key.
  • Page 686: Onkeydown (Key.onkeydown Event Listener)

    Example The following example shows how to use the property to ascertain the number of length listener objects currently registered to the Key object. var myListener:Object = new Object(); myListener.onKeyDown = function () { trace ("You pressed a key."); Key.addListener(myListener); trace(Key._listeners.length);...
  • Page 687: Onkeyup (Key.onkeyup Event Listener)

    onKeyUp (Key.onKeyUp event listener) onKeyUp = function() {} Notified when a key is released. To use , you must create a listener object. You can onKeyUp then define a function for and use to register the listener with the onKeyUp addListener() Key object, as shown in the following example: var keyListener:Object = new Object();...
  • Page 688: Pgup (Key.pgup Property)

    PGUP (Key.PGUP property) public static PGUP : Number The key code value for the Page Up key (33). Availability: ActionScript 1.0; Flash Player 5 Example The following example rotates a movie clip called when you press the Page Down or car_mc Page Up key.
  • Page 689: Right (Key.right Property)

    break; case Key.RIGHT : car_mc._x += 10; break; case Key.ESCAPE : Key.removeListener(keyListener); Key.addListener(keyListener); RIGHT (Key.RIGHT property) public static RIGHT : Number The key code value for the Right Arrow key (39). Availability: ActionScript 1.0; Flash Player 5 Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key.
  • Page 690: Shift (Key.shift Property)

    SHIFT (Key.SHIFT property) public static SHIFT : Number The key code value for the Shift key (16). Availability: ActionScript 1.0; Flash Player 5 Example The following example scales when you press Shift. car_mc var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.SHIFT)) { car_mc._xscale = 2;...
  • Page 691: Tab (Key.tab Property)

    break; case Key.RIGHT : car_mc._x += DISTANCE; break; case Key.DOWN : car_mc._y += DISTANCE; break; Key.addListener(keyListener_obj); TAB (Key.TAB property) public static TAB : Number The key code value for the Tab key (9). Availability: ActionScript 1.0; Flash Player 5 Example The following example creates a text field, and displays the date in the text field when you press Tab.
  • Page 692: Loadvars

    Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key. A sound plays when you press the Spacebar. For this example, give a sound in the library a linkage identifier of horn_id var DISTANCE:Number = 10;...
  • Page 693 The LoadVars class lets you send all the variables in an object to a specified URL and to load all the variables at a specified URL into an object. It also lets you send specific variables, rather than all variables, which can make your application more efficient. You can use the handler to ensure that your application runs when data is loaded, and not LoadVars.onLoad before.
  • Page 694 Constructor summary Signature Description Creates a LoadVars object. LoadVars() Method summary Modifiers Signature Description Adds or changes HTTP request headers (such as addRequestHeader(hea Content-Type or SOAPAction) sent with POST der:Object, actions. headerValue:String) : Void Converts the variable string to properties of the decode(queryString:S specified LoadVars object.
  • Page 695: Addrequestheader (Loadvars.addrequestheader Method)

    addRequestHeader (LoadVars.addRequestHeader method) public addRequestHeader(header:Object, headerValue:String) : Void Adds or changes HTTP request headers (such as ) sent with Content-Type SOAPAction actions. In the first usage, you pass two strings to the method: POST header . In the second usage, you pass an array of strings, alternating header names and headerValue header values.
  • Page 696: Contenttype (Loadvars.contenttype Property)

    See also addRequestHeader (XML.addRequestHeader method) contentType (LoadVars.contentType property) public contentType : String The MIME type that is sent to the server when you call LoadVars.send() . The default is application/x-www-form-urlencoded. LoadVars.sendAndLoad() Availability: ActionScript 1.0; Flash Player 6 Example The following example creates a LoadVars object and displays the default content type of the data that is sent to the server.
  • Page 697: Getbytesloaded (Loadvars.getbytesloaded Method)

    for (var prop in my_lv) { trace(prop+" -> "+my_lv[prop]); See also onData (LoadVars.onData handler) parseXML (XML.parseXML method) getBytesLoaded (LoadVars.getBytesLoaded method) public getBytesLoaded() : Number Returns the number of bytes downloaded by LoadVars.load() . This method returns if no load operation is in LoadVars.sendAndLoad() undefined progress or if a load operation has not yet begun.
  • Page 698: Getbytestotal (Loadvars.getbytestotal Method)

    loadvars_pb.setProgress(my_lv.getBytesLoaded(), my_lv.getBytesTotal()); delete timer_mc.onEnterFrame; if (success) { trace("LoadVars loaded successfully."); } else { trace("An error occurred while loading variables."); my_lv.load("[place a valid URL pointing to a text file here]"); See also load (LoadVars.load method) sendAndLoad (LoadVars.sendAndLoad method) getBytesTotal (LoadVars.getBytesTotal method) public getBytesTotal() : Number Returns the total number of bytes downloaded by LoadVars.load()
  • Page 699: Load (Loadvars.load Method)

    if (lvBytesTotal != undefined) { trace("Loaded "+lvBytesLoaded+" of "+lvBytesTotal+" bytes."); loadvars_pb.setProgress(lvBytesLoaded, lvBytesTotal); my_lv.onLoad = function(success:Boolean) { loadvars_pb.setProgress(my_lv.getBytesLoaded(), my_lv.getBytesTotal()); delete timer_mc.onEnterFrame; if (success) { trace("LoadVars loaded successfully."); } else { trace("An error occurred while loading variables."); my_lv.load("[place a valid URL pointing to a text file here]"); See also load (LoadVars.load method) sendAndLoad (LoadVars.sendAndLoad method)
  • Page 700 Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis For Flash Player 7 and later websites can permit cross-domain access to a resource via a cross- domain policy file.
  • Page 701: Loaded (Loadvars.loaded Property)

    For another example, see the guestbook.fla file in the ActionScript samples folder. Here are some typical paths to this folder: Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/ Samples/ActionScript See also load (XML.load method) loaded (LoadVars.loaded property)
  • Page 702: Loadvars Constructor

    LoadVars constructor public LoadVars() Creates a LoadVars object. You can then use the methods of that LoadVars object to send and load data. Availability: ActionScript 1.0; Flash Player 6 Example The following example creates a LoadVars object called my_lv var my_lv:LoadVars = new LoadVars(); onData (LoadVars.onData handler) onData = function(src:String) {} Invoked when data has completely downloaded from the server or when an error occurs while...
  • Page 703: Onhttpstatus (Loadvars.onhttpstatus Handler)

    return; content_ta.text = src; my_lv.load("content.txt", my_lv, "GET"); See also onLoad (LoadVars.onLoad handler) onLoad (LoadVars.onLoad handler) load (LoadVars.load method) sendAndLoad (LoadVars.sendAndLoad method) onHTTPStatus (LoadVars.onHTTPStatus handler) onHTTPStatus = function(httpStatus:Number) {} Invoked when Flash Player receives an HTTP status code from the server. This handler lets you capture and act on HTTP status codes.
  • Page 704 < 600) { this.httpStatusType = "serverError"; myLoadVars.onData = function(src:String) { trace(">> " + this.httpStatusType + ": " + this.httpStatus); if(src != undefined) { this.decode(src); this.loaded = true; this.onLoad(true); else { this.onLoad(false); myLoadVars.onLoad = function(success:Boolean) { myLoadVars.load("http://weblogs.macromedia.com/mxna/flashservices/ getMostRecentPosts.cfm"); ActionScript classes...
  • Page 705: Onload (Loadvars.onload Handler)

    See also onHTTPStatus (XML.onHTTPStatus handler) load (LoadVars.load method) sendAndLoad (LoadVars.sendAndLoad method) onLoad (LoadVars.onLoad handler) onLoad = function(success:Boolean) {} Invoked when a operation has ended. If the LoadVars.load() LoadVars.sendAndLoad() operation was successful, is populated with variables downloaded by the operation, and my_lv these variables are available when this handler is invoked.
  • Page 706: Send (Loadvars.send Method)

    To view a more robust example, see the login.fla file in the ActionScript samples folder. Here are some typical paths to this folder: Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/ Samples/ActionScript See also onLoad (XML.onLoad handler) loaded (LoadVars.loaded property)
  • Page 707 For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 6 Parameters - A string;...
  • Page 708: Sendandload (Loadvars.sendandload Method)

    For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis For Flash Player 7 and later: Websites can permit cross-domain access to a resource via a cross-domain policy file.
  • Page 709 To view a more robust example, see the login.fla file in the ActionScript samples folder. Typical paths to the ActionScript samples folder are: Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/ Samples/ActionScript LoadVars...
  • Page 710: Tostring (Loadvars.tostring Method)

    See also send (LoadVars.send method) load (LoadVars.load method) sendAndLoad (XML.sendAndLoad method) toString (LoadVars.toString method) public toString() : String Returns a string containing all enumerable variables in , in the MIME content my_lv encoding application/x-www-form-urlencoded. Availability: ActionScript 1.0; Flash Player 6 Returns - A string.
  • Page 711 The primary methods used to send and receive data are LocalConnection.send() . At its most basic, your code will implement the following LocalConnection.connect() commands; notice that both the LocalConnection.send() commands specify the same connection name, LocalConnection.connect() lc_name // Code in the receiving SWF file this.createTextField("result_txt", 1, 10, 10, 100, 22);...
  • Page 712 Event summary Event Description Invoked whenever receiving_lc receives a request to invoke a method allowDomain from a sending LocalConnection object. function([sendin gDomain:String]) Invoked whenever receiving_lc, which is in a SWF file hosted at a domain allowInsecureDom using a secure protocol (HTTPS), receives a request to invoke a method from a sending LocalConnection object that is in a SWF file hosted at a function([sendin nonsecure protocol.
  • Page 713: Allowdomain (Localconnection.allowdomain Handler)

    Method summary Modifiers Signature Description Closes (disconnects) a LocalConnection object. close() : Void Prepares a LocalConnection object to receive connect(connectionNa commands from a LocalConnection.send() me:String) : Boolean command (called the sending LocalConnection object). Returns a string representing the domain of the domain() : String location of the current SWF file.
  • Page 714 to explicitly permit LocalConnection objects from LocalConnection.allowDomain specified domains, or from any domain, to execute methods of the receiving LocalConnection object. If you don't declare the sendingDomain parameter, you probably want to accept commands from any domain, and the code in your handler would be simply return true. If you do declare sendingDomain, you probably want to compare the value of sendingDomain with domains from which you want to accept commands.
  • Page 715 The opposite situation can also occur: You might create a child SWF file that wants to accept LocalConnection calls from its parent but doesn't know the domain of its parent. In this situation, implement this method by checking whether the domain argument matches the domain of _parent._url.
  • Page 716 += aString+newline; aLocalConn.allowDomain = function(sendingDomain) { return (sendingDomain == this.domain() || sendingDomain == "www.macromedia.com"); aLocalConn.connect("_mylc"); When published for Flash Player 7 or later, exact domain matching is used. This means that the example will fail if the SWF files are located at www.thatDomain.com but will work if the files are located at thatDomain.com.
  • Page 717: Allowinsecuredomain (Localconnection.allowinsecuredomain Handler)

    LocalConnection object. Example The following example allows connections from the current domain or from www.macromedia.com, or allows insecure connections only from the current domain. this.createTextField("welcome_txt", this.getNextHighestDepth(), 10, 10, 100, 20); var my_lc:LocalConnection = new LocalConnection(); my_lc.allowDomain = function(sendingDomain:String) { domain_txt.text = sendingDomain;...
  • Page 718: Close (Localconnection.close Method)

    my_lc.sayHello = function(name:String) { welcome_txt.text = "Hello, "+name; my_lc.connect("lc_name"); If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method used in MovieClip.getNextHighestDepth() this example. See also allowDomain (LocalConnection.allowDomain handler) connect (LocalConnection.connect method) close (LocalConnection.close method) public close() : Void...
  • Page 719: Connect (Localconnection.connect Method)

    method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also connect (LocalConnection.connect method) connect (LocalConnection.connect method) public connect(connectionName:String) : Boolean Prepares a LocalConnection object to receive commands from a LocalConnection.send()
  • Page 720 If you are implementing communication between SWF files in different domains, specifying a string for that begins with an underscore (_) will make the SWF with the connectionName receiving LocalConnection object more portable between domains. Here are the two possible cases: If the string for does not begin with an underscore (_), Flash Player...
  • Page 721 Example The following example shows how a SWF file in a particular domain can invoke a method named in a receiving SWF file in the same domain. printOut First, create one SWF file with the following code: this.createTextField("tf", this.getNextHighestDepth(), 10, 10, 300, 100); var aLocalConnection:LocalConnection = new LocalConnection();...
  • Page 722: Domain (Localconnection.domain Method)

    "macromedia.com" In SWF files published for Flash Player 7 or later, the returned string is the exact domain of the current SWF file. For example, if the SWF file is located at www.macromedia.com, this command returns "www.macromedia.com" If the current SWF file is a local file residing on the client computer, this command returns "localhost"...
  • Page 723 // If either the sending or receiving SWF file is Flash Player 7 or later, // then use the exact domain. In this case, commands from a SWF file posted // at www.macromedia.com will be accepted, but those from one posted at // a different subdomain, e.g. livedocs.macromedia.com, will not.
  • Page 724 Line numbers are included for reference purposes. The sequence of events is described in the following list: The receiving SWF file prepares to receive commands on a connection named (line "sum" 11). The Flash Player resolves the name of this connection to (see "mydomain.com:sum"...
  • Page 725: Localconnection Constructor

    // determine our domain and see if we need to truncate it 57 var channelDomain:String = lc.domain(); 58 if (getVersion() >= 7 && this.getSWFVersion() >= 7) 59 { // split domain name into elements 60 var domainArray:Array = channelDomain.split("."); // if more than two elements are found, // chop off first element to create superdomain 61 if (domainArray.length >...
  • Page 726: Onstatus (Localconnection.onstatus Handler)

    // Code in the sending SWF file var sending_lc:LocalConnection = new LocalConnection(); sending_lc.send("lc_name", "methodToExecute", 5, 7); See also connect (LocalConnection.connect method) send (LocalConnection.send method) onStatus (LocalConnection.onStatus handler) onStatus = function(infoObject:Object) {} Invoked after a sending LocalConnection object tries to send a command to a receiving LocalConnection object.
  • Page 727: Send (Localconnection.send Method)

    Example The following example displays a status message about whether the SWF file connects to another local connection object called . A TextInput component called lc_name name_ti TextArea instance called and a Button instance called are used to status_ta send_button display content.
  • Page 728 For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 6...
  • Page 729: Locale (Mx.lang.locale)

    Returns - A Boolean value: if Flash can carry out the request; otherwise. Boolean true false A return value of true does not necessarily mean that Flash successfully connected to a receiving object; It means only that the command us syntactically LocalConnection correct.
  • Page 730 —String ID replacement is controlled using "via ActionScript at runtime" ActionScript at runtime. This option gives you control over both the timing and language of string ID replacement. You can use the properties and methods of this class when you want to replace the string IDs "via ActionScript at runtime."...
  • Page 731 Method summary Modifiers Signature Description Adds the {instance, string ID} pair into the internal static addDelayedInstance(i array for later use. nstance:Object, stringID:String) : Void Adds the {languageCode and languagePath} pair into static addXMLPath(langCode: the internal array for later use. String, path:String) : Void Returns true if the XML file is loaded;...
  • Page 732: Adddelayedinstance (Locale.adddelayedinstance Method)

    Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method) addDelayedInstance (Locale.addDelayedInstance method) public static addDelayedInstance(instance:Object, stringID:String) : Void Adds the {instance, string ID} pair into the internal array for later use.
  • Page 733: Autoreplace (Locale.autoreplace Property)

    Parameters - The language code. langCode:String - The XML path to add. path:String Example The following example uses the method to check whether the language XML setInterval() file has successfully loaded. import mx.lang.Locale; Locale.setLoadCallback(localeCallback); Locale.loadLanguageXML("en"); // create interval to check if language XML file is loaded var locale_int:Number = setInterval(checkLocaleStatus, 10);...
  • Page 734: Checkxmlstatus (Locale.checkxmlstatus Method)

    Example The following example uses the property to populate the dynamically Locale.autoReplace created text field on the Stage with the contents of the string greeting_txt IDS_GREETING in the English XML file. In the Strings panel, click the Settings button to open the Settings dialog box.
  • Page 735: Getdefaultlang (Locale.getdefaultlang Method)

    getDefaultLang (Locale.getDefaultLang method) public static getDefaultLang() : String The default language code as set in the Strings panel dialog box or by calling the method. setDefaultLang() Availability: ActionScript 2.0; Flash Player 8 Returns - Returns the default language code. String Example The following example creates a variable called , which is used to hold the initial...
  • Page 736: Languagecodearray (Locale.languagecodearray Property)

    Example This example shows how to use the method to automatically populate the initialize() text field on the Stage with the user's current OS language. Instead of using greeting_txt method directly, use the string replacement method of initialize() "automatically at runtime" import mx.lang.Locale;...
  • Page 737: Loadlanguagexml (Locale.loadlanguagexml Method)

    Example The following example loads a language XML file based on the current value of a ComboBox component. You drag a ComboBox component onto the Stage and give it an instance name . Using the Text tool, you create a dynamic text field and give it an instance name lang_cb .
  • Page 738: Loadstring (Locale.loadstring Method)

    Example The following example uses the method to load the English (en) XML loadLanguageXML() language file. Once the language file loads, the method is called and localeCallback() populates the text field on the Stage with the contents of the greeting_txt IDS_GREETING string in the XML file.
  • Page 739: Loadstringex (Locale.loadstringex Method)

    function checkLocaleStatus():Void { if (Locale.checkXMLStatus()) { clearInterval(locale_int); trace("clearing interval @ " + getTimer() + " ms"); // callback function for Locale.setLoadCallback() function localeCallback(success:Boolean):Void { greeting_txt.text = Locale.loadString("IDS_GREETING"); See also loadStringEx (Locale.loadStringEx method) loadStringEx (Locale.loadStringEx method) public static loadStringEx(stringID:String, languageCode:String) : String Returns the string value associated with the given string ID and language code.
  • Page 740: Setdefaultlang (Locale.setdefaultlang Method)

    See also loadString (Locale.loadString method) setDefaultLang (Locale.setDefaultLang method) public static setDefaultLang(langCode:String) : Void Sets the default language code. Availability: ActionScript 2.0; Flash Player 7 Parameters - A string representing a language code. langCode:String Example The following example creates a variable called , which is used to hold the initial defLang default language for the Flash document.
  • Page 741: Setstring (Locale.setstring Method)

    Parameters - The function to call when the XML language file loads. loadCallback:Function Example The following example uses an interval to check every 10 milliseconds to see if the language file has successfully loaded. Once the XML file has loaded, the text field greeting_txt instance on the Stage is populated with the...
  • Page 742: Stringidarray (Locale.stringidarray Property)

    stringIDArray (Locale.stringIDArray property) public static stringIDArray : Array [read-only] An array containing all the string IDs in the FLA file. The string IDs are not sorted alphabetically. Availability: ActionScript 2.0; Flash Player 8 Example The following example traces the property for the currently loaded Locale.stringIDArray language XML file.
  • Page 743 To calculate a radian value, use the following formula: radians = degrees * Math.PI/180 The following is an example of passing the equation as a parameter to calculate the sine of a 45° angle: is the same as Math.sin(45 * Math.PI/180) Math.sin(.7854) Availability: ActionScript 1.0;...
  • Page 744 Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Computes and returns an absolute value for the static abs(x:Number) : number specified by the parameter x. Number Computes and returns the arc cosine of the number static acos(x:Number) :...
  • Page 745: Abs (Math.abs Method)

    Modifiers Signature Description Returns a pseudo-random number n, where 0 <= n < 1. static random() : Number Rounds the value of the parameter x up or down to static round(x:Number) : the nearest integer and returns the value. Number Computes and returns the sine of the specified angle static sin(x:Number) :...
  • Page 746: Acos (Math.acos Method)

    trace(num); // output: -12 trace(numAbsolute); // output: 12 acos (Math.acos method) public static acos(x:Number) : Number Computes and returns the arc cosine of the number specified in the parameter , in radians. Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 747: Atan (Math.atan Method)

    Returns - A number between negative pi divided by 2 and positive pi divided by 2. Number Example The following example displays the arc sine for several values. trace(Math.asin(-1)); // output: -1.5707963267949 trace(Math.asin(0)); // output: 0 trace(Math.asin(1)); // output: 1.5707963267949 See also acos (Math.acos method) atan (Math.atan method)
  • Page 748: Atan2 (Math.atan2 Method)

    atan2 (Math.atan2 method) public static atan2(y:Number, x:Number) : Number Computes and returns the angle of the point in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle). The return value is between positive pi and negative pi. Availability: ActionScript 1.0;...
  • Page 749: Cos (Math.cos Method)

    Returns - An integer that is both closest to, and greater than or equal to, parameter Number Example The following code returns a value of 13: Math.ceil(12.5); See also floor (Math.floor method) round (Math.round method) cos (Math.cos method) public static cos(x:Number) : Number Computes and returns the cosine of the specified angle in radians.
  • Page 750: E (Math.e Property)

    See also acos (Math.acos method) asin (Math.asin method) atan (Math.atan method) atan2 (Math.atan2 method) sin (Math.sin method) tan (Math.tan method) E (Math.E property) public static E : Number A mathematical constant for the base of natural logarithms, expressed as e. The approximate value of eis 2.71828182845905.
  • Page 751: Floor (Math.floor Method)

    Parameters - The exponent; a number or expression. x:Number Returns - A number. Number Example The following example displays the logarithm for two number values. trace(Math.exp(1)); // output: 2.71828182845905 trace(Math.exp(2)); // output: 7.38905609893065 See also E (Math.E property) floor (Math.floor method) public static floor(x:Number) : Number Returns the floor of the number or expression specified in the parameter .
  • Page 752: Ln10 (Math.ln10 Property)

    LN10 (Math.LN10 property) public static LN10 : Number A mathematical constant for the natural logarithm of 10, expressed as loge10, with an approximate value of 2.302585092994046. Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 753: Log10E (Math.log10E Property)

    Example The following example displays the logarithm for three numerical values. trace(Math.log(0)); // output: -Infinity trace(Math.log(1)); // output: 0 trace(Math.log(2)); // output: 0.693147180559945 trace(Math.log(Math.E)); // output: 1 LOG10E (Math.LOG10E property) public static LOG10E : Number A mathematical constant for the base-10 logarithm of the constant e ( ), expressed as Math.E log10e, with an approximate value of 0.4342944819032518.
  • Page 754: Max (Math.max Method)

    max (Math.max method) public static max(x:Number, y:Number) : Number Evaluates and returns the larger value. Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 755: Pi (Math.pi Property)

    Returns - A number. Number Example The following example displays , which is the smaller Sat Dec 25 00:00:00 GMT-0700 2004 of the evaluated expressions. var date1:Date = new Date(2004, 11, 25); var date2:Date = new Date(2004, 11, 30); var minDate:Number = Math.min(date1.getTime(), date2.getTime()); trace(new Date(minDate).toString());...
  • Page 756: Pow (Math.pow Method)

    mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y); pow (Math.pow method) public static pow(x:Number, y:Number) : Number Computes and returns to the power of Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 757: Random (Math.random Method)

    method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() random (Math.random method) public static random() : Number Returns a pseudo-random number n, where 0 <= n <...
  • Page 758: Sin (Math.sin Method)

    Returns - A number; an integer. Number Example The following example returns a random number between two specified integers. function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.round(Math.random() * (max-min+1) + (min- .5)); return randomNum; for (var i = 0; i<25; i++) { trace(randRange(4, 11));...
  • Page 759: Sqrt (Math.sqrt Method)

    mc.curveTo(r+x, Math.tan(Math.PI/8)*r+y, Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y); mc.curveTo(Math.tan(Math.PI/8)*r+x, r+y, x, r+y); mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.sin(Math.PI/4)*r+y); mc.curveTo(-r+x, Math.tan(Math.PI/8)*r+y, -r+x, y); mc.curveTo(-r+x, -Math.tan(Math.PI/8)*r+y, -Math.sin(Math.PI/4)*r+x, - Math.sin(Math.PI/4)*r+y); mc.curveTo(-Math.tan(Math.PI/8)*r+x, -r+y, x, -r+y); mc.curveTo(Math.tan(Math.PI/8)*r+x, -r+y, Math.sin(Math.PI/4)*r+x, - Math.sin(Math.PI/4)*r+y); mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y); See also acos (Math.acos method) asin (Math.asin method) atan (Math.atan method) atan2 (Math.atan2 method) cos (Math.cos method)
  • Page 760: Sqrt1_2 (Math.sqrt1_2 Property)

    this.newY = _ymouse; var minY = Math.min(this.origY, this.newY); var nextDepth:Number = canvas_mc.getNextHighestDepth(); var line_mc:MovieClip = canvas_mc.createEmptyMovieClip("line"+nextDepth+"_mc", nextDepth); line_mc.moveTo(this.origX, this.origY); line_mc.lineStyle(2, 0x000000, 100); line_mc.lineTo(this.newX, this.newY); var hypLen:Number = Math.sqrt(Math.pow(line_mc._width, 2)+Math.pow(line_mc._height, 2)); line_mc.createTextField("length"+nextDepth+"_txt", canvas_mc.getNextHighestDepth(), this.origX, this.origY-22, 100, 22); line_mc['length'+nextDepth+'_txt'].text = Math.round(hypLen) +" pixels"; Mouse.addListener(mouseListener);...
  • Page 761: Tan (Math.tan Method)

    tan (Math.tan method) public static tan(x:Number) : Number Computes and returns the tangent of the specified angle. To calculate a radian, use the information outlined in the introduction to the Math class. Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 762: Matrix (Flash.geom.matrix)

    Matrix (flash.geom.Matrix) Object +-flash.geom.Matrix public class Matrix extends Object The flash.geom.Matrix class represents a transformation matrix that determines how to map points from one coordinate space to another. By setting the properties of a Matrix object and applying it to a MovieClip or BitmapData object you can perform various graphical transformations on the object.
  • Page 763 The Matrix class supports the four major types of transformation functions: translation, scaling, rotation, and skewing. There are specialized methods for three of these functions, as described in the following table. Transformation Method Matrix values Display result Description Translation Moves the translate(tx, ty) (displacement) image...
  • Page 764 Availability: ActionScript 1.0; Flash Player 8 See also transform (MovieClip.transform property) Transform (flash.geom.Transform) draw (BitmapData.draw method) a (Matrix.a property) b (Matrix.b property) (Matrix.c property) d (Matrix.d property) tx (Matrix.tx property) (Matrix.ty property) translate (Matrix.translate method) scale (Matrix.scale method) rotate (Matrix.rotate method) Property summary Modifiers Property...
  • Page 765 Constructor summary Signature Description Creates a new Matrix object with the specified parameters. Matrix([a:Number], [b:Number], [c:Number], [d:Number], [tx:Number], [ty:Number]) Method summary Modifiers Signature Description Returns a new Matrix object that is a clone of this clone() : Matrix matrix, with an exact copy of the contained object. Concatenates a matrix with the current matrix, concat(m:Matrix) : effectively combining the geometric effects of the two.
  • Page 766: A (Matrix.a Property)

    Modifiers Signature Description Returns a text value listing the properties of the Matrix toString() : String object. Applies the geometric transformation represented by transformPoint(pt:Po the Matrix object to the specified point. int) : Point Modifies a Matrix object so that the effect of its translate(tx:Number, transformation is to move an object along the x and y ty:Number) : Void...
  • Page 767: C (Matrix.c Property)

    Availability: ActionScript 1.0; Flash Player 8 Example The following example creates the Matrix object and sets its value. myMatrix import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(); trace(myMatrix.b); // 0 var degrees:Number = 45; var radians:Number = (degrees/180) Math.PI; myMatrix.b = radians; trace(myMatrix.b);...
  • Page 768: Concat (Matrix.concat Method)

    Example The following example creates the variable from the variable. The clonedMatrix myMatrix Matrix class does not have an method, so the following example uses a custom written equals function to test the equality of two matrixes. import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(2, 0, 0, 2, 0, 0); var clonedMatrix:Matrix = new Matrix();...
  • Page 769 Example The following example creates three matrixes that define transformations for three rectangle movie clips. The first two matrixes are applied to rotate45Matrix doubleScaleMatrix the two rectangles . Then the third matrix is created rectangleMc_1 rectangleMc_2 using the method on to create concat() rotate45Matrix...
  • Page 770: Createbox (Matrix.createbox Method)

    function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; createBox (Matrix.createBox method) public createBox(scaleX:Number, scaleY:Number, [rotation:Number], [tx:Number], [ty:Number]) : Void Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters.
  • Page 771: Creategradientbox (Matrix.creategradientbox Method)

    Example The following example sets the scale, rotation, x location, and y location of scaleX scaleY by calling its method. myMatrix createBox() import flash.geom.Matrix; import flash.geom.Transform; var myMatrix:Matrix = new Matrix(); trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) myMatrix.createBox(1, 2, Math.PI/4, 100, 200); trace(myMatrix.toString());...
  • Page 772: D (Matrix.d Property)

    Example The following example uses as a parameter for the MovieClip object's myMatrix method. beginGradientFill() import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(); trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) myMatrix.createGradientBox(200, 200, 0, 50, 50); trace(myMatrix.toString()); // (a=0.1220703125, b=0, c=0, d=0.1220703125, tx=150, ty=150) var depth:Number = this.getNextHighestDepth();...
  • Page 773: Deltatransformpoint (Matrix.deltatransformpoint Method)

    deltaTransformPoint (Matrix.deltaTransformPoint method) public deltaTransformPoint(pt:Point) : Point Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters Availability: ActionScript 1.0;...
  • Page 774: Identity (Matrix.identity Method)

    var pointMc_1:MovieClip = createRectangle(10, 10, 0x00FF00); pointMc_1._x = deltaTransformedPoint.x; function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; identity (Matrix.identity method) public identity() : Void Sets each matrix property to a value that cause a transformed movie clip or geometric construct to be identical to the original.
  • Page 775: Invert (Matrix.invert Method)

    myMatrix.translate(100,200); trace(myMatrix.toString()); // (a=1.6, b=1.2, c=-1.2, d=1.6, tx=100, ty=200) myMatrix.scale(2, 2); trace(myMatrix.toString()); // (a=3.2, b=2.4, c=-2.4, d=3.2, tx=200, ty=400) myMatrix.identity(); trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) invert (Matrix.invert method) public invert() : Void Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to undo the transformation performed when applying the original matrix.
  • Page 776: Matrix Constructor

    halfScaleMatrix.invert(); rectangleTrans_2.matrix = halfScaleMatrix; rectangleMc_2._x = 200; trace(halfScaleMatrix.toString()); // (a=0.5, b=0, c=0, d=0.5, tx=0, ty=0) var originalAndInverseMatrix:Matrix = doubleScaleMatrix.clone(); originalAndInverseMatrix.concat(halfScaleMatrix); rectangleTrans_3.matrix = originalAndInverseMatrix; rectangleMc_3._x = 300; trace(originalAndInverseMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_"...
  • Page 777: Rotate (Matrix.rotate Method)

    In matrix notation the identity matrix looks like this: Availability: ActionScript 1.0; Flash Player 8 Parameters [optional] - The value in the first row and first column of the new Matrix object. a:Number [optional] - The value in the first row and second column of the new Matrix object. b:Number [optional] - The value in the second row and first column of the new Matrix object.
  • Page 778 method alters the properties of the Matrix object. In matrix notation rotate() this is shown as follows: Availability: ActionScript 1.0; Flash Player 8 Parameters - The rotation angle in radians. angle:Number Example The following example shows how the method rotates 30°...
  • Page 779 mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; The previous example uses the property of the MovieClip object to position . Generally, when dealing with Matrix object positioning, mixing positioning rectangleMc techniques is considered poor format. The previous example written in correct syntax would concatenate a translation Matrix to to change the horizontal location of myMatrix...
  • Page 780: Scale (Matrix.scale Method)

    scale (Matrix.scale method) public scale(sx:Number, sy:Number) : Void Modifies a matrix so that its effect, when applied, is to resize an image. In the resized image, the location of each pixel on the x axis is multiplied by ; and on the y axis it is multiplied by method alters the properties of the matrix object.
  • Page 781: Transformpoint (Matrix.transformpoint Method)

    Example The following example creates and converts its values to a string in the format of myMatrix (a=A, b=B, c=C, d=D, tx=TX, ty=TY). import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(); trace("myMatrix: " + myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) transformPoint (Matrix.transformPoint method) public transformPoint(pt:Point) : Point...
  • Page 782: Translate (Matrix.translate Method)

    var transformedPoint:Point = myMatrix.transformPoint(myPoint); trace(transformedPoint); // (450, 0) var pointMc_0:MovieClip = createRectangle(10, 10, 0xFF0000); pointMc_0._x = myPoint.x; var pointMc_1:MovieClip = createRectangle(10, 10, 0x00FF00); pointMc_1._x = transformedPoint.x; function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color);...
  • Page 783: Tx (Matrix.tx Property)

    Example The following example uses the method to position x:100 and translate() rectangleMc y:50. The method affects the translation properties , but it doesn't translate() affect the , or properties. import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(2, 0, 0, 2, 100, 100); trace(myMatrix.toString());...
  • Page 784: Microphone

    trace(myMatrix.ty); // 0 myMatrix.ty = 50; trace(myMatrix.ty); // 50 Microphone Object +-Microphone public class Microphone extends Object The Microphone class lets you capture audio from a microphone attached to the computer that is running Flash Player. The Microphone class is primarily for use with Flash Communication Server but can be used in a limited fashion without the server, for example, to transmit sound from your microphone through the speakers on your local system.
  • Page 785 Modifiers Property Description [read- A string that specifies the name of the current sound name:String only] capture device, as returned by the sound capture hardware. [read- Retrieves an array of strings reflecting the names of all static names:Array only] available sound capture devices without displaying the Flash Player Privacy Settings panel.
  • Page 786: Activitylevel (Microphone.activitylevel Property)

    Method summary Modifiers Signature Description Returns a reference to a Microphone object for static get([index:Number]) capturing audio. : Microphone Sets the microphone gain--that is, the amount by setGain(gain:Number) which the microphone should multiply the signal : Void before transmitting it. Sets the rate, in kHz, at which the microphone should setRate(rate:Number) capture sound.
  • Page 787: Gain (Microphone.gain Property)

    Example The following example displays the activity level of the current microphone in a ProgressBar instance called activityLevel_pb var activityLevel_pb:mx.controls.ProgressBar; activityLevel_pb.mode = "manual"; activityLevel_pb.label = "Activity Level: %3%%"; activityLevel_pb.setStyle("themeColor", "0xFF0000"); this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth()); var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); this.onEnterFrame = function() { activityLevel_pb.setProgress(active_mic.activityLevel, 100);...
  • Page 788: Get (Microphone.get Method)

    gain_pb.label = "Gain: %3"; gain_pb.mode = "manual"; gain_pb.setProgress(active_mic.gain, 100); gain_nstep.value = active_mic.gain; function changeGain() { active_mic.setGain(gain_nstep.value); gain_pb.setProgress(active_mic.gain, 100); gain_nstep.addEventListener("change", changeGain); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method.
  • Page 789 When the user responds to this dialog box, the event handler returns Microphone.onStatus an information object that indicates the user's response. To determine whether the user has denied or allowed access to the camera without processing this event handler, use Microphone.muted The user can also specify permanent privacy settings for a particular domain by right-clicking (Windows) or Control-clicking (Macintosh) while a SWF file is playing, choosing Settings,...
  • Page 790: Index (Microphone.index Property)

    var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also get (Microphone.get method) index (Microphone.index property) muted...
  • Page 791: Muted (Microphone.muted Property)

    method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also get (Microphone.get method) names (Microphone.names property) muted (Microphone.muted property) public muted : Boolean [read-only] A Boolean value that specifies whether the user has denied access to the microphone (...
  • Page 792: Names (Microphone.names Property)

    status_ta.text += "You have "+microphone_array.length+" device(s) installed."+newline+newline; for (var i = 0; i<microphone_array.length; i++) { status_ta.text += "["+i+"] "+microphone_array[i]+newline; See also get (Microphone.get method) names (Microphone.names property) names (Microphone.names property) public static names : Array [read-only] Retrieves an array of strings reflecting the names of all available sound capture devices without displaying the Flash Player Privacy Settings panel.
  • Page 793: Onactivity (Microphone.onactivity Handler)

    You have 2 device(s) installed. [0] Logitech USB Headset [1] YAMAHA AC-XG WDM Audio See also name (Microphone.name property) get (Microphone.get method) onActivity (Microphone.onActivity handler) onActivity = function(active:Boolean) {} Invoked when the microphone starts or stops detecting sound. If you want to respond to this event handler, you must create a function to process its activity value.
  • Page 794: Onstatus (Microphone.onstatus Handler)

    method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also setSilenceLevel (Microphone.setSilenceLevel method) onStatus (Microphone.onStatus handler) onStatus = function(infoObject:Object) {} Invoked when the user allows or denies access to the microphone.
  • Page 795: Rate (Microphone.rate Property)

    this.createTextField("muted_txt", this.getNextHighestDepth(), 10, 10, 100, 22); muted_txt.autoSize = true; muted_txt.html = true; muted_txt.selectable = false; muted_txt.htmlText = "<a href=\"asfunction:System.showSettings\"><u>Click Here</u></a> to Allow/Deny access."; this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth()); var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); active_mic.onStatus = function(infoObj:Object) { status_txt._visible = active_mic.muted; muted_txt.htmlText = "Status: <a href=\"asfunction:System.showSettings\"><u>"+infoObj.code+"</u></a>";...
  • Page 796: Setgain (Microphone.setgain Method)

    Example The following code lets you use a ComboBox instance, called , to change the rate at rate_cb which your microphone captures sound. The current rate displays in a Label instance called rate_lbl this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth()); var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); var rate_array:Array = new Array(5, 8, 11, 22, 44);...
  • Page 797: Setrate (Microphone.setrate Method)

    Parameters - An integer that specifies the amount by which the microphone should boost gain:Number the signal. Valid values are 0 to 100. The default value is 50; however, the user may change this value in the Flash Player Microphone Settings panel. Example The following example uses a ProgressBar instance called to display and a...
  • Page 798: Setsilencelevel (Microphone.setsilencelevel Method)

    Example The following example sets the microphone rate to the user's preference (which you have assigned to the variable) if it is one of the following values: 5, 8, 11, 22, or 44. If it userRate is not, the value is rounded to the nearest acceptable value that the sound capture device supports.
  • Page 799 To prevent the microphone from detecting sound at all, pass a value of 100 for level is never invoked. Microphone.onActivity To determine the amount of sound the microphone is currently detecting, use Microphone.activityLevel Activity detection is the ability to detect when audio levels suggest that a person is talking. When someone is not talking, bandwidth can be saved because there is no need to send the associated audio stream.
  • Page 800 var silenceLevel_nstep:mx.controls.NumericStepper; this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth()); var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); silenceLevel_pb.label = "Activity level: %3"; silenceLevel_pb.mode = "manual"; silenceLevel_nstep.minimum = 0; silenceLevel_nstep.maximum = 100; silenceLevel_nstep.value = active_mic.silenceLevel; var nstepListener:Object = new Object(); nstepListener.change = function(evt:Object) { active_mic.setSilenceLevel(evt.target.value, active_mic.silenceTimeOut); silenceLevel_nstep.addEventListener("change", nstepListener); this.onEnterFrame = function() { silenceLevel_pb.setProgress(active_mic.activityLevel, 100);...
  • Page 801: Setuseechosuppression (Microphone.setuseechosuppression Method)

    setUseEchoSuppression (Microphone.setUseEchoSuppression method) public setUseEchoSuppression(useEchoSuppression:Boolean) : Void Specifies whether to use the echo suppression feature of the audio codec. The default value is unless the user has selected Reduce Echo in the Flash Player Microphone Settings false panel. Echo suppression is an effort to reduce the effects of audio feedback, which is caused when sound going out the speaker is picked up by the microphone on the same computer.
  • Page 802: Silencelevel (Microphone.silencelevel Property)

    active_mic.setUseEchoSuppression(evt.target.selected); useEchoSuppression_ch.addEventListener("click", chListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also setUseEchoSuppression (Microphone.setUseEchoSuppression method) useEchoSuppression (Microphone.useEchoSuppression property) silenceLevel (Microphone.silenceLevel property) public silenceLevel : Number [read-only]...
  • Page 803: Silencetimeout (Microphone.silencetimeout Property)

    silenceLevel_pb.setProgress(active_mic.activityLevel, 100); active_mic.onActivity = function(active:Boolean) { if (active) { silenceLevel_pb.indeterminate = false; silenceLevel_pb.setStyle("themeColor", "haloGreen"); silenceLevel_pb.label = "Activity level: %3"; } else { silenceLevel_pb.indeterminate = true; silenceLevel_pb.setStyle("themeColor", "0xFF0000"); silenceLevel_pb.label = "Activity level: (inactive)"; method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later.
  • Page 804: Useechosuppression (Microphone.useechosuppression Property)

    this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth()); var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); silenceLevel_pb.label = "Activity level: %3"; silenceLevel_pb.mode = "manual"; silenceTimeOut_nstep.minimum = 0; silenceTimeOut_nstep.maximum = 10; silenceTimeOut_nstep.value = active_mic.silenceTimeOut/1000; var nstepListener:Object = new Object(); nstepListener.change = function(evt:Object) { active_mic.setSilenceLevel(active_mic.silenceLevel, evt.target.value 1000); silenceTimeOut_nstep.addEventListener("change", nstepListener); this.onEnterFrame = function() { silenceLevel_pb.setProgress(active_mic.activityLevel, 100);...
  • Page 805: Mouse

    Availability: ActionScript 1.0; Flash Player 6 Example The following example turns on echo suppression if the user selects a CheckBox instance called . The ProgressBar instance called useEchoSuppression_ch activityLevel_pb displays the current activity level of the audio stream. var useEchoSuppression_ch:mx.controls.CheckBox; var activityLevel_pb:mx.controls.ProgressBar;...
  • Page 806 A Flash application can only monitor mouse events that occur within its focus. A Flash application cannot detect mouse events in another application. Availability: ActionScript 1.0; Flash Player 5 Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property),...
  • Page 807: Addlistener (Mouse.addlistener Method)

    Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method) addListener (Mouse.addListener method) public static addListener(listener:Object) : Void Registers an object to receive notifications of the onMouseDown onMouseMove...
  • Page 808: Hide (Mouse.hide Method)

    To view the entire script, see the animation.fla file in the ActionScript samples Folder. The following list shows typical paths to the ActionScript samples Folder: Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/ Samples/ActionScript See also onMouseDown (Mouse.onMouseDown event listener) onMouseMove (Mouse.onMouseMove event listener)
  • Page 809: Onmousedown (Mouse.onmousedown Event Listener)

    updateAfterEvent(); Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also show (Mouse.show method) _xmouse (MovieClip._xmouse property) _ymouse (MovieClip._ymouse property)
  • Page 810: Onmousemove (Mouse.onmousemove Event Listener)

    this.target_mc.clear(); this.target_mc.lineStyle(1, 0xFF0000, 100); this.target_mc.moveTo(this.orig_x, this.orig_y); this.target_mc.lineTo(_xmouse, this.orig_y); this.target_mc.lineTo(_xmouse, _ymouse); this.target_mc.lineTo(this.orig_x, _ymouse); this.target_mc.lineTo(this.orig_x, this.orig_y); updateAfterEvent(); mouseListener.onMouseUp = function() { this.isDrawing = false; Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method.
  • Page 811 var mouseListener:Object = new Object(); mouseListener.onMouseDown = function() { this.isDrawing = true; canvas_mc.lineStyle(2, 0xFF0000, 100); canvas_mc.moveTo(_xmouse, _ymouse); mouseListener.onMouseMove = function() { if (this.isDrawing) { canvas_mc.lineTo(_xmouse, _ymouse); updateAfterEvent(); mouseListener.onMouseUp = function() { this.isDrawing = false; Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later.
  • Page 812: Onmouseup (Mouse.onmouseup Event Listener)

    onMouseUp (Mouse.onMouseUp event listener) onMouseUp = function() {} Notified when the mouse is released. To use the listener, you must create a listener onMouseUp object. You can then define a function for and use to register the onMouseUp addListener() listener with the Mouse object, as shown in the following code: var someListener:Object = new Object();...
  • Page 813: Onmousewheel (Mouse.onmousewheel Event Listener)

    onMouseWheel (Mouse.onMouseWheel event listener) onMouseWheel = function([delta:Number], [scrollTarget:String]) {} Notified when the user rolls the mouse wheel. To use the listener, you must onMouseWheel create a listener object. You can then define a function for and use onMouseWheel to register the listener with the Mouse object. addListener() Note: Mouse wheel event listeners are available only in Windows versions of Flash Player.
  • Page 814: Removelistener (Mouse.removelistener Method)

    mouseListener.onMouseWheel = function(delta:Number) { line_mc._rotation += delta; mouseListener.onMouseDown = function() { trace("Down"); Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method.
  • Page 815 startDrawing_button.enabled = false; this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth()); var mouseListener:Object = new Object(); mouseListener.onMouseDown = function() { this.isDrawing = true; canvas_mc.lineStyle(2, 0xFF0000, 100); canvas_mc.moveTo(_xmouse, _ymouse); mouseListener.onMouseMove = function() { if (this.isDrawing) { canvas_mc.lineTo(_xmouse, _ymouse); updateAfterEvent(); mouseListener.onMouseUp = function() { this.isDrawing = false; Mouse.addListener(mouseListener); var clearListener:Object = new Object();...
  • Page 816: Show (Mouse.show Method)

    show (Mouse.show method) public static show() : Number Displays the mouse pointer in a SWF file. The pointer is visible by default. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer; either . If the mouse pointer was hidden before the call to Number then the return value is .
  • Page 817: Movieclip

    MovieClip Object +-MovieClip public dynamic class MovieClip extends Object The methods for the MovieClip class provide the same functionality as actions that target movie clips. Some additional methods do not have equivalent actions in the Actions toolbox in the Actions panel. You do not use a constructor method to create a movie clip.
  • Page 818 Modifiers Property Description A Boolean value that indicates whether a movie clip enabled:Boolean is enabled. An indexed array containing each filter object filters:Array currently associated with the movie clip. If the value is undefined or false, a movie clip focusEnabled:Boolean cannot receive input focus unless it is a button.
  • Page 819 Modifiers Property Description The scrollRect property allows you to quickly scrollRect:Object scroll movie clip content and have a window viewing larger content. Specifies the number of seconds a sound prebuffers _soundbuftime:Number before it starts to stream. Determines whether the children of a movie clip are tabChildren:Boolean included in the automatic tab ordering.
  • Page 820 Modifiers Property Description Sets the y coordinate of a movie clip relative to the _y:Number local coordinates of the parent movie clip. [read- Indicates the y coordinate of the mouse position. _ymouse:Number only] Sets the vertical scale (percentage) of the movie _yscale:Number clip as applied from the registration point of the movie clip.
  • Page 821 Event Description Invoked when the mouse button is released. onMouseUp function() {} Invoked when the user clicks the mouse while the pointer is over a movie onPress clip. function() {} Invoked when a user releases the mouse button over a movie clip. onRelease function() {} Invoked after a user presses the mouse button inside the movie clip area...
  • Page 822 Modifiers Signature Description Fills a drawing area with a bitmap image. beginBitmapFill(bmp: BitmapData, [matrix:Matrix], [repeat:Boolean], [smoothing:Boolean]) : Void Indicates the beginning of a new drawing path. beginFill(rgb:Number , [alpha:Number]) : Void Indicates the beginning of a new drawing path. beginGradientFill(fi llType:String, colors:Array, alphas:Array,...
  • Page 823 Modifiers Signature Description Creates an instance of the specified movie clip while duplicateMovieClip(n the SWF file is playing. ame:String, depth:Number, [initObject:Object]) : MovieClip Applies a fill to the lines and curves that were since the endFill() : Void last call to beginFill() or beginGradientFill(). Returns properties that are the minimum and getBounds(bounds:Obj maximum x and y coordinate values of the movie clip,...
  • Page 824 Modifiers Signature Description Converts the pt object from Stage (global) globalToLocal(pt:Obj coordinates to the movie clip's (local) coordinates. ect) : Void Starts playing the SWF file at the specified frame. gotoAndPlay(frame:Ob ject) : Void Brings the playhead to the specified frame of the gotoAndStop(frame:Ob movie clip and stops it there.
  • Page 825 Modifiers Signature Description Converts the pt object from the movie clip's (local) localToGlobal(pt:Obj coordinates to the Stage (global) coordinates. ect) : Void Moves the current drawing position to (x, y). moveTo(x:Number, y:Number) : Void Sends the playhead to the next frame and stops it. nextFrame() : Void Moves the playhead in the timeline of the movie clip.
  • Page 826: Alpha (Movieclip._Alpha Property)

    Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method) _alpha (MovieClip._alpha property) public _alpha : Number The alpha transparency value of the movie clip. Valid values are 0 (fully transparent) to 100 (fully opaque).
  • Page 827: Attachaudio (Movieclip.attachaudio Method)

    See also _alpha (Button._alpha property) _alpha (TextField._alpha property) _visible (MovieClip._visible property) attachAudio (MovieClip.attachAudio method) public attachAudio(id:Object) : Void Specifies the audio source to be played. To stop playing the audio source, pass the value false for the You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
  • Page 828: Attachbitmap (Movieclip.attachbitmap Method)

    audio_sound.setVolume(audio_sound.getVolume()-10); updateVolume(); // Updates the volume. this.createTextField("volume_txt", this.getNextHighestDepth(), 0, 0, 100, 22); updateVolume(); function updateVolume() { volume_txt.text = "Volume: "+audio_sound.getVolume(); The following example specifies a microphone as the audio source for a dynamically created movie clip instance called audio_mc var active_mic:Microphone = Microphone.get(); this.createEmptyMovieClip("audio_mc", this.getNextHighestDepth());...
  • Page 829: Attachmovie (Movieclip.attachmovie Method)

    Pixel snapping forces the position of the bitmap to the nearest whole pixel value instead of positioning to be on a partial pixel. There are three pixel snapping modes: Auto mode does pixel snapping as long as the bitmap is not stretched or rotated. Always mode always does pixel snapping, regardless of stretching and rotation.
  • Page 830: Beginbitmapfill (Movieclip.beginbitmapfill Method)

    Parameters - The linkage name of the movie clip symbol in the library to attach to a movie id:String clip on the Stage. This is the name that you enter in the Identifier field in the Linkage Properties dialog box. - A unique instance name for the movie clip being attached to the movie clip.
  • Page 831 [optional] - A matrix object (of the flash.geom.Matrix class), matrix:flash.geom.Matrix which you can use to define transformations on the bitmap. For instance, you can use the following matrix to rotate a bitmap by 45 degrees (pi/4 radians): var matrix = new flash.geom.Matrix(); matrix.rotate(Math.PI/4);...
  • Page 832: Beginfill (Movieclip.beginfill Method)

    this.createEmptyMovieClip("bmp_fill_mc", this.getNextHighestDepth()); with (bmp_fill_mc) { matrix = new Matrix(); matrix.rotate(Math.PI/8); repeat = true; smoothing = true; beginBitmapFill(bmpd, matrix, repeat, smoothing); moveTo(0, 0); lineTo(0, 60); lineTo(60, 60); lineTo(60, 0); lineTo(0, 0); endFill(); bmp_fill_mc._xscale = 200; bmp_fill_mc._yscale = 200; If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method, which is MovieClip.getNextHighestDepth()
  • Page 833: Begingradientfill (Movieclip.begingradientfill Method)

    MovieClip.getNextHighestDepth() An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ See also moveTo (MovieClip.moveTo method) endFill (MovieClip.endFill method) beginGradientFill (MovieClip.beginGradientFill method)
  • Page 834 The flash.geom.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the method of MovieClip class. Macromedia recommends that you beginGradientFill() use this form of matrix for Flash Player 8 and later.
  • Page 835 3 matrix of the following form: a b c d e f g h i For Flash Player 8 and later, Macromedia recommends that you define the matrix parameter in the form of a object (as described in the first item in flash.geom.Matrix the list).
  • Page 836 For Flash Player 8 and later, Macromedia recommends that you define the matrix parameter in the form of a object (as described in the first item in flash.geom.Matrix...
  • Page 837 colors = [0xFF0000, 0x0000FF]; fillType = "radial" alphas = [100, 100]; ratios = [0, 0xFF]; spreadMethod = "reflect"; interpolationMethod = "linearRGB"; focalPointRatio = 0.9; matrix = {matrixType:"box", x:100, y:100, w:200, h:200, r:(45/ 180)*Math.PI}; beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio); moveTo(100, 100);...
  • Page 838 this.lineTo(0, 0); this.endFill(); This example uses for the spread method, so the gradient fill looks like the following: "pad" If you used for the spread method, the gradient fill would look like the following: "reflect" If you used for the spread method, the gradient fill would look like the following: "repeat"...
  • Page 839 [optional] - Added in Flash Player 8. A number that controls the focalPointRatio:Number location of the focal point of the gradient. The value 0 means the focal point is in the center. The value 1 means the focal point is at one border of the gradient circle. The value -1 means the focal point is at the other border of the gradient circle.
  • Page 840: Blendmode (Movieclip.blendmode Property)

    This draws the following image (the image is scaled by 50%): If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example. See also createGradientBox (Matrix.createGradientBox method) beginFill (MovieClip.beginFill method)
  • Page 841 The following table describes the settings. To set the property, you can blendMode blendMode use either an integer from 1 to 14 or a string. The illustrations in the table show blendMode values applied to a circular movie clip (2) superimposed on another onscreen object (1). Integer value String value Illustration Description The movie clip appears in front of the...
  • Page 842 Integer value String value Illustration Description Multiplies the complement (inverse) of the "screen" movie clip color by the complement of the background color, resulting in a bleaching effect. This setting is commonly used for highlights or to remove black areas of the movie clip.
  • Page 843 Integer value String value Illustration Description Compares the constituent colors of the "difference" movie clip with those of its background, and subtracts the darker of the values of the two constituent colors from the lighter one. This setting is commonly used for more vibrant colors.
  • Page 844 Integer value String value Illustration Description Applies the alpha value of each pixel of the "alpha" movie clip to the background. This requires the "layer" setting to be applied blendMode to a parent movie clip. For example, in the illustration, the parent movie clip, which is a white background, has blendMode = "layer"...
  • Page 845 Example The following example sets up two movie clips with gradient fills, and changes the blend mode of the one in the foreground every second. In order to have the blend mode "alpha" show up with an effect, the gradient for the movie clip includes a range of alpha ratios, and the blend mode is applied to the parent movie clip...
  • Page 846: Cacheasbitmap (Movieclip.cacheasbitmap Property)

    cacheAsBitmap (MovieClip.cacheAsBitmap property) public cacheAsBitmap : Boolean If set to , Flash Player caches an internal bitmap representation of the movie clip. This true can increase performance for movie clips that contain complex vector content. All vector data for a movie clip that has a cached bitmap is drawn to the bitmap instead of to the main Stage.
  • Page 847: Clear (Movieclip.clear Method)

    Example The following example applies a drop shadow to a movie clip instance. It then traces the value of the property which is set to when a filter is applied. cacheAsBitmap true import flash.filters.DropShadowFilter; var container:MovieClip = setUpShape(); trace(container.cacheAsBitmap); // false var dropShadow:DropShadowFilter = new DropShadowFilter(6, 45, 0x000000, 50, 5, 5, 1, 2, false, false, false);...
  • Page 848 An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI folder. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ ActionScript See also lineStyle (MovieClip.lineStyle method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method)
  • Page 849 You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0; Flash Player 6 Parameters - A string that identifies the instance name of the new movie clip. name:String - An integer that specifies the depth of the new movie clip. depth:Number Returns - A reference to the newly created movie clip.
  • Page 850: Createtextfield (Movieclip.createtextfield Method)

    createTextField (MovieClip.createTextField method) public createTextField(instanceName:String, depth:Number, x:Number, y:Number, width:Number, height:Number) : TextField Creates a new, empty text field as a child of the movie clip on which you call this method. You can use the method to create text fields while a SWF file plays. The createTextField() parameter determines the new text field's depth level (z-order position) in the movie depth...
  • Page 851 = "This is my first test field object text."; my_txt.setTextFormat(my_fmt); An example is also in the animation.fla file in the Samples\ActionScriptAnimation folder. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ MovieClip...
  • Page 852: Currentframe (Movieclip._Currentframe Property)

    See also getInstanceAtDepth (MovieClip.getInstanceAtDepth method) getNextHighestDepth (MovieClip.getNextHighestDepth method) TextFormat _currentframe (MovieClip._currentframe property) public _currentframe : Number [read-only] Returns the number of the frame in which the playhead is located in the movie clip's timeline. Availability: ActionScript 1.0; Flash Player 4 Example The following example uses the property to direct the playhead of the...
  • Page 853 - An integer that specifies the vertical position of the next anchor point anchorY:Number relative to the registration point of the parent movie clip. Example The following example draws a nearly circular curve with a solid blue hairline stroke and a solid red fill: this.createEmptyMovieClip("circle_mc", 1);...
  • Page 854: Droptarget (Movieclip._Droptarget Property)

    -Math.tan(Math.PI/8)*r+y, r+x, y); An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ See also beginFill (MovieClip.beginFill method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method)
  • Page 855: Duplicatemovieclip (Movieclip.duplicatemovieclip Method)

    } else { this._x = origX; this._y = origY; See also startDrag (MovieClip.startDrag method) stopDrag (MovieClip.stopDrag method) eval function duplicateMovieClip (MovieClip.duplicateMovieClip method) public duplicateMovieClip(name:String, depth:Number, [initObject:Object]) : MovieClip Creates an instance of the specified movie clip while the SWF file is playing. Duplicated movie clips always start playing at Frame 1, no matter what frame the original movie clip is on when the method is called.
  • Page 856 [optional] - (Supported for Flash Player 6 and later.) An object that initObject:Object contains properties with which to populate the duplicated movie clip. This parameter allows dynamically created movie clips to receive clip parameters. If is not an object, it initObject is ignored.
  • Page 857: Enabled (Movieclip.enabled Property)

    enabled (MovieClip.enabled property) public enabled : Boolean A Boolean value that indicates whether a movie clip is enabled. The default value of enabled . If is set to , the movie clip's callback methods and event true enabled false onaction handlers are no longer invoked, and the Over, Down, and Up frames are disabled.
  • Page 858: Filters (Movieclip.filters Property)

    MovieClip.getNextHighestDepth() An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ See also beginFill (MovieClip.beginFill method) beginGradientFill (MovieClip.beginGradientFill method)
  • Page 859 If the array is empty, you need not use a temporary array. Instead, you can directly filters assign an array literal that contains one or more filter objects that you created. To modify an existing filter object, whether it was created at design-time or at runtime, you must use the technique of modifying a copy of the array: filters...
  • Page 860: Focusenabled (Movieclip.focusenabled Property)

    focusEnabled (MovieClip.focusEnabled property) public focusEnabled : Boolean If the value is , a movie clip cannot receive input focus unless it is a undefined false button. If the property value is , a movie clip can receive input focus even focusEnabled true if it is not a button.
  • Page 861: Framesloaded (Movieclip._Framesloaded Property)

    mc3_mc.onRelease = traceOnRelease; function traceOnRelease() { trace(this._name); Test the SWF file in a browser window by selecting File > Publish Preview > HTML. Give the SWF focus by clicking it in the browser window, and press Tab to focus each instance. You cannot execute code for this movie clip in the browser by pressing Enter or the Spacebar when is disabled.
  • Page 862: Getbounds (Movieclip.getbounds Method)

    Place your content on or after Frame 3. Then add the following code on Frame 3: stop(); See also MovieClipLoader getBounds (MovieClip.getBounds method) public getBounds(bounds:Object) : Object Returns properties that are the minimum and maximum x and y coordinate values of the movie clip, based on the parameter.
  • Page 863: Getbytesloaded (Movieclip.getbytesloaded Method)

    var bounds_obj:Object = square_mc.getBounds(this); for (var i in bounds_obj) { trace(i+" --> "+bounds_obj[i]); The following information appears in the Output panel: yMax --> 110 yMin --> 10 xMax --> 110 xMin --> 10 See also getRect (MovieClip.getRect method) globalToLocal (MovieClip.globalToLocal method) localToGlobal (MovieClip.localToGlobal method) getBytesLoaded (MovieClip.getBytesLoaded...
  • Page 864: Getbytestotal (Movieclip.getbytestotal Method)

    Add the following code on Frame 2: if (this._framesloaded<this._totalframes) { this.gotoAndPlay(1); } else { this.gotoAndStop(3); Place your content on or after Frame 3, and then add the following code on Frame 3: stop(); See also getBytesTotal (MovieClip.getBytesTotal method) getBytesTotal (MovieClip.getBytesTotal method) public getBytesTotal() : Number Returns the size, in bytes, of the movie clip.
  • Page 865: Getdepth (Movieclip.getdepth Method)

    Place your content on or after Frame 3. Then add the following code on Frame 3: stop(); See also getBytesLoaded (MovieClip.getBytesLoaded method) getDepth (MovieClip.getDepth method) public getDepth() : Number Returns the depth of the movie clip instance. Each movie clip, button, and text field has a unique depth associated with it that determines how the object appears in front of or in back of other objects.
  • Page 866: Getinstanceatdepth (Movieclip.getinstanceatdepth Method)

    getInstanceAtDepth (MovieClip.getInstanceAtDepth method) public getInstanceAtDepth(depth:Number) : MovieClip Determines if a particular depth is already occupied by a movie clip. You can use this method before using , or MovieClip.attachMovie() MovieClip.duplicateMovieClip() to determine if the depth parameter you want to pass MovieClip.createEmptyMovieClip() to any of these methods already contains a movie clip.
  • Page 867 getNextHighestDepth (MovieClip.getNextHighestDepth method) public getNextHighestDepth() : Number Determines a depth value that you can pass to MovieClip.attachMovie() , or to ensure MovieClip.duplicateMovieClip() MovieClip.createEmptyMovieClip() that Flash renders the movie clip in front of all other objects on the same level and layer in the current movie clip.
  • Page 868: Getrect (Movieclip.getrect Method)

    mc.label.text = mc.getDepth(); See also getDepth (MovieClip.getDepth method) getInstanceAtDepth (MovieClip.getInstanceAtDepth method) swapDepths (MovieClip.swapDepths method) attachMovie (MovieClip.attachMovie method) duplicateMovieClip (MovieClip.duplicateMovieClip method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method) getRect (MovieClip.getRect method) public getRect(bounds:Object) : Object Returns properties that are the minimum and maximum x and y coordinate values of the movie clip, based on the parameter, excluding any strokes on shapes.
  • Page 869 Example The following example creates a movie clip and draws inside of it a square with a stroke width of 4 pixels. The example then calls both the MovieClip.getBounds() methods to show the difference between the two. The MovieClip.getRect() getBounds() method returns the minimum and maximum coordinate values of the entire movie clip, including the stroke width of the square.
  • Page 870: Getswfversion (Movieclip.getswfversion Method)

    See also getBounds (MovieClip.getBounds method) globalToLocal (MovieClip.globalToLocal method) localToGlobal (MovieClip.localToGlobal method) getSWFVersion (MovieClip.getSWFVersion method) public getSWFVersion() : Number Returns an integer that indicates the Flash Player version for the movie clip was published. If the movie clip is a JPEG, GIF, or PNG file, or if an error occurs and Flash Player can't determine the SWF version of the movie clip, -1 is returned.
  • Page 871: Gettextsnapshot (Movieclip.gettextsnapshot Method)

    You can't specify a tab index value for static text in Flash. However, other products may do so (for example, Macromedia FlashPaper). The contents of the TextSnapshot object aren't dynamic; that is, if the movie clip moves to a different frame, or is altered in some way (for example, objects in the movie clip are added or removed), the TextSnapshot object might not represent the current text in the movie clip.
  • Page 872: Geturl (Movieclip.geturl Method)

    Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis You can extend the methods and event handlers of the MovieClip class by creating a subclass.
  • Page 873 POST sends the variables in a separate HTTP header and is used for long strings of variables. Example The following ActionScript creates a movie clip instance and opens the Macromedia website in a new browser window: this.createEmptyMovieClip("loader_mc", this.getNextHighestDepth()); loader_mc.getURL("http://www.macromedia.com", "_blank");...
  • Page 874: Globaltolocal (Movieclip.globaltolocal Method)

    globalToLocal (MovieClip.globalToLocal method) public globalToLocal(pt:Object) : Void Converts the object from Stage (global) coordinates to the movie clip's (local) coordinates. method allows you to convert any given x and y MovieClip.globalToLocal() coordinates from values that are relative to the top-left corner of the Stage to values that are relative to the top-left corner of a specific movie clip.
  • Page 875 The movie clip coordinates were expressed using , because those are the MovieClip properties that you use to set the x and y values for MovieClips. However, your generic object uses without the underscore. The following code converts the x and y values to the local coordinates: var myPoint:Object = {x:0, y:0};...
  • Page 876: Gotoandplay (Movieclip.gotoandplay Method)

    Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also getBounds (MovieClip.getBounds method) localToGlobal (MovieClip.localToGlobal method) Object gotoAndPlay (MovieClip.gotoAndPlay method)
  • Page 877: Gotoandstop (Movieclip.gotoandstop Method)

    See also gotoAndPlay function play function gotoAndStop (MovieClip.gotoAndStop method) public gotoAndStop(frame:Object) : Void Brings the playhead to the specified frame of the movie clip and stops it there. To specify a scene in addition to a frame, use the method. gotoAndStop() You can extend the methods and event handlers of the MovieClip class by creating a subclass.
  • Page 878: Height (Movieclip._Height Property)

    _height (MovieClip._height property) public _height : Number The height of the movie clip, in pixels. Availability: ActionScript 1.0; Flash Player 4 Example The following code example displays the height and width of a movie clip in the Output panel: this.createEmptyMovieClip("image_mc", this.getNextHighestDepth()); var image_mcl:MovieClipLoader = new MovieClipLoader();...
  • Page 879: Hitarea (Movieclip.hitarea Property)

    Example The following ActionScript specifies that best quality anti-aliasing should be applied to the SWF file. my_mc._highquality = 2; See also _quality (MovieClip._quality property) _quality property hitArea (MovieClip.hitArea property) public hitArea : Object Designates another movie clip to serve as the hit area for a movie clip. If the property hitArea does not exist or the value is...
  • Page 880: Hittest (Movieclip.hittest Method)

    hitTest (MovieClip.hitTest method) public hitTest() : Boolean Evaluates the movie clip to see if it overlaps or intersects with the hit area that the target coordinate parameters identify. Usage 1: Compares the x and y coordinates to the shape or bounding box of the specified instance, according to the setting.
  • Page 881: Linegradientstyle (Movieclip.linegradientstyle Method)

    See also getBounds (MovieClip.getBounds method) globalToLocal (MovieClip.globalToLocal method) localToGlobal (MovieClip.localToGlobal method) lineGradientStyle (MovieClip.lineGradientStyle method) public lineGradientStyle(fillType:String, colors:Array, alphas:Array, ratios:Array, matrix:Object, [spreadMethod:String], [interpolationMethod:String], [focalPointRatio:Number]) : Void Specifies a line style that Flash uses for subsequent calls to the lineTo() curveTo() methods until you call the method or the method with lineStyle()
  • Page 882 For example, for a linear gradient that includes two colors, blue and green, the following figure illustrates the placement of the colors in the gradient based on different values in the array: ratios Gradient ratios [0, 127] [0, 255] [127, 255] The values in the array must increase, sequentially;...
  • Page 883 This code draws the following image onscreen: matrixType The properties indicate the following: is the string " ", is the horizontal matrixType position relative to the registration point of the parent clip for the upper-left corner of the gradient, is the vertical position relative to the registration point of the parent clip for the upper-left corner of the gradient, is the width of the gradient, is the height of the...
  • Page 884 [optional] - A Number that controls the location of the focal focalPointRatio:Number point of the gradient. The value 0 means the focal point is in the center. The value 1 means the focal point is at one border of the gradient circle. The value -1 means that the focal point is at the other border of the gradient circle.
  • Page 885: Linestyle (Movieclip.linestyle Method)

    This code draws the following image (the image is scaled by 50%): See also beginGradientFill (MovieClip.beginGradientFill method) lineStyle (MovieClip.lineStyle method) lineTo (MovieClip.lineTo method) moveTo (MovieClip.moveTo method) lineStyle (MovieClip.lineStyle method) public lineStyle(thickness:Number, rgb:Number, alpha:Number, pixelHinting:Boolean, noScale:String, capsStyle:String, jointStyle:String, miterLimit:Number) : Void Specifies a line style that Flash uses for subsequent calls to the lineTo() curveTo()
  • Page 886 - A hexadecimal color value of the line; for example, red is 0xFF0000, blue is rgb:Number 0x0000FF, and so on. If a value isn't indicated, Flash uses 0x000000 (black). - An integer that indicates the alpha value of the line's color; valid values are 0 alpha:Number to 100.
  • Page 887 Notice that for set to , you can limit the length of the miter point by jointStyle "miter" using the parameter. miterLimit - Added in Flash Player 8. A number that indicates the limit at which a miterLimit:Number miter is cut off. Valid values range from 1 to 255 (and values outside of that range are rounded to 1 or 255).
  • Page 888: Lineto (Movieclip.lineto Method)

    If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example. See also beginFill (MovieClip.beginFill method) beginGradientFill (MovieClip.beginGradientFill method) clear (MovieClip.clear method) curveTo (MovieClip.curveTo method) lineTo (MovieClip.lineTo method) moveTo (MovieClip.moveTo method)
  • Page 889: Loadmovie (Movieclip.loadmovie Method)

    See also beginFill (MovieClip.beginFill method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method) endFill (MovieClip.endFill method) lineStyle (MovieClip.lineStyle method) moveTo (MovieClip.moveTo method) loadMovie (MovieClip.loadMovie method) public loadMovie(url:String, [method:String]) : Void Loads a SWF, JPEG, GIF, or PNG file into a movie clip in Flash Player while the original SWF file is playing.
  • Page 890 Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis You can extend the methods and event handlers of the MovieClip class by creating a subclass.
  • Page 891: Loadvariables (Movieclip.loadvariables Method)

    Reads data from an external file and sets the values for variables in the movie clip. The external file can be a text file that Macromedia ColdFusion generates, a CGI script, an Active Server Page (ASP), a PHP script, or any other properly formatted text file. The file can contain any number of variables.
  • Page 892 In SWF files of any version running in Flash Player 7 or later, must be in exactly the same domain as the SWF file that is issuing this call. For example, a SWF file at www.someDomain.com can load data only from sources that are also at www.someDomain.com.
  • Page 893: Localtoglobal (Movieclip.localtoglobal Method)

    The params.txt file includes the following text: var1="hello"&var2="goodbye"&done="done" method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also loadMovie (MovieClip.loadMovie method)
  • Page 894 For example, if you create a movie clip that is positioned at the point (_x:100, _y:100), and you pass a local point representing a point near the top-left corner of the movie clip (x:10, y:10) to the method, the method should convert the x and y values to localToGlobal() global coordinates, which in this case is (x:110, y:110).
  • Page 895: Lockroot (Movieclip._Lockroot Property)

    this.stopDrag(); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also globalToLocal (MovieClip.globalToLocal method) _lockroot (MovieClip._lockroot property) public _lockroot : Boolean A Boolean value that specifies what refers to when a SWF file is loaded into a movie...
  • Page 896 Example In the following example, lockroot.fla has applied to the main SWF file. If the _lockroot SWF file is loaded into another FLA document, always refers to the scope of _root lockroot.swf, which helps prevent conflicts. Place the following ActionScript on the main Timeline of lockroot.fla: this._lockroot = true;...
  • Page 897 which traces the following information: from current SWF file dumpRoot -> [type Function] $version -> WIN 7,0,19,0 nolockroot_mc -> _level0.nolockroot_mc lockroot_mc -> _level0.lockroot_mc from nolockroot.swf myVar -> 1 i -> lockroot_mc dumpRoot -> [type Function] $version -> WIN 7,0,19,0 nolockroot_mc -> _level0.nolockroot_mc lockroot_mc ->...
  • Page 898: Menu (Movieclip.menu Property)

    See also _root property _lockroot (MovieClip._lockroot property) attachMovie (MovieClip.attachMovie method) loadMovie (MovieClip.loadMovie method) onLoadInit (MovieClipLoader.onLoadInit event listener) menu (MovieClip.menu property) public menu : ContextMenu Associates the specified ContextMenu object with the movie clip. The ContextMenu class lets you modify the context menu that appears when the user right-clicks (Windows) or Control- clicks (Macintosh) in Flash Player.
  • Page 899: Moveto (Movieclip.moveto Method)

    moveTo (MovieClip.moveTo method) public moveTo(x:Number, y:Number) : Void Moves the current drawing position to (x, y). If any of the parameters are missing, this method fails and the current drawing position is not changed. You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
  • Page 900: Nextframe (Movieclip.nextframe Method)

    Example The following example lets you right-click (Windows) or Control-click (Macintosh) a movie clip on the Stage and select from the context menu to view information about that Info instance. Add several movie clips with instance names, and then add the following ActionScript to your AS or FLA file: var menu_cm:ContextMenu = new ContextMenu();...
  • Page 901: Ondata (Movieclip.ondata Handler)

    See also nextFrame function prevFrame function prevFrame (MovieClip.prevFrame method) onData (MovieClip.onData handler) onData = function() {} Invoked when a movie clip receives data from a call or a MovieClip.loadVariables() call. You must define a function that executes when the event MovieClip.loadMovie() handler is invoked.
  • Page 902: Ondragout (Movieclip.ondragout Handler)

    onDragOut (MovieClip.onDragOut handler) onDragOut = function() {} Invoked when the mouse button is pressed and the pointer rolls outside the object. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
  • Page 903: Onenterframe (Movieclip.onenterframe Handler)

    onEnterFrame (MovieClip.onEnterFrame handler) onEnterFrame = function() {} Invoked repeatedly at the frame rate of the SWF file. The function that you assign to the event handler is processed before any other ActionScript code that is attached onEnterFrame to the affected frames. You must define a function that executes when the event handler is invoked.
  • Page 904: Onkeyup (Movieclip.onkeyup Handler)

    Example The following example defines a function for the method that sends a onKeyDown() trace() action to the Output panel. Create a movie clip called my_mc and add the following ActionScript to your FLA or AS file: my_mc.onKeyDown = function () { trace ("key was pressed");...
  • Page 905: Onkillfocus (Movieclip.onkillfocus Handler)

    Example The following example defines a function for the method that sends a onKeyUp trace() action to the Output panel: my_mc.onKeyUp = function () { trace ("onKey called"); The following example sets input focus: my_mc.focusEnabled = true; Selection.setFocus(my_mc); See also getAscii (Key.getAscii method) getCode (Key.getCode method) onKeyDown...
  • Page 906: Onload (Movieclip.onload Handler)

    Tab between the two instances, and information displays in the Output panel. See also onSetFocus (MovieClip.onSetFocus handler) onLoad (MovieClip.onLoad handler) onLoad = function() {} Invoked when the movie clip is instantiated and appears in the timeline. You must define a function that executes when the event handler is invoked.
  • Page 907: Onmousedown (Movieclip.onmousedown Handler)

    See also loadMovie (MovieClip.loadMovie method) onClipEvent handler MovieClipLoader onMouseDown (MovieClip.onMouseDown handler) onMouseDown = function() {} Invoked when the mouse button is pressed. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
  • Page 908: Onpress (Movieclip.onpress Handler)

    Availability: ActionScript 1.0; Flash Player 6 Example The following example defines a function for the method that sends a onMouseUp() trace() action to the Output panel: my_mc.onMouseUp = function () { trace ("onMouseUp called"); onPress (MovieClip.onPress handler) onPress = function() {} Invoked when the user clicks the mouse while the pointer is over a movie clip.
  • Page 909: Onreleaseoutside (Movieclip.onreleaseoutside Handler)

    onReleaseOutside (MovieClip.onReleaseOutside handler) onReleaseOutside = function() {} Invoked after a user presses the mouse button inside the movie clip area and then releases it outside the movie clip area. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
  • Page 910: Onrollover (Movieclip.onrollover Handler)

    onRollOver (MovieClip.onRollOver handler) onRollOver = function() {} Invoked when user moves the pointer over a movie clip area. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
  • Page 911: Onunload (Movieclip.onunload Handler)

    Example The following example displays information about the movie clip that receives keyboard focus, and the instance that previously had focus. Two movie clips, called my_mc are on the Stage. Add the following ActionScript to your AS or FLA document: other_mc my_mc.onRelease = Void;...
  • Page 912: Parent (Movieclip._Parent Property)

    You recognize a greater performance benefit with a movie clip that would have many transparent regions if were not set. opaqueBackground Note:The opaque background region is not matched in a method that has the hitTest() parameter set to shapeFlag true Availability: ActionScript 1.0;...
  • Page 913: Play (Movieclip.play Method)

    Example The following example traces the reference to a movie clip and its parent timeline. Create a movie clip with the instance name , and add it to the main timeline. Add the following my_mc ActionScript to your FLA or AS file: my_mc.onRelease = function() { trace("You clicked the movie clip: "+this);...
  • Page 914: Prevframe (Movieclip.prevframe Method)

    See also play function gotoAndPlay (MovieClip.gotoAndPlay method) gotoAndPlay function prevFrame (MovieClip.prevFrame method) public prevFrame() : Void Sends the playhead to the previous frame and stops it. You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
  • Page 915: Quality (Movieclip._Quality Property)

    _quality (MovieClip._quality property) public _quality : String Sets or retrieves the rendering quality used for a SWF file. Device fonts are always aliased and therefore are unaffected by the property. _quality You can set the to the following values: _quality Value Description Graphic anti-...
  • Page 916 Value Description Graphic anti- Bitmap smoothing aliasing " " High rendering quality. Graphics are anti- Flash Player 8: Bitmaps HIGH This setting is the aliased using a 4 x 4 are smoothed based on the default rendering pixel grid. parameter used smoothing quality setting that Flash uses.
  • Page 917: Removemovieclip (Movieclip.removemovieclip Method)

    See also _quality property removeMovieClip (MovieClip.removeMovieClip method) public removeMovieClip() : Void Removes a movie clip instance created with duplicateMovieClip() , or MovieClip.duplicateMovieClip() MovieClip.createEmptyMovieClip() MovieClip.attachMovie() This method does not remove a movie clip assigned to a negative depth value. Movie clips created in the authoring tool are assigned negative depth values by default.
  • Page 918: Rotation (Movieclip._Rotation Property)

    var randNum:Number = Math.round(Math.random()*(max-min))+min; return randNum; var bugNum:Number = 0; addBug_btn.onRelease = addBug; function addBug() { var thisBug:MovieClip = this._parent.attachMovie("bug_id", "bug"+bugNum+"_mc", bugNum, {_x:randRange(50, 500), _y:randRange(50, 350)}); thisBug.onRelease = function() { this.removeMovieClip(); bugNum++; See also duplicateMovieClip function createEmptyMovieClip (MovieClip.createEmptyMovieClip method) duplicateMovieClip (MovieClip.duplicateMovieClip method) attachMovie (MovieClip.attachMovie method)
  • Page 919: Scale9Grid (Movieclip.scale9Grid Property)

    Example The following example creates a movie clip instance dynamically. When you run triangle the SWF file, click the movie clip to rotate it. this.createEmptyMovieClip("triangle", this.getNextHighestDepth()); triangle.beginFill(0x0000FF, 100); triangle.moveTo(100, 100); triangle.lineTo(100, 150); triangle.lineTo(150, 100); triangle.lineTo(100, 100); triangle.onMouseUp= function() { this._rotation += 15; method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later.
  • Page 920 You can think of the eight regions outside of the center (defined by the rectangle) as being like a picture frame that has special rules applied to it when the movie clip is scaled. When the property is set and a movie clip is scaled, all text and child movie clips scale9Grid scale normally, regardless of which regions of the scale9 grid they are located in;...
  • Page 921 In the Macromedia Flash authoring environment, you can enable guides for 9-slice scaling for a movie clip symbol in a library. This lets you graphically determine the for the scale9grid object.
  • Page 922 Example The following creates a movie clip that contains a 20-pixel line (which forms a border) and a gradient fill. The movie clip scales based on the mouse position, and because of the set for the movie clip, the thickness of the 20-pixel line does not vary when the scale9Grid movie clip scales (although the gradient in the movie clip does scale): import flash.geom.Rectangle;...
  • Page 923: Scrollrect (Movieclip.scrollrect Property)

    scrollRect (MovieClip.scrollRect property) public scrollRect : Object property allows you to quickly scroll movie clip content and have a window scrollRect viewing larger content. Text fields and complex content scroll much faster, because pixel level copying is used to scroll data instead of regenerating the entire movie clip from vector data. To see the performance gain, use in conjunction with a movie clip that has scrollRect...
  • Page 924: Setmask (Movieclip.setmask Method)

    content.lineTo(0, 300); content.lineTo(0, 0); content.endFill(); content._rotation = -90; mc.onEnterFrame = function() { this.content._y += 1; return mc; function performs the following steps: setUpContainer() Create a MovieClip named container Create a MovieClip named inside of content container Draw a gradient shape inside of the MovieClip content Return a reference to the...
  • Page 925: Soundbuftime (Movieclip._Soundbuftime Property)

    Parameters - The instance name of a movie clip to be a mask. This can be a String or a mc:Object MovieClip. Example The following code uses the movie clip to mask the movie circleMask_mc theMaskee_mc clip: theMaskee_mc.setMask(circleMask_mc); _soundbuftime (MovieClip._soundbuftime property) public _soundbuftime : Number Specifies the number of seconds a sound prebuffers before it starts to stream.
  • Page 926: Stop (Movieclip.stop Method)

    [optional] - Value relative to the coordinates of the movie clip's parent that top:Number specify a constraint rectangle for the movie clip. [optional] - Value relative to the coordinates of the movie clip's parent that right:Number specify a constraint rectangle for the movie clip. [optional] - Value relative to the coordinates of the movie clip's parent that bottom:Number specify a constraint rectangle for the movie clip.
  • Page 927: Stopdrag (Movieclip.stopdrag Method)

    Example The following example shows how to stop a movie clip named aMovieClip aMovieClip.stop(); See also stop function stopDrag (MovieClip.stopDrag method) public stopDrag() : Void Ends a method. A movie clip that was made draggable with that MovieClip.startDrag() method remains draggable until a method is added, or until another movie clip stopDrag() becomes draggable.
  • Page 928: Swapdepths (Movieclip.swapdepths Method)

    swapDepths (MovieClip.swapDepths method) public swapDepths(target:Object) : Void Swaps the stacking, or depth level (z-order), of this movie clip with the movie clip that is specified by the parameter, or with the movie clip that currently occupies the depth target level that is specified in the parameter.
  • Page 929: Tabchildren (Movieclip.tabchildren Property)

    tabChildren (MovieClip.tabChildren property) public tabChildren : Boolean Determines whether the children of a movie clip are included in the automatic tab ordering. If property is , the children of a movie clip are included in tabChildren undefined true automatic tab ordering. If the value of , the children of a movie clip are tabChildren false...
  • Page 930: Tabenabled (Movieclip.tabenabled Property)

    tabEnabled (MovieClip.tabEnabled property) public tabEnabled : Boolean Specifies whether the movie clip is included in automatic tab ordering. It is undefined default. If the property is , the object is included in automatic tab ordering tabEnabled undefined only if it defines at least one movie clip handler, such as .
  • Page 931: Target (Movieclip._Target Property)

    property must be a positive integer. The objects are ordered according to their tabIndex properties, in ascending order. An object with a value of precedes an tabIndex tabIndex object with a value of . The custom tab ordering disregards the hierarchical tabIndex relationships of objects in a SWF file.
  • Page 932: Totalframes (Movieclip._Totalframes Property)

    _totalframes (MovieClip._totalframes property) public _totalframes : Number [read-only] Returns the total number of frames in the movie clip instance specified in the MovieClip parameter. Availability: ActionScript 1.0; Flash Player 4 Example In the following example, two movie clip buttons control the Timeline. The button prev_mc moves the playhead to the previous frame, and the...
  • Page 933: Transform (Movieclip.transform Property)

    Example The following example sets the property for three movie clips on the Stage. trackAsMenu Click a movie clip and release the mouse button on a second movie clip to see which instance receives the event. myMC1_mc.trackAsMenu = true; myMC2_mc.trackAsMenu = true; myMC3_mc.trackAsMenu = false;...
  • Page 934 myNewDisplayObj.transform = myOldDisplayObj.transform; The new movie clip, , now has the same values for its matrix, color myNewDisplayObj transform, and pixel bounds as the old movie clip, myOldDisplayObj Availability: ActionScript 1.0; Flash Player 8 Example The following example shows how to use a movie clip's property to access and transform modify a movie clip's location by using Matix positioning.
  • Page 935: Unloadmovie (Movieclip.unloadmovie Method)

    unloadMovie (MovieClip.unloadMovie method) public unloadMovie() : Void 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() You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
  • Page 936: Url (Movieclip._Url Property)

    Output panel. this.createEmptyMovieClip("image_mc", 1); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace("_url: "+target_mc._url); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/ 112x112/box_studio_112x112.jpg", image_mc); The following example assigns the ContextMenu object to the movie clip. menu_cm image_mc...
  • Page 937: Usehandcursor (Movieclip.usehandcursor Property)

    The MovieClipLoader class used in these examples requires Flash Player 7 or later. The method used in these examples requires Flash Player 7 MovieClip.getNextHighestDepth() or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method.
  • Page 938: Width (Movieclip._Width Property)

    Example The following example sets the property for two movie clips called _visible myMC1_mc . The property is set to for one instance, and for the other. Notice that myMC2_mc true false instance cannot be clicked after the property is set to myMC1_mc _visible false...
  • Page 939: X (Movieclip._X Property)

    _x (MovieClip._x property) public _x : Number An integer that sets the x coordinate of a movie clip relative to the local coordinates of the parent movie clip. If a movie clip is in the main Timeline, its coordinate system refers to the upper-left corner of the Stage as (0, 0).
  • Page 940: Xscale (Movieclip._Xscale Property)

    Example The following example returns the current x and y coordinates of the mouse on the Stage ) and in relation to a movie clip on the Stage called _level0 my_mc this.createTextField("mouse_txt", this.getNextHighestDepth(), 0, 0, 150, 66); mouse_txt.html = true; mouse_txt.multiline = true;...
  • Page 941: Y (Movieclip._Y Property)

    with (box_mc) { lineStyle(1, 0xCCCCCC); beginFill(0xEEEEEE); moveTo(0, 0); lineTo(80, 0); lineTo(80, 60); lineTo(0, 60); lineTo(0, 0); endFill(); box_mc.onRollOver = function() { this._x -= this._width/2; this._y -= this._height/2; this._xscale = 200; this._yscale = 200; box_mc.onRollOut = function() { this._xscale = 100; this._yscale = 100;...
  • Page 942: Ymouse (Movieclip._Ymouse Property)

    Example The following example attaches a movie clip with the linkage identifier to a SWF cursor_id file. The movie clip is called , and it is used to replace the default mouse pointer. cursor_mc The following ActionScript sets the current coordinates of the movie clip instance to the position of the mouse pointer: this.attachMovie("cursor_id", "cursor_mc", this.getNextHighestDepth(), {_x:_xmouse, _y:_ymouse});...
  • Page 943: Yscale (Movieclip._Yscale Property)

    mouse_txt.htmlText += "</textformat>"; method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also Mouse _xmouse (MovieClip._xmouse property) _yscale (MovieClip._yscale property) public _yscale : Number Sets the vertical scale (...
  • Page 944: Moviecliploader

    this._yscale = 200; box_mc.onRollOut = function() { this._xscale = 100; this._yscale = 100; this._x += this._width/2; this._y += this._height/2; See also _height (MovieClip._height property) _x (MovieClip._x property) _xscale (MovieClip._xscale property) _y (MovieClip._y property) MovieClipLoader Object +-MovieClipLoader public class MovieClipLoader extends Object This class lets you implement listener callbacks that provide status information while SWF, JPEG, GIF, and PNG files are being loaded into movie clips.
  • Page 945 Availability: ActionScript 1.0; Flash Player 7 Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Event summary Event Description Invoked when a file that was loaded with MovieClipLoader.loadClip() onLoadComplete is completely downloaded. function([target _mc:MovieClip], [httpStatus:Numb...
  • Page 946: Addlistener (Moviecliploader.addlistener Method)

    Constructor summary Signature Description Creates a MovieClipLoader object that you can use to implement a MovieClipLoader() number of listeners to respond to events while a SWF, JPEG, GIF, or PNG file is downloading. Method summary Modifiers Signature Description Registers an object to receive notification when a addListener(listener MovieClipLoader event handler is invoked.
  • Page 947 Parameters - An object that listens for a callback notification from the listener:Object event handlers. MovieClipLoader Returns - A Boolean value. Returns if the listener was established successfully; Boolean true otherwise false Example The following example loads an image into a movie clip called .
  • Page 948: Getprogress (Moviecliploader.getprogress Method)

    getProgress (MovieClipLoader.getProgress method) public getProgress(target:Object) : Object Returns the number of bytes loaded and the total number of bytes of a file that is being loaded by using ; for compressed movies, returns the number of MovieClipLoader.loadClip() compressed bytes. The method lets you explicitly request this information, getProgress instead of (or in addition to) writing a...
  • Page 949: Loadclip (Moviecliploader.loadclip Method)

    var progress:Object = mcLoader.getProgress(image); trace("bytesLoaded: " + progress.bytesLoaded + " bytesTotal: " + progress.bytesTotal); if(progress.bytesLoaded == progress.bytesTotal) { clearInterval(interval.id); If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example.
  • Page 950 System.security.allowDomain() For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis ActionScript classes...
  • Page 951 Availability: ActionScript 1.0; Flash Player 7 - Support for unanimated GIF files, PNG files, and progressive JPEG files is available as of Flash Player 8. Parameters - The absolute or relative URL of the SWF, JPEG, GIF, or PNG file to be url:String loaded.
  • Page 952: Moviecliploader Constructor

    MovieClipLoader constructor public MovieClipLoader() Creates a MovieClipLoader object that you can use to implement a number of listeners to respond to events while a SWF, JPEG, GIF, or PNG file is downloading. Availability: ActionScript 1.0; Flash Player 7 Example MovieClipLoader.loadClip() See also addListener (MovieClipLoader.addListener method) loadClip...
  • Page 953 Availability: ActionScript 1.0; Flash Player 7 - Support for unanimated GIF files, PNG files, and progressive JPEG files is available as of Flash Player 8. Parameters [optional] - A movie clip loaded by the target_mc:MovieClip method. MovieClipLoader.loadClip() [optional] - (Flash Player 8 only) The HTTP status code returned by httpStatus:Number the server.
  • Page 954: Onloaderror (Moviecliploader.onloaderror Event Listener)

    See also addListener (MovieClipLoader.addListener method) loadClip (MovieClipLoader.loadClip method) onLoadStart (MovieClipLoader.onLoadStart event listener) onLoadError (MovieClipLoader.onLoadError event listener) onLoadInit (MovieClipLoader.onLoadInit event listener) onLoadError (MovieClipLoader.onLoadError event listener) onLoadError = function(target_mc:MovieClip, errorCode:String, [httpStatus:Number]) {} Invoked when a file loaded with has failed to load. This MovieClipLoader.loadClip() listener can be invoked for various reasons;...
  • Page 955 Parameters - A movie clip loaded by the target_mc:MovieClip MovieClipLoader.loadClip() method. - A string that explains the reason for the failure, either errorCode:String "URLNotFound" "LoadNeverCompleted" [optional] - (Flash Player 8 only) The HTTP status code returned by httpStatus:Number the server. For example, a status code of 404 indicates that the server has not found anything that matches the requested URI.
  • Page 956: Onloadinit (Moviecliploader.onloadinit Event Listener)

    onLoadInit (MovieClipLoader.onLoadInit event listener) onLoadInit = function([target_mc:MovieClip]) {} Invoked when the actions on the first frame of the loaded clip have been executed. When this listener has been invoked, you can set properties, use methods, and otherwise interact with the loaded movie. Call this listener on a listener object that you add by using MovieClipLoader.addListener() The value for identifies the movie clip for which this call is being made.
  • Page 957 this.createEmptyMovieClip("tester_mc", 1); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace("movie loaded"); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.yourserver.com/your_movie.swf", tester_mc); If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example.
  • Page 958: Onloadstart (Moviecliploader.onloadstart Event Listener)

    - The total number of bytes in the file being loaded. totalBytes:Number Example The following example creates a movie clip, a new instance, and an MovieClipLoader anonymous event listener. It periodically outputs the progress of a load and finally provides notification when the load is complete and the asset is available to ActionScript.
  • Page 959 Parameters [optional] - A movie clip loaded by the target_mc:MovieClip method. MovieClipLoader.loadClip() Example The following example loads an image into a movie clip instance called . The image_mc events are used to determine how long it takes to load the onLoadInit onLoadComplete image.
  • Page 960: Removelistener (Moviecliploader.removelistener Method)

    removeListener (MovieClipLoader.removeListener method) public removeListener(listener:Object) : Boolean Removes the listener that was used to receive notification when a event MovieClipLoader handler was invoked. No further loading messages will be received. Availability: ActionScript 1.0; Flash Player 7 Parameters - A listener object that was added by using listener:Object MovieClipLoader.addListener() Returns...
  • Page 961: Unloadclip (Moviecliploader.unloadclip Method)

    image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.helpexamples.com/flash/images/ image1.jpg", image_mc); stop_button.clickHandler = function() { trace("Stopping..."); start_button.enabled = true; stop_button.enabled = false; image_mcl.removeListener(mclListener); stop_button.enabled = false; If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example.
  • Page 962: Netconnection

    target_mc._y = 100; target_mc.onRelease = function() { trace("Unloading clip..."); trace("\t name: "+target_mc._name); trace("\t url: "+target_mc._url); image_mcl.unloadClip(target_mc); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc); If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example.
  • Page 963: Connect (Netconnection.connect Method)

    Constructor summary Signature Description Creates a NetConnection object that you can use in conjunction with NetConnection() a NetStream object to play back local streaming video (FLV) files. Method summary Modifiers Signature Description Opens a local connection through which you can play connect(targetURI:St back video (FLV) files from an HTTP address or from ring) : Boolean...
  • Page 964 Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 7 - Note: This method is also supported in Flash Player 6 when used with Flash Communication Server.
  • Page 965: Netconnection Constructor

    NetConnection constructor public NetConnection() Creates a NetConnection object that you can use in conjunction with a NetStream object to play back local streaming video (FLV) files. After creating the NetConnection object, use to make the actual connection. NetConnection.connect() Playing external FLV files provides several advantages over embedding video in a Flash document, such as better performance and memory management, and independent video and Flash frame rates.
  • Page 966 Property summary Modifiers Property Description The number of seconds of data currently in the buffer. bufferLength:Number [read-only] The number of seconds assigned to the buffer by bufferTime:Number [read-only] NetStream.setBufferTime(). The number of bytes of data that have been loaded bytesLoaded:Number [read-only] into the player.
  • Page 967: Bufferlength (Netstream.bufferlength Property)

    Method summary Modifiers Signature Description Stops playing all data on the stream, sets the close() : Void NetStream.time property to 0, and makes the stream available for another use. Pauses or resumes playback of a stream. pause([flag:Boolean] ) : Void Begins playback of an external video (FLV) file.
  • Page 968: Buffertime (Netstream.buffertime Property)

    this.createTextField("buffer_txt", this.getNextHighestDepth(), 10, 10, 300, 22); buffer_txt.html = true; var connection_nc:NetConnection = new NetConnection(); connection_nc.connect(null); var stream_ns:NetStream = new NetStream(connection_nc); stream_ns.setBufferTime(3); my_video.attachVideo(stream_ns); stream_ns.play("video1.flv"); var buffer_interval:Number = setInterval(checkBufferTime, 100, stream_ns); function checkBufferTime(my_ns:NetStream):Void { var bufferPct:Number = Math.min(Math.round(my_ns.bufferLength/ my_ns.bufferTime 100), 100); var output_str:String = "<textformat tabStops='[100,200]'>"; output_str += "Length: "+my_ns.bufferLength+"\t"+"Time: "+my_ns.bufferTime+"\t"+"Buffer:"+bufferPct+"%";...
  • Page 969: Bytesloaded (Netstream.bytesloaded Property)

    this.createTextField("buffer_txt", this.getNextHighestDepth(), 10, 10, 300, 22); buffer_txt.html = true; var connection_nc:NetConnection = new NetConnection(); connection_nc.connect(null); var stream_ns:NetStream = new NetStream(connection_nc); stream_ns.setBufferTime(3); my_video.attachVideo(stream_ns); stream_ns.play("video1.flv"); var buffer_interval:Number = setInterval(checkBufferTime, 100, stream_ns); function checkBufferTime(my_ns:NetStream):Void { var bufferPct:Number = Math.min(Math.round(my_ns.bufferLength/ my_ns.bufferTime 100), 100); var output_str:String = "<textformat tabStops='[100,200]'>"; output_str += "Length: "+my_ns.bufferLength+"\t"+"Time: "+my_ns.bufferTime+"\t"+"Buffer:"+bufferPct+"%";...
  • Page 970 connection_nc.connect(null); var stream_ns:NetStream = new NetStream(connection_nc); my_video.attachVideo(stream_ns); stream_ns.play("video1.flv"); this.createTextField("loaded_txt", this.getNextHighestDepth(), 10, 10, 160, 22); this.createEmptyMovieClip("progressBar_mc", this.getNextHighestDepth()); progressBar_mc.createEmptyMovieClip("bar_mc", progressBar_mc.getNextHighestDepth()); with (progressBar_mc.bar_mc) { beginFill(0xFF0000); moveTo(0, 0); lineTo(100, 0); lineTo(100, 10); lineTo(0, 10); lineTo(0, 0); endFill(); _xscale = 0; progressBar_mc.createEmptyMovieClip("stroke_mc", progressBar_mc.getNextHighestDepth()); with (progressBar_mc.stroke_mc) { lineStyle(0, 0x000000);...
  • Page 971: Bytestotal (Netstream.bytestotal Property)

    See also bytesTotal (NetStream.bytesTotal property) bufferLength (NetStream.bufferLength property) bytesTotal (NetStream.bytesTotal property) public bytesTotal : Number [read-only] The total size in bytes of the file being loaded into the player. Availability: ActionScript 1.0; Flash Player 7 Example The following example creates a progress bar using the Drawing API and the bytesLoaded properties that displays the loading progress of video1.flv into the video bytesTotal...
  • Page 972: Close (Netstream.close Method)

    var loaded_interval:Number = setInterval(checkBytesLoaded, 500, stream_ns); function checkBytesLoaded(my_ns:NetStream) { var pctLoaded:Number = Math.round(my_ns.bytesLoaded/my_ns.bytesTotal 100); loaded_txt.text = Math.round(my_ns.bytesLoaded/1000)+" of "+Math.round(my_ns.bytesTotal/1000)+" KB loaded ("+pctLoaded+"%)"; progressBar_mc.bar_mc._xscale = pctLoaded; if (pctLoaded>=100) { clearInterval(loaded_interval); If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method, which is MovieClip.getNextHighestDepth()
  • Page 973: Currentfps (Netstream.currentfps Property)

    close_btn.onRelease = function(){ stream_ns.close(); See also pause (NetStream.pause method) play (NetStream.play method) currentFps (NetStream.currentFps property) public currentFps : Number [read-only] The number of frames per second being displayed. If you are exporting FLV files to be played back on a number of systems, you can check this value during testing to help you determine how much compression to apply when exporting the file.
  • Page 974: Netstream Constructor

    NetStream constructor public NetStream(connection:NetConnection) Creates a stream that can be used for playing FLV files through the specified NetConnection object. Availability: ActionScript 1.0; Flash Player 7 - Note: This class is also supported in Flash Player 6 when used with Flash Communication Server. For more information, see the Flash Communication Server documentation.
  • Page 975 event handler receives an object with these properties: onCuePoint() Property Description name The name given to the cue point when it was embedded in the FLV file. time The time in seconds at which the cue point occurred in the video file during playback.
  • Page 976 var ns:NetStream = new NetStream(nc); ns.onCuePoint = function(infoObject:Object) trace("onCuePoint:"); for (var propName:String in infoObject) { if (propName != "parameters") trace(propName + " = " + infoObject[propName]); else trace("parameters ="); if (infoObject.parameters != undefined) { for (var paramName:String in infoObject.parameters) trace(" " + paramName + ": " + infoObject.parameters[paramName]);...
  • Page 977: Onmetadata (Netstream.onmetadata Handler)

    time = 16.02 name = point3 --------- The parameter name "lights" is an arbitrary name used by the author of the example video. You can give cue point parameters any name you want. See also onMetaData (NetStream.onMetaData handler) onMetaData (NetStream.onMetaData handler) onMetaData = function(infoObject:Object) {} Invoked when the Flash Player receives descriptive information embedded in the FLV file being played.
  • Page 978: Onstatus (Netstream.onstatus Handler)

    ns.play("http://www.helpexamples.com/flash/video/water.flv"); This causes the following information to be displayed: canSeekToEnd = true videocodecid = 4 framerate = 15 videodatarate = 400 height = 215 width = 320 duration = 7.347 The list of properties will vary depending on the software that was used to encode the FLV file.
  • Page 979 Code property Level property Meaning status Playback has stopped. NetStream.Play.Stop error The FLV passed to the method can't NetStream.Play.Stream play() be found. NotFound error For video downloaded with progressive NetStream.Seek.Invali download, the user has tried to seek or play dTime past the end of the video data that has downloaded thus far, or past the end of the video once the entire file has downloaded.
  • Page 980: Pause (Netstream.pause Method)

    pause (NetStream.pause method) public pause([flag:Boolean]) : Void Pauses or resumes playback of a stream. The first time you call this method (without sending a parameter), it pauses play; the next time, it resumes play. You might want to attach this method to a button that the user presses to pause or resume playback.
  • Page 981 Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 7 - Note: This method is also supported in Flash Player 6 when used with Flash Communication Server.
  • Page 982: Seek (Netstream.seek Method)

    // Play a file on a server. my_ns.play("http://someServer.someDomain.com/flash/video/orientation.flv"); See also attachAudio (MovieClip.attachAudio method) close (NetStream.close method) onStatus (NetStream.onStatus handler) pause (NetStream.pause method) attachVideo (Video.attachVideo method) seek (NetStream.seek method) public seek(offset:Number) : Void Seeks the keyframe closest to the specified number of seconds from the beginning of the stream.
  • Page 983: Setbuffertime (Netstream.setbuffertime Method)

    // Move to a location 30 seconds from the beginning of the stream my_ns.seek(30); // Move backwards three minutes from current location my_ns.seek(my_ns.time - 180); See also time (NetStream.time property) setBufferTime (NetStream.setBufferTime method) public setBufferTime(bufferTime:Number) : Void Specifies how long to buffer messages before starting to display the stream. For example, if you want to make sure that the first 15 seconds of the stream play without interruption, set to 15;...
  • Page 984 Example The following example displays the current position of the playhead in a dynamically created text field called . Select New Video from the Library options menu to create a video time_txt object instance, and give it an instance name .
  • Page 985: Number

    Number Object +-Number public class Number extends Object The Number class is a simple wrapper object for the Number data type. You can manipulate primitive numeric values by using the methods and properties associated with the Number class. This class is identical to the JavaScript Number class. The properties of the Number class are static, which means you do not need an object to use them, so you do not need to use the constructor.
  • Page 986: Max_Value (Number.max_Value Property)

    Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Constructor summary Signature Description Creates a new Number object. Number(num:Object) Method summary Modifiers Signature Description Returns the string representation of the specified toString(radix:Numbe Number object (myNumber).
  • Page 987: Min_Value (Number.min_Value Property)

    This code displays the following values: Number.MIN_VALUE = 4.94065645841247e-324 Number.MAX_VALUE = 1.79769313486232e+308 MIN_VALUE (Number.MIN_VALUE property) public static MIN_VALUE : Number The smallest representable number (double-precision IEEE-754). This number is approximately 5e-324. Availability: ActionScript 1.0; Flash Player 5 Example The following ActionScript displays the largest and smallest representable numbers to the Output panel.
  • Page 988: Number Constructor

    Example This example compares the result of dividing the following values. var posResult:Number = 1/0; if (posResult == Number.POSITIVE_INFINITY) { trace("posResult = "+posResult); // output: posResult = Infinity var negResult:Number = -1/0; if (negResult == Number.NEGATIVE_INFINITY) { trace("negResult = "+negResult); // output: negResult = -Infinity Number constructor public Number(num:Object) Creates a new Number object.
  • Page 989: Tostring (Number.tostring Method)

    Example This example compares the result of dividing the following values. var posResult:Number = 1/0; if (posResult == Number.POSITIVE_INFINITY) { trace("posResult = "+posResult); // output: posResult = Infinity var negResult:Number = -1/0; if (negResult == Number.NEGATIVE_INFINITY) { trace("negResult = "+negResult); // output: negResult = -Infinity toString (Number.toString method) public toString(radix:Number) : String Returns the string representation of the specified Number object (...
  • Page 990: Valueof (Number.valueof Method)

    valueOf (Number.valueOf method) public valueOf() : Number Returns the primitive value type of the specified Number object. Availability: ActionScript 1.0; Flash Player 5 Returns - A string. Number Example The following example results in the primative value of the object. numSocks var numSocks = new Number(2);...
  • Page 991 Constructor summary Signature Description Creates an Object object and stores a reference to the object's Object() constructor method in the object's constructor property. Method summary Modifiers Signature Description Creates a getter/setter property. addProperty(name:Str ing, getter:Function, setter:Function) : Boolean Indicates whether an object has a specified property hasOwnProperty(name: defined.
  • Page 992: Addproperty (Object.addproperty Method)

    addProperty (Object.addProperty method) public addProperty(name:String, getter:Function, setter:Function) : Boolean Creates a getter/setter property. When Flash reads a getter/setter property, it invokes the function, and the function's return value becomes the value of . When Flash writes a name getter/setter property, it invokes the function and passes it the new value as a parameter.
  • Page 993 - The function that is invoked to set the value of the property; this setter:Function parameter is a Function object. If you pass the value for this parameter, the property is null read-only. Returns - A Boolean value: if the property is successfully created; otherwise.
  • Page 994 The previous example works, but the properties are added to every bookcount bookname instance of the object, which requires having two properties for every instance of the Book object. If there are many properties, such as in a class, they could bookcount bookname, consume a great deal of memory.
  • Page 995: Constructor (Object.constructor Property)

    The following code can then be placed in a FLA file and will function the same way as it does in the previous examples: var myBook:Book = new Book(); myBook.bookcount = 5; trace("You ordered "+myBook.bookcount+" copies of "+myBook.bookname); See also get statement set statement constructor (Object.constructor property)
  • Page 996: Hasownproperty (Object.hasownproperty Method)

    hasOwnProperty (Object.hasOwnProperty method) public hasOwnProperty(name:String) : Boolean Indicates whether an object has a specified property defined. This method returns if the true target object has a property that matches the string specified by the parameter, and name otherwise. This method does not check the object's prototype chain and returns false true only if the property exists on the object itself.
  • Page 997: Isprototypeof (Object.isprototypeof Method)

    var myObj:Object = new Object(); myObj.prop1 = "hello"; trace(myObj.isPropertyEnumerable("prop1")); // Output: true var myArray = new Array(); trace(myArray.isPropertyEnumerable("length")); // Output: false See also for..in statement isPrototypeOf (Object.isPrototypeOf method) public isPrototypeOf(theClass:Object) : Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as an argument.
  • Page 998: Proto__ (Object.__Proto__ Property)

    __proto__ (Object.__proto__ property) public __proto__ : Object Refers to the property of the class (ActionScript 2.0) or constructor function prototype (ActionScript 1.0) used to create the object. The property is automatically __proto__ assigned to all objects when they are created. The ActionScript interpreter uses the __proto__ property to access the property of the object's class or constructor function to find...
  • Page 999: Prototype (Object.prototype Property)

    prototype (Object.prototype property) public static prototype : Object A reference to the superclass of a class or function object. The property is prototype automatically created and attached to any class or function object you create. This property is static in that it is specific to the class or function you create. For example, if you create a custom class, the value of the property is shared by all instances of the class, and is prototype...
  • Page 1000: Registerclass (Object.registerclass Method)

    registerClass (Object.registerClass method) public static registerClass(name:String, theClass:Function) : Boolean Associates a movie clip symbol with an ActionScript object class. If a symbol doesn't exist, Flash creates an association between a string identifier and an object class. When an instance of the specified movie clip symbol is placed on the Timeline, it is registered to the class specified by the parameter rather than to the class MovieClip.

This manual is also suitable for:

Flash 8

Table of Contents