MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference
MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

Quick Links

Flash Lite 2.x ActionScript Language Reference

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Questions and answers

Summary of Contents for MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE

  • Page 1 Flash Lite 2.x ActionScript Language Reference...
  • Page 2 Nellymoser, Inc.: Speech compression and decompression technology licensed by Nellymoser, Inc. (http:www.nellymoser.com). Opera ® browser Copyright © 1995-2002 Opera Software ASA and its suppliers. All rights reserved. Macromedia Flash 8 video is powered by On2 TrueMotion video technology. © 1992-2005 On2 Technologies, Inc. All Rights Reserved. http://www.on2.com.
  • Page 3: Table Of Contents

    Contents Chapter 1: ActionScript language elements....23 Compiler Directives ......... . . 23 #endinitclip directive .
  • Page 4 loadMovieNum function ........58 loadVariables function .
  • Page 5 _capSMAF property ........100 _capSMS property.
  • Page 6 >= greater than or equal to operator ......148 ge greater than or equal to (strings) operator ....149 ++ increment operator.
  • Page 7 for statement..........196 for..in statement .
  • Page 8 SetFocusRectColor fscommand2 Command ....240 SetInputTextType fscommand2 Command ....240 SetSoftKeys fscommand2 Command .
  • Page 9 onDragOver (Button.onDragOver handler) ....280 onKeyDown (Button.onKeyDown handler) ....280 onKeyUp (Button.onKeyUp handler) .
  • Page 10 hasMIDI (capabilities.hasMIDI property) ..... 309 hasMMS (capabilities.hasMMS property)....309 hasMouse (capabilities.hasMouse property) .
  • Page 11 getLocaleLongDate (Date.getLocaleLongDate method) ..334 getLocaleShortDate (Date.getLocaleShortDate method)..334 getLocaleTime (Date.getLocaleTime method)....335 getMilliseconds (Date.getMilliseconds method)....335 getMinutes (Date.getMinutes method) .
  • Page 12 ExtendedKey ..........362 SOFT1 (ExtendedKey.SOFT1 property) .
  • Page 13 LoadVars ........... 390 addRequestHeader (LoadVars.addRequestHeader method) .
  • Page 14 round (Math.round method) ....... . 425 sin (Math.sin method)........426 sqrt (Math.sqrt method).
  • Page 15 hitArea (MovieClip.hitArea property)......480 hitTest (MovieClip.hitTest method) ......480 lineStyle (MovieClip.lineStyle method) .
  • Page 16 trackAsMenu (MovieClip.trackAsMenu property) ....519 unloadMovie (MovieClip.unloadMovie method) ....520 _url (MovieClip._url property) ....... . 521 _visible (MovieClip._visible property) .
  • Page 17 registerClass (Object.registerClass method) ....559 __resolve (Object.__resolve property) ......560 toString (Object.toString method) .
  • Page 18 start (Sound.start method) ........616 stop (Sound.stop method) ........617 Stage .
  • Page 19 _highquality (TextField._highquality property) ....661 hscroll (TextField.hscroll property) ......661 html (TextField.html property).
  • Page 20 TextFormat ..........695 align (TextFormat.align property) .
  • Page 21 XMLNode........... 738 appendChild (XMLNode.appendChild method) .
  • Page 22 Contents...
  • Page 23: 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 24: 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 ■...
  • Page 25: Initclip Directive

    Parameters The filename and optional path for the script to add to [path]filename.as filename.as 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 26 Initialization actions execute only once when a SWF file plays; use them for one-time initializations, such as class definition and registration. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - A non-negative integer that specifies the execution order of blocks of order #initclip code.
  • Page 27: 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 false opposite of true. Specifies the IEEE-754 value representing Infinity positive infinity.
  • Page 28: Infinity Constant

    Example This example shows how automatic data typing converts to a number and to a string: false var bool1:Boolean = Boolean(false); // converts it to the number 0 trace(1 + bool1); // outputs 1 // converts it to a string trace("String: "...
  • Page 29: Newline Constant

    newline constant Inserts a carriage return character ( ) that generates a blank line in text output generated by your code. Use to make space for information that is retrieved by a function or newline statement in your code. Availability: ActionScript 1.0; Flash Lite 1.1 Example The following example shows how displays output from the...
  • Page 30: 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 Lite 1.1 Example The following example shows the use of in an...
  • Page 31 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 32: 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 33 Deprecated since Flash Player 5. ifFrameLoaded([scene:String], This function has been deprecated. frame:Object, statement(s):Object) Macromedia recommends that you use the MovieClip._framesloaded property. Checks whether the contents of a specific frame are available locally.
  • Page 34 This function, along with all the variable:Object) : Number string functions, has been deprecated. Macromedia recommends that you use the methods of the String class and the String.length property to perform the same operations. Returns the length of the specified string or variable.
  • Page 35 Modifiers Signature Description Deprecated since Flash Player 5. mbchr(number:Number) This function was deprecated in favor of the String.fromCharCode() method. Converts an ASCII code number to a multibyte character. Deprecated since Flash Player 5. mblength(string:String) : Number This function was deprecated in favor of the String.length property.
  • Page 36 Modifiers Signature Description Deprecated since Flash Player 5. ord(character:String) : Number This function was deprecated in favor of the methods and properties of the String class. Converts characters to ASCII code numbers. Converts a string to a floating-point parseFloat(string:String) : Number number.
  • Page 37 Returns a string containing the targetPath(targetObject:Object) : target path of movieClipObject. String Deprecated since Flash Player 5. tellTarget(target:String, Macromedia recommends that you statement(s):Object) use dot (.) notation and the with statement. Applies the instructions specified in the statements parameter to the Timeline specified in the target parameter.
  • Page 38: Array Function

    Array function Array(): Array Array(numElements:Number): Array Array( [element0:Object [, element1, element2, ...elementN] ]) : Array Creates a new array of length zero or more, or an array populated by a list of specified elements, possibly of different data types. Lets you create one of the following: an empty array ■...
  • Page 39: Boolean Function

    Usage 3: The following example creates an array with three defined elements: var myArray:Array = Array("firstElement", "secondElement", "thirdElement"); trace (myArray); // traces firstElement,secondElement,thirdElement Unlike the Array class constructor, the Array() function does not use the keyword new . See also Array Boolean function Boolean(expression:Object) : Boolean...
  • Page 40: Call Function

    Example trace(Boolean(-1)); // output: true trace(Boolean(0)); // output: false trace(Boolean(1)); // output: true trace(Boolean(true)); // output: true trace(Boolean(false)); // output: false trace(Boolean("true")); // output: true trace(Boolean("false")); // output: true trace(Boolean("Craiggers")); // output: true trace(Boolean("")); // output: false If files are published for Flash Player 6 and earlier, the results differ for three of the preceding examples: trace(Boolean("true"));...
  • Page 41: Chr Function

    Executes the script in the called frame without moving the playhead to that frame. Local variables do not exist after the script executes. If variables are not declared inside a block ( ) but the action list was executed with a ■...
  • Page 42: Clearinterval Function

    clearInterval function clearInterval(intervalID:Number) : Void Cancels an interval created by a call to setInterval(). Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - A numeric (integer) identifier returned from a call to intervalID:Number setInterval() Example The following example first sets and then clears an interval call: function callback() { trace("interval called: "+getTimer()+"...
  • Page 43: Escape Function

    Parameters - The target path of the movie clip to duplicate. This parameter can be either target:Object a String (e.g. "my_mc") or a direct reference to the movie clip instance (e.g. my_mc). Parameters that can accept more than one data type are listed as type Object - A unique identifier for the duplicated movie clip.
  • Page 44: Eval Function

    Parameters - The expression to convert into a string and encode in a URL-encoded expression:String format. Returns - URL-encoded string. String 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...
  • Page 45 In Flash 5 or later, you cannot use to dynamically set and retrieve the value of a eval() variable or instance name, because you cannot use on the left side of an equation. For eval() example, replace the code eval ("var" + i) = "first"; with this: this["var"+i] = "first"...
  • Page 46: Fscommand Function

    fscommand function fscommand(command:String, parameters:String) : Void function lets a SWF file communicate with the Flash Lite player or the fscommand() environment for a mobile device (such as an operating system). The parameters define the name of the application being started and the parameters to it, separated by commas. Command Parameters Purpose...
  • Page 47: Fscommand2 Function

    fscommand2 function fscommand2(command:String, parameter1:String,...parameterN:String) : Void Lets the SWF file communicate with the Flash Lite player or a host application on a mobile device. function is similar to the function, with the following fscommand2() fscommand() differences: function can take any number of arguments. By contrast, ■...
  • Page 48: Getproperty Function

    Command Deprecated By GetTimeSeconds method of Date object getSeconds() GetTimeZoneOffset method of Date object getTimeZoneOffset() SetQuality MovieClip._quality Unescape global function unescape() Availability: ActionScript 1.0; Flash Lite 1.1 Parameters - A string passed to the host application for any use, or a command passed command:String to the Flash Lite player.
  • Page 49: Gettimer Function

    getTimer function getTimer() : Number Returns the number of milliseconds that have elapsed since the SWF file started playing. Availability: ActionScript 1.0; Flash Lite 1.0 Returns - The number of milliseconds that have elapsed since the SWF file started playing. Number Example In the following example, the...
  • Page 50 = "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 51: Getversion Function

    getVersion function getVersion() : String Returns a string containing Flash Player version and platform information. The getVersion function returns information only for Flash Player 5 or later versions of Flash Player. Availability: ActionScript 1.0; Flash Lite 2.0 Returns - A string containing Flash Player version and platform information. String Example The following examples trace the version number of the Flash Player playing the SWF file:...
  • Page 52: Gotoandstop Function

    Example In the following example, a document has two scenes: . Scene one sceneOne sceneTwo contains a frame label on Frame 10 called and two buttons, newFrame myBtn_btn . This ActionScript is placed on Frame 1, Scene 1 of the main Timeline. myOtherBtn_btn stop();...
  • Page 53: Ifframeloaded Function

    [scene,] frame) { 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...
  • Page 54: Int Function

    See also addListener (MovieClipLoader.addListener method) int function int(value) : Number Deprecated since Flash Player 5. This function was deprecated in favor of Math.round() Converts a decimal number to an integer value by truncating the decimal value. This function is equivalent to if the parameter is positive and if the...
  • Page 55: Isnan Function

    Example The following example shows return values for isFinite isFinite(56) // returns true isFinite(Number.POSITIVE_INFINITY) //returns false isNaN function isNaN(expression:Object) : Boolean Evaluates the parameter and returns if the value is (not a number). This function is true useful for checking whether a mathematical expression evaluates successfully to a number. Availability: ActionScript 1.0;...
  • Page 56: 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 57: Loadmovie Function

    loadMovie function loadMovie(url:String, target:Object [, method:String]) : VoidloadMovie(url:String, target:String [, method:String]) : Void Loads a SWF or JPEG file into Flash Player while the original SWF file plays. JPEG files saved in progressive format are not supported. Tip: If you want to monitor the progress of the download, use instead of this function.
  • Page 58: Loadmovienum Function

    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 59 Normally, Flash Player displays a single SWF file and then closes. The loadMovieNum() action lets you display several SWF files at once and switch among SWF files without loading another HTML document. If you want to specify a target instead of a level, use instead of loadMovie() loadMovieNum()
  • Page 60: 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 61 If you want to load variables into a specific level, use instead of loadVariablesNum() loadVariables() Availability: ActionScript 1.0; Flash Lite 1.1 - Behavior changed in Flash Player 7. 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;...
  • Page 62: 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 63: Mbchr Function

    [optional] - Specifies an HTTP method for sending variables. The parameter method:String must be the string . If there are no variables to be sent, omit this parameter. The POST method appends the variables to the end of the URL and is used for small numbers of variables.
  • Page 64: Mblength Function

    Availability: ActionScript 1.0; Flash Lite 1.0 Parameters - The number to convert to a multibyte character. number:Number See also fromCharCode (String.fromCharCode method) mblength function mblength(string) : Number Deprecated since Flash Player 5. This function was deprecated in favor of the String.length property.
  • Page 65: Mbsubstring Function

    Returns - The converted character. Number See also charCodeAt (String.charCodeAt method) mbsubstring function mbsubstring(value, index, count) : String Deprecated since Flash Player 5. This function was deprecated in favor of String.substr() method. Extracts a new multibyte character string from a multibyte character string. Availability: ActionScript 1.0;...
  • Page 66: Nextframe Function

    nextFrame function nextFrame() : Void Sends the playhead to the next frame. Availability: ActionScript 1.0; Flash Lite 1.0 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 67 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 68: Number Function

    Number function Number(expression) : Number Converts the parameter to a number and returns a value as described in the expression following list: is a number, the return value is ■ expression expression is a Boolean value, the return value is 1 if , 0 if expression expression...
  • Page 69: 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 70 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. ■...
  • Page 71: Onclipevent Handler

    Example In the following script, the function executes when the mouse is pressed, and startDrag() the conditional script is executed when the mouse is released and the object is dropped: on (press) { startDrag(this); on (release) { trace("X:"+this._x); trace("Y:"+this._y); stopDrag(); See also onClipEvent handler onClipEvent handler...
  • Page 72 The action is initiated when the left mouse button is pressed. ■ mouseDown Note: This event is supported in Flash Lite only if System.capabilities.hasMouse true System.capabilities.hasStylus true The action is initiated when the left mouse button is released. ■ mouseUp Note: This event is supported in Flash Lite only if System.capabilities.hasMouse true...
  • Page 73: Ord Function

    See also _xmouse (MovieClip._xmouse property) _ymouse (MovieClip._ymouse property) on handler ord function ord(character) : Number Deprecated since Flash Player 5. This function was deprecated in favor of the methods and properties of the String class. Converts characters to ASCII code numbers. Availability: ActionScript 1.0;...
  • Page 74: Parseint Function

    Example The following examples use the function to evaluate various types of numbers: parseFloat() trace(parseFloat("-2")); // output: -2 trace(parseFloat("2.5")); // output: 2.5 trace(parseFloat(" 2.5")); // output: 2.5 trace(parseFloat("3.5e6")); // output: 3500000 trace(parseFloat("foobar")); // output: NaN trace(parseFloat("3.75math")); // output: 3.75 trace(parseFloat("0garbage")); // output: 0 See also NaN constant parseInt function...
  • Page 75: Play Function

    The following example returns 4: parseInt("4foo") The following example shows a hexadecimal conversion that returns 1016: parseInt("0x3F8") The following example shows a hexadecimal conversion using the optional parameter radix that returns 1000: parseInt("3E8", 16) The following example shows a binary conversion and returns 10, which is the decimal representation of the binary 1010: parseInt("1010", 2) The following examples show octal number parsing and return 511, which is the decimal...
  • Page 76: Prevframe Function

    prevFrame function prevFrame() : Void Sends the playhead to the previous frame. If the current frame is Frame 1, the playhead does not move. Availability: ActionScript 1.0; Flash Lite 1.0 Example When the user clicks a button called and the following ActionScript is placed on a myBtn_btn frame in the Timeline for that button, the playhead is sent to the previous frame: stop();...
  • Page 77: Removemovieclip Function

    Returns - A random integer. Number 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 Lite 1.0 Parameters - The target path of a movie clip instance created with target:Object...
  • Page 78: Setinterval Function

    See also duplicateMovieClip function duplicateMovieClip (MovieClip.duplicateMovieClip method) attachMovie (MovieClip.attachMovie method) removeMovieClip (MovieClip.removeMovieClip method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method) setInterval function setInterval(functionName:Object, interval:Number [, param1:Object, param2, ..., paramN]) : Number setInterval(objectName:Object, methodName:String, interval:Number [, param1:Object, param2, ..., paramN]) : Number Calls a function or a method or an object at periodic intervals while a SWF file plays. You can use an interval function to update variables from a database or to update a time display.
  • Page 79 Example Usage 1: The following example calls an anonymous function every 1000 milliseconds (1 second). setInterval( function(){ trace("interval called"); }, 1000 ); Usage 2: The following example defines two event handlers and calls each of them. The first call to calls the function, which contains a statement.
  • Page 80 When working with this function, you need to be careful about the memory you use in a SWF file. For example, when you remove a movie clip from the SWF file, it will not remove function running within it. Always remove the function setInterval() setInterval()
  • Page 81: Setproperty Function

    Then create a file called User.as in the same directory as your FLA file. Enter the following ActionScript: class User { var intervalID:Number; var username:String; function User(param_username:String) { trace("Welcome, "+param_username); this.username = param_username; this.intervalID = setInterval(this, "traceUsername", 1000, this.username); function traceUsername(str:String) { trace(this.username+"...
  • Page 82: Startdrag Function

    See also getProperty 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...
  • Page 83: Stop Function

    See also stopDrag function _droptarget (MovieClip._droptarget property) startDrag (MovieClip.startDrag method) 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 Lite 1.0 See also gotoAndStop function gotoAndStop (MovieClip.gotoAndStop method)
  • Page 84: Stopdrag Function

    /* get the current offset. if you stop all sounds and click the play button, the MP3 continues from where it was stopped, instead of restarting from the beginning. */ var numSecondsOffset:Number = (bg_sound.position/1000); bg_sound.start(numSecondsOffset); this.stop_mc.onRelease = function() { stopAllSounds(); See also Sound stopDrag function...
  • Page 85: 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 ■...
  • Page 86: Substring Function

    substring function substring("string", index, count) : 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 Lite 1.0 Parameters - The string from which to extract the new string.
  • Page 87: Telltarget Function

    // _level0.myClip_mc See also eval function tellTarget function tellTarget("target") { 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 88: Togglehighquality Function

    Example This tellTarget statement controls the movie clip instance ball on the main Timeline. Frame 1 of the ball instance is blank and has a stop() action so it isn't visible on the Stage. When you click the button with the following action, tellTarget tells the playhead in ball to go to Frame 2, where the animation starts: on(release) { tellTarget("_parent.ball") {...
  • Page 89: Trace Function

    Example The following code could be applied to a button that, when clicked, would toggle anti- aliasing on and off: on(release) { toggleHighQuality(); See also _quality property trace function trace(expression:Object) You can use Flash Debug Player to capture output from the function and write that trace() output to the log file.
  • Page 90: Unescape Function

    Example The following example uses a statement to display in the Output panel the methods trace() and properties of the dynamically created text field called error_txt this.createTextField("error_txt", this.getNextHighestDepth(), 0, 0, 100, 22); for (var i in error_txt) { trace("error_txt."+i+" = "+error_txt[i]); /* output: error_txt.styleSheet = undefined error_txt.mouseWheelEnabled = true...
  • Page 91: Unloadmovie Function

    unloadMovie function unloadMovie(target:MovieClip) : Void unloadMovie(target:String) : Void Removes a movie clip that was loaded by means of from Flash Player. To unload loadMovie() a movie clip that was loaded by means of , use instead loadMovieNum() unloadMovieNum() unloadMovie() Availability: ActionScript 1.0; Flash Lite 1.1 Parameters - The target path of a movie clip.
  • Page 92: Global Properties

    Availability: ActionScript 1.0; Flash Lite 1.1 Parameters - The level ( ) of a loaded movie. level:Number _level N Example The following example loads an image into a SWF file. When you click , the unload_btn loaded content is removed. loadMovieNum("yourimage.jpg", 1);...
  • Page 93 Modifiers Property Description Deprecated since Flash Lite Player 2.0. This _capCompoundSound action was deprecated in favor of the System.capabilities.hasCompoundSound property. Indicates whether Flash Lite can process compound sound data. Deprecated since Flash Lite Player 2.0. This _capEmail action was deprecated in favor of the System.capabilities.hasEmail property.
  • Page 94 Modifiers Property Description Deprecated since Flash Lite Player 2.0. This _capSMAF action was deprecated in favor of the System.capabilities.hasSMAF property. Indicates whether the device can play multimedia files in the Synthetic music Mobile Application Format (SMAF). If so, this variable is defined and has a value of 1;...
  • Page 95: Version Property

    Modifiers Property Description Specifies or returns a reference to the movie clip or _parent object that contains the current movie clip or object. Sets or retrieves the rendering quality used for a _quality movie clip. Specifies or returns a reference to the root movie _root clip Timeline.
  • Page 96: Cap4Waykeyas Property

    _cap4WayKeyAS property _cap4WayKeyAS Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the property. System.capabilities.has4WayKeyAS Numeric variable; indicates whether Flash Lite executes ActionScript expressions attached to key event handlers associated with the Right, Left, Up, and Down Arrow keys. This variable is defined and has a value of 1 only when the host application uses four-way key navigation mode to move between Flash controls (buttons and input text fields).
  • Page 97: Capemail Property

    Numeric variable; indicates whether Flash Lite can process compound sound data. If so, this variable is defined and has a value of 1; if not, this variable is undefined. For example, a single Flash file can contain the same sound represented in both MIDI and MFi formats. The player will then play back data in the appropriate format based on the format supported by the device.
  • Page 98: Caploaddata Property

    See also capabilities (System.capabilities) _capLoadData property _capLoadData Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the property. System.capabilities.hasDataLoading Numeric variable; indicates whether the host application can dynamically load additional data through calls to the , and loadMovie() loadMovieNum() loadVariables()
  • Page 99: Capmidi Property

    Example If the device can play MFi sound data, the following example sets canMFi canMFi = _capMFi; if (canMFi == 1) { // send movieclip buttons to frame with buttons that trigger events sounds tellTarget("buttons") { gotoAndPlay(2); _capMIDI property _capMIDI Deprecated since Flash Lite Player 2.0.
  • Page 100: Capsmaf Property

    Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the property. System.capabilities.hasMMS Numeric variable; indicates whether Flash Lite can send Multimedia Messaging Service (MMS) messages by using the ActionScript command. If so, this variable is defined GetURL() and has a value of 1;...
  • Page 101: Capsms Property

    Example The following example sets in Flash Lite 1.1, but leaves it undefined in Flash canSMAF Lite 1.0 (however, not all Flash Lite 1.1 phones can send SMAF messages, so this code is still dependent on the phone): canSMAF = _capSMAF; if (canSMAF) { // send movieclip buttons to frame with buttons that trigger events sounds...
  • Page 102: Capstreamsound Property

    See also capabilities (System.capabilities) _capStreamSound property _capStreamSound Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the property. System.capabilities.hasStreamingAudio Numeric variable; indicates whether the device can play streaming (synchronized) sound. If so, this variable is defined and has a value of 1; if not, this variable is undefined. Availability: ActionScript 1.0;...
  • Page 103: Forceframerate Property

    If the global property is set to , the default behavior for all buttons and _focusrect false movieclips is that keyboard navigation is limited to the Tab key. All other keys, including the Enter and arrow keys, are ignored. To restore full keyboard navigation, you must set .
  • Page 104: 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 105: Highquality Property

    _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 the best quality. Specify 1 (high quality) to apply anti-aliasing. Specify 0 (low quality) to prevent anti-aliasing.
  • Page 106: 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 the _level9 document that contains the following ActionScript: loadMovieNum("sub.swf", 9);...
  • Page 107: 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 108: 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 109: Soundbuftime Property

    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 110: 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 111 Because is evaluated in the context of the script that contains it, you can't use in a this this script to refer to a variable defined in a class file. Create ApplyThis.as, and enter the following code: class ApplyThis { var str:String = "Defined in ApplyThis.as";...
  • Page 112: Operators

    Example 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 113 Operator Description Assigns the value of expression2 (the parameter on = (assignment) the right) to the variable, array element, or property in expression1. Converts expression1 and expression2 to 32-bit & (bitwise AND) unsigned integers, and performs a Boolean AND operation on each bit of the integer parameters. Assigns expression1 the value of expression1&...
  • Page 114 Indicates one or more lines of script comments. (block comment delimiter) Evaluates expression1 , then expression2 , and so , (comma) Deprecated since Flash Player 5. Macromedia (concatenation (strings)) recommends you use the addition (+) operator when creating content for Flash Player 5 or later.
  • Page 115 != (inequality) operator. Deprecated since Flash Player 5. This operator has <> (inequality) been deprecated. Macromedia recommends that you use the != (inequality) operator. Tests for the exact opposite of the equality (==) operator. Tests whether object is an instance of...
  • Page 116 Performs a Boolean operation on the values of one or && (logical AND) both of the expressions. Deprecated since Flash Player 5. Macromedia (logical AND) recommends that you use the logical AND (&&) operator. Performs a logical AND (&&) operation in Flash Player Inverts the Boolean value of a variable or expression.
  • Page 117: Addition Operator

    Operator Description Creates a new object and initializes it with the specified (object initializer) name and value property pairs. Performs a grouping operation on one or more () (parentheses) parameters, performs sequential evaluation of expressions, or surrounds one or more parameters and passes them as parameters to a function outside the parentheses.
  • Page 118 Note: Flash Lite 2.0 supports the addition ( ) operator for adding numeric expressions and concatenating strings. Flash Lite 1.x only supports the addition ( ) operator for adding numeric expressions (such as ). For Flash Lite 1.x, you must var1 = 1 + 2 // output: 3 use the operator to concatenate strings.
  • Page 119: 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 120: [] 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 121 var my_array:Array = new Array(); my_array[0] = 15; my_array[1] = "Hello"; my_array[2] = true; You can use brackets ([]) to add a fourth element, as shown in the following example: my_array[3] = "George"; You can use brackets ([]) to access an element in a multidimensional array. The first set of brackets identifies the element in the original array, and the second set identifies the element in the nested array.
  • Page 122 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 123: 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 124: 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 125 Note: The behavior of this operator is different for Flash Lite, depending on the version. For example, Flash Lite 2.0 supports the AND ( ) operator as a bitwise AND. To concatenate & strings in Flash Lite 2.0, you must use the addition ( ) operator.
  • Page 126: Bitwise And Assignment Operator

    &= bitwise AND assignment operator expression1 &= expression2 Assigns the value of . For example, the following expression1 expression1& expression2 two expressions are equivalent: x &= y; x = x & y; Availability: ActionScript 1.0; Flash Lite 2.0 Operands - A number. expression1 : Number - A number.
  • Page 127 Floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive integers are converted to an unsigned hex value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit.
  • Page 128: Bitwise Left Shift And Assignment Operator

    <<= bitwise left shift and assignment operator expression1 <<= expression2 This operator performs a bitwise left shift (<<=) operation and stores the contents as a result . The following two expressions are equivalent: expression1 A <<= BA = (A << B) Availability: ActionScript 1.0;...
  • Page 129 In hexadecimal, this is 0x8888. Therefore, ~0x7777 is 0x8888. The most common use of bitwise operators is for representing flag bits (Boolean values packed into 1 bit each). Floating-point numbers are converted to integers by discarding any digits after the decimal point.
  • Page 130: Bitwise Or Operator

    See also & bitwise AND operator &= bitwise AND assignment operator ^ bitwise XOR operator ^= bitwise XOR assignment operator | bitwise OR operator bitwise OR assignment 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...
  • Page 131: Bitwise Or Assignment Operator

    See also & bitwise AND operator &= bitwise AND assignment operator ^ bitwise XOR operator ^= bitwise XOR assignment operator |= bitwise OR assignment operator ~ bitwise NOT operator |= bitwise OR assignment operator expression1 |= expression2 Assigns the value of .
  • Page 132: 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 133: Bitwise Right Shift And Assignment Operator

    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); // outputs -1 The following example shows the result of the previous example: var x:Number = -1; This is because -1 decimal equals 11111111111111111111111111111111 binary (thirty-two 1s), shifting right by one bit causes the least significant (bit farthest to the right) to be discarded and the most significant bit to be filled in with 1.
  • Page 134: Bitwise Unsigned Right Shift Operator

    string result = (lsb ? "1" : "0")+result; // Shift numberToConvert right by one bit, to see next bit numberToConvert >>= 1; return result; trace(convertToBinary(479)); // Returns the string 00000000000000000000000111011111 // This string is the binary representation of the decimal // number 479 See also >>...
  • Page 135: Bitwise Unsigned Right Shift And Assignment Operator

    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. The result is 01111111111111111111111111111111 binary, which represents the 32-bit integer 2147483647.
  • Page 136: Bitwise Xor 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 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point.
  • Page 137: Bitwise Xor Assignment Operator

    ^= bitwise XOR assignment operator expression1 ^= expression2 Assigns the value of . For example, the expression1 expression1 ^ expression2 following two statements are equivalent: x ^= y x = x ^ y Availability: ActionScript 1.0; Flash Lite 2.0 Operands - Integers and variables.
  • Page 138: Comma Operator

    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. Use the // (comment delimiter) to identify single- line comments.
  • Page 139 Operands - An expression to be evaluated. expression1 : Number - An expression to be evaluated. expression2 : Number - Any number of additional expressions to be evaluated. expressionN : Number Returns - The value of , and so on. Object expression1 expression2...
  • Page 140: Add Concatenation (Strings) Operator

    () parentheses operator add concatenation (strings) operator string1 add string2 Deprecated since Flash Player 5. Macromedia recommends you use the addition ( ) operator when creating content for Flash Player 5 or later. Note: Flash Lite 2.0 also deprecates the operator in favor of the addition ( ) operator.
  • Page 141: Conditional 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; Flash Lite 1.0 Operands An expression that evaluates to a Boolean value;...
  • Page 142: 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 143: 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 144: Dot Operator

    See also / division operator . dot operator object.property_or_method instancename.variable instancename.childinstance instancename.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 145: 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 146: 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 147: 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 Lite 1.0 Operands - Numbers, strings, or variables. expression1 : Object - Numbers, strings, or variables.
  • Page 148: 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 149: Ge Greater Than Or Equal To (Strings) Operator

    Availability: ActionScript 1.0; Flash Lite 1.0 - 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 150: 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 151 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 152: Inequality Operator

    This script displays the following result in the Output panel: 0,1,2,3,4,5,6,7,8,9 != 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...
  • Page 153: Inequality Operator

    && logical AND operator || logical OR 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) Operators...
  • Page 154: Instanceof Operator

    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: Numbers, strings, and Boolean values are compared by value.
  • Page 155: Less Than Operator

    Returns - If is an instance of or a subclass of Boolean object classConstructor instanceof returns , otherwise it returns . Also, returns true false _global instanceof Object false See also typeof operator < less than operator expression1 < expression2 Compares two expressions and determines whether is less than ;...
  • Page 156: Lt Less Than (Strings) Operator

    Example The following examples show returns for both numeric and string true false comparisons: trace(3 < 10); // true trace(10 < 3); // false trace("Allen" < "Jack"); // true trace("Jack" < "Allen"); //false trace("11" < "3"); // true trace("11" < 3); // false (numeric comparison) trace("C"...
  • Page 157: Le Less Than Or Equal To (Strings) Operator

    Availability: ActionScript 1.0; Flash Lite 1.0 - In Flash 4, is a numeric operator. In Flash 5 <= or later, the less 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 158: Line Comment Delimiter Operator

    Operands - Numbers, strings, or variables. expression1 : Object - Numbers, strings, or variables. expression2 : Object Returns - The result of the comparison. Boolean See also <= less than or equal to operator // line comment delimiter operator // comment Indicates the beginning of a script comment.
  • Page 159 Performs a Boolean operation on the values of one or both of the expressions. Evaluates (the expression on the left side of the operator) and returns if the expression1 false expression evaluates to . If evaluates to (the false expression1 true expression2 expression on the right side of the operator) is evaluated.
  • Page 160: And Logical And Operator

    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 &&) , the entire expression is...
  • Page 161: Not Logical Not Operator

    Example In the following example, the variable is set to . The condition evaluates the happy false condition , and if the condition is , the trace() statement sends a string to the !happy true Output panel. var happy:Boolean = false; if (!happy) { trace("don't worry, be happy");...
  • Page 162: Logical Or Operator

    || logical OR operator expression1 || expression2 Evaluates (the expression on the left side of the operator) and returns expression1 true the expression evaluates to . If evaluates to (the true expression1 false expression2 expression on the right side of the operator) is evaluated. If evaluates to expression2 false...
  • Page 163: Or Logical Or Operator

    The following example demonstrates how using a function call as can lead to expression2 unexpected results. If the expression on the left of the operator evaluates to , that result is true returned without evaluating the expression on the right (the function is not called).
  • Page 164: Modulo Operator

    % modulo operator expression1 % expression2 Calculates the remainder of divided by . If either of the expression1 expression2 parameters are non-numeric, the modulo ( ) operator attempts to convert them expression to numbers. The can be a number or string that converts to a numeric value. expression The sign of the result of modulo operation matches the sign of the dividend (the first number).
  • Page 165: Multiplication Operator

    Availability: ActionScript 1.0; Flash Lite 1.0 - In Flash 4 files, the operator is expanded in the SWF file as and may not be as fast or as accurate in later versions of x - int(x/y) * y Flash Player. Operands - A number or expression that evaluates to a number.
  • Page 166: Multiplication Assignment Operator

    The result, 6, is an integer. Usage 2: This statement multiplies the floating-point numbers 2.0 and 3.1416: trace(2.0 * 3.1416); // output: 6.2832 The result, 6.2832, is a floating-point number. *= multiplication assignment operator expression1 *= expression2 Assigns the value of .
  • Page 167: New Operator

    new operator new constructor() Creates a new, initially anonymous, object and calls the function identified by the parameter. The operator passes to the function any optional parameters in constructor parentheses, as well as the newly created object, which is referenced using the keyword this function can then use this to set the variables of the object.
  • Page 168: Object Initializer Operator

    Operands - Numbers, strings, or variables. expression1 : Object - Numbers, strings, or variables. expression2 : Object Returns - Returns true if expression1 is not equal to expression2; false otherwise. Boolean See also != inequality operator {} object initializer operator object = { name1 : value1 , name2 : value2 ,...
  • Page 169: () Parentheses Operator

    = {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 170 Usage 1: Controls the order in which the operators execute in the expression. Parentheses override the normal precedence order and cause the expressions within the parentheses to be evaluated first. When parentheses are nested, the contents of the innermost parentheses are evaluated before the contents of the outer ones.
  • Page 171: Strict Equality Operator

    See also with statement === strict equality operator expression1 === expression2 Tests two expressions for equality; the strict equality ( )operator performs in the same way as the equality ( ) operator, except that data types are not converted. The result is true both expressions, including their data types, are equal.
  • Page 172 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"; var string2:String = "5"; trace(string1 == string2); // true trace(string1 === string2);...
  • Page 173: Strict Inequality Operator

    !== strict inequality operator expression1 !== expression2 Tests for the exact opposite of the strict equality ( )operator. The strict inequality operator performs the same as the inequality operator except that data types are not converted. is equal to , and their data types are equal, the result is expression1 expression2 false...
  • Page 174: String Delimiter Operator

    See also ! logical NOT operator != inequality operator && logical AND operator logical OR operator == equality operator === strict equality operator " string delimiter operator "text" When used before and after characters, quotation marks (") indicate that the characters have a literal value and are considered a string, not a variable, numerical value, or other ActionScript element.
  • Page 175: Subtraction Assignment Operator

    Availability: ActionScript 1.0; Flash Lite 1.0 Operands - A number or expression that evaluates to a number. expression1 : Number - A number or expression that evaluates to a number. expression2 : Number Returns - An integer or floating-point number. Number Example Usage 1: The following statement reverses the sign of the expression 2 + 3:...
  • Page 176: Type Operator

    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; var y:Number = 10; x -= y; trace(x); // output: -5 The following example shows how strings are converted to numbers: var x:String = "5";...
  • Page 177: Typeof Operator

    Example Usage 1: The following example declares a public variable named whose type is userName String and assigns an empty string to it: var userName:String = ""; Usage 2: The following example shows how to specify a function's parameter type by defining a function named that takes a parameter named of type Number:...
  • Page 178: Void Operator

    Expression Type Result Button object Text field object Number number Boolean boolean Object object Function function See also instanceof operator void operator void expression operator evaluates an expression and then discards its value, returning void undefined operator is often used in comparisons using the operator to test for undefined void values.
  • Page 179 Statement Description Defines a custom class, which lets you instantiate objects that share class methods and properties that you define. Jumps past all remaining statements in the innermost loop and starts continue the next iteration of the loop as if control had passed through to the end of the loop normally.
  • Page 180: Break Statement

    Statement Description Specifies that a variable or function is available to any caller. public Specifies the value returned by a function. return Permits implicit setting of properties associated with objects based on classes you have defined in external class files. Assigns a value to a variable.
  • Page 181: Case Statement

    Example The following example uses the statement to exit an otherwise infinite loop: break var i:Number = 0; while (true) { trace(i); if (i >= 10) { break; // this will terminate/exit the loop i++; which traces the following output: See also for statement case statement...
  • Page 182: Class Statement

    Parameters - Any expression. expression:String Example The following example defines conditions for the switch statement . If thisMonth thisMonth equals the expression in the case statement, the statement executes. var thisMonth:Number = new Date().getMonth(); switch (thisMonth) { case 0 : trace("January");...
  • Page 183 The name of the class must match the name of the external file that contains the class. The name of the external file must be the name of the class with the file extension .as appended. For example, if you name a class Student, the file that defines the class must be named Student.as.
  • Page 184 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 185: 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 186: Default Statement

    In a loop, causes the Flash interpreter to skip the rest of the loop body. In the continue following example, if the i modulo 3 equals 0, then the statement is skipped: trace(i) trace("example 3"); for (var i = 0; i < 10; i++) { if (i % 3 == 0) { continue;...
  • Page 187: Delete Statement

    Example In the following example, the expression A does not equal the expressions B or D, so the statement following the keyword is run and the statement is sent to the default trace() Output panel. var dayOfWeek:Number = new Date().getDay(); switch (dayOfWeek) { case 1 : trace("Monday");...
  • Page 188 operator can fail and return if the parameter does not exist or delete false reference cannot be deleted. You cannot delete predefined objects and properties, nor can you delete variables that are declared within a function with the statement. You cannot use the operator to remove movie clips.
  • Page 189: Do..while Statement

    Usage 4: The following example shows the behavior of on object references: delete var ref1:Object = new Object(); ref1.name = "Jody"; // copy the reference variable into a new variable // and delete ref1 ref2 = ref1; delete ref1; trace("ref1.name "+ref1.name); //output: ref1.name undefined trace("ref2.name "+ref2.name);...
  • Page 190: Dynamic Statement

    Example The following example uses a loop to evaluate whether a condition is do..while true, traces until is greater than 5. When is greater than 5, the loop ends. myVar myVar myVar var myVar:Number = 0; do { trace(myVar); myVar++; while (myVar <...
  • Page 191 Example In the following example, class has not yet been marked as dynamic, so calling an Person2 undeclared function on it generates an error at compile time: class Person2 { var name:String; var age:Number; function Person2(param_name:String, param_age:Number) { trace ("anything"); this.name = param_name;...
  • Page 192: Else Statement

    else statement if (condition){ statement(s); } else { statement(s); } Specifies the statements to run if the condition in the statement returns . The curly false braces ( ) used to enclose the block of statements to be executed by the statement are else not necessary if only one statement will execute.
  • Page 193: Extends Statement

    Parameters - An expression that evaluates to condition:Boolean true false 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");...
  • Page 194 The following example shows the contents of a file called Vehicle.as, which defines the Vehicle class: class Vehicle { var numDoors:Number; var color:String; function Vehicle(param_numDoors:Number, param_color:String) { this.numDoors = param_numDoors; this.color = param_color; function start():Void { trace("[Vehicle] start"); function stop():Void { trace("[Vehicle] stop");...
  • Page 195 The following example instantiates a Car object, calls a method defined in the Vehicle class ), then calls the method overridden by the Car class ( ), and finally calls a start() stop() method from the Car class ( activateCarAlarm() var myNewCar:Car = new Car(2, "Red", true);...
  • Page 196: 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 197: 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.
  • Page 198: Function Statement

    The following example shows using 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 199 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 200: 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 } Note: To use this keyword, you must specify ActionScript 2.0 and Flash Player 6 or later in the Flash tab of your FLA file's Publish Settings dialog box.
  • Page 201: 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 202: 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 203: Import Statement

    import statement import className import packageName.* Note: To use this keyword, you must specify ActionScript 2.0 and Flash Player 6 or later in the Flash tab of your FLA file's Publish Settings dialog box. This statement is supported in the Actions panel as well as in external class files.
  • Page 204: Interface Statement

    interface statement interface InterfaceName [extends InterfaceName ] {} Note: To use this keyword, you must specify ActionScript 2.0 and Flash Player 6 or later in the Flash tab of your FLA file's Publish Settings dialog box. This keyword is supported only when used in external script files, not in scripts written in the Actions panel.
  • Page 205 interface Ib { function o():Void; class D implements Ia, Ib { function k():Number { return 15; function n(x:Number):Number { return x * x; function o():Void { trace("o"); } // external script or Actions panel // script file mvar = new D(); trace(mvar.k());...
  • Page 206: Intrinsic Statement

    intrinsic statement intrinsic class className [extends superClass] [implements interfaceName [, interfaceName...] ] { //class definition here Allows compile-time type checking of previously defined classes. Flash uses intrinsic class declarations to enable compile-time type checking of built-in classes such as Array Object .
  • Page 207: Private Statement

    return Math.PI*this.radius*this.radius; this.getDiameter = function() { return 2*this.radius; this.setRadius = function(param_radius) { this.radius = param_radius; // ActionScript 2.0 code that uses the Circle class var myCircle:Circle = new Circle(5); trace(myCircle.getArea()); trace(myCircle.getDiameter()); myCircle.setRadius("10"); trace(myCircle.radius); trace(myCircle.getArea()); trace(myCircle.getDiameter()); See also class statement private statement class someClassName{ private var name;...
  • Page 208: Public Statement

    Example The following example demonstrates how you can hide certain properties within a class using keyword. Create a new AS file called Login.as. private class Login { private var loginUserName:String; private var loginPassword:String; public function Login(param_username:String, param_password:String) { this.loginUserName = param_username; this.loginPassword = param_password;...
  • Page 209: Return Statement

    Specifies that a variable or function is available to any caller. Because variables and functions are public by default, this keyword is used primarily for stylistic reasons. For example, you might want to use it for reasons of consistency in a block of code that also contains private or static variables.
  • Page 210: Set Statement

    Availability: ActionScript 1.0; Flash Lite 2.0 Returns - The evaluated parameter, if provided. String expression Parameters - A string, number, Boolean, array, or object to evaluate and return as a value of expression the function. This parameter is optional. Example The following example uses the statement inside the body of the function to...
  • Page 211: Set Variable Statement

    Example The following example creates a Login class that demonstrates how the keyword can be used to set private variables: class Login { private var loginUserName:String; private var loginPassword:String; public function Login(param_username:String, param_password:String) { this.loginUserName = param_username; this.loginPassword = param_password; public function get username():String { return this.loginUserName;...
  • Page 212 Variables can hold any data type (for example, String, Number, Boolean, Object, or MovieClip). The Timeline of each SWF file and movie clip has its own set of variables, and each variable has its own value independent of variables on other Timelines. Strict data typing is not supported inside a statement.
  • Page 213: Static Statement

    See also var statement static statement class someClassName{ static var name; static function name() { // your statements here } } Note: To use this keyword, you must specify ActionScript 2.0 and Flash Player 6 or later in the Flash tab of your FLA file's Publish Settings dialog box. This keyword is supported only when used in external script files, not in scripts written in the Actions panel.
  • Page 214: Super Statement

    Create a FLA or AS document in the same directory, and enter the following ActionScript in Frame 1 of the Timeline: trace(Users.instances); var user1:Users = new Users(); trace(Users.instances); var user2:Users = new Users(); trace(Users.instances); See also private statement super statement super.method([arg1, ..., argN]) super([arg1, ..., argN]) the first syntax style may be used within the body of an object method to invoke the...
  • Page 215: Switch Statement

    switch statement switch (expression){caseClause: [defaultClause:] } Creates a branching structure for ActionScript statements. As with the statement, the statement tests a condition and executes statements if the condition returns a value switch . All switch statements should include a default case. The default case should include a true break statement that prevents a fall-through error if another case is added later.
  • Page 216: Throw Statement

    See also === strict equality operator throw statement throw expression Generates, or throws, an error that can be handled, or caught, by a code block. If an catch{} exception is not caught by a block, the string representation of the thrown value is sent catch to the Output panel.
  • Page 217: Try..catch..finally Statement

    In a FLA or AS file, enter the following ActionScript in Frame 1 of the Timeline: import InvalidEmailAddress; function checkEmail(email:String) { if (email.indexOf("@") == -1) { throw new InvalidEmailAddress(); try { checkEmail("Joe Smith"); catch (e) { this.createTextField("error_txt", this.getNextHighestDepth(), 0, 0, 100, 22);...
  • Page 218 If the exception thrown is an object, the type will match if the thrown object is a subclass of the specified type. If an error of a specific type is thrown, the block that handles the catch corresponding error is executed. If an exception that is not of the specified type is thrown, the block does not execute and the exception is automatically thrown out of the block catch...
  • Page 219 In the following example, the block is used to delete an ActionScript object, finally regardless of whether an error occurred. Create a new AS file called Account.as. class Account { var balance:Number = 1000; function getAccountInfo():Number { return (Math.round(Math.random() * 10) % 2); In the same directory as Account.as, create a new AS or FLA document and enter the following ActionScript in Frame 1 of the Timeline: import Account;...
  • Page 220 The following example shows a code block with multiple, typed code blocks. catch Depending on the type of error that occurred, the code block throws a different type of object. In this case, is an instance of a (hypothetical) class named RecordSet myRecordSet whose method can throw two types of errors, RecordSetException and...
  • Page 221: 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 222: 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 223: 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 224 The scope chain used by the statement to resolve identifiers starts with the first item in with the following list and continues to the last item: The object specified in the parameter in the innermost statement. ■ object with The object specified in the parameter in the outermost statement.
  • Page 225: Fscommand2 Commands

    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. Math Setting as a default object resolves the identifiers , and Math Math.cos , and...
  • Page 226 Command Description Returns the maximum signal strength level as a numeric value. GetMaxSignalLevel Returns the maximum volume level of the device as a numeric GetMaxVolumeLevel value. Returns the name of the active or default network connection. GetNetworkConnectionName Returns a value that indicates the current network connection GetNetworkConnectStatus status.
  • Page 227: Extendbacklightduration Fscommand2 Command

    ExtendBacklightDuration fscommand2 Command ExtendBacklightDuration Extends the duration of a backlight for a specified period of time. If the duration is greater than zero, this command specifies the amount of time in seconds (maximum of 60 seconds) that the backlight should be kept on. If the time elapses without an additional call to this command, the backlight behavior reverts to the default duration.
  • Page 228: Getbatterylevel Fscommand2 Command

    Example The following example sets the size of the display area to the full screen: status = fscommand2("FullScreen", true); GetBatteryLevel fscommand2 Command GetBatteryLevel Returns the current battery level. It is a numeric value that ranges from 0 to the maximum value returned by the GetMaxBatteryLevel variable.
  • Page 229: Getdeviceid Fscommand2 Command

    Some sample results and the devices they signify follow: A Mitsubishi 506i phone. A Mitsubishi FOMA1 phone. A Fujitsu 506i D506i DFOMA1 F506i phone. A Fujitsu FOMA1 phone. An NEC 506i phone. An NEC FFOMA1 N506i NFOMA1 FOMA1 phone. A Nokia 3650 phone. A Panasonic 506i phone.
  • Page 230: Getmaxbatterylevel Fscommand2 Command

    Example The following example sets status equal to the amount of free memory: status = fscommand2("GetFreePlayerMemory"); GetMaxBatteryLevel fscommand2 Command GetMaxBatteryLevel Returns the maximum battery level of the device. It is a numeric value greater than 0. Command Parameters Value Returned GetMaxBatteryLevel None -1: Not supported.
  • Page 231: Getmaxvolumelevel Fscommand2 Command

    GetMaxVolumeLevel fscommand2 Command GetMaxVolumeLevel Returns the maximum volume level of the device as a numeric value. Command Parameters Value Returned GetMaxVolumeLevel None -1: Not supported. Other values: The maximum volume level. Availability: ActionScript 1.0; Flash Lite 1.1 Example The following example sets the variable to the maximum volume level of the maxvolume device:...
  • Page 232: Getnetworkconnectstatus Fscommand2 Command

    GetNetworkConnectStatus fscommand2 Command GetNetworkConnectStatus Returns a value that indicates the current network connection status. Command Parameters Value Returned GetNetworkConnectStatus None : Not supported. : There is currently an active network connection. : The device is attempting to connect to the network.
  • Page 233: Getnetworkgeneration Fscommand2 Command

    GetNetworkGeneration fscommand2 Command GetNetworkGeneration Returns the generation of the current mobile wireless network, such as 2G (second generation of mobile wireless). Command Parameters Value Returned GetNetworkGeneration None : Not supported : Unknown generation of mobile wireless network : 2G : 2.5G : 3G Availability: ActionScript 1.0;...
  • Page 234: Getnetworkrequeststatus Fscommand2 Command

    GetNetworkRequestStatus fscommand2 Command GetNetworkRequestStatus Returns a value indicating the status of the most recent HTTP request. Command Parameters Value Returned GetNetworkRequestStatus None : The command is not supported. : There is a pending request, a network connection has been established, the server's host name has been resolved, and a connection to the server has been made.
  • Page 235: Getnetworkstatus Fscommand2 Command

    case 2: _root.myText += "pending request, contacting network" + "\n"; break; case 3: _root.myText += "pending request, resolving domain" + "\n"; break; case 4: _root.myText += "failed, network error" + "\n"; break; case 5: _root.myText += "failed, couldn't reach server" + "\n"; break;...
  • Page 236: Getplatform Fscommand2 Command

    networkstatus = fscommand2("GetNetworkStatus"); switch(networkstatus) { case -1: _root.myText += "network status not supported" + "\n"; break; case 0: _root.myText += "no network registered" + "\n"; break; case 1: _root.myText += "on home network" + "\n"; break; case 2: _root.myText += "on extended home network" + "\n"; break;...
  • Page 237: Getpowersource Fscommand2 Command

    GetPowerSource fscommand2 Command GetPowerSource Returns a value that indicates whether the power source is currently supplied from a battery or from an external power source. Command Parameters Value Returned GetPowerSource None : Not supported. : Device is operating on battery power. : Device is operating on an external power source.
  • Page 238: Gettotalplayermemory Fscommand2 Command

    GetTotalPlayerMemory fscommand2 Command GetTotalPlayerMemory Returns the total amount of heap memory, in kilobytes, allocated to Flash Lite. Command Parameters Value Returned GetTotalPlayerMemory None : Not supported. or positive value: Total kilobytes of heap memory. Availability: ActionScript 1.0; Flash Lite 1.1 Example The following example sets the variable to the total amount of heap memory:...
  • Page 239: Quit Fscommand2 Command

    Quit fscommand2 Command Quit Causes the Flash Lite player to stop playback and exit. This command is supported only when Flash Lite is running in stand-alone mode. It is not supported when the player is running in the context of another application (for example, as a plug-in to a browser).
  • Page 240: Setfocusrectcolor Fscommand2 Command

    SetFocusRectColor fscommand2 Command SetFocusRectColor Sets the color of the focus rectangle to any color. The acceptable range of values for red, green, and blue is 0-255. For Flash, you cannot change the default color of the focus rectangle, which is yellow. Command Parameters Value Returned...
  • Page 241: Setsoftkeys Fscommand2 Command

    The following table shows what effect each mode has, and what modes are substituted: InputTextType Mode Sets the FEP to one of If not supported on current these mutually device, opens the FEP in this exclusive modes mode Numeric Numbers only (0 to 9) Alphanumeric Alpha Alphabetic characters only...
  • Page 242 For backward compatibility with Flash Lite 1.1, the soft key is always mapped to the SOFT1 left key on the handset, and the soft key is always mapped to the right key on the SOFT2 handset. For the soft key and higher, the locations are dependent on each handset. SOFT3 The arguments for this command specify the text to be displayed for the corresponding soft keys.
  • Page 243: Startvibrate Fscommand2 Command

    StartVibrate fscommand2 Command StartVibrate Starts the phone's vibration feature. If a vibration is already occurring, Flash Lite stops that vibration before starting the new one. Vibrations also stop when playback of the Flash application is stopped or paused, and when the Flash Lite player quits.
  • Page 244 ActionScript language elements...
  • Page 245: 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 246: Callee (Arguments.callee Property)

    Property summary Modifiers Property Description A reference to the currently executing function. callee:Object A reference to the function that called the currently caller:Object executing function, or null if it wasn't called from another function. The number of arguments passed to the function. length:Number Properties inherited from class Object constructor (Object.constructor...
  • Page 247: Length (Arguments.length Property)

    See also callee (arguments.callee property) length (arguments.length property) public length : Number The number of arguments passed to the function. This may be more or less than the function declares. Availability: ActionScript 1.0; Flash Lite 2.0 Array Object +-Array public dynamic class Array extends Object The Array class lets you access and manipulate indexed arrays.
  • Page 248 The Array class should not be used to create associative arrays, which are different data structures that contain named elements instead of numbered elements. You should use the Object class to create associative arrays (also called hashes). Although ActionScript permits you to create associative arrays using the Array class, you can not use any of the Array class methods or properties.
  • Page 249 Property summary Modifiers Property Description Represents case-insensitive sorting. static CASEINSENSITIVE:Number Represents a descending sort order. static DESCENDING:Number A non-negative integer specifying the length:Number number of elements in the array. Represents numeric sorting instead of static NUMERIC:Number string-based sorting. Represents the option to return an static RETURNINDEXEDARRAY:Number indexed array as a result of calling the...
  • Page 250 Method summary Modifiers Signature Description Concatenates the elements concat([value:Object]) : Array specified in the parameters with the elements in an array and creates a new array. Converts the elements in an array to join([delimiter:String]) : String strings, inserts the specified separator between the elements, concatenates them, and returns the resulting string.
  • Page 251: 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 252: 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 253 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. my_array Availability: ActionScript 1.0;...
  • Page 254: Descending (Array.descending Property)

    DESCENDING (Array.DESCENDING property) public static DESCENDING : Number Represents a descending sort order. You can use this constant for the parameter in options method. The value of this constant is 2. sort() sortOn() Availability: ActionScript 1.0; Flash Lite 2.0 See also sort (Array.sort method) sortOn (Array.sortOn method) join (Array.join method)
  • Page 255: Length (Array.length Property)

    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 256: Numeric (Array.numeric Property)

    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 Represents numeric sorting instead of string-based sorting. String-based sorting, which is the default setting, treats numbers as strings when sorting them. For example, string-based sorting places 10 before 3.
  • Page 257: Push (Array.push Method)

    push (Array.push method) public push(value:Object) : Number Adds one or more elements to the end of an array and returns the new length of the array. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - One or more values to append to the array. value:Object Returns - An integer representing the length of the new array.
  • Page 258: Reverse (Array.reverse Method)

    reverse (Array.reverse method) public reverse() : Void Reverses the array in place. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example uses this method to reverse the array numbers_array var numbers_array:Array = new Array(1, 2, 3, 4, 5, 6); trace(numbers_array);...
  • Page 259 If you don't pass any parameters, a duplicate of the original array is created. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters [optional] - A number specifying the index of the starting point for the startIndex:Number slice. If is a negative number, the starting point begins at the end of the array, where -1 start is the last element.
  • Page 260: Sort (Array.sort Method)

    sort (Array.sort method) public sort([compareFunction:Object], [options:Number]) : Array Sorts the elements in an array. Flash sorts according to Unicode values. (ASCII is a subset of Unicode.) By default, works as described in the following list: Array sort() Sorting is case-sensitive (Z precedes a). ■...
  • Page 261 Note: is defined in ECMA-262, but the array sorting options introduced in Array.sort() Flash Player 7 are Flash-specific extensions to the ECMA-262 specification. Returns - The return value depends on whether you pass any parameters, as described in the Array following list: If you specify a value of 4 or for the...
  • Page 262: Sorton (Array.sorton Method)

    trace("Unsorted:"); //Displays Unsorted: trace(passwords_array); //Displays mom:glam,ana:ring,jay:mag,anne:home,regina:silly. //Writes mom:glam,ana:ring,jay:mag,anne:home,regina:silly passwords_array.sort(order); trace("Sorted:"); //Displays Sorted: trace(passwords_array); //Displays ana:ring,anne:home,jay:mag,mom:glam,regina:silly. //Writes ana:ring,anne:home,jay:mag,mom:glam,regina:silly. See also | bitwise OR operator 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.
  • Page 263 You can use the parameter to override the default sort behavior. If you want to sort a options simple array (for example, an array with only one field), or if you want to specify a sort order that the parameter doesn't support, use options Array.sort() To pass multiple flags, separate them with the bitwise OR (...
  • Page 264 var rec_array:Array = new Array(); rec_array.push({name: "john", city: "omaha", zip: 68144}); rec_array.push({name: "john", city: "kansas city", zip: 72345}); rec_array.push({name: "bob", city: "omaha", zip: 94010}); for(i=0; i<rec_array.length; i++){ trace(rec_array[i].name + ", " + rec_array[i].city); // Results: // john, omaha // john, kansas city // bob, omaha rec_array.sortOn(["name", "city"]);...
  • Page 265: Splice (Array.splice Method)

    // catchy 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...
  • Page 266 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 267: 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 268: 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 Lite 2.0 Parameters - One or more numbers, elements, or variables to be inserted at the beginning value:Object of the array.
  • Page 269: Boolean Constructor

    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 Creates a Boolean object. Boolean([value:Object]) Method summary Modifiers Signature Description Returns the string representation ("true" or toString() : String "false") of the Boolean object.
  • Page 270: Tostring (Boolean.tostring Method)

    Example The following code creates a new empty Boolean object called myBoolean var myBoolean:Boolean = new Boolean(); toString (Boolean.toString method) public toString() : String Returns the string representation ( ) of the Boolean object. "true" "false" Availability: ActionScript 1.0; Flash Lite 2.0 Returns - A string;...
  • Page 271: Button

    Button Object +-Button public class Button extends Object All button symbols in a SWF file are instances of the Button object. You can give a button an instance name in the Property inspector, and use the methods and properties of the Button class to manipulate buttons with ActionScript.
  • Page 272 Property summary Modifiers Property Description The alpha transparency value of the button _alpha:Number specified by my_btn. A Boolean value that specifies whether a enabled:Boolean button is enabled. A Boolean value that specifies whether a _focusrect:Boolean button has a yellow rectangle around it when it has input focus.
  • Page 273 Modifiers Property Description A Boolean value that indicates whether the _visible:Boolean button specified by my_btn is visible. The width of the button, in pixels. _width:Number An integer that sets the x coordinate of a _x:Number button relative to the local coordinates of the parent movie clip.
  • Page 274: Alpha (Button._Alpha Property)

    Event Description Invoked when a button loses keyboard focus. onKillFocus function(newFocus:Object) {} Invoked when a button is pressed. onPress = function() {} Invoked when a button is released. onRelease = function() {} Invoked when the mouse is released with the pointer onReleaseOutside = function() {} outside the button after the mouse button is pressed...
  • Page 275: Enabled (Button.enabled Property)

    Example The following code sets the property of a button named myBtn_btn to 50% when the _alpha user clicks the button. First, add a Button instance on the Stage. Second, give it an instance name of myBtn_btn. Lastly, with frame 1 selected, place the following code into the Actions panel: myBtn_btn.onRelease = function(){ this._alpha = 50;...
  • Page 276: 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 input focus. This property can override the global property. By default, the _focusrect property of a button instance is null; the button instance does not override the _focusrect global property.
  • Page 277: Getdepth (Button.getdepth Method)

    getDepth (Button.getDepth method) public getDepth() : Number Returns the depth of the button 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. Objects with higher depths appear in front.
  • Page 278: Height (Button._Height Property)

    _height (Button._height property) public _height : Number The height of the button, in pixels. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example sets the height and width of a button called to a specified my_btn width and height. my_btn._width = 500;...
  • Page 279: Ondragout (Button.ondragout Handler)

    Instance name of the button specified by my_btn Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces all instance names of any Button instances within the current Timeline of a SWF file. for (i in this) { if (this[i] instanceof Button) { trace(this[i]._name);...
  • Page 280: Ondragover (Button.ondragover Handler)

    onDragOver (Button.onDragOver handler) onDragOver = function() {} Invoked when the user presses the mouse button outside of the button and then drags the pointer over the button. You must define a function that is executed when the event handler is invoked.
  • Page 281: Onkeyup (Button.onkeyup Handler)

    Example In the following example, a function that sends text to the Output panel is defined for the handler. Create a button called on the Stage, and enter the following onKeyDown my_btn ActionScript in a frame on the Timeline: my_btn.onKeyDown = function() { trace("onKeyDown: "+this._name+"...
  • Page 282: Onkillfocus (Button.onkillfocus Handler)

    Example In the following example, a function that sends text to the Output panel is defined for the . Create a button called on the Stage, and enter the following onKeyDown handler my_btn ActionScript in a frame on the Timeline: my_btn.onKeyDown = function() { trace("onKeyDown: "+this._name+"...
  • Page 283: Onpress (Button.onpress Handler)

    Parameters - The object that is receiving the focus. newFocus:Object Example The following example demonstrates how statements can be executed when a button loses focus. Create a button instance on the Stage called and add the following my_btn ActionScript to Frame 1 of the Timeline: this.createTextField("output_txt", this.getNextHighestDepth(), 0, 0, 300, 200);...
  • Page 284: Onreleaseoutside (Button.onreleaseoutside Handler)

    Example In the following example, a function that sends a trace() statement to the Output panel is defined for the handler: onRelease my_btn.onRelease = function () { trace ("onRelease called"); onReleaseOutside (Button.onReleaseOutside handler) onReleaseOutside = function() {} Invoked when the mouse is released with the pointer outside the button after the mouse button is pressed with the pointer inside the button.
  • Page 285: Onrollover (Button.onrollover Handler)

    Example In the following example, a function that sends a trace() statement to the Output panel is defined for the handler: onRollOut my_btn.onRollOut = function () { trace ("onRollOut called"); onRollOver (Button.onRollOver handler) onRollOver = function() {} Invoked when the button gains focus. This can happen when the user clicks another button outside of the currently selected button.
  • Page 286: 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 287: 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 288: Soundbuftime (Button._Soundbuftime 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 289: 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 290: 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 291: 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 292: Url (Button._Url Property)

    Example The following example demonstrates how to track two buttons as a menu. Place two button instances called on the stage. 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 293: Visible (Button._Visible Property)

    When you click each button, the file name of the SWF containing the buttons displays in the Output panel. _visible (Button._visible property) public _visible : Boolean A Boolean value that indicates whether the button specified by is visible. Buttons that my_btn are not visible ( property set to...
  • Page 294: X (Button._X Property)

    See also _width (MovieClip._width 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 295: Xscale (Button._Xscale Property)

    Example The following example displays the x coordinate of the mouse position for the Stage and a button called that is placed on the Stage. Enter the following ActionScript in Frame 1 my_btn of the Timeline: this.createTextField("mouse_txt", 999, 5, 5, 150, 40); mouse_txt.html = true;...
  • Page 296: Y (Button._Y Property)

    Example The following example scales a button called my_btn. When you click and release the button, it grows 10% on the x and y axis. Enter the following ActionScript in Frame 1 of the Timeline: my_btn.onRelease = function(){ this._xscale ~= 1.1; this._yscale ~= 1.1;...
  • Page 297: Ymouse (Button._Ymouse Property)

    _ymouse (Button._ymouse property) public _ymouse : Number [read-only] Returns the y coordinate of the mouse position relative to the button. Note: The property is supported for Flash Lite 2.0 only if _ymouse System.capabilities.hasMouse is true System.capabilities.hasStylus is true Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example displays the x coordinate of the mouse position for the Stage and a button called...
  • Page 298: Yscale (Button._Yscale 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; Flash Lite 2.0 Example The following example scales a button called .
  • Page 299 The following example shows a string for a mobile device: that indicates a normal screen orientation ■ that is running an undetermined language ■ that is running the Symbian7.0sSeries60V2 operating system ■ thatis configured so the user can't access hard disk, camera or microphone ■...
  • Page 300 Property summary Modifiers Property Description [read-only] Returns an array of MIME types for static audioMIMETypes:Array audio codecs supported by a mobile device. [read-only] A Boolean value that specifies static avHardwareDisable:Boolean whether access to the user's camera and microphone has been administratively prohibited (true) or allowed (false).
  • Page 301 Modifiers Property Description [read-only] A Boolean value that is true if the static hasEmbeddedVideo:Boolean player is running on a mobile device that supports embedded video; false otherwise. Returns true if the mobile device static hasMappableSoftKeys:Boolean allows you to reset or reassign softkey labels and handle events from those softkeys.
  • Page 302 Modifiers Property Description [read-only] A Boolean value that is true if the static hasScreenPlayback:Boolean player supports the playback of screen broadcast applications that are being run through Flash Media Server; false otherwise. [read-only] Returns true if the Flash Lite static hasSharedObjects:Boolean content playing back in an application can access the Flash...
  • Page 303 Modifiers Property Description [read- A Boolean value that indicates static localFileReadDisable:Boolean only] whether read access to the user's hard disk has been administratively prohibited (true) or allowed (false). [read-only] Returns an array that contains all static MIMETypes:Array MIME types that the loadMovie function, Sound and Video objects support.
  • Page 304: Audiomimetypes (Capabilities.audiomimetypes 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) audioMIMETypes (capabilities.audioMIMETypes property) public static audioMIMETypes : Array [read-only] Returns an array of MIME types for audio codecs supported by a mobile device.
  • Page 305: Has4Waykeyas (Capabilities.has4Waykeyas Property)

    has4WayKeyAS (capabilities.has4WayKeyAS property) public static has4WayKeyAS : Boolean [read-only] A Boolean value that is if the Flash Lite player executes the ActionScript code associated true with key event handlers that are associated with the left, right, up, and down keys. Otherwise, this property returns false If the value of this variable is...
  • Page 306: Hasaudioencoder (Capabilities.hasaudioencoder Property)

    Example The following example traces the value of this read-only property: trace(System.capabilities.hasAudio); hasAudioEncoder (capabilities.hasAudioEncoder property) public static hasAudioEncoder : Boolean [read-only] Specifies if the Flash Player can encode an audio stream. A Boolean value that is if the true player can encode an audio stream, such as that coming from a microphone; otherwise.
  • Page 307: Hasdataloading (Capabilities.hasdataloading Property)

    Example The following example traces the value of this read-only property: trace(System.capabilities.hasCompoundSound); hasDataLoading (capabilities.hasDataLoading property) public static hasDataLoading : Boolean [read-only] Returns if the Flash Lite player can dynamically load additional data through calls to true specific functions. You can call the following specific functions: loadMovie() ■...
  • Page 308: Hasembeddedvideo (Capabilities.hasembeddedvideo Property)

    Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasEmail); hasEmbeddedVideo (capabilities.hasEmbeddedVideo property) public static hasEmbeddedVideo : Boolean [read-only] A Boolean value that is if the player is running on a mobile device that supports true embedded video;...
  • Page 309: Hasmidi (Capabilities.hasmidi Property)

    Example The following example traces the value of this read-only property: trace(System.capabilities.hasMFI); hasMIDI (capabilities.hasMIDI property) public static hasMIDI : Boolean [read-only] Returns if the mobile device is capable of playing sound data in the MIDI audio format. true Otherwise, this property returns false Availability: ActionScript 1.0;...
  • Page 310: Hasmp3 (Capabilities.hasmp3 Property)

    Example The following example traces the value of this read-only property: trace(System.capabilities.hasMouse); hasMP3 (capabilities.hasMP3 property) public static hasMP3 : Boolean [read-only] Specifies if the mobile device has a MP3 decoder. A Boolean value that is if the player is true running on a system that has an MP3 decoder;...
  • Page 311: Hasscreenbroadcast (Capabilities.hasscreenbroadcast Property)

    Example The following example traces the value of this read-only property: trace(System.capabilities.hasQWERTYKeyboard); hasScreenBroadcast (capabilities.hasScreenBroadcast property) public static hasScreenBroadcast : Boolean [read-only] A Boolean value that is if the player supports the development of screen broadcast true applications to be run through Flash Media Server; otherwise.
  • Page 312: Hassmaf (Capabilities.hassmaf Property)

    Otherwise, this property returns false Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasSharedObjects); hasSMAF (capabilities.hasSMAF property) public static hasSMAF : Boolean [read-only] Returns if the mobile device is capable of playing sound data in the SMAF audio format. true Otherwise, this property returns false...
  • Page 313: Hasstreamingvideo (Capabilities.hasstreamingvideo Property)

    Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasStreamingAudio); hasStreamingVideo (capabilities.hasStreamingVideo property) public static hasStreamingVideo : Boolean [read-only] A Boolean value that is if the player can play streaming video; otherwise. The true false server string is...
  • Page 314: Imagemimetypes (Capabilities.imagemimetypes Property)

    Specifies if the Flash Player can encode a video stream. A Boolean value that is if the true player can encode a video stream, such as that coming from a web camera; otherwise. false The server string is Note: For Flash Lite 2.0, the value returned is always false Availability: ActionScript 1.0;...
  • Page 315: Language (Capabilities.language Property)

    language (capabilities.language property) public static language : String [read-only] Indicates the language of the system on which the player is running. This property is specified as a lowercase two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code subtag from ISO 3166 distinguishes between Simplified and Traditional Chinese.
  • Page 316: Localfilereaddisable (Capabilities.localfilereaddisable Property)

    Language Simplified Chinese zh-CN Spanish Swedish Traditional Chinese zh-TW Turkish Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the value of this read-only property: trace(System.capabilities.language); localFileReadDisable (capabilities.localFileReadDisable property) public static localFileReadDisable : Boolean [read-only] A Boolean value that indicates whether read access to the user's hard disk has been administratively prohibited ( ) or allowed ( ).
  • Page 317: Mimetypes (Capabilities.mimetypes Property)

    MIMETypes (capabilities.MIMETypes property) public static MIMETypes : Array [read-only] Returns an array that contains all MIME types that the function, Sound and loadMovie Video objects support. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the value of this read-only property: trace(System.capabilities.MIMETypes);...
  • Page 318: Screenorientation (Capabilities.screenorientation Property)

    Example The following example traces the value of this read-only property: trace(System.capabilities.screenOrientation); screenResolutionX (capabilities.screenResolutionX property) public static screenResolutionX : Number [read-only] An integer that indicates the maximum horizontal resolution of the screen. The server string is (which returns both the width and height of the screen). Availability: ActionScript 1.0;...
  • Page 319: Version (Capabilities.version Property)

    version (capabilities.version property) public static version : String [read-only] A string that contains the Flash Player platform and version information (for example, "WIN ). The server string is 7,1,0,0" Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the value of this read-only property: trace(System.capabilities.version);...
  • Page 320: Color Constructor

    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 Creates a Color object for the movie clip specified by the target_mc Color(target:Object) parameter. Method summary Modifiers Signature Description Returns the R+G+B combination...
  • Page 321: Getrgb (Color.getrgb Method)

    Parameters - The instance name of a movie clip. target:Object Example The following example creates a Color object called for the movie clip my_color my_mc sets its RGB value to orange: var my_color:Color = new Color(my_mc); my_color.setRGB(0xff9933); getRGB (Color.getRGB method) public getRGB() : Number Returns the R+G+B combination currently in use by the color object.
  • Page 322: Setrgb (Color.setrgb Method)

    Returns - An object whose properties contain the current offset and percentage values for the Object specified color. Example The following example gets the transform object, and then sets new percentages for colors and alpha of relative to their current values. To see this code work, place a multicolored my_mc movie clip on the Stage with the instance name .
  • Page 323: Settransform (Color.settransform Method)

    setTransform (Color.setTransform method) public setTransform(transformObject:Object) : Void Sets color transform information for a Color object. The parameter colorTransformObject is a generic object that you create from the constructor. It has parameters new Object specifying the percentage and offset values for the red, green, blue, and alpha (transparency) components of a color, entered in the format 0xRRGGBBAA.
  • Page 324: Date

    Example This example creates a new Color object for a target SWF file, creates a generic object called with the properties defined above, and uses the method myColorTransform setTransform() to pass the to a Color object. To use this code in a Flash (FLA) colorTransformObject document, place it on Frame 1 on the main Timeline and place a movie clip on the Stage with the instance name...
  • Page 325 Mac OS X - the Date object automatically adjusts its output for daylight saving time. The ■ time zone information database in Mac OS X is used to determine whether any date or time in the present or past should have a daylight saving time bias applied. Mac OS 9 - the operating system provides only enough information to determine whether ■...
  • Page 326 Method summary Modifiers Signature Description Returns the day of the month (an getDate() : Number integer from 1 to 31) of the specified Date object according to local time. Returns the day of the week (0 for getDay() : Number Sunday, 1 for Monday, and so on) of the specified Date object according to local time.
  • Page 327 Modifiers Signature Description Returns the seconds (an integer getSeconds() : Number from 0 to 59) of the specified Date object, according to local time. Returns the number of milliseconds getTime() : Number since midnight January 1, 1970, universal time, for the specified Date object.
  • Page 328 Modifiers Signature Description Returns the year of the specified getYear() : Number Date object, according to local time. Sets the day of the month for the setDate(date:Number) : Number specified Date object, according to local time, and returns the new time in milliseconds.
  • Page 329 Modifiers Signature Description Sets the hour for the specified Date setUTCHours(hour:Number, object in universal time and returns [minute:Number], [second:Number], the new time in milliseconds. [millisecond:Number]) : Number Sets the milliseconds for the setUTCMilliseconds(millisecond:Number specified Date object in universal Number time and returns the new time in milliseconds.
  • Page 330: Date Constructor

    Date constructor public Date([yearOrTimevalue:Number], [month:Number], [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number]) Constructs a new Date object that holds the specified date and time. constructor takes up to seven parameters (year, month, ..., millisecond) to specify Date() a date and time to the millisecond. Alternatively, you can pass a single value to the Date() constructor that indicates a time value based on the number of milliseconds since January 1, 1970 0:00:000 GMT.
  • Page 331: Getdate (Date.getdate Method)

    [optional] - An integer from 0 (midnight) to 23 (11 p.m.). hour:Number [optional] - An integer from 0 to 59. minute:Number [optional] - An integer from 0 to 59. second:Number [optional] - An integer from 0 to 999 of milliseconds. millisecond:Number Example The following example retrieves the current date and time:...
  • Page 332: Getday (Date.getday Method)

    Example The following example creates a new Date object and concatenates the returned values of , and Date.getMonth() Date.getDate() Date.getFullYear(): var today_date:Date = new Date(); var date_str:String = (today_date.getDate()+"/ "+(today_date.getMonth()+1)+"/"+today_date.getFullYear()); trace(date_str); // displays current date in United States date format See also getMonth (Date.getMonth method) getFullYear (Date.getFullYear method)
  • Page 333: Gethours (Date.gethours Method)

    Returns - An integer representing the year. Number Example The following example uses the constructor to create a Date object. The trace statement shows the value returned by the method. getFullYear() var my_date:Date = new Date(); trace(my_date.getYear()); // displays 104 trace(my_date.getFullYear());...
  • Page 334: Getlocalelongdate (Date.getlocalelongdate Method)

    getLocaleLongDate (Date.getLocaleLongDate method) public getLocaleLongDate() : String Returns a string representing the current date, in long form, formatted according to the currently defined locale. Note: The format of the date depends on the mobile device and the locale. Availability: ActionScript 1.0; Flash Lite 2.0 Returns - A string representing the current date, in long form, formatted according to the String...
  • Page 335: Getlocaletime (Date.getlocaletime Method)

    Example The following example uses the constructor to create a Date object based on the current time. It also uses the method to return the current date, in short form, getLocaleShortDate() formatted according to the currently defined locale, as follows: var my_date:Date = new Date();...
  • Page 336: Getminutes (Date.getminutes Method)

    Returns - An integer. Number Example The following example uses the constructor to create a Date object based on the current time and uses the method to return the milliseconds value from that object: getMilliseconds() var my_date:Date = new Date(); trace(my_date.getMilliseconds());...
  • Page 337: Getseconds (Date.getseconds Method)

    Example The following example uses the constructor to create a Date object based on the current time and uses the method to return the month value from that object: getMonth() var my_date:Date = new Date(); trace(my_date.getMonth()); The following example uses the constructor to create a Date object based on the current time and uses the method to display the current month as a numeric value, and getMonth()
  • Page 338: Gettimezoneoffset (Date.gettimezoneoffset Method)

    Availability: ActionScript 1.0; Flash Lite 2.0 Returns - An integer. Number Example The following example uses the constructor to create a Date object based on the current time, and uses the method to return the number of milliseconds since midnight January getTime() 1, 1970: var my_date:Date = new Date();...
  • Page 339: Getutcday (Date.getutcday Method)

    Returns - An integer. Number Example The following example creates a new Date object and uses Date.getUTCDate() . The value returned by can differ from the value Date.getDate() Date.getUTCDate() returned by depending on the relationship between your local time zone Date.getDate(), and universal time.
  • Page 340: Getutcfullyear (Date.getutcfullyear Method)

    getUTCFullYear (Date.getUTCFullYear method) public getUTCFullYear() : Number Returns the four-digit year of the specified Date object, according to universal time. Availability: ActionScript 1.0; Flash Lite 2.0 Returns - An integer. Number Example The following example creates a new Date object and uses Date.getUTCFullYear() .
  • Page 341: Getutcmilliseconds (Date.getutcmilliseconds Method)

    Example The following example creates a new Date object and uses Date.getUTCHours() . The value returned by may differ from the value Date.getHours() Date.getUTCHours() returned by depending on the relationship between your local time zone Date.getHours(), and universal time. var today_date:Date = new Date(); trace(today_date.getHours());...
  • Page 342: Getutcmonth (Date.getutcmonth Method)

    Returns - An integer. Number Example The following example creates a new Date object and uses to return the getUTCMinutes() minutes value from the Date object: var today_date:Date = new Date(); trace(today_date.getUTCMinutes()); getUTCMonth (Date.getUTCMonth method) public getUTCMonth() : Number Returns the month (0 [January] to 11 [December]) of the specified Date object, according to universal time.
  • Page 343: Getutcyear (Date.getutcyear Method)

    Returns - An integer. Number Example The following example creates a new Date object and uses to return the getUTCSeconds() seconds value from the Date object: var today_date:Date = new Date(); trace(today_date.getUTCSeconds()); getUTCYear (Date.getUTCYear method) public getUTCYear() : Number Returns the year of this according to universal time (UTC).
  • Page 344: Setdate (Date.setdate Method)

    Returns - An integer. Number Example The following example creates a Date object with the month and year set to May 2004. The method returns 104, and returns 2004: Date.getYear() Date.getFullYear() var today_date:Date = new Date(2004,4); trace(today_date.getYear()); // output: 104 trace(today_date.getFullYear());...
  • Page 345: Setfullyear (Date.setfullyear Method)

    setFullYear (Date.setFullYear method) public setFullYear(year:Number, [month:Number], [date:Number]) : Number Sets the year of the specified Date object, according to local time and returns the new time in milliseconds. If the parameters are specified, they are set to local time. Local month date time is determined by the operating system on which Flash Player is running.
  • Page 346: Sethours (Date.sethours Method)

    setHours (Date.setHours method) public setHours(hour:Number) : Number Sets the hours 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 347: Setminutes (Date.setminutes 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 then uses to change the milliseconds value to 575: Date.setMilliseconds() var my_date:Date = new Date(2004,4,15,8,30,0,250); trace(my_date.getMilliseconds());...
  • Page 348: Setseconds (Date.setseconds Method)

    Parameters - An integer from 0 (January) to 11 (December). month:Number [optional] - An integer 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,...
  • Page 349: Settime (Date.settime Method)

    setTime (Date.setTime method) public setTime(millisecond:Number) : Number Sets the date for the specified Date object in milliseconds since midnight on January 1, 1970, and returns the new time in milliseconds. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - A number; an integer value where 0 is midnight on January 1, millisecond:Number universal time.
  • Page 350: Setutcfullyear (Date.setutcfullyear Method)

    Returns - An integer. Number Example The following example initially creates a new Date object with today's date, uses to change the date value to 10, and changes it again to 25: Date.setUTCDate() var my_date:Date = new Date(); my_date.setUTCDate(10); trace(my_date.getUTCDate()); // output: 10 my_date.setUTCDate(25);...
  • Page 351: Setutchours (Date.setutchours Method)

    Example The following example initially creates a new Date object with today's date, uses to change the year value to 2001, and changes the date to May 25, Date.setUTCFullYear() 1995: var my_date:Date = new Date(); my_date.setUTCFullYear(2001); trace(my_date.getUTCFullYear()); // output: 2001 my_date.setUTCFullYear(1995, 4, 25);...
  • Page 352: Setutcmilliseconds (Date.setutcmilliseconds Method)

    Example The following example initially creates a new Date object with today's date, uses to change the time to 8:30 a.m., and changes the time again to 5:30:47 Date.setUTCHours() p.m.: var my_date:Date = new Date(); my_date.setUTCHours(8,30); trace(my_date.getUTCHours()); // output: 8 trace(my_date.getUTCMinutes());...
  • Page 353: Setutcminutes (Date.setutcminutes Method)

    setUTCMinutes (Date.setUTCMinutes method) public setUTCMinutes(minute:Number, [second:Number], [millisecond:Number]) : Number Sets the minute for the specified Date object in universal time and returns the new time in milliseconds. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - An integer from 0 to 59. minute:Number [optional] - An integer from 0 to 59.
  • Page 354: Setutcseconds (Date.setutcseconds Method)

    Parameters - An integer from 0 (January) to 11 (December). month:Number [optional] - An integer 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,...
  • Page 355: Setyear (Date.setyear Method)

    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:30:45 Date.setSeconds() a.m.: var my_date:Date = new Date(2004,4,15,8,0,0); trace(my_date.getUTCSeconds()); // output: 0 my_date.setUTCSeconds(45);...
  • Page 356: Tostring (Date.tostring Method)

    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 Lite 2.0 Returns - A string. String Example The following example returns the information in the Date object as a dateOfBirth_date string.
  • Page 357: 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 358 Property summary Modifiers Property Description Contains the message associated with the message:String Error object. Contains the name of the Error object. name:String 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 Error object.
  • Page 359: Error Constructor

    Error constructor public Error([message:String]) Creates a new Error object. If is specified, its value is assigned to the objects message property. Error.message Availability: ActionScript 1.0; Flash Lite 2.0 Parameters [optional] - A string associated with the Error object. message:String 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 {...
  • Page 360: Name (Error.name Property)

    Example In the following example, a function throws a specified message depending on the parameters entered into . If two numbers can be divided, and the number are shown. theNum SUCCESS Specific errors are shown if you try to divide by 0 or enter only 1 parameter: function divideNum(num1:Number, num2:Number):Number { if (isNaN(num1) || isNaN(num2)) { throw new Error("divideNum function requires two numeric parameters.");...
  • Page 361: Tostring (Error.tostring Method)

    var theNum:Number = divideNumber(1, 0); trace("SUCCESS! "+theNum); // output: DivideByZeroError -> Unable to divide by zero. } catch (e_err:DivideByZeroError) { // divide by zero error occurred trace(e_err.name+" -> "+e_err.toString()); } catch (e_err:Error) { // generic error occurred trace(e_err.name+" -> "+e_err.toString()); To add a custom error, add the following code to a .AS file called DivideByZeroError.as and save the class file in the same directory as your FLA document.
  • Page 362: Extendedkey

    See also message (Error.message property) throw statement try..catch..finally statement ExtendedKey Object +-ExtendedKey public class ExtendedKey extends Object Provides extended key codes that can be returned from the method. Key.getCode() Availability: ActionScript 2.0; Flash Lite 2.0 Example The following example creates a listener that is called when a key is pressed. It uses the method to get the key code for the key that was pressed: Key.getCode() var myListener = new Object();...
  • Page 363 See also getCode (Key.getCode method) Property summary Modifiers Property Description The key code value for the SOFT1 soft key. static SOFT1:String The key code value for the SOFT10 soft key. static SOFT10:String The key code value for the SOFT11 soft key. static SOFT11:String The key code value for the SOFT12 soft key.
  • Page 364: Soft1 (Extendedkey.soft1 Property)

    SOFT1 (ExtendedKey.SOFT1 property) public static SOFT1 : String The key code value for the SOFT1 soft key. The SOFT1 key code always corresponds to the left soft key; the SOFT2 always corresponds to the right soft key. Availability: ActionScript 2.0; Flash Lite 2.0 Example The following example creates a listener that handles the left and right soft keys: var myListener:Object = new Object();...
  • Page 365: Soft2 (Extendedkey.soft2 Property)

    SOFT2 (ExtendedKey.SOFT2 property) public static SOFT2 : String The key code value for the SOFT2 soft key. The SOFT2 key code always corresponds to the right soft key; the SOFT1 key code always corresponds to the left soft key. Availability: ActionScript 2.0; Flash Lite 2.0 See also SOFT1 (ExtendedKey.SOFT1 property) SOFT3 (ExtendedKey.SOFT3 property)
  • Page 366: Soft8 (Extendedkey.soft8 Property)

    Availability: ActionScript 2.0; Flash Lite 2.0 SOFT8 (ExtendedKey.SOFT8 property) public static SOFT8 : String The key code value for the SOFT8 soft key. Availability: ActionScript 2.0; Flash Lite 2.0 SOFT9 (ExtendedKey.SOFT9 property) public static SOFT9 : String The key code value for the SOFT9 soft key. Availability: ActionScript 2.0;...
  • Page 367: Apply (Function.apply Method)

    Method summary Modifiers Signature Description Specifies the value of thisObject to be apply(thisObject:Object, used within any function that [argArray:Array]) ActionScript calls. Invokes the function represented by a call(thisObject:Object, Function object. [parameter1:Object]) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable...
  • Page 368 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() { trace(arguments); // create a new array to pass as a parameter to apply() var firstArray:Array = new Array(1,2,3);...
  • Page 369: Call (Function.call Method)

    See also call (Function.call method) call (Function.call method) public call(thisObject:Object, [parameter1: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. In almost all cases, the function call ( ) operator can be used instead of this method.
  • Page 370: Key

    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(); myMethod.call(obj, obj);...
  • Page 371 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 372: Addlistener (Key.addlistener Method)

    Method summary Modifiers Signature Description Registers an object to receive static addListener(listener:Object) : onKeyDown and onKeyUp notification. Void Returns the ASCII code of the last key static getAscii() : Number pressed or released. Returns the key code value of the last static getCode() : Number...
  • Page 373: Backspace (Key.backspace 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 onKeyUp addListener() it can receive notification from the key down and key up events. var myListener:Object = new Object();...
  • Page 374: Capslock (Key.capslock Property)

    CAPSLOCK (Key.CAPSLOCK property) public static CAPSLOCK : Number The key code value for the Caps Lock key (20). Availability: ActionScript 1.0; Flash Lite 2.0 CONTROL (Key.CONTROL property) public static CONTROL : Number The key code value for the Control key (17). Availability: ActionScript 1.0;...
  • Page 375: Down (Key.down Property)

    keyListener.onKeyDown = function() { if (Key.isDown(Key.DELETEKEY) || Key.isDown(Key.BACKSPACE)) { canvas_mc.clear(); Key.addListener(keyListener); When using this example, make sure that you select Control > Disable Keyboard Shortcuts in the test environment. DOWN (Key.DOWN property) public static DOWN : Number The key code value for the Down Arrow key (40). Availability: ActionScript 1.0;...
  • Page 376: End (Key.end Property)

    END (Key.END property) public static END : Number The key code value for the End key (35). Availability: ActionScript 1.0; Flash Lite 2.0 ENTER (Key.ENTER property) public static ENTER : Number The key code value for the Enter key (13).. Availability: ActionScript 1.0;...
  • Page 377: Escape (Key.escape Property)

    When using this example, make sure that you select Control > Disable Keyboard Shortcuts in the test environment. ESCAPE (Key.ESCAPE property) public static ESCAPE : Number The key code value for the Escape key (27). Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example sets a timer.
  • Page 378: 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...
  • Page 379 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 keyListener event by calling . The object is then registered to onKeyDown Key.getCode() keyListener...
  • Page 380: 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 Lite 2.0 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, car_mc returns to 0,0. Create a movie clip that has a linkage ID , and add the following ActionScript to Frame 1 of the Timeline: car_id...
  • Page 381: Isdown (Key.isdown 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 382: 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 Lite 2.0 Example The following example moves a movie clip called a constant distance (10) when you car_mc press the arrow keys.
  • Page 383: Listeners (Key._Listeners Property)

    _listeners (Key._listeners property) public static _listeners : Array [read-only] A list of references to all listener objects registered with the Key object. This property is intended for internal use, but may be useful if you want to ascertain the number of listeners currently registered with the Key object.
  • Page 384: 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 385: 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 Lite 2.0 Example The following example rotates a movie clip called when you press the Page Down and car_mc Page Up keys.
  • Page 386: Right (Key.right Property)

    Example The following example moves a movie clip called using the Left and Right arrow keys. car_mc The listener is removed when you press Escape, and no longer moves. car_mc var keyListener:Object = new Object(); keyListener.onKeyDown = function() { switch (Key.getCode()) { case Key.LEFT : car_mc._x -= 10;...
  • Page 387: Shift (Key.shift Property)

    break; case Key.RIGHT : car_mc._x += DISTANCE; break; case Key.DOWN : car_mc._y += DISTANCE; break; Key.addListener(keyListener_obj); SHIFT (Key.SHIFT property) public static SHIFT : Number The key code value for the Shift key (16). Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example scales when you press Shift.
  • Page 388: Tab (Key.tab Property)

    Example The following example moves a movie clip called a constant distance (10) when you car_mc press the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage identifier of for this example. horn_id var DISTANCE:Number = 10;...
  • Page 389: Up (Key.up Property)

    date_txt.text = today_date.toString(); Key.addListener(keyListener); When using this example, make sure that you select Control > Disable Keyboard Shortcuts in the test environment. UP (Key.UP property) public static UP : Number The key code value for the Up Arrow key (38). Availability: ActionScript 1.0;...
  • Page 390: Loadvars

    LoadVars Object +-LoadVars public dynamic class LoadVars extends Object You can use the LoadVars class to obtain verification of successful data loading and to monitor download progress. The LoadVars class is an alternative to the loadVariables() function for transferring variables between a Flash application and a server. The LoadVars class lets you send all the variables in an object to a specified URL and load all the variables at a specified URL into an object.
  • Page 391 Property summary Modifiers Property Description The MIME type that is sent to the server when you contentType:String call LoadVars.send() or LoadVars.sendAndLoad(). A Boolean value that indicates whether a load or loaded:Boolean sendAndLoad operation has completed, undefined by default. Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__...
  • Page 392: Addrequestheader (Loadvars.addrequestheader Method)

    Method summary Modifiers Signature Description Adds or changes HTTP request headers addRequestHeader(header:Object, (such as Content-Type or SOAPAction) headerValue:String) : Void sent with POST actions. Converts the variable string to properties decode(queryString:String) : Void of the specified LoadVars object. Returns the number of bytes getBytesLoaded() : Number downloaded by LoadVars.load() or...
  • Page 393 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 394: Contenttype (Loadvars.contenttype Property)

    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 Lite 2.0 Example The following example creates a LoadVars object and displays the default content type of the data that is sent to the server.
  • Page 395: Getbytesloaded (Loadvars.getbytesloaded Method)

    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. Availability: ActionScript 1.0;...
  • Page 396: Getbytestotal (Loadvars.getbytestotal Method)

    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 397: Load (Loadvars.load Method)

    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) load (LoadVars.load method) public load(url:String) : Boolean Downloads variables from the specified URL, parses the variable data, and places the resulting...
  • Page 398 An example is also in the guestbook.fla file in the ActionScript samples folder. The following list gives 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 399: Loaded (Loadvars.loaded Property)

    loaded (LoadVars.loaded property) public loaded : Boolean A Boolean value that indicates whether a operation has completed, load sendAndLoad by default. When a operation is undefined LoadVars.load() LoadVars.sendAndLoad() started, the property is set to ; when the operation completes, the loaded false loaded...
  • Page 400: Ondata (Loadvars.ondata Handler)

    onData (LoadVars.onData handler) onData = function(src:String) {} Invoked when data has completely downloaded from the server or when an error occurs while data is downloading from a server. This handler is invoked before the data is parsed and can be used to call a custom parsing routine instead of the one built in to Flash Player. The value of the parameter passed to the function assigned to can be either...
  • Page 401: Onload (Loadvars.onload Handler)

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

    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 See also onLoad (XML.onLoad handler) loaded (LoadVars.loaded property)
  • Page 403 The Flash test environment always uses the GET method. To test using the POST method, be sure you are attempting to use it from within a browser. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - A string; the URL to which to upload variables. url:String - A string;...
  • Page 404: Sendandload (Loadvars.sendandload Method)

    sendAndLoad (LoadVars.sendAndLoad method) public sendAndLoad(url:String, target:Object, [method:String]) : Boolean Posts variables in the object to the specified URL. The server response is downloaded, my_lv parsed as variable data, and the resulting variables are placed in the object. target Variables are posted in the same manner as .
  • Page 405: Tostring (Loadvars.tostring Method)

    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 See also send (LoadVars.send method) load (LoadVars.load method)
  • Page 406: Locale (Mx.lang.locale)

    Returns - A string. String Example The following example instantiates a new object, creates two properties, and uses LoadVars() to return a string containing both properties in URL encoded format: toString() var my_lv:LoadVars = new LoadVars(); my_lv.name = "Gary"; my_lv.age = 26; trace (my_lv.toString());...
  • Page 407 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 Add the {instance, string ID} static addDelayedInstance(instance:Object, pair into the internal array for stringID:String) later use. Adds the {languageCode and static addXMLPath(langCode:String, path:String) :...
  • Page 408: Adddelayedinstance (Locale.adddelayedinstance Method)

    addDelayedInstance (Locale.addDelayedInstance method) public static addDelayedInstance(instance:Object, stringID:String) Add the {instance, string ID} pair into the internal array for later use. This is primarily used by Flash when the strings replacement method is "automatically at runtime". Availability: ActionScript 2.0; Flash Lite 2.0 Parameters instance:Object stringID:String...
  • Page 409: Initialize (Locale.initialize Method)

    initialize (Locale.initialize method) public static initialize() : Void Determine the language to use and begin xml loading. This is primarily used by Flash when the strings replacement method is "automatically at runtime". Availability: ActionScript 2.0; Flash Lite 2.0 loadLanguageXML (Locale.loadLanguageXML method) public static loadLanguageXML(xmlLanguageCode:String, customXmlCompleteCallback:Function) : Void...
  • Page 410: Setloadcallback (Locale.setloadcallback Method)

    Parameters - A String representing a language code. langCode:String setLoadCallback (Locale.setLoadCallback method) public static setLoadCallback(loadCallback:Function) Set the callback function that will be called after the xml file is loaded. Availability: ActionScript 2.0; Flash Lite 2.0 Parameters loadCallback:Function Math Object +-Math public class Math extends Object...
  • Page 411 Availability: ActionScript 1.0; Flash Lite 2.0 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports. Property summary Modifiers Property...
  • Page 412 Method summary Modifiers Signature Description Computes and returns an absolute value for static abs(x:Number) : Number the number specified by the parameter x. Computes and returns the arc cosine of the static acos(x:Number) : Number number specified in the parameter x, in radians.
  • Page 413: Abs (Math.abs Method)

    Modifiers Signature Description Computes and returns the sine of the static sin(x:Number) : Number specified angle in radians. Computes and returns the square root of the static sqrt(x:Number) : Number specified number. Computes and returns the tangent of the static tan(x:Number) : Number specified angle.
  • Page 414: Acos (Math.acos Method)

    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 Lite 2.0 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 415: Atan (Math.atan Method)

    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) atan2 (Math.atan2 method) cos (Math.cos method) sin (Math.sin method) tan (Math.tan method) atan (Math.atan method) public static atan(tangent:Number) : Number...
  • Page 416: 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 417: 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 418: 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 419: 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 420: 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 Lite 2.0 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 421: 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 422: 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 Lite 2.0 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 423: 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 424: 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 Lite 2.0 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 425: Random (Math.random Method)

    random (Math.random method) public static random() : Number Returns a pseudo-random number n, where 0 <= n < 1. The number returned is a pseudo- random number because it is not generated by a truly random natural phenomenon such as radioactive decay.
  • Page 426: Sin (Math.sin Method)

    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)); See also ceil (Math.ceil method) floor (Math.floor method) sin (Math.sin method) public static sin(x:Number) : Number...
  • Page 427: Sqrt (Math.sqrt Method)

    Example The following example draws a circle using the mathematical constant pi, the sine of an angle, and the Drawing API. drawCircle(this, 100, 100, 50); function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void { mc.lineStyle(2, 0xFF0000, 100); mc.moveTo(x+r, 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);...
  • Page 428: Sqrt1_2 (Math.sqrt1_2 Property)

    Example The following example uses to calculate the length of a line. Math.pow Math.sqrt this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth()); var mouseListener:Object = new Object(); mouseListener.onMouseDown = function() { this.origX = _xmouse; this.origY = _ymouse; mouseListener.onMouseUp = function() { this.newX = _xmouse; this.newY = _ymouse; var minY = Math.min(this.origY, this.newY);...
  • Page 429: Sqrt2 (Math.sqrt2 Property)

    SQRT2 (Math.SQRT2 property) public static SQRT2 : Number A mathematical constant for the square root of 2, with an approximate value of 1.4142135623730951. Availability: ActionScript 1.0; Flash Lite 2.0 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
  • Page 430: Mouse

    Example The following example draws a circle using the mathematical constant pi, the tangent of an angle, and the Drawing API. drawCircle(this, 100, 100, 50); function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void { mc.lineStyle(2, 0xFF0000, 100); mc.moveTo(x+r, 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);...
  • Page 431 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 Notified when the mouse button is onMouseDown = function() {} pressed. Notified when the mouse moves. onMouseMove = function() {} Notified when the mouse button is onMouseUp...
  • Page 432: Addlistener (Mouse.addlistener Method)

    addListener (Mouse.addListener method) public static addListener(listener:Object) : Void Registers an object to receive notifications of the , and onMouseDown onMouseMove listeners. onMouseUp parameter should contain an object that has a defined method for at least one listener of the listeners. When the mouse button is pressed, moved, released, or used to scroll, regardless of the input focus, all listening objects that are registered with this method have their onMouseDown...
  • Page 433: Onmousedown (Mouse.onmousedown Event Listener)

    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 434 Example The following example uses the Drawing API to draw a rectangle when the user presses the mouse button, moves the mouse, and then releases the mouse button at runtime. this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth()); var mouseListener:Object = new Object(); mouseListener.onMouseDown = function() { this.isDrawing = true;...
  • Page 435: Onmousemove (Mouse.onmousemove Event Listener)

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

    The following example sets the positions of the movie clip instance to pointer_mc pointer positions. The device must support a stylus or mouse for this example to work. To use the example, you create a movie clip and set its Linkage identifier to .
  • Page 437: Removelistener (Mouse.removelistener Method)

    Example The following example uses the mouse pointer as a tool to draw lines using onMouseMove the Drawing API. The user draws a line by moving the pointer and stops drawing the line by releasing the mouse button. this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth()); var mouseListener:Object = new Object();...
  • Page 438 Example The following example attaches three buttons to the Stage, and lets the user draw lines in the SWF file at runtime, using the mouse pointer. One button clears all of the lines from the SWF file. The second button removes the mouse listener so the user cannot draw lines. The third button adds the mouse listener after it is removed, so the user can draw lines again.
  • Page 439: Movieclip

    stopDrawing_button.enabled = true; startDrawing_button.addEventListener("click", startDrawingListener); 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.
  • Page 440 Property summary Modifiers Property Description The alpha transparency value of the _alpha:Number movie clip. [read-only] Returns the number of the frame in which _currentframe:Number the playhead is located in the movie clip's Timeline. [read-only] Returns the absolute path in slash- _droptarget:String syntax notation of the movie clip instance on which this movie clip was dropped.
  • Page 441 Modifiers Property Description Specifies the rotation of the movie clip, in _rotation:Number degrees, from its original orientation. Specifies the number of seconds a _soundbuftime:Number sound prebuffers before it starts to stream. Determines whether the children of a tabChildren:Boolean movie clip are included in the automatic tab ordering.
  • Page 442 Modifiers Property Description [read-only] Indicates the y coordinate of the mouse _ymouse:Number position. Sets the vertical scale (percentage) of _yscale:Number the movie clip as applied from the registration point of the movie clip. Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property),...
  • Page 443 Event Description Invoked when the mouse button is pressed inside the onReleaseOutside = function() {} movie clip area and then released outside the movie clip area. Invoked when the pointer moves outside a movie clip onRollOut = function() {} area. Invoked when the pointer moves over a movie clip area.
  • Page 444 Method summary Modifiers Signature Description Takes a symbol from the library and attachMovie(id:String, name:String, attaches it to the movie clip. depth:Number, [initObject:Object]) MovieClip Indicates the beginning of a new beginFill(rgb:Number, drawing path. [alpha:Number]) : Void Indicates the beginning of a new beginGradientFill(fillType:String, drawing path.
  • Page 445 Modifiers Signature Description Returns the number of bytes that have getBytesLoaded() : Number already loaded (streamed) for the movie clip. Returns the size, in bytes, of the movie getBytesTotal() : Number clip. Returns the depth of the movie clip getDepth() : Number instance.
  • Page 446 Modifiers Signature Description Specifies a line style that Flash uses lineStyle(thickness:Number, for subsequent calls to lineTo() and rgb:Number, alpha:Number, curveTo() until you call lineStyle() pixelHinting:Boolean, with different parameters. noScale:String, capsStyle:String, jointStyle:String, miterLimit:Number) : Void Draws a line using the current line style lineTo(x:Number, y:Number) : Void from the current drawing position to (x,...
  • Page 447: Alpha (Movieclip._Alpha Property)

    Modifiers Signature Description Lets the user drag the specified movie startDrag([lockCenter:Boolean], clip. [left:Number], [top:Number], [right:Number], [bottom:Number]) : Void Stops the movie clip currently playing. stop() : Void Ends a MovieClip.startDrag() stopDrag() : Void method. Swaps the stacking, or depth level (z- swapDepths(target:Object) : Void order), of this movie clip with the movie...
  • Page 448: Attachmovie (Movieclip.attachmovie Method)

    Example The following code sets the property of a dynamically created movie clip named _alpha to 50% when the mouse rolls over the movie clip. Add the following ActionScript triangle to your FLA or AS file: this.createEmptyMovieClip("triangle", this.getNextHighestDepth()); triangle.beginFill(0x0000FF, 100); triangle.moveTo(10, 10);...
  • Page 449: Beginfill (Movieclip.beginfill Method)

    [optional] - (Supported for Flash Player 6 and later) An object initObject:Object containing properties with which to populate the newly attached movie clip. This parameter allows dynamically created movie clips to receive clip parameters. If is not an initObject object, it is ignored. All properties of are copied into the new instance.
  • Page 450: Begingradientfill (Movieclip.begingradientfill Method)

    An example is also in the drawingapi.fla file in the ActionScript samples folder. The following list gives 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 moveTo (MovieClip.moveTo method) endFill (MovieClip.endFill method)
  • Page 451 Parameters - Either the string " " or the string " ". fillType:String linear radial - An array of RGB hex color values to be used in the gradient (for example, red colors:Array is 0xFF0000, blue is 0x0000FF, and so on). - An array of alpha values for the corresponding colors in the array;...
  • Page 452 This code draws the following image on the screen: matrixType ■ The properties indicate the following: is the string is the horizontal matrixType "box" 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,...
  • Page 453: Clear (Movieclip.clear Method)

    This code draws the following image on the screen: See also beginFill (MovieClip.beginFill method) endFill (MovieClip.endFill method) lineStyle (MovieClip.lineStyle method) lineTo (MovieClip.lineTo method) moveTo (MovieClip.moveTo method) clear (MovieClip.clear method) public clear() : Void Removes all the graphics created during runtime by using the movie clip draw methods, including line styles specified with .
  • Page 454: Createemptymovieclip (Movieclip.createemptymovieclip Method)

    An example is also in the drawingapi.fla file in the ActionScript samples folder. The following list gives 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 lineStyle (MovieClip.lineStyle method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method)
  • Page 455: 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 th e 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 456 rightMargin = 0 indent = 0 leading = 0 blockIndent = 0 bullet = false display = block tabStops = [] // (empty array) You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
  • Page 457: Currentframe (Movieclip._Currentframe Property)

    An example is also in the animations.fla file in the ActionScript samples folder. The following list gives typical paths to this folder: Windows: 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 getInstanceAtDepth (MovieClip.getInstanceAtDepth method)
  • Page 458 Parameters - An integer that specifies the horizontal position of the control point controlX:Number relative to the registration point of the parent movie clip. - An integer that specifies the vertical position of the control point relative controlY:Number to the registration point of the parent movie clip. - An integer that specifies the horizontal position of the next anchor point anchorX:Number relative to the registration point of the parent movie clip.
  • Page 459 An example is also in the drawingapi.fla file in the ActionScript samples folder. The following list gives 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 beginFill (MovieClip.beginFill method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method)
  • Page 460: Droptarget (Movieclip._Droptarget Property)

    _droptarget (MovieClip._droptarget property) public _droptarget : String [read-only] Returns the absolute path in slash-syntax notation of the movie clip instance on which this movie clip was dropped. The property always returns a path that starts with a _droptarget slash ( ).
  • Page 461: Duplicatemovieclip (Movieclip.duplicatemovieclip Method)

    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 462: Enabled (Movieclip.enabled Property)

    Example The following example duplicates a newly created MovieClip a number of times and traces the target for each duplicate. var container:MovieClip = setUpContainer(); var ln:Number = 10; var spacer:Number = 1; var duplicate:MovieClip; for(var i:Number = 1; i < ln; i++) { var newY:Number = i * (container._height + spacer);...
  • Page 463: Endfill (Movieclip.endfill Method)

    An example is also in the drawingapi.fla file in the ActionScript samples folder. The following list gives 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 MovieClip...
  • Page 464: Focusenabled (Movieclip.focusenabled Property)

    See also beginFill (MovieClip.beginFill method) beginGradientFill (MovieClip.beginGradientFill method) moveTo (MovieClip.moveTo method) 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...
  • Page 465: Framesloaded (Movieclip._Framesloaded Property)

    Example This example demonstrates how to hide the yellow rectangle around a specified movie clip instance in a SWF file when the instance has focus in a browser window. Create three movie clips called , and , and add the following ActionScript to Frame 1 of mc1_mc mc2_mc mc3_mc...
  • Page 466: Getbounds (Movieclip.getbounds Method)

    Example The following example uses the property to start a SWF file when all the _framesloaded frames are loaded. If all the frames aren't loaded, the property of the movie _xscale bar_mc clip instance is increased proportionally to create a progress bar. Enter the following ActionScript in Frame 1 of the Timeline: var pctLoaded:Number = Math.round(this.getBytesLoaded()/ this.getBytesTotal()*100);...
  • Page 467: Getbytesloaded (Movieclip.getbytesloaded Method)

    Example The following example creates a movie clip called . The code draws a square for square_mc that movie clip and uses to display the coordinate values of the MovieClip.getBounds() instance in the Output panel. this.createEmptyMovieClip("square_mc", 1); square_mc._x = 10; square_mc._y = 10;...
  • Page 468: Getbytestotal (Movieclip.getbytestotal Method)

    Example The following example uses the property to start a SWF file when all the _framesloaded frames are loaded. If all the frames aren't loaded, the property of the movie _xscale loader clip instance is increased proportionally to create a progress bar. Enter the following ActionScript in Frame 1 of the Timeline: var pctLoaded:Number = Math.round(this.getBytesLoaded()/ this.getBytesTotal() * 100);...
  • Page 469: Getdepth (Movieclip.getdepth Method)

    Enter the following ActionScript in Frame 1 of the Timeline: var pctLoaded:Number = Math.round(this.getBytesLoaded()/ this.getBytesTotal()*100); bar_mc._xscale = pctLoaded; Add the following code to Frame 2: if (this._framesloaded<this._totalframes) { this.gotoAndPlay(1); } else { this.gotoAndStop(3); Place your content on or after Frame 3. Then add the following code to Frame 3: stop();...
  • Page 470: Getinstanceatdepth (Movieclip.getinstanceatdepth Method)

    See also getInstanceAtDepth (MovieClip.getInstanceAtDepth method) getNextHighestDepth (MovieClip.getNextHighestDepth method) swapDepths (MovieClip.swapDepths method) getDepth (TextField.getDepth method) getDepth (Button.getDepth 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()
  • Page 471: Getnexthighestdepth (Movieclip.getnexthighestdepth Method)

    See also attachMovie (MovieClip.attachMovie method) duplicateMovieClip (MovieClip.duplicateMovieClip method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method) getDepth (MovieClip.getDepth method) getNextHighestDepth (MovieClip.getNextHighestDepth method) swapDepths (MovieClip.swapDepths method) 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...
  • Page 472: Getswfversion (Movieclip.getswfversion Method)

    Example The following example draws thre movie clip instances, using the getNextHighestDepth() method as the parameter of the method, and labels each depth createEmptyMovieClip() movie clip them with its depth: for (i = 0; i < 3; i++) { drawClip(i); function drawClip(n:Number):Void { this.createEmptyMovieClip("triangle"...
  • Page 473: Geturl (Movieclip.geturl Method)

    Returns - An integer that specifies the Flash Player version that was targeted when the SWF Number file loaded into the movie clip was published. Example The following example creates a new container and outputs the value of . It getSWFVersion() then uses MovieClipLoader to load an external SWF file that was published to Flash Player 7 and outputs the value of...
  • Page 474: Globaltolocal (Movieclip.globaltolocal Method)

    POST sends the variables in a separate HTTP header and is used for long strings of variables. Example The following ActionScript creates a new movie clip instance and opens the Macromedia website in a new browser window: this.createEmptyMovieClip("loader_mc", this.getNextHighestDepth()); loader_mc.getURL("http://www.macromedia.com", "_blank");...
  • Page 475 You must first create a generic object that has two properties, x and y. These x and y values (and they must be called x and y) are called the global coordinates because they relate to the top-left corner of the Stage. The x property represents the horizontal offset from the top-left corner.
  • Page 476 You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - The name or identifier of an object created with the generic Object class. The pt:Object object specifies the x and y coordinates as properties. Example Add the following ActionScript to a FLA or AS file in the same directory as an image called photo1.jpg:...
  • Page 477: Gotoandplay (Movieclip.gotoandplay Method)

    gotoAndPlay (MovieClip.gotoAndPlay method) public gotoAndPlay(frame:Object) : Void Starts playing the SWF file at the specified frame. To specify a scene as well as a frame, use gotoAndPlay() You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
  • Page 478: Gotoandstop (Movieclip.gotoandstop Method)

    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 gotoAndStop() You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
  • Page 479: Highquality (Movieclip._Highquality Property)

    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(); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace(target_mc._name+" = "+target_mc._width+" X "+target_mc._height+" pixels"); image_mcl.addListener(mclListener);...
  • Page 480: Hitarea (Movieclip.hitarea 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 is , the movie clip itself is used as the hit area. The value null undefined of the...
  • Page 481 Usage 2: Evaluates the bounding boxes of the and specified instance, and returns target true if they overlap or intersect at any point. Parameters The x coordinate of the hit area on the Stage. The y x: Number y: Number coordinate of the hit area on the Stage.
  • Page 482: Linestyle (Movieclip.linestyle 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 until you lineTo() curveTo() call with different parameters. You can call in the middle of lineStyle() lineStyle() drawing a path to specify different styles for different line segments within a path.
  • Page 483: Lineto (Movieclip.lineto Method)

    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) lineTo (MovieClip.lineTo method) public lineTo(x:Number, y:Number) : Void Draws a line using the current line style from the current drawing position to (x, y); the current drawing position is then set to (x, y).
  • Page 484: 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 SWF or JPEG files into a movie clip in Flash Player while the original SWF file is playing.
  • Page 485: Loadvariables (Movieclip.loadvariables Method)

    Parameters - The absolute or relative URL of the SWF or JPEG file to be loaded. A relative url:String path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// file:/// [optional] - Specifies an HTTP method for sending or loading variables.
  • Page 486 method can also be used to update variables in the active movie clip with loadVariables new values. method requires that the text of the URL be in the standard MIME loadVariables format: application/x-www-form-urlencoded (CGI script format). 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 487: Localtoglobal (Movieclip.localtoglobal Method)

    Example The following example loads information from a text file called params.txtinto the target_mc movie clip that is created by using . The function createEmptyMovieClip() setInterval() is used to check the loading progress. The script checks for a variable in the params.txt file named done this.createEmptyMovieClip("target_mc", this.getNextHighestDepth());...
  • Page 488 You must first create a generic object that has two properties, x and y. These x and y values (and they must be called x and y) are called the local coordinates because they relate to the top-left corner of the movie clip. The x property represents the horizontal offset from the top- left corner of the movie clip.
  • Page 489: Lockroot (Movieclip._Lockroot Property)

    Parameters - The name or identifier of an object created with the Object class, specifying the pt:Object x and y coordinates as properties. Example The following example converts x and y coordinates of the object, from the movie clip's my_mc (local) coordinates to the Stage (global) coordinates.
  • Page 490 If you don't have access to Chess.fla (for example, if you are loading Chess.swf from someone else's site into ), you can set the Chess.swf property when you load it. chess_mc _lockroot Place the following ActionScript on the main Timeline of Games.fla: chess_mc._lockroot = true;...
  • Page 491 The lockroot.swf file has _ applied to it, and nolockroot.swf does not. After the files lockroot are loaded, each file dumps variables from their scopes. Place the following _root ActionScript on the main Timeline of a FLA document: this.createEmptyMovieClip("lockroot_mc", this.getNextHighestDepth()); lockroot_mc.loadMovie("lockroot.swf");...
  • Page 492: Moveto (Movieclip.moveto Method)

    which then traces the following: 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 myOtherVar -> 2 myVar -> 1 from lockroot.swf myOtherVar -> 2 myVar -> 1 See also _root property _lockroot (MovieClip._lockroot property) attachMovie...
  • Page 493: Name (Movieclip._Name Property)

    Example The following example draws a triangle with a 5-pixel, solid magenta line and a partially transparent blue fill: this.createEmptyMovieClip("triangle_mc", 1); triangle_mc.beginFill(0x0000FF, 30); triangle_mc.lineStyle(5, 0xFF00FF, 100); triangle_mc.moveTo(200, 200); triangle_mc.lineTo(300, 300); triangle_mc.lineTo(100, 300); triangle_mc.lineTo(200, 200); triangle_mc.endFill(); See also createEmptyMovieClip (MovieClip.createEmptyMovieClip method) lineStyle (MovieClip.lineStyle method) lineTo (MovieClip.lineTo method)
  • Page 494: Ondata (Movieclip.ondata Handler)

    Example The following example uses to load content into a SWF _framesloaded nextFrame() file. Do not add any code to Frame 1, but add the following ActionScript to Frame 2 of the Timeline: if (this._framesloaded >= 3) { this.nextFrame(); } else { this.gotoAndPlay(1);...
  • Page 495: Ondragout (Movieclip.ondragout Handler)

    The last function uses onClipEvent(data). The onClipEvent() event handler is invoked for any movie clip that receives data, whether the movie clip is in the library or not. Therefore, the last function in this example is invoked when symbol_mc is instantiated and also when replacement.swf is loaded.
  • Page 496: Ondragover (Movieclip.ondragover Handler)

    Example The following example defines a function for the method that sends a onDragOut trace() action to the Output panel: my_mc.onDragOut = function () { trace ("onDragOut called"); See also onDragOver (MovieClip.onDragOver handler) onDragOver (MovieClip.onDragOver handler) onDragOver = function() {} Invoked when the pointer is dragged outside and then over the movie clip.
  • Page 497: Onkeydown (Movieclip.onkeydown Handler)

    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 that is linked to a symbol in the library. Availability: ActionScript 1.0;...
  • Page 498: Onkeyup (Movieclip.onkeyup Handler)

    The movie clip must have focus for the onKeyDown event handler to work. Add the following ActionScript to set input focus: my_mc.tabEnabled = true; my_mc.focusEnabled = true; Selection.setFocus(my_mc); When you tab to the movie clip and press a key, is displayed in the Output key was pressed panel.
  • Page 499: Onkillfocus (Movieclip.onkillfocus Handler)

    The following example sets input focus: my_mc.focusEnabled = true; Selection.setFocus(my_mc); See also getAscii (Key.getAscii method) getCode (Key.getCode method) focusEnabled (MovieClip.focusEnabled property) setFocus (Selection.setFocus method) onKeyDown (Key.onKeyDown event listener) onKeyDown (MovieClip.onKeyDown handler) onKillFocus (MovieClip.onKillFocus handler) onKillFocus = function(newFocus:Object) {} Invoked when a movie clip loses input focus. The method receives one onKillFocus parameter, newFocus, which is an object that represents the new object receiving the focus.
  • Page 500: Onload (Movieclip.onload 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. 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 501: Onmousedown (Movieclip.onmousedown Handler)

    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 502: Onmouseup (Movieclip.onmouseup Handler)

    onMouseUp (MovieClip.onMouseUp handler) onMouseUp = function() {} Invoked when the mouse button is released. 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 503: Onreleaseoutside (Movieclip.onreleaseoutside Handler)

    Example The following example defines a function for the method that sends a onRelease trace() action to the Output panel: my_mc.onRelease = function () { trace ("onRelease called"); onReleaseOutside (MovieClip.onReleaseOutside handler) onReleaseOutside = function() {} Invoked when the mouse button is pressed inside the movie clip area and then released outside the movie clip area.
  • Page 504: Onrollover (Movieclip.onrollover Handler)

    Example The following example defines a function for the method that sends a onRollOut trace() action to the Output panel: my_mc.onRollOut = function () { trace ("onRollOut called"); onRollOver (MovieClip.onRollOver handler) onRollOver = function() {} Invoked when the pointer moves over a movie clip area. You must define a function that executes when the event handler is invoked.
  • Page 505: Onunload (Movieclip.onunload Handler)

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

    You can use to move up multiple levels in the display list as in the following: _parent this._parent._parent._alpha = 20; Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the reference to a movie clip and its relationship to the main Timeline.
  • Page 507: Prevframe (Movieclip.prevframe Method)

    Use the following ActionScript to play the Timeline of a movie clip in a SWF file. This ActionScript is for a button called on the main Timeline that plays a movie clip called my_btn animation_mc animation_mc.stop(); my_btn.onRelease = function(){ animation_mc.play(); See also play function gotoAndPlay (MovieClip.gotoAndPlay method)
  • Page 508: Quality (Movieclip._Quality Property)

    See also prevFrame function _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 property can be set to the following values: _quality Value Description...
  • Page 509: Removemovieclip (Movieclip.removemovieclip Method)

    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. To remove a movie clip that is assigned to a negative depth value, first use to move MovieClip.swapDepths()
  • Page 510: Rotation (Movieclip._Rotation Property)

    Example Each time you click a button in the following example, you attach a movie clip instance to the Stage in a random position. When you click a movie clip instance, you remove that instance from the SWF file. function randRange(min:Number, max:Number):Number { var randNum:Number = Math.round(Math.random()*(max-min))+min;...
  • Page 511: Setmask (Movieclip.setmask Method)

    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; See also _rotation (Button._rotation property) _rotation (TextField._rotation...
  • Page 512: 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 513: Stop (Movieclip.stop Method)

    [optional] - Value relative to the coordinates of the movie clip's parent that left:Number specify a constraint rectangle for the movie clip. [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.
  • Page 514: 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 515: Swapdepths (Movieclip.swapdepths Method)

    See also _droptarget (MovieClip._droptarget property) startDrag (MovieClip.startDrag method) stopDrag function 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 specified by parameter, or with the movie clip that currently occupies the depth level specified target in the parameter.
  • Page 516: 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 517: 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 518: 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 519: 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 Lite 2.0 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 520: Unloadmovie (Movieclip.unloadmovie Method)

    You can change the property at any time; the modified movie clip immediately trackAsMenu takes on the new behavior. Note: This property is supported in Flash Lite only if System.capabilities.hasMouse true System.capabilities.hasStylus true Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example sets the property for three movie clips on the Stage.
  • Page 521: Url (Movieclip._Url Property)

    Example The following example unloads a movie clip instance called when a user clicks the movie clip: this.createEmptyMovieClip("box", 1); with (box) { lineStyle(1, 0xCCCCCC); beginFill(0x4827CF); moveTo(0, 0); lineTo(80, 0); lineTo(80, 60); lineTo(0, 60); lineTo(0, 0); endFill(); box.onRelease = function() { box.unloadMovie();...
  • Page 522: Visible (Movieclip._Visible Property)

    Example The following example displays the URL of the image that is loaded into the image_mc instance in the 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.helpexamples.com/flash/images/image1.jpg", image_mc);...
  • Page 523: Width (Movieclip._Width Property)

    _width (MovieClip._width property) public _width : Number The width of the movie clip, in pixels. Availability: ActionScript 1.0; Flash Lite 2.0 - as a read-only property. Example The following code example displays the height and width of a movie clip in the Output panel: this.createEmptyMovieClip("triangle", this.getNextHighestDepth());...
  • Page 524: Xmouse (Movieclip._Xmouse Property)

    _xmouse (MovieClip._xmouse property) public _xmouse : Number [read-only] Returns the x coordinate of the mouse position. Note: This property is supported in Flash Lite only if System.capabilities.hasMouse true System.capabilities.hasStylus true Availability: ActionScript 1.0; Flash Lite 2.0 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...
  • Page 525 Example The following example creates a movie clip called at runtime. The Drawing API is box_mc used to draw a box in this instance, and when the mouse rolls over the box, horizontal and vertical scaling is applied to the movie clip. When the mouse rolls off the instance, it returns to the previous scaling.
  • Page 526: Y (Movieclip._Y Property)

    _y (MovieClip._y property) public _y : Number Sets the y 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 527: Yscale (Movieclip._Yscale Property)

    See also Mouse _xmouse (MovieClip._xmouse property) _yscale (MovieClip._yscale property) public _yscale : Number Sets the vertical scale ( ) of the movie clip as applied from the registration point of percentage the movie clip. The default registration point is (0,0). Scaling the local coordinate system affects the property settings, which are defined in whole pixels.
  • Page 528: Moviecliploader

    See also _x (MovieClip._x property) _xscale (MovieClip._xscale property) (MovieClip._y property) _height (MovieClip._height property) MovieClipLoader Object +-MovieClipLoader public class MovieClipLoader extends Object The MovieClipLoader class lets you implement listener callbacks that provide status information while SWF, JPEG, GIF, and PNG files are being loaded (downloaded) into movie clips.
  • Page 529 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 loaded with onLoadComplete = function(listenerObject, MovieClipLoader.loadClip() is [target_mc]) {} completely downloaded. Invoked when a file loaded with onLoadError = function(target_mc, MovieClipLoader.loadClip() has failed to...
  • Page 530: Addlistener (Moviecliploader.addlistener Method)

    Method summary Modifiers Signature Description Registers an object to receive addListener(listener:Object) : notification when a MovieClipLoader Boolean event handler is invoked. Returns the number of bytes loaded and getProgress(target:Object) : total number of bytes for a file that is Object being loaded by using MovieClipLoader.loadClip();...
  • Page 531 Parameters - An object that listens for a callback notification from the listener:Object MovieClipLoader event handlers. Returns - A Boolean value. The return value is if the listener was established Boolean true successfully; otherwise the return value is false Example The following example loads an image into a movie clip called .
  • Page 532: Getprogress (Moviecliploader.getprogress Method)

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

    trace(">> checking progress now with : " + interval.id); var progress:Object = mcLoader.getProgress(image); trace("bytesLoaded: " + progress.bytesLoaded + " bytesTotal: " + progress.bytesTotal); if(progress.bytesLoaded == progress.bytesTotal) { clearInterval(interval.id); See also loadClip (MovieClipLoader.loadClip method) onLoadProgress (MovieClipLoader.onLoadProgress event listener) loadClip (MovieClipLoader.loadClip method) public loadClip(url:String, target:Object) : Boolean Loads a SWF or JPEG file into a movie clip in Flash Player while the original movie is playing.
  • Page 534 You can use the method to load one or more files into a single movie clip or level; loadClip() MovieClipLoader listener objects are passed to the loading target movie clip instance as a parameter. Alternatively, you can create a different object for each file that MovieClipLoader you load.
  • Page 535: Moviecliploader Constructor

    Create an empty MovieClip and use the MovieClipLoader to load an image into it. var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth()); var mcLoader:MovieClipLoader = new MovieClipLoader(); mcLoader.addListener(this); mcLoader.loadClip("YourImage.jpg", container); function onLoadInit(mc:MovieClip) { trace("onLoadInit: " + mc); See also onLoadInit (MovieClipLoader.onLoadInit event listener) MovieClipLoader constructor public MovieClipLoader() Creates a MovieClipLoader object that you can use to implement a number of listeners to...
  • Page 536 = function(target_mc:MovieClip) { var timerMS:Number = target_mc.completeTimer-target_mc.startTimer; target_mc.createTextField("timer_txt", target_mc.getNextHighestDepth(), 0, target_mc._height, target_mc._width, 22); target_mc.timer_txt.text = "loaded in "+timerMS+" ms."; 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); See also addListener (MovieClipLoader.addListener method) loadClip (MovieClipLoader.loadClip method) onLoadStart (MovieClipLoader.onLoadStart event listener) onLoadError (MovieClipLoader.onLoadError event listener)
  • Page 537: Onloaderror (Moviecliploader.onloaderror Event Listener)

    onLoadError (MovieClipLoader.onLoadError event listener) onLoadError = function(target_mc, errorCode) {} Invoked when a file loaded with has failed to load. This MovieClipLoader.loadClip() listener can be invoked for various reasons, including if the server is down, if the file is not found, or if a security violation occurs. Call this listener on a listener object that you add using MovieClipLoader.addListener() The value for...
  • Page 538: Onloadinit (Moviecliploader.onloadinit Event Listener)

    var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.fakedomain.com/images/bad_hair_day.jpg", image_mc); See also addListener (MovieClipLoader.addListener method) loadClip (MovieClipLoader.loadClip method) onLoadStart (MovieClipLoader.onLoadStart event listener) onLoadComplete (MovieClipLoader.onLoadComplete event listener) onLoadInit (MovieClipLoader.onLoadInit event listener) onLoadInit = function([target_mc]) {} Invoked when the actions on the first frame of the loaded clip are executed. After this listener is invoked, you can set properties, use methods, and otherwise interact with the loaded movie.
  • Page 539: (Moviecliploader.onloadprogress Event Listener)

    var timerMS:Number = target_mc.completeTimer-target_mc.startTimer; target_mc.createTextField("timer_txt", target_mc.getNextHighestDepth(), 0, target_mc._height, target_mc._width, 22); target_mc.timer_txt.text = "loaded in "+timerMS+" ms."; var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc); The following example checks whether a movie is loaded into a movie clip created at runtime: this.createEmptyMovieClip("tester_mc", 1);...
  • Page 540 Parameters A movie clip loaded by a target_mc: MovieClip [optional] method. MovieClipLoader.loadClip() The number of bytes that had been loaded when the listener was loadedBytes: Number invoked. The total number of bytes in the file being loaded. totalBytes: Number Availability: ActionScript 1.0; Flash Lite 2.0 Parameters [optional] - A movie clip loaded by a method.
  • Page 541: Onloadstart (Moviecliploader.onloadstart Event Listener)

    onLoadStart (MovieClipLoader.onLoadStart event listener) onLoadStart = function([target_mc]) {} Invoked when a call to has successfully begun to download a MovieClipLoader.loadClip() file. Call this listener on a listener object that you add using MovieClipLoader.addListener() The value for identifies the movie clip this call is being made for. This parameter target_mc is useful if you are loading multiple files with the same set of listeners.
  • Page 542: Removelistener (Moviecliploader.removelistener Method)

    See also addListener (MovieClipLoader.addListener method) loadClip (MovieClipLoader.loadClip method) onLoadError (MovieClipLoader.onLoadError event listener) onLoadInit (MovieClipLoader.onLoadInit event listener) onLoadComplete (MovieClipLoader.onLoadComplete event listener) 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.
  • Page 543: Unloadclip (Moviecliploader.unloadclip Method)

    var image_mcl:MovieClipLoader = new MovieClipLoader(); start_button.clickHandler = function() { trace("Starting..."); start_button.enabled = false; stop_button.enabled = true; 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; See also addListener (MovieClipLoader.addListener method) unloadClip (MovieClipLoader.unloadClip method) public unloadClip(target:Object) : Boolean Removes a movie clip that was loaded by means of...
  • Page 544: Number

    Example The following example loads an image into a movie clip called . If you click the image_mc movie clip, the movie clip is removed and information is displayed in the Output panel. this.createEmptyMovieClip("image_mc", this.getNextHighestDepth()); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { target_mc._x = 100;...
  • Page 545 The following example assigns the value of the property to a variable declared MIN_VALUE without the use of the constructor: var smallest:Number = Number.MIN_VALUE; Availability: ActionScript 1.0; Flash Lite 2.0 - (became a native object in Flash Player 6, which improved performance significantly). Property summary Modifiers Property...
  • Page 546: Max_Value (Number.max_Value Property)

    Method summary Modifiers Signature Description Returns the string representation of toString(radix:Number) : String the specified Number object (myNumber). Returns the primitive value type of valueOf() : Number the specified Number object. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable...
  • Page 547: Nan (Number.nan Property)

    Example The following ActionScript displays the largest and smallest representable numbers to the Output panel to the log file. trace("Number.MIN_VALUE = "+Number.MIN_VALUE); trace("Number.MAX_VALUE = "+Number.MAX_VALUE); This code displays the following values: Number.MIN_VALUE = 4.94065645841247e-324 Number.MAX_VALUE = 1.79769313486232e+308 NaN (Number.NaN property) public static NaN : Number The IEEE-754 value representing Not A Number (...
  • Page 548: Number Constructor

    Number constructor public Number(num:Object) Creates a new Number object. The constructor is primarily used as a placeholder. new Number A Number object is not the same as the function that converts a parameter to a Number() primitive value. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - The numeric value of the Number object being created or a value to be num:Object...
  • Page 549: Tostring (Number.tostring Method)

    toString (Number.toString method) public toString(radix:Number) : String Returns the string representation of the specified Number object ( myNumber Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - Specifies the numeric base (from 2 to 36) to use for the number-to-string radix:Number conversion.
  • Page 550: Object

    Object Object public class Object The Object class is at the root of the ActionScript class hierarchy. This class contains a small subset of the features provided by the JavaScript Object class. Availability: ActionScript 1.0; Flash Lite 2.0 - (became a native object in Flash Player 6, which improved performance significantly).
  • Page 551: Addproperty (Object.addproperty Method)

    Modifiers Signature Description Indicates whether an instance of the isPrototypeOf(theClass:Object) : Object class is in the prototype Boolean chain of the object specified as an argument. Associates a movie clip symbol with static registerClass(name:String, an ActionScript object class. theClass:Function) : Boolean Converts the specified object to a toString() :...
  • Page 552 If invoked incorrectly, can fail with an error. The following table Object.addProperty() describes errors that can occur: Error condition What happens is not a valid property name; for example, Returns and the property is not added. name false an empty string. is not a valid function object.
  • Page 553 function Book() { this.setQuantity = function(numBooks:Number):Void { this.books = numBooks; this.getQuantity = function():Number { return this.books; this.getTitle = function():String { return "Catcher in the Rye"; this.addProperty("bookcount", this.getQuantity, this.setQuantity); this.addProperty("bookname", this.getTitle, null); var myBook = new Book(); myBook.bookcount = 5; trace("You ordered "+myBook.bookcount+" copies of "+myBook.bookname); // output: You ordered 5 copies of Catcher in the Rye The previous example works, but the properties are added to every...
  • Page 554: Constructor (Object.constructor Property)

    The following example shows how to use the implicit getter and setter functions available in ActionScript 2.0. Rather than defining the function and editing , you Book Book.prototype define the class in an external file named Book.as. The following code must be in a Book separate external file named Book.as that contains only this class definition and resides within the Flash application's classpath:...
  • Page 555: Hasownproperty (Object.hasownproperty Method)

    If you use the operator, you can also determine if an object belongs to a specified instanceof class: var my_str:String = new String("sven"); trace(my_str instanceof String); //output: true However, in the following example the property converts primitive Object.constructor data types (such as the string literal seen here) into wrapper objects. The operator instanceof does not perform any conversion, as seen in the following example:...
  • Page 556: Isprototypeof (Object.isprototypeof Method)

    Properties that you create are enumerable, but built-in properties are generally not enumerable. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters name:String Returns - A Boolean value: if the property specified by the parameter is Boolean true name enumerable. Example The following example creates a generic object, adds a property to the object, then checks whether the object is enumerable.
  • Page 557: Object Constructor

    Returns - A Boolean value: if the object is in the prototype chain of the object specified Boolean true by the parameter; otherwise. theClass false Object constructor public Object() Creates an Object object and stores a reference to the object's constructor method in the object's property.
  • Page 558: Prototype (Object.prototype Property)

    The following trace statements show that the property of both instances refers to __proto_ property of the Circle class. prototype trace(Circle.prototype == oneCircle.__proto__); // Output: true trace(Circle.prototype == twoCircle.__proto__); // Output: true See also prototype (Object.prototype property) prototype (Object.prototype property) public static prototype : Object A reference to the superclass of a class or function object.
  • Page 559: Registerclass (Object.registerclass Method)

    The following trace statement shows how you can use the property and the prototype property together to move two levels up the inheritance hierarchy (or prototype __proto__ chain). The property contains a reference to the superclass of Circle.prototype.__proto__ the Shape class. trace(Circle.prototype.__proto__ == Shape.prototype);...
  • Page 560: Resolve (Object.__Resolve Property)

    Parameters - String; the linkage identifier of the movie clip symbol or the string identifier name:String for the ActionScript class. - A reference to the constructor function of the ActionScript class or theClass:Function to unregister the symbol. null Returns - A Boolean value: if the class registration succeeds, a value of is returned;...
  • Page 561 Usage 1: the following example uses to build an object where every undefined __resolve property returns the value "Hello, world!" // instantiate a new object var myObject:Object = new Object(); // define the __resolve function myObject.__resolve = function (name) { return "Hello, world!";...
  • Page 562 this.myFunction(name); // create a new object method and assign it the reference this[name] = f; // return the reference return f; // test __resolve using undefined method names // __resolve will only be called once for each method name myObject.someMethod(); // calls __resolve myObject.someMethod();...
  • Page 563: Tostring (Object.tostring Method)

    // define a generic function for __resolve to call myObject.myFunction = function (name) { arguments.shift(); trace("Method " + name + " was called with arguments: " + arguments.join(',')); // define the __resolve function myObject.__resolve = function (name) { // reserve the name "onStatus" for local use if (name == "onStatus") { return undefined;...
  • Page 564 Example This example shows the return value for toString() on a generic object: var myObject:Object = new Object(); trace(myObject.toString()); // output: [object Object] This method can be overridden to return a more meaningful value. The following examples show that this method has been overridden for the built-in classes Date, Array, and Number: // Date.toString() returns the current date and time var myDate:Date = new Date();...
  • Page 565: Unwatch (Object.unwatch Method)

    // output: A vehicle that is red and has 2 doors // for comparison purposes, this is a call to valueOf() // there is no primitive value of myVehicle, so the object is returned // giving the same output as toString(). trace(myVehicle.valueOf());...
  • Page 566: Watch (Object.watch Method)

    Example The following example shows the return value of valueOf() for a generic object (which does not have a primitive value) and compares it to the return value of toString(). First, create a generic object. Second, create a new Date object set to February 1, 2004, 8:15 AM. The toString() method returns the current time in human-readable form.
  • Page 567 You can use the statement in your method definition to affect the value of return callback the property you are watching. The value returned by your method is assigned to callback the watched object property. The value you choose to return depends on whether you wish to monitor, modify or prevent changes to the property: If you are merely monitoring the property, return the parameter.
  • Page 568 [optional] - An arbitrary piece of ActionScript data that is passed to the userData:Object method. If the parameter is omitted, is passed to the callback callback userData undefined method. Returns - A Boolean value: if the watchpoint is created successfully, otherwise.
  • Page 569: Security (System.security)

    security (System.security) Object +-System.security public class security extends Object The System.security class contains methods that specify how SWF files in different domains can communicate with each other. Availability: ActionScript 1.0; Flash Lite 2.0 Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__...
  • Page 570: Allowdomain (Security.allowdomain Method)

    Method summary Modifiers Signature Description Lets SWF files and HTML files in static allowDomain(domain1:String) : Void the identified domains access objects and variables in the calling SWF file or in any other SWF file from the same domain as the calling SWF file.
  • Page 571 ■ "http://domain.com" ■ ■ "http://IPaddress" Example The SWF file located at www.macromedia.com/MovieA.swf contains the following lines: System.security.allowDomain("www.shockwave.com"); loadMovie("http://www.shockwave.com/MovieB.swf", my_mc); Because MovieA contains the call, MovieB can access the objects and allowDomain() variables in MovieA. If MovieA didn't contain this call, the Flash security implementation would prevent MovieB from accessing MovieA's objects and variables.
  • Page 572 HTTPS protocol. This implementation maintains the integrity provided by the HTTPS protocol. Macromedia does not recommend using this method to override the default behavior because it compromises HTTPS security. However, you might need to do so, for example, if you must permit access to HTTPS files published for Flash Player 7 or later from HTTP files published for Flash Player 6.
  • Page 573: Loadpolicyfile (Security.loadpolicyfile Method)

    Example In the following example, you host a math test on a secure domain so that only registered students can access it. You have also developed a number of SWF files that illustrate certain concepts, which you host on an insecure domain. You want students to access the test from the SWF file that contains information about a concept.
  • Page 574 You can use to load any number of policy files. When considering a loadPolicyFile() request that requires a policy file, Flash Player always waits for the completion of any policy file downloads before denying a request. As a final fallback, if no policy file specified with authorizes a request, Flash Player consults the original default location, / loadPolicyFile() crossdomain.xml.
  • Page 575: Selection

    A policy file obtained from the old default location--/crossdomain.xml on an HTTP server on port 80—implicitly authorizes access to all ports 1024 and above. There is no way to retrieve a policy file to authorize XMLSocket operations from any other location on an HTTP server; any custom locations for XMLSocket policy files must be on an XMLSocket server.
  • Page 576: Addlistener (Selection.addlistener Method)

    Method summary Modifiers Signature Description Registers an object to receive static addListener(listener:Object) : Void keyboard focus change notifications. Returns a string specifying the static getFocus() : String target path of the object that has focus. Removes an object previously static removeListener(listener:Object) : registered with Boolean...
  • Page 577: Getfocus (Selection.getfocus Method)

    Example In the following example, you create two input text fields at runtime, setting the borders for each text field to . This code creates a new (generic) ActionScript object named true . This object defines for itself an property, to which it assigns a focusListener onSetFocus function.
  • Page 578: Onsetfocus (Selection.onsetfocus Event Listener)

    Returns - A string or String null Example The following example displays the currently focused selections target path in a TextArea component instance. Add several component instances or button, text field and movie clip instances to the Stage. Add several component instances or button, text field and movie clip instances to your SWF file.
  • Page 579 Parameters [optional] - The object losing focus. oldfocus: [optional] - The object receiving focus. newfocus: Example The following example demonstrates how to determine when input focus changes in a SWF file between several dynamically created text fields. Enter the following ActionScript into a FLA or AS file and then test the document: this.createTextField("one_txt", 1, 0, 0, 100, 22);...
  • Page 580: Removelistener (Selection.removelistener Method)

    removeListener (Selection.removeListener method) public static removeListener(listener:Object) : Boolean Removes an object previously registered with Selection.addListener() Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - The object that will no longer receive focus notifications. listener:Object Returns - If was successfully removed, the method returns a value.
  • Page 581: Setfocus (Selection.setfocus Method)

    setFocus (Selection.setFocus method) public static setFocus(newFocus:Object) : Boolean Gives focus to the selectable (editable) text field, button, or movie clip, specified by the parameter. You can use dot or slash notation to specify the path. You can also use a newFocus relative or absolute path.
  • Page 582: Sharedobject

    function checkForm():Boolean { if (username_txt.text.length == 0) { status_txt.text = "fill in username"; Selection.setFocus("username_txt"); return false; if (password_txt.text.length == 0) { status_txt.text = "fill in password"; Selection.setFocus("password_txt"); return false; status_txt.text = "success!"; Selection.setFocus(null); return true; See also getFocus (Selection.getFocus method) SharedObject Object +-SharedObject...
  • Page 583 The following examples describe the potential of using shared objects: A Flash application can be used as a user interface for a service that enables the user to ■ search used car listings. The application connects to a server that provides listings of cars based on the search terms and preferences that the user enters.
  • Page 584 (SharedObject:mySO) { if (0 == mySO.getSize() ) // If the size is 0, we need to initialize the data: mySO.data.name = "Sigismund"; mySO.data.email = "siggy@macromedia.com"; else // Trace all the data in mySO: trace( "Prefs:" ); for (var idx in mySO.data) { trace( "...
  • Page 585 Property summary Modifiers Property Description The collection of attributes assigned to the data:Object data property of the object. 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 every time an error, warning, or onStatus = function(infoObject:Object) {} informational note is posted for a shared...
  • Page 586: Addlistener (Sharedobject.addlistener Method)

    Method summary Modifiers Signature Description Creates an event listener that the static addListener(objectName:String, Flash Lite player invokes when the notifyFunction:Function) : Void player has loaded the shared object data from the device. Purges all the data from the shared clear() : Void object and deletes the shared object from the disk.
  • Page 587: Clear (Sharedobject.clear Method)

    Availability: ActionScript 2.0; Flash Lite 2.0 Parameters - A string that represents the name of the shared object. objectName:String - The name of a function the player calls to notify the notifyFunction:Function application that the method has executed and the data is finished loading. getLocal() clear (SharedObject.clear method) public clear() : Void...
  • Page 588 Note: For Flash Lite, if the shared object listener has not been invoked, the property data could contain undefined values. For details, see the description of the addListener() method. var items_array:Array = new Array(101, 346, 483); var currentUserIsAdmin:Boolean = true; var currentUserName:String = "Ramona";...
  • Page 589: Flush (Sharedobject.flush Method)

    The shared object contains the following data: favoriteSong: My World is Blue favoriteNightClub: The Bluenote Tavern favoriteColor: blue data: [object Object] Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example saves text to a shared object named (for the complete example, my_so SharedObject.getLocal() var my_so:SharedObject = SharedObject.getLocal("savedText");...
  • Page 590 Returns - A Boolean value, ; or a string value of . The Object true false "pending" flush() method returns for most requests, with the following exceptions: pending If there is no need to write data (that is, the data has already been written), flush() ■...
  • Page 591: Getlocal (Sharedobject.getlocal Method)

    getLocal (SharedObject.getLocal method) public static getLocal(name:String) : SharedObject Returns a reference to a locally persistent shared object that is available only to the current client. If the shared object does not already exist, creates one. This method is a getLocal() static method of the SharedObject class.
  • Page 592: Getmaxsize (Sharedobject.getmaxsize Method)

    The following code block is placed on each SWF file frame: // On each frame, call the rememberme function to save the frame number. function rememberme() { my_so.data.frame=this._currentframe; my_so.data.user="John"; getMaxSize (SharedObject.getMaxSize method) public static getMaxSize() : Number Returns the total number of bytes the SWF file can use to store mobile shared objects on the device.
  • Page 593: Onstatus (Sharedobject.onstatus Handler)

    If the shared object listener has not yet been called, returns 0. For details about getSize() using the listener, see the method. addListener() Availability: ActionScript 1.0; Flash Lite 2.0 Returns - A numeric value specifying the size of the shared object, in bytes. Number Example The following example gets the size of the shared object...
  • Page 594 The following events notify you when certain SharedObject activities occur: Code property Level property Meaning Error method that SharedObject.Flush.Failed SharedObject.flush() returned has failed (the "pending" user did not allot additional disk space for the shared object when Flash Player showed the Local Storage Settings dialog box).
  • Page 595: Removelistener (Sharedobject.removelistener Method)

    var flushResult = my_so.flush(1000001); switch (flushResult) { case 'pending' : message_txt.text = "flush is pending, waiting on user interaction."; break; case true : message_txt.text = "flush was successful. Requested storage space approved."; break; case false : message_txt.text = "flush failed. User denied request for additional storage.";...
  • Page 596 Availability: ActionScript 1.0; Flash Lite 2.0 Property summary Modifiers Property Description [read-only] The duration of a sound, in milliseconds. duration:Number [read-only] Provides access to the metadata that is part id3:Object of an MP3 file. [read-only] The number of milliseconds a sound has been position:Number playing.
  • Page 597 Method summary Modifiers Signature Description Attaches the sound specified in the attachSound(id:String) : Void id parameter to the specified Sound object. Returns the number of bytes loaded getBytesLoaded() : Number (streamed) for the specified Sound object. Returns the size, in bytes, of the getBytesTotal() : Number specified Sound object.
  • Page 598: Attachsound (Sound.attachsound 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) attachSound (Sound.attachSound method) public attachSound(id:String) : Void Attaches the sound specified in the parameter to the specified Sound object.
  • Page 599 Example The following example loads a sound and displays the duration of the sound file in the Output panel. Add the following ActionScript to your FLA or AS file. var my_sound:Sound = new Sound(); my_sound.onLoad = function(success:Boolean) { var totalSeconds:Number = this.duration/1000; trace(this.duration+"...
  • Page 600: Getbytesloaded (Sound.getbytesloaded Method)

    with (pb.stroke_mc) { lineStyle(3, 0x000000); moveTo(0, 0); lineTo(pb_width, 0); lineTo(pb_width, pb_height); lineTo(0, pb_height); lineTo(0, 0); var my_interval:Number; var my_sound:Sound = new Sound(); my_sound.onLoad = function(success:Boolean) { if (success) { trace("sound loaded"); my_sound.onSoundComplete = function() { clearInterval(my_interval); trace("Cleared interval"); my_sound.loadSound("song3.mp3", true); my_interval = setInterval(updateProgressBar, 100, my_sound);...
  • Page 601 Example The following example dynamically creates two text fields that display the bytes that are loaded and the total number of bytes for a sound file that loads into the SWF file. A text field also displays a message when the file finishes loading. Add the following ActionScript to your FLA or AS file: this.createTextField("message_txt", this.getNextHighestDepth(), 10,10,300,22)
  • Page 602: Getbytestotal (Sound.getbytestotal Method)

    getBytesTotal (Sound.getBytesTotal method) public getBytesTotal() : Number Returns the size, in bytes, of the specified Sound object. Availability: ActionScript 1.0; Flash Lite 2.0 Returns - An integer indicating the total size, in bytes, of the specified Sound object. Number Example For a sample usage of this method, see Sound.getBytesLoaded() See also...
  • Page 603: Gettransform (Sound.gettransform Method)

    You can use the following example to start the device sound. Because Flash Lite does not support streaming sound, it is a good practice to load the sound before playing it. var my_sound:Sound = new Sound(); my_sound.onLoad = function(success) { if (success) { my_sound.start();...
  • Page 604 transform_mc.transform_txt.html = true; var knob_ll:MovieClip = transform_mc.attachMovie("knob_id", "ll_mc", transform_mc.getNextHighestDepth(), {_x:0, _y:30}); var knob_lr:MovieClip = transform_mc.attachMovie("knob_id", "lr_mc", transform_mc.getNextHighestDepth(), {_x:30, _y:30}); var knob_rl:MovieClip = transform_mc.attachMovie("knob_id", "rl_mc", transform_mc.getNextHighestDepth(), {_x:60, _y:30}); var knob_rr:MovieClip = transform_mc.attachMovie("knob_id", "rr_mc", transform_mc.getNextHighestDepth(), {_x:90, _y:30}); knob_ll.top = knob_ll._y; knob_ll.bottom = knob_ll._y+100; knob_ll.left = knob_ll._x;...
  • Page 605: Getvolume (Sound.getvolume Method)

    function pressKnob() { this.startDrag(false, this.left, this.top, this.right, this.bottom); function releaseKnob() { this.stopDrag(); updateTransformTxt(); function updateTransformTxt() { var ll_num:Number = 30+100-knob_ll._y; var lr_num:Number = 30+100-knob_lr._y; var rl_num:Number = 30+100-knob_rl._y; var rr_num:Number = 30+100-knob_rr._y; my_sound.setTransform({ll:ll_num, lr:lr_num, rl:rl_num, rr:rr_num}); transform_mc.transform_txt.htmlText = "<textformat tabStops='[0,30,60,90]'>"; transform_mc.transform_txt.htmlText += ll_num+"\t"+lr_num+"\t"+rl_num+"\t"+rr_num;...
  • Page 606 Example The following example creates a slider using the Drawing API and a movie clip that is created at runtime. A dynamically created text field displays the current volume level of the sound playing in the SWF file. Add the following ActionScript to your ActionScript or FLA file: var my_sound:Sound = new Sound();...
  • Page 607: Id3 (Sound.id3 Property)

    See also setVolume (Sound.setVolume method) id3 (Sound.id3 property) public id3 : Object [read-only] Provides access to the metadata that is part of an MP3 file. MP3 sound files can contain ID3 tags, which provide metadata about the file. If an MP3 sound that you load using contains ID3 tags, Sound.attachSound()
  • Page 608 Property Description TPE3 Conductor/performer refinement TPE4 Interpreted, remixed, or otherwise modified by TPOS Part of a set TPUB Publisher TRCK Track number/position in set TRDA Recording dates TRSN Internet radio station name TRSO Internet radio station owner TSIZ Size TSRC ISRC (international standard recording code) TSSE Software/hardware and settings used for encoding...
  • Page 609: Loadsound (Sound.loadsound Method)

    Example The following example traces the ID3 properties of song.mp3 to the Output panel: var my_sound:Sound = new Sound(); my_sound.onID3 = function(){ for( var prop in my_sound.id3 ){ trace( prop + " : "+ my_sound.id3[prop] ); my_sound.loadSound("song.mp3", false); See also attachSound (Sound.attachSound method) loadSound (Sound.loadSound method) loadSound (Sound.loadSound method)
  • Page 610: Onid3 (Sound.onid3 Handler)

    The following example loads a streaming sound: var my_sound:Sound = new Sound(); my_sound.loadSound("song1.mp3", true); See also onLoad (Sound.onLoad handler) onID3 (Sound.onID3 handler) onID3 = function() {} Invoked each time new ID3 data is available for an MP3 file that you load using .
  • Page 611: Onload (Sound.onload Handler)

    See also attachSound (Sound.attachSound method) id3 (Sound.id3 property) loadSound (Sound.loadSound method) onLoad (Sound.onLoad handler) onLoad = function(success:Boolean) {} Invoked automatically when a sound loads. You must create a function that executes when the this handler is invoked. You can use either an anonymous function or a named function (for an example of each, see ).
  • Page 612: Onsoundcomplete (Sound.onsoundcomplete Handler)

    onSoundComplete (Sound.onSoundComplete handler) onSoundComplete = function() {} Invoked automatically when a sound finishes playing. You can use this handler to trigger events in a SWF file when a sound finishes playing. You must create a function that executes when this handler is invoked. You can use either an anonymous function or a named function.
  • Page 613: Setpan (Sound.setpan Method)

    Example For a sample usage of this property, see Sound.duration See also duration (Sound.duration property) setPan (Sound.setPan method) public setPan(value:Number) : Void Determines how the sound is played in the left and right channels (speakers). For mono sounds, determines which speaker (left or right) the sound plays through. Note: Flash Lite 2.0 supports this method for native Flash sound only.
  • Page 614 Sounds use a considerable amount of disk space and memory. Because stereo sounds use twice as much data as mono sounds, it is generally best to use 22-KHz 6-bit mono sounds. You can to play mono sounds as stereo, play stereo sounds as mono, and to add setTransform() interesting effects to sounds.
  • Page 615: Setvolume (Sound.setvolume Method)

    Example The following example illustrates a setting that can be achieved by using setTransform() but cannot be achieved by using , even if they are combined. setVolume() setPan() The following code creates a new object and sets its properties so soundTransformObject that sound from both channels plays in the left channel only .
  • Page 616: Sound Constructor

    Parameters - A number from 0 to 100 representing a volume level. 100 is full volume and value:Number 0 is no volume. The default setting is 100. Example For a sample usage of this method, see Sound.getVolume() See also setPan (Sound.setPan method) setTransform (Sound.setTransform method) Sound constructor public Sound([target:Object])
  • Page 617: Stop (Sound.stop Method)

    Parameters [optional] - A parameter that lets you start playing the sound at a secondOffset:Number specific point. For example, if you have a 30-second sound and want the sound to start playing in the middle, specify 15 for the parameter. The sound is not delayed secondOffset 15 seconds, but rather starts playing at the 15-second mark.
  • Page 618: Stage

    Parameters [optional] - A parameter specifying a specific sound to stop playing. The linkageID:String parameter must be enclosed in quotation marks (" "). idName Example The following example uses two buttons, , to control the playback of stop_btn play_btn a sound that loads into a SWF file. Add two buttons to your document and add the following ActionScript to your FLA or AS file: var my_sound:Sound = new Sound();...
  • Page 619 Property summary Modifiers Property Description Indicates the current alignment of the SWF static align:String file in the player or browser. Property (read-only); indicates the current static height:Number height, in pixels, of the Stage. Indicates the current scaling of the SWF file static scaleMode:String within Flash Player.
  • Page 620: Addlistener (Stage.addlistener Method)

    addListener (Stage.addListener method) public static addListener(listener:Object) : Void Detects when a SWF file is resized (but only if ). The Stage.scaleMode = "noScale" method doesn't work with the default movie clip scaling setting ( addListener() showAll or other scaling settings ( exactFit noBorder , you must first create a listener object.
  • Page 621: Height (Stage.height Property)

    The following table lists the values for the property. Any value not listed here centers align the SWF file in Flash player or browser area, which is the default setting. Value Vertical Horizontal "T" center "B" bottom center "L" center left "R"...
  • Page 622: Onresize (Stage.onresize Event Listener)

    Example This example creates a new listener object called . It then uses stageListener myListener call and define a function that will be called when is triggered. Finally, onResize onResize the code adds the object to the callback list of the Stage object. Listener objects myListener allow multiple objects to listen for resize notifications.
  • Page 623: Removelistener (Stage.removelistener Method)

    removeListener (Stage.removeListener method) public static removeListener(listener:Object) : Boolean Removes a listener object created with addListener(). Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - An object added to an object's callback list with listener:Object addListener() Returns - A Boolean value. Boolean Example The following example displays the Stage dimensions in a dynamically created text field.
  • Page 624: Scalemode (Stage.scalemode Property)

    scaleMode (Stage.scaleMode property) public static scaleMode : String Indicates the current scaling of the SWF file within Flash Player. The property scaleMode forces the SWF file into a specific scaling mode. By default, the SWF file uses the HTML parameters set in the Publish Settings dialog box. property can use the values , and scaleMode...
  • Page 625: Width (Stage.width Property)

    To view another example, see the stagesize.fla file in the ActionScript samples Folder. The following list provides 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 width (Stage.width property) public static width : Number Property (read-only);...
  • Page 626: String

    String Object +-String public class String extends Object The String class is a wrapper for the string primitive data type, and provides methods and properties that let you manipulate primitive string value types. You can convert the value of any object into a string using the function.
  • Page 627 Constructor summary Signature Description Creates a new String object. String(value:String) Method summary Modifiers Signature Description Returns the character in the position charAt(index:Number) : String specified by the parameter index. Returns a 16-bit integer from 0 to charCodeAt(index:Number) : Number 65535 that represents the character specified by index.
  • Page 628: Charat (String.charat Method)

    Modifiers Signature Description Returns the characters in a string substr(start:Number, length:Number) : from the index specified in the String start parameter through the number of characters specified in the length parameter. Returns a string comprising the substring(start:Number, end:Number) : characters between the points String specified by the start and end parameters.
  • Page 629: Charcodeat (String.charcodeat Method)

    Parameters - An integer specifying the position of a character in the string. The first index:Number character is indicated by , and the last character is indicated by my_str.length-1 Returns - The character at the specified index. Or an empty if the specified index is String String...
  • Page 630: Concat (String.concat Method)

    See also charAt (String.charAt method) concat (String.concat method) public concat(value:Object) : String Combines the value of the String object with the parameters and returns the newly formed string; the original value, , is unchanged. my_str Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - value1[,...valueN] Zero or more values to be concatenated.
  • Page 631: Indexof (String.indexof Method)

    indexOf (String.indexOf method) public indexOf(value:String, [startIndex:Number]) : Number Searches the string and returns the position of the first occurrence of found at or after value within the calling string. This index is zero-based, meaning that the first startIndex character in a string is considered to be at index 0--not index 1. If is not found, the value method returns -1.
  • Page 632: Lastindexof (String.lastindexof Method)

    lastIndexOf (String.lastIndexOf method) public lastIndexOf(value:String, [startIndex:Number]) : Number Searches the string from right to left and returns the index of the last occurrence of value found before within the calling string. This index is zero-based, meaning that the startIndex first character in a string is considered to be at index 0--not index 1. If is not found, the value method returns -1.
  • Page 633: Length (String.length Property)

    An example is also in the Strings.fla file in the ActionScript samples folder. The following list gives 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 String...
  • Page 634: Slice (String.slice Method)

    slice (String.slice method) public slice(start:Number, end:Number) : String Returns a string that includes the character and all characters up to, but not including, start character. The original String object is not modified. If the parameter is not specified, the end of the substring is the end of the string. If the character indexed by start the same as or to the right of the character indexed by , the method returns an empty...
  • Page 635: Split (String.split Method)

    An example is also in the Strings.fla file in the ActionScript samples folder. The following list gives 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 substr (String.substr method) substring (String.substring method)
  • Page 636 An example is also in the Strings.fla file in the ActionScript samples folder. The following list gives 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 join (Array.join method)
  • Page 637: String Constructor

    String constructor public String(value:String) Creates a new String object. Note: Because string literals use less overhead than String objects and are generally easier to use, you should use string literals instead of the constructor for the String class unless you have a good reason to use a String object rather than a string literal.
  • Page 638: Substring (String.substring Method)

    An example is also in the Strings.fla file in the ActionScript samples folder. The following list gives 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 substring (String.substring method) public substring(start:Number, end:Number) : String...
  • Page 639: Tolowercase (String.tolowercase Method)

    An example is also in the Strings.fla file in the ActionScript samples folder. The following list gives 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 toLowerCase (String.toLowerCase method) public toLowerCase() : String Returns a copy of the object, with all uppercase characters converted to lowercase.
  • Page 640: Tostring (String.tostring Method)

    An example is also in the Strings.fla file in the ActionScript samples folder. The following list gives 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 toUpperCase (String.toUpperCase method) toString (String.toString method)
  • Page 641: Touppercase (String.touppercase Method)

    An example is also found in the Strings.fla file in the ActionScript samples folder. The following list gives 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 toLowerCase (String.toLowerCase method) valueOf (String.valueOf method)
  • Page 642: System

    Example The following example creates a new instance of the String object and then shows that the method returns a reference to the primitive value, rather than an instance of the valueOf object. var str:String = new String("Hello World"); var value:String = str.valueOf(); trace(str instanceof String);...
  • Page 643: Onstatus (System.onstatus Handler)

    Event summary Event Description Event handler: provides a super event handler onStatus = function(infoObject:Object) {} for certain objects. 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),...
  • Page 644: Usecodepage (System.usecodepage Property)

    Example The following example shows how to create a function to process System.onStatus() information objects when a class-specific onStatus() function does not exist: // Create generic function System.onStatus = function(genericError:Object){ // Your script would do something more meaningful here trace("An error has occurred. Please try again."); See also onStatus (SharedObject.onStatus handler) useCodepage (System.useCodepage property)
  • Page 645: Textfield

    If you set to true, remember that the traditional code page of the System.useCodepage operating system running the player must include the characters used in your external text file in order for the text to display. For example, if you load an external text file that contains Chinese characters, those characters cannot display on a system that uses the CP1252 code page because that code page does not include Chinese characters.
  • Page 646 See also Object createTextField (MovieClip.createTextField method) Property summary Modifiers Property Description Sets or retrieves the alpha transparency value _alpha:Number of the text field. Controls automatic sizing and alignment of autoSize:Object text fields. Specifies if the text field has a background fill. background:Boolean The color of the text field background.
  • Page 647 Modifiers Property Description Indicates the maximum number of characters maxChars:Number that the text field can contain. [read-only] Indicates the maximum value of maxhscroll:Number TextField.hscroll. [read-only] Indicates the maximum value of maxscroll:Number TextField.scroll. Indicates whether the text field is a multiline multiline:Boolean text field.
  • Page 648 Modifiers Property Description [read-only] Retrieves the URL of the SWF file that _url:String created the text field. The name of the variable that the text field is variable:String associated with. A Boolean value that indicates whether the _visible:Boolean text field my_txt is visible. The width of the text field, in pixels.
  • Page 649 Event summary Event Description Event handler/listener; invoked onChanged = function(changedField:TextField) {} when the content of a text field changes. Invoked when a text field loses onKillFocus = function(newFocus:Object) {} keyboard focus. Event handler/listener; invoked onScroller = function(scrolledField:TextField) {} when one of the text field scroll properties changes.
  • Page 650: Addlistener (Textfield.addlistener Method)

    Modifiers Signature Description Sets the default new text format of a setNewTextFormat(tf:TextFormat) : text field. Void Applies the text formatting specified setTextFormat([beginIndex:Number], by the textFormat parameter to [endIndex:Number], some or all of the text in a text field. textFormat:TextFormat) : Void Methods inherited from class Object addProperty (Object.addProperty...
  • Page 651: Alpha (Textfield._Alpha Property)

    Returns Boolean Example The following example defines an handler for the input text field . It then onChanged my_txt defines a new listener object, , and defines an handler for that txtListener onChanged object. This handler will be invoked when the text field is changed.
  • Page 652: Autosize (Textfield.autosize Property)

    Example The following code sets the property of a text field named to 20%. Create a _alpha my_txt new font symbol in the library by selecting New Font from the Library options menu. Then set the linkage of the font to .Set the linkage for a font symbol to .
  • Page 653 is set to , then the text is treated as center-justified text, meaning any autoSize "center" resizing of a single line text field will be equally distributed to both the right and left sides. If the text includes a line break (for example, , then the bottom side will also be "\n"...
  • Page 654: Background (Textfield.background Property)

    false_txt.text = "This is much longer text"; // register the listener object with the Mouse object Mouse.addListener(myMouseListener); background (TextField.background property) public background : Boolean Specifies if the text field has a background fill. If , the text field has a background fill. If true , the text field has no background fill.
  • Page 655: Border (Textfield.border Property)

    border (TextField.border property) public border : Boolean Specifies if the text field has a border. If , the text field has a border. If , the text true false field has no border. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field called , sets the border property to , and...
  • Page 656: Condensewhite (Textfield.condensewhite Property)

    All the text between lines is currently TextField.scroll TextField.bottomScroll visible in the text field. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field and fills it with text. You must insert a button (with the instance name "my_btn"), and when you click it, the scroll bottomScroll properties for the text field are then traced for the...
  • Page 657: Embedfonts (Textfield.embedfonts Property)

    Example The following example creates two text fields, called . The white first_txt second_txt space is removed from the second text field. Add the following ActionScript to your FLA or ActionScript file: var my_str:String = "Hello\tWorld\nHow are you?\t\t\tEnd"; this.createTextField("first_txt", this.getNextHighestDepth(), 10, 10, 160, 120);...
  • Page 658: Getdepth (Textfield.getdepth Method)

    Example In this example, you need to create a dynamic text field called , and then use the my_txt following ActionScript to embed fonts and rotate the text field. The string refers to a my font font symbol in the library, with the linkage identifier name .
  • Page 659: Getnewtextformat (Textfield.getnewtextformat Method)

    getNewTextFormat (TextField.getNewTextFormat method) public getNewTextFormat() : TextFormat Returns a TextFormat object containing a copy of the text field's text format object. The text format object is the format that newly inserted text, such as text entered by a user, receives. When is invoked, the TextFormat object returned has all of its getNewTextFormat()
  • Page 660 Usage 3: ■ my_textField.getTextFormat(beginIndex:Number,endIndex:Number) Returns a TextFormat object containing formatting information for the span of text from . Only properties that are common to all of the text in the beginIndex endIndex specified range is set in the resulting TextFormat object. Any property that is mixed (it has different values at different points in the range) has its value set to null.
  • Page 661: Height (Textfield._Height Property)

    _height (TextField._height property) public _height : Number The height of the text field in pixels. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following code example sets the height and width of a text field: my_txt._width = 200; my_txt._height = 200; _highquality (TextField._highquality property) public _highquality : Number...
  • Page 662: Html (Textfield.html Property)

    Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example scrolls the text field horizontally using two buttons called my_txt . The amount of scroll appears in a text field called scrollLeft_btn scrollRight_btn . Add the following ActionScript to your FLA or ActionScript file: scroll_txt this.createTextField("scroll_txt", this.getNextHighestDepth(), 10, 10, 160, 20);...
  • Page 663: Htmltext (Textfield.htmltext Property)

    Example The following example creates a text field that sets the property to . HTML- html true formatted text appears in the text field. this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 160, 22); my_txt.html = true; my_txt.htmlText = "<b> this is bold text </b>"; See also htmlText (TextField.htmlText property) htmlText (TextField.htmlText property)
  • Page 664: Maxchars (Textfield.maxchars Property)

    Example The following example outputs the number of characters in the text field, which date_txt displays the current date. var today:Date = new Date(); this.createTextField("date_txt", this.getNextHighestDepth(), 10, 10, 100, 22); date_txt.autoSize = true; date_txt.text = today.toString(); trace(date_txt.length); maxChars (TextField.maxChars property) public maxChars : Number Indicates the maximum number of characters that the text field can contain.
  • Page 665: Maxscroll (Textfield.maxscroll Property)

    maxscroll (TextField.maxscroll property) public maxscroll : Number [read-only] Indicates the maximum value of TextField.scroll Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example sets the maximum value for the scrolling text field . Create two my_txt buttons, to scroll the text field. Add the following scrollUp_btn scrollDown_btn, ActionScript to your FLA or ActionScript file.
  • Page 666: Name (Textfield._Name Property)

    Example The following example creates a multiline text field called myText this.createTextField("myText", this.getNextHighestDepth(), 10, 30, 110, 100); myText.text = "Flash is an authoring tool that designers and developers use to create presentations, applications, and other content that enables user interaction."; myText.border = true;...
  • Page 667: Onkillfocus (Textfield.onkillfocus Handler)

    A reference to the text field instance is passed as a parameter to the handler. You onChanged can capture this data by putting a parameter in the event handler method. For example, the following code uses as the parameter that is passed to the event textfield_txt onChanged...
  • Page 668: Onscroller (Textfield.onscroller Handler)

    Example The following example creates two text fields called . When you first_txt second_txt give focus to a text field, information about the text field with current focus and the text field that lost focus is displayed in the Output panel. this.createTextField("first_txt", 1, 10, 10, 300, 20);...
  • Page 669 is called whether the scroll position changed because of a users interaction with onScroller the text field, or programmatic changes. The handler fires only if a user onChanged interaction causes the change. These two options are necessary because often one piece of code changes the scrolling position, while the scroll bar code is unrelated and won't know that the scroll position changed without being notified.
  • Page 670: Onsetfocus (Textfield.onsetfocus Handler)

    See also hscroll (TextField.hscroll property) maxhscroll (TextField.maxhscroll property) maxscroll (TextField.maxscroll property) scroll (TextField.scroll property) onSetFocus (TextField.onSetFocus handler) onSetFocus = function(oldFocus:Object) {} Invoked when a text field receives keyboard focus. The parameter is the object that oldFocus loses the focus. For example, if the user presses the Tab key to move the input focus from a button to a text field, oldFocus contains the button instance.
  • Page 671: Password (Textfield.password Property)

    Example The following ActionScript creates two text fields and outputs information about the of each object. The first text field, , is created on the main Timeline. The _parent first_txt second text field, , is created inside the movie clip called second_txt holder_mc this.createTextField("first_txt", this.getNextHighestDepth(), 10, 10, 160,...
  • Page 672: Quality (Textfield._Quality Property)

    Example The following example creates two text fields: . Text is username_txt password_txt entered into both text fields; however, has the password property set to password_txt true Therefore, the characters display as asterisks instead of as characters in the password_txt field.
  • Page 673: Removelistener (Textfield.removelistener Method)

    Example The following example sets the rendering quality to my_txt._quality = "LOW"; See also _quality property removeListener (TextField.removeListener method) public removeListener(listener:Object) : Boolean Removes a listener object previously registered to a text field instance with TextField.addListener() Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - The object that will no longer receive notifications from listener:Object...
  • Page 674: Removetextfield (Textfield.removetextfield Method)

    my_txt.addListener(txtListener); removeListener_btn.onRelease = function() { trace("Removing listener..."); if (!my_txt.removeListener(txtListener)) { trace("Error! Unable to remove listener"); removeTextField (TextField.removeTextField method) public removeTextField() : Void Removes the text field. This operation can only be performed on a text field that was created with .
  • Page 675: Rotation (Textfield._Rotation Property)

    Parameters - The start index value for the replacement range. beginIndex:Number - The end index value for the replacement range. endIndex:Number - The text to use to replace the specified range of characters. newText:String Example The following example creates a text field called and assigns the text my_txt dog@house.net...
  • Page 676: Scroll (Textfield.scroll Property)

    Example In this example, you need to create a dynamic text field called , and then use the my_txt following ActionScript to embed fonts and rotate the text field. The string refers to a my font font symbol in the library, with a linkage identifier of my font var my_fmt:TextFormat = new TextFormat();...
  • Page 677: Selectable (Textfield.selectable Property)

    Example The following example sets the maximum value for the scrolling text field . Create two my_txt buttons, , to scroll the text field. Add the following scrollUp_btn scrollDown_btn ActionScript to your FLA or ActionScript file. this.createTextField("scroll_txt", this.getNextHighestDepth(), 10, 10, 160, 20);...
  • Page 678: Setnewtextformat (Textfield.setnewtextformat Method)

    Note: This property is not supported for Arabic, Hebrew, and Thai. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a selectable text field that constantly updates with the current date and time. this.createTextField("date_txt", this.getNextHighestDepth(), 10, 10, 100, 22);...
  • Page 679: Settextformat (Textfield.settextformat Method)

    my_txt.type = "input"; my_txt.setNewTextFormat(my_fmt); my_txt.text = "Oranges are a good source of vitamin C"; See also getNewTextFormat (TextField.getNewTextFormat method) getTextFormat (TextField.getTextFormat method) setTextFormat (TextField.setTextFormat method) setTextFormat (TextField.setTextFormat method) public setTextFormat([beginIndex:Number], [endIndex:Number], textFormat:TextFormat) : Void Applies the text formatting specified by the parameter to some or all of the text textFormat in a text field.
  • Page 680 Availability: ActionScript 1.0; Flash Lite 2.0 Parameters [optional] - An integer that specifies the first character of the desired beginIndex:Number text span. If you do not specify , the TextFormat is applied to the beginIndex endIndex entire TextField. [optional] - An integer that specifies the first character after the desired endIndex:Number text span.
  • Page 681: Soundbuftime (Textfield._Soundbuftime Property)

    _soundbuftime (TextField._soundbuftime property) public _soundbuftime : Number Specifies the number of seconds a sound prebuffers before it starts to stream. Note: Although you can specify this property for a TextField object, it is actually a global property that applies to all sounds loaded, and you can specify its value simply as .
  • Page 682 Example The following example creates a new text field at runtime, called . Three buttons on news_txt the Stage, , are used to change the style sheet that is css1_btn css2_btn clearCss_btn applied to , or clear the style sheet from the text field. Add the following news_txt ActionScript to your FLA or ActionScript file: this.createTextField("news_txt", this.getNextHighestDepth(), 0, 0, 300,...
  • Page 683: Tabenabled (Textfield.tabenabled Property)

    The following styles are applied to the text field. Save the following two CSS files in the same directory as the FLA or ActionScript file you created previously: // in styles.css .important { color: #FF0000; .bold { font-weight: bold; .headline { color: #000000;...
  • Page 684: Tabindex (Textfield.tabindex Property)

    Example The following example creates several text fields, called one_txt two_txt three_txt . The text field has the property set to , so it is four_txt three_txt tabEnabled false excluded from the automatic tab ordering. this.createTextField("one_txt", this.getNextHighestDepth(), 10, 10, 100, 22);...
  • Page 685: Target (Textfield._Target Property)

    The custom tab ordering defined by the property is flat. This means that no tabIndex attention is paid to the hierarchical relationships of objects in the SWF file. All objects in the SWF file with properties are placed in the tab order, and the tab order is tabIndex determined by the order of the values.
  • Page 686: Text (Textfield.text Property)

    Example The following ActionScript creates a text field called and outputs the target path of my_txt the new field, in both slash and dot notation. this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 100, 22); trace(my_txt._target); // output: /my_txt trace(eval(my_txt._target)); // output: _level0.my_txt text (TextField.text property) public text : String Indicates the current text in the text field.
  • Page 687: Textcolor (Textfield.textcolor Property)

    textColor (TextField.textColor property) public textColor : Number Indicates the color of the text in a text field. The hexadecimal color system uses six digits to represent color values. Each digit has sixteen possible values or characters. The characters range from 0 to 9 and then A to F. Black is represented by ( ) and white, at the #000000 opposite end of the color system, is (...
  • Page 688: Textwidth (Textfield.textwidth Property)

    See also textWidth (TextField.textWidth property) textWidth (TextField.textWidth property) public textWidth : Number Indicates the width of the text. Availability: ActionScript 1.0; Flash Lite 2.0 Example See the example for TextField.textHeight See also textHeight (TextField.textHeight property) type (TextField.type property) public type : String Specifies the type of text field.
  • Page 689: Url (Textfield._Url Property)

    _url (TextField._url property) public _url : String [read-only] Retrieves the URL of the SWF file that created the text field. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example retrieves the URL of the SWF file that created the text field, and a SWF file that loads into it.
  • Page 690: Visible (Textfield._Visible Property)

    _visible (TextField._visible property) public _visible : Boolean A Boolean value that indicates whether the text field is visible. Text fields that are not my_txt visible ( property set to ) are disabled. _visible false Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field called .
  • Page 691: Wordwrap (Textfield.wordwrap Property)

    this.createTextField("width_txt", this.getNextHighestDepth(), 10, 10, 30, 20); width_txt.border = true; width_txt.maxChars = 3; width_txt.type = "input"; width_txt.text = my_txt._width; width_txt.onChanged = function() { my_txt._width = this.text; this.createTextField("height_txt", this.getNextHighestDepth(), 70, 10, 30, 20); height_txt.border = true; height_txt.maxChars = 3; height_txt.type = "input"; height_txt.text = my_txt._height;...
  • Page 692: X (Textfield._X Property)

    _x (TextField._x property) public _x : Number An integer that sets the x coordinate of a text field relative to the local coordinates of the parent movie clip. If a text field is on the main Timeline, then its coordinate system refers to the upper left corner of the Stage as (0, 0).
  • Page 693: Xscale (Textfield._Xscale Property)

    Example The following example creates three text fields on the Stage. The instance displays mouse_txt the current position of the mouse in relation to the Stage. The instance textfield_txt displays the current position of the mouse pointer in relation to the instance.
  • Page 694: Y (Textfield._Y Property)

    my_txt.text = "Sample text goes here."; scaleUp_btn.onRelease = function() { my_txt._xscale = 2; my_txt._yscale = 2; scaleDown_btn.onRelease = function() { my_txt._xscale /= 2; my_txt._yscale /= 2; See also _x (TextField._x property) _y (TextField._y property) _yscale (TextField._yscale property) _y (TextField._y property) public _y : Number The y coordinate of a text field relative to the local coordinates of the parent movie clip.
  • Page 695: Yscale (Textfield._Yscale Property)

    Availability: ActionScript 1.0; Flash Lite 2.0 Example See the example for TextField._xmouse See also _xmouse (TextField._xmouse property) _yscale (TextField._yscale property) public _yscale : Number The vertical scale of the text field as applied from the registration point of the text field, expressed as a percentage.
  • Page 696 Property summary Modifiers Property Description A string that indicates the alignment of the align:String paragraph. A number that indicates the block indentation blockIndent:Number in points. A Boolean value that specifies whether the bold:Boolean text is boldface. A Boolean value that indicates that the text is bullet:Boolean part of a bulleted list.
  • Page 697: Align (Textformat.align 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 TextFormat object with the TextFormat([font:String], [size:Number], specified properties. [color:Number], [bold:Boolean], [italic:Boolean], [underline:Boolean], [url:String], [target:String], [align:String], [leftMargin:Number], [rightMargin:Number], [indent:Number], [leading:Number]) Method summary Modifiers...
  • Page 698: Blockindent (Textformat.blockindent Property)

    The default value is , which indicates that the property is undefined. null Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field with a border and uses TextFormat.align center the text. var my_fmt:TextFormat = new TextFormat(); my_fmt.align = "center";...
  • Page 699: Bold (Textformat.bold Property)

    bold (TextFormat.bold property) public bold : Boolean A Boolean value that specifies whether the text is boldface. The default value is , which null indicates that the property is undefined. If the value is , the text is boldface. true Note: For Arabic, Hebrew, and Thai, this property works for paragraph-level formatting only.
  • Page 700: Color (Textformat.color Property)

    Example The following example creates a new text field at runtime, and puts a string with a line break into the field. The TextFormat class is used to format the characters by adding bullets to each line in the text field. This is demonstrated in the following ActionScript: var my_fmt:TextFormat = new TextFormat();...
  • Page 701: Font (Textformat.font Property)

    font (TextFormat.font property) public font : String A string that specifies the name of the font for text. The default value is , which indicates null that the property is undefined. Note: For Flash Lite, this property works for embedded fonts only. This property is not supported for Arabic, Hebrew, and Thai.
  • Page 702 If you are creating a text field based on the text metrics, use rather than textFieldHeight rather than height textFieldWidth width The following figure illustrates these measurements. When setting up your TextFormat object, set all the attributes exactly as they will be set for the creation of the text field, including font name, font size, and leading.
  • Page 703 = "Arial"; my_fmt.bold = true; my_fmt.leading = 4; // The string of text to be displayed var textToDisplay:String = "Macromedia Flash Player 7, now with improved text metrics."; // Obtain text measurement information for the string, // wrapped at 100 pixels.
  • Page 704: Indent (Textformat.indent Property)

    indent (TextFormat.indent property) public indent : Number An integer that indicates the indentation from the left margin to the first character in the paragraph. The default value is , which indicates that the property is undefined. null Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field and sets the indentation to 10: this.createTextField("mytext",1,100,100,100,100);...
  • Page 705: Leading (Textformat.leading Property)

    leading (TextFormat.leading property) public leading : Number An integer that represents the amount of vertical space in pixels (called leading) between lines. The default value is , which indicates that the property is undefined. null Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field and sets the leading to 10.
  • Page 706: Rightmargin (Textformat.rightmargin Property)

    rightMargin (TextFormat.rightMargin property) public rightMargin : Number The right margin of the paragraph, in points. The default value is , which indicates that null the property is undefined. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field and sets the right margin to 20 points. this.createTextField("mytext",1,100,100,100,100);...
  • Page 707: Tabstops (Textformat.tabstops Property)

    tabStops (TextFormat.tabStops property) public tabStops : Array Specifies custom tab stops as an array of non-negative integers. Each tab stop is specified in pixels. If custom tab stops are not specified ( ), the default tab stop is 4 (average character null width).
  • Page 708: Textformat Constructor

    Example The following example creates a text field with a hyperlink to the Macromedia website. The example uses to display the Macromedia website in a new browser TextFormat.target window. var myformat:TextFormat = new TextFormat(); myformat.url = "http://www.macromedia.com"; myformat.target = "_blank";...
  • Page 709 To view another example, see the animations.fla file in the ActionScript samples Folder. The following list provides 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 TextFormat...
  • Page 710: Underline (Textformat.underline Property)

    , which indicates that the null property is undefined. Availability: ActionScript 1.0; Flash Lite 2.0 Example This example creates a text field that is a hyperlink to the Macromedia website. var myformat:TextFormat = new TextFormat(); myformat.url = "http://www.macromedia.com"; this.createTextField("mytext",1,100,100,200,100); mytext.multiline = true;...
  • Page 711: Video

    Video Object +-Video public class Video extends Object The Video class enables you to display video content that is embedded in your SWF file, stored locally on the host device, or streamed in from a remote location. Note: The player for Flash Lite 2.0 handles video differently than Flash Player 7 does. These are the major differences: Flash Player 7 directly renders the video data (embedded or streaming).
  • Page 712 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 Callback handler that can be invoked by the onStatus = function(infoObject:Object) {} device to indicate status or error conditions. Method summary Modifiers Signature...
  • Page 713: Close (Video.close Method)

    close (Video.close method) public close() : Void Stops playback of the video, frees the memory associated with this Video object, and clears the video area onscreen. Availability: ActionScript 2.0; Flash Lite 2.0 Example The following example closes the video that is playing in a Video object named video1 video1.close() See also...
  • Page 714: Pause (Video.pause Method)

    - A value of if the mobile device can render the video; otherwise, Boolean true false Example The following example pauses and clears video1.flv, which is playing in a Video object (called video1 video1.play( "http://www.macromedia.com/samples/videos/clock.3gp" ); See also stop (Video.stop method) ActionScript classes...
  • Page 715: Resume (Video.resume Method)

    resume (Video.resume method) public resume() : Void Calling this method resumes playback of the video. was previously called, playback begins from the current position. If Video.pause() was previously called, playback begins from the first frame. Video.stop() Availability: ActionScript 2.0; Flash Lite 2.0 Example The following example resumes the video that is playing in a Video object called video1...
  • Page 716 Object +-XMLNode +-XML public class XML extends XMLNode Use the methods and properties of the XML class to load, parse, send, build, and manipulate XML document trees. You must use the constructor to create an XML object before calling any method new XML() of the XML class.
  • Page 717 See also appendChild (XMLNode.appendChild method) attributes (XMLNode.attributes property) childNodes (XMLNode.childNodes property) cloneNode (XMLNode.cloneNode method) firstChild (XMLNode.firstChild property) hasChildNodes (XMLNode.hasChildNodes method) insertBefore (XMLNode.insertBefore method) lastChild (XMLNode.lastChild property) nextSibling (XMLNode.nextSibling property) nodeName (XMLNode.nodeName property) nodeType (XMLNode.nodeType property) nodeValue (XMLNode.nodeValue property) parentNode (XMLNode.parentNode property) previousSibling (XMLNode.previousSibling property) removeNode (XMLNode.removeNode method)
  • Page 718 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 XML text has been completely onData = function(src:String) {} downloaded from the server, or when an error occurs downloading XML text from a server.
  • Page 719: Addrequestheader (Xml.addrequestheader Method)

    Modifiers Signature Description Parses the XML text specified in the value parseXML(value:String) : Void parameter, and populates the specified XML object with the resulting XML tree. Encodes the specified XML object into an send(url:String, XML document, and sends it to the specified [target:String], URL using the POST method in a browser.
  • Page 720: Contenttype (Xml.contenttype Property)

    If multiple calls are made to set the same header name, each successive value replaces the value set in the previous call. You cannot add or change the following standard HTTP headers using this method: Accept- Ranges Allow Allowed Connection Content-Length Content-Location Content-Range...
  • Page 721: Createelement (Xml.createelement Method)

    Example The following example creates a new XML document and checks its default content type: // create a new XML document var doc:XML = new XML(); // trace the default content type trace(doc.contentType); // output: application/x-www-form-urlencoded The following example defines an XML packet, and sets the content type for the XML object. The data is then sent to a server and shows a result in a browser window.
  • Page 722: Createtextnode (Xml.createtextnode Method)

    Example The following example creates three XML nodes using the method: createElement() // create an XML document var doc:XML = new XML(); // create three XML nodes using createElement() var element1:XMLNode = doc.createElement("element1"); var element2:XMLNode = doc.createElement("element2"); var element3:XMLNode = doc.createElement("element3"); // place the new nodes into the XML tree doc.appendChild(element1);...
  • Page 723: Doctypedecl (Xml.doctypedecl Property)

    Example The following example creates two XML text nodes using the method, createTextNode() and places them into existing XML nodes: // create an XML document var doc:XML = new XML(); // create three XML nodes using createElement() var element1:XMLNode = doc.createElement("element1"); var element2:XMLNode = doc.createElement("element2");...
  • Page 724: Getbytesloaded (Xml.getbytesloaded Method)

    If no declaration was encountered during a parse operation, the DOCTYPE XML.docTypeDecl property is set to . The method outputs the contents of undefined XML.toString() immediately after the XML declaration stored in , and XML.docTypeDecl XML.xmlDecl before any other text in the XML object. If is undefined, no XML.docTypeDecl DOCTYPE...
  • Page 725: Getbytestotal (Xml.getbytestotal Method)

    var percentLoaded:Number = Math.floor((bytesLoaded / bytesTotal ) 100); trace ("milliseconds elapsed: " + getTimer()); trace ("bytesLoaded: " + bytesLoaded); trace ("bytesTotal: " + bytesTotal); trace ("percent loaded: " + percentLoaded); trace ("---------------------------------"); doc.onLoad = function(success:Boolean) { clearInterval(intervalID); trace("intervalID: " + intervalID); doc.load("[place a valid URL pointing to an XML file here]");...
  • Page 726 Usage 1: You can set the property for individual XML objects, as the following ignoreWhite code shows: my_xml.ignoreWhite = true; Usage 2: You can set the default property for XML objects, as the following ignoreWhite code shows: XML.prototype.ignoreWhite = true; Availability: ActionScript 1.0;...
  • Page 727: Load (Xml.load Method)

    The XML_blogTracker.fla and XML_languagePicker.fla files in the ActionScript samples folder also contain a code example. The following are 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 load (XML.load method) public load(url:String) : Boolean Loads an XML document from the specified URL, and replaces the contents of the specified XML object with the downloaded XML data.
  • Page 728 You can define a custom function that executes when the event handler of the XML onLoad object is invoked. Availability: ActionScript 1.0; Flash Lite 2.0 - Behavior changed in Flash Player 7. Parameters - A string that represents the URL where the XML document to be loaded is url:String located.
  • Page 729: Loaded (Xml.loaded Property)

    loaded (XML.loaded property) public loaded : Boolean Indicates if the XML document has successfully loaded. If there is no custom event onLoad() handler defined for the XML object, then this property is set to when the document- true loading process initiated by the call has completed successfully;...
  • Page 730: Onload (Xml.onload Handler)

    Availability: ActionScript 1.0; Flash Lite 2.0 Parameters - A string or ; the raw data, usually in XML format, that is sent by the src:String undefined server. Example The following example shows what the XML.onData event handler looks like by default: XML.prototype.onData = function (src:String) { if (src == undefined) { this.onLoad(false);...
  • Page 731: Parsexml (Xml.parsexml Method)

    Example The following example includes ActionScript for a simple e-commerce storefront application. method transmits an XML element that contains the user's name and sendAndLoad() password, and uses an handler to process the reply from the server. XML.onLoad var login_str:String = "<login username=\""+username_txt.text+"\" password=\""+password_txt.text+"\"...
  • Page 732: Send (Xml.send Method)

    Example The following example creates and parses an XML packet: var xml_str:String = "<state name=\"California\"> <city>San Francisco</city></state>" // defining the XML source within the XML constructor: var my1_xml:XML = new XML(xml_str); trace(my1_xml.firstChild.attributes.name); // output: California // defining the XML source using the XML.parseXML method: var my2_xml:XML = new XML();...
  • Page 733: Sendandload (Xml.sendandload Method)

    Example The following example defines an XML packet and sets the content type for the XML object. The data is then sent to a server and shows a result in a browser window. var my_xml:XML = new XML("<highscore><name>Ernie</name> <score>13045</score></highscore>"); my_xml.contentType = "text/xml"; my_xml.send("http://www.flash-mx.com/mm/highscore.cfm", "_blank");...
  • Page 734 Parameters - A string; the destination URL for the specified XML object. 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. - A target XML object created with the XML constructor method that will resultXML:XML receive the return information from the server.
  • Page 735: Status (Xml.status Property)

    status (XML.status property) public status : Number Automatically sets and returns a numeric value that indicates whether an XML document was successfully parsed into an XML object. The following are the numeric status codes, with descriptions: 0 No error; parse was completed successfully. ■...
  • Page 736: Xml Constructor

    case -4 : errorMessage = "The DOCTYPE declaration was not properly terminated."; break; case -5 : errorMessage = "A comment was not properly terminated."; break; case -6 : errorMessage = "An XML element was malformed."; break; case -7 : errorMessage = "Out of memory."; break;...
  • Page 737: Xmldecl (Xml.xmldecl Property)

    Example The following example creates a new, empty XML object: var my_xml:XML = new XML(); The following example creates an XML object by parsing the XML text specified in the parameter, and populates the newly created XML object with the resulting XML source document tree: var other_xml:XML = new XML("<state name=\"California\"><city>San...
  • Page 738: Xmlnode

    my_txt.setNewTextFormat(my_fmt); var my_xml:XML = new XML(); my_xml.ignoreWhite = true; my_xml.onLoad = function(success:Boolean) { var endTime:Number = getTimer(); var elapsedTime:Number = endTime-startTime; if (success) { my_txt.text = "xmlDecl:"+newline+my_xml.xmlDecl+newline+newline; my_txt.text += "contentType:"+newline+my_xml.contentType+newline+newline; my_txt.text += "docTypeDecl:"+newline+my_xml.docTypeDecl+newline+newline; my_txt.text += "packet:"+newline+my_xml.toString()+newline+newline; } else { my_txt.text = "Unable to load remote XML."+newline+newline; my_txt.text += "loaded in: "+elapsedTime+"...
  • Page 739 Property summary Modifiers Property Description An object containing all of the attributes of the attributes:Object specified XML instance. [read-only] An array of the specified XML object's childNodes:Array children. [read-only] Evaluates the specified XML object and firstChild:XMLNode references the first child in the parent node's child list.
  • Page 740: Appendchild (Xmlnode.appendchild Method)

    Method summary Modifiers Signature Description Appends the specified node to the appendChild(newChild:XMLNode) : Void XML object's child list. Constructs and returns a new XML cloneNode(deep:Boolean) : XMLNode node of the same type, name, value, and attributes as the specified XML object.
  • Page 741 Parameters - An XMLNode that represents the node to be moved from its current newChild:XMLNode location to the child list of the object. my_xml Example This example does the following things in the order shown: Creates two empty XML documents, doc1 doc2 ■...
  • Page 742: Attributes (Xmlnode.attributes Property)

    attributes (XMLNode.attributes property) public attributes : Object An object containing all of the attributes of the specified XML instance. The XML.attributes object contains one variable for each attribute of the XML instance. Because these variables are defined as part of the object, they are generally referred to as properties of the object. The value of each attribute is stored in the corresponding property as a string.
  • Page 743 Example The following example shows how to use the XML.childNodes property to return an array of child nodes: // create a new XML document var doc:XML = new XML(); // create a root node var rootNode:XMLNode = doc.createElement("rootNode"); // create three child nodes var oldest:XMLNode = doc.createElement("oldest");...
  • Page 744: Clonenode (Xmlnode.clonenode Method)

    cloneNode (XMLNode.cloneNode method) public cloneNode(deep:Boolean) : XMLNode Constructs and returns a new XML node of the same type, name, value, and attributes as the specified XML object. If is set to , all child nodes are recursively cloned, resulting in deep true an exact copy of the original object's document tree.
  • Page 745: Firstchild (Xmlnode.firstchild Property)

    // insert the clone node into rootNode between the middle and youngest nodes rootNode.insertBefore(middle2, youngest); trace(rootNode); // output (with line breaks added): // <rootNode> // <oldest /> // <middle /> // <middle /> // <youngest /> // </rootNode> // create a copy of rootNode using cloneNode() to demonstrate a deep copy var rootClone:XMLNode = rootNode.cloneNode(true);...
  • Page 746 (var stringNode:XMLNode = childNode.firstChild; stringNode != null; stringNode = stringNode.nextSibling, j++) { masterArray[i][j] = stringNode.firstChild.nodeValue; To view the entire script, see XML_languagePicker.fla in 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 ActionScript classes...
  • Page 747: Haschildnodes (Xmlnode.haschildnodes Method)

    See also appendChild (XMLNode.appendChild method) insertBefore (XMLNode.insertBefore method) removeNode (XMLNode.removeNode method) hasChildNodes (XMLNode.hasChildNodes method) public hasChildNodes() : Boolean Specifies whether or not the XML object has child nodes. Availability: ActionScript 1.0; Flash Lite 2.0 Returns if the specified XMLNode has one or more child nodes; otherwise Boolean true false...
  • Page 748: Lastchild (Xmlnode.lastchild Property)

    Parameters - The XMLNode object to be inserted. newChild:XMLNode - The XMLNode object that will follow the node after the insertPoint:XMLNode newChild method is invoked. Example The following inserts a new XML node between two existing nodes: var my_xml:XML = new XML("<a>1</a>\n<c>3</c>"); var insertPoint:XMLNode = my_xml.lastChild;...
  • Page 749 doc.appendChild(rootNode); // add each of the child nodes as children of rootNode rootNode.appendChild(oldest); rootNode.appendChild(middle); rootNode.appendChild(youngest); // use lastChild to iterate through the child nodes of rootNode for (var aNode:XMLNode = rootNode.lastChild; aNode != null; aNode = aNode.previousSibling) { trace(aNode); // output: // <youngest />...
  • Page 750: Nextsibling (Xmlnode.nextsibling Property)

    nextSibling (XMLNode.nextSibling property) public nextSibling : XMLNode [read-only] An XMLNode value that references the next sibling in the parent node's child list. This property is if the node does not have a next sibling node. This property cannot be used null to manipulate child nodes;...
  • Page 751 Example The following example creates an element node and a text node, and checks the node name of each: // create an XML document var doc:XML = new XML(); // create an XML node using createElement() var myNode:XMLNode = doc.createElement("rootNode"); // place the new node into the XML tree doc.appendChild(myNode);...
  • Page 752: Nodetype (Xmlnode.nodetype Property)

    nodeType (XMLNode.nodeType property) public nodeType : Number [read-only] value, either 1 for an XML element or 3 for a text node. nodeType is a numeric value from the NodeType enumeration in the W3C DOM Level nodeType 1 recommendation: www.w3.org/tr/1998/REC-DOM-Level-1-19981001/level-one- core.html. The following table lists the values: Integer value Defined constant ELEMENT_NODE...
  • Page 753: Nodevalue (Xmlnode.nodevalue Property)

    var myTextNode:XMLNode = doc.createTextNode("textNode"); // place the new node into the XML tree myNode.appendChild(myTextNode); trace(myNode.nodeType); trace(myTextNode.nodeType); // output: // 1 // 3 See also nodeValue (XMLNode.nodeValue property) nodeValue (XMLNode.nodeValue property) public nodeValue : String The node value of the XML object. If the XML object is a text node, the is 3, and nodeType is the text of the node.
  • Page 754: Parentnode (Xmlnode.parentnode Property)

    // null // myTextNode The following example creates and parses an XML packet. The code loops through each child node, and displays the node value using the property and firstChild . When you use to display contents of the node, it firstChild.nodeValue firstChild maintains the...
  • Page 755: Previoussibling (Xmlnode.previoussibling Property)

    Example The following example creates an XML packet and displays the parent node of the username node in the Output panel: var my_xml:XML = new XML("mortongood&evil"); // first child is the <login /> node var rootNode:XMLNode = my_xml.firstChild; // first child of the root is the <username /> node var targetNode:XMLNode = rootNode.firstChild;...
  • Page 756: Removenode (Xmlnode.removenode Method)

    See also lastChild (XMLNode.lastChild property) appendChild (XMLNode.appendChild method) insertBefore (XMLNode.insertBefore method) removeNode (XMLNode.removeNode method) removeNode (XMLNode.removeNode method) public removeNode() : Void Removes the specified XML object from its parent. Also deletes all descendants of the node. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates an XML packet, and then deletes the specified XML object and its descendant nodes:...
  • Page 757: Xmlui

    For top-level XML objects (those created with the constructor), the method XML.toString() outputs the document's XML declaration (stored in the property), followed by XML.xmlDecl the document's declaration (stored in the property), followed by DOCTYPE XML.docTypeDecl the text representation of all XML nodes in the object. The XML declaration is not output if property is undefined.
  • Page 758 Macromedia Flash MX 2004 and Macromedia Flash MX Professional 2004 come with several extensibility features including Behaviors, Commands (JavaScript API), Effects, and Tools. With these features, advanced users can extend or automate the authoring tool's functionality. The XML to UI engine works with each of these extensibility features to create dialog boxes that the user sees if the extension either requires or accepts parameters.
  • Page 759: Accept (Xmlui.accept Method)

    accept (XMLUI.accept method) public static accept() Makes the current XMLUI dialog exit with an "accept" state. Identical to the user clicking the OK button. Availability: ActionScript 1.0; Flash Lite 2.0 cancel (XMLUI.cancel method) public static cancel() Makes the current XMLUI dialog exit with a "cancel" state. Identical to the user clicking the Cancel button.
  • Page 760 ActionScript classes...
  • Page 761: Chapter 3: Deprecated Actionscript

    While deprecated elements still work in Flash Player 8, Macromedia recommends that you do not continue using deprecated elements in your code. Support of deprecated elements in the future is not guaranteed.
  • Page 762 String.substr(). tellTarget(target:String, Deprecated since Flash Player 5. statement(s)) Macromedia recommends that you use dot (.) notation and the with statement. toggleHighQuality() Deprecated since Flash Player 5. This function was deprecated in favor of _quality.
  • Page 763: Deprecated Property Summary

    != (inequality) operator. (concatenation (strings)) 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. (logical AND) Deprecated since Flash Player 5.
  • Page 764 Operator Description (equality (strings)) Deprecated since Flash Player 5. This operator was deprecated in favor of the == (equality) operator. (greater than or equal to (strings)) Deprecated since Flash Player 5. This operator was deprecated in favor of the >= (greater than or equal to) operator.
  • Page 765: Chapter 4: Unsupported Actionscript

    CHAPTER 4 Unsupported ActionScript Flash Lite 2.0 does not support the following elements: Unsupported Classes Accessibility, Camera, ContextMenu, ContextMenuItem, CustomActions, LocalConnection, Microphone, NetConnection, NetStream, PrintJob, TextField.StyleSheet, TextSnapshot, XMLSocket Unsupported Methods Mouse.hide, Mouse.show, MovieClip.attachAudio, MovieClip.getTextSnapshot, Selection.getBeginIndex, Selection.getCaretIndex, Selection.getEndIndex, Selection.removeListener, Selection.setSelection, System.setClipboard, System.showSettings, TextField.getFontList, TextField.replaceSel, Video.attachVideo, Video.clear Unsupported Properties...
  • Page 766: Unsupported Global Functions

    Unsupported Global Functions asfunction, MMExecute, print, printAsBitmap, printAsBitmapNum, printNum, updateAfterEvent Unsupported Event Handlers onUpdate, Mouse.onMouseWheel Unsupported fscommands allowscale, exec, fullscreen, quit, showmenu, trapallkeys Unsupported ActionScript...
  • Page 767: Index

    Index Symbols >= greater than or equal to operator 148 >> bitwise right shift operator 132 126, 128, 155, 156 >>= bitwise right shift and assignment operator 133 ! logical NOT operator 160 >>> bitwise unsigned right shift operator 134 != inequality operator 152 >>>= bitwise unsigned right shift and assignment !== strict inequality operator 173...
  • Page 768 _rotation property 287, 510, 675 NUMERIC property 256 _soundbuftime property 109, 288, 512, 681 pop() method 256 _target property 290, 518, 685 push() method 257 _totalframes property 519 RETURNINDEXEDARRAY property 257 _url property 292, 521, 689 reverse() method 258 _visible property 293, 522, 690 shift() method 258 _width property 293, 523, 690 slice() method 258...
  • Page 769 Button hasAccessibility property 305 _alpha property 274 hasAudio property 305 _focusrect property 276 hasAudioEncoder property 306 _height property 278 hasCMIDI property 306 _highquality property 278 hasCompoundSound property 306 _name property 278 hasDataLoading property 307 _parent property 286 hasEmail property 307 _quality property 287 hasEmbeddedVideo property 308 _rotation property 287...
  • Page 770 class dispatched by Button 279, 280, 281, 282, 283, data property 587 284, 285 Date dispatched by Key 383, 384 Date() constructor 330 dispatched by LoadVars 400, 401 getDate() method 331 dispatched by Mouse 433, 435, 436 getDay() method 332 dispatched by MovieClip 494, 495, 496, 497, getFullYear() method 332 498, 499, 500, 501, 502, 503, 504, 505...
  • Page 771 default statement 186 delete statement 187 false constant 27 DELETEKEY property 374 firstChild property 745 DESCENDING property 254 floor() method 419 do..while statement 189 flush() method 589 docTypeDecl property 723 focusEnabled property 464 DOWN property 375 font property 701 duplicateMovieClip function 42 for statement 196 duplicateMovieClip() method 461 for..in statement 197...
  • Page 772 getMilliseconds() method 335 gotoAndStop function 52 getMinutes() method 336 gotoAndStop() method 478 getMonth() method 336 gt greater than (strings) operator 148 GetNetworkConnectionName command 231 GetNetworkConnectStatus command 232 GetNetworkGeneration command 233 GetNetworkName command 233 has4WayKeyAS property 305 GetNetworkRequestStatus command 234 hasAccessibility property 305 GetNetworkStatus command 235 hasAudio property 305 getNewTextFormat() method 659...
  • Page 773 implements statement 202 TAB property 388 import statement 203 UP property 389 indent property 704 Key class 370 indexOf() method 631 onKeyDown event 383 Infinity constant 28 onKeyUp event 384 initialize() method 409 INSERT property 380 insertBefore() method 747 instanceof operator 154 language property 315 int function 54 lastChild property 748...
  • Page 774 LoadVars() constructor 399 MAX_VALUE property 546 Locale maxChars property 664 addDelayedInstance() method 408 maxhscroll property 664 addXMLPath() method 408 maxscroll property 106, 665 checkXMLStatus() method 408 mbchr function 63 initialize() method 409 mblength function 64 loadLanguageXML() method 409 mbord function 64 loadString() method 409 mbsubstring function 65 setDefaultLang() method 409...
  • Page 775 createTextField() method 455 onMouseUp event 502 curveTo() method 457 onPress event 502 duplicateMovieClip() method 461 onRelease event 502 enabled property 462 onReleaseOutside event 503 endFill() method 463 onRollOut event 503 focusEnabled property 464 onRollOver event 504 getBounds() method 466 onSetFocus event 504 getBytesLoaded() method 467 onUnload event 505 getBytesTotal() method 468...
  • Page 776 toString() method 549 onReleaseOutside event 284, 503 valueOf() method 549 onResize event 622 Number class 544 onRollOut event 284, 503 Number function 68 onRollOver event 285, 504 Number() constructor 548 onScroller event 668 NUMERIC property 256 onSetFocus event 285, 504, 578, 670 onSoundComplete event 612 onStatus event 593, 643, 713 onUnload event 505...
  • Page 777 removeListener() method 385, 437, 542, 580, 595, setLoadCallback() method 410 623, 673 setMask() method 511 removeMovieClip function 77 setMilliseconds() method 346 removeMovieClip() method 509 setMinutes() method 347 removeNode() method 756 setMonth() method 347 removeTextField() method 674 setNewTextFormat() method 678 replaceText() method 674 setPan() method 613 ResetSoftKeys command 239 setProperty function 81...
  • Page 778 SOFT9 property 366 stopAllSounds function 83 softKeyCount property 318 stopDrag function 84 sort() method 260 stopDrag() method 514 sortOn() method 262 StopVibrate command 243 Sound String attachSound() method 598 charAt() method 628 duration property 598 charCodeAt() method 629 getBytesLoaded() method 600 concat() method 630 getBytesTotal() method 602 fromCharCode() method 630...
  • Page 779 TextField text property 686 _alpha property 651 textColor property 687 _height property 661 textHeight property 687 _highquality property 661 textWidth property 688 _name property 666 type property 688 _parent property 670 variable property 689 _quality property 672 wordWrap property 691 _rotation property 675 TextField class 645 _soundbuftime property 681...
  • Page 780 docTypeDecl property 723 getBytesLoaded() method 724 undefined constant 30 getBytesTotal() method 725 underline property 710 ignoreWhite property 725 unescape function 90 load() method 727 UNIQUESORT property 267 loaded property 729 unloadClip() method 543 parseXML() method 731 unloadMovie function 91 send() method 732 unloadMovie() method 520 sendAndLoad() method 733 unloadMovieNum function 91...

Table of Contents