Flash Lite 2.
Trademarks 1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flash Video Endocer, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are eith
Contents Chapter 1: ActionScript language elements. . . . . . . . . . . . . . . . . 23 Compiler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 #endinitclip directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 #include directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 #initclip directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadMovieNum function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 loadVariables function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 loadVariablesNum function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 mbchr function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 mblength function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
_capSMAF property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 _capSMS property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 _capStreamSound property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 _focusrect property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102 _forceframerate property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
>= greater than or equal to operator . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 ge greater than or equal to (strings) operator . . . . . . . . . . . . . . . . . . 149 ++ increment operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 != inequality operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 <> inequality operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
for statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196 for..in statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 function statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .198 get statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 if statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SetFocusRectColor fscommand2 Command . . . . . . . . . . . . . . . . 240 SetInputTextType fscommand2 Command . . . . . . . . . . . . . . . . . . 240 SetSoftKeys fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . . 241 StartVibrate fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . .243 StopVibrate fscommand2 Command . . . . . . . . . . . . . . . . . . . . . . . .243 Chapter 2: ActionScript classes . . . . . . . . . . . . . . . . . . . . . . . . . 245 arguments . . . . . . . . . .
onDragOver (Button.onDragOver handler) . . . . . . . . . . . . . . . . . . . 280 onKeyDown (Button.onKeyDown handler) . . . . . . . . . . . . . . . . . . . 280 onKeyUp (Button.onKeyUp handler) . . . . . . . . . . . . . . . . . . . . . . . . .281 onKillFocus (Button.onKillFocus handler) . . . . . . . . . . . . . . . . . . . . 282 onPress (Button.onPress handler). . . . . . . . . . . . . . . . . . . . . . . . . . . 283 onRelease (Button.onRelease handler) . . . . . . . . . . . . . . . . . . . . . .
hasMIDI (capabilities.hasMIDI property) . . . . . . . . . . . . . . . . . . . . . 309 hasMMS (capabilities.hasMMS property). . . . . . . . . . . . . . . . . . . . 309 hasMouse (capabilities.hasMouse property) . . . . . . . . . . . . . . . . . 309 hasMP3 (capabilities.hasMP3 property) . . . . . . . . . . . . . . . . . . . . . . 310 hasPrinting (capabilities.hasPrinting property) . . . . . . . . . . . . . . . . 310 hasQWERTYKeyboard (capabilities.hasQWERTYKeyboard property) . . . . . . . . . . . . . .
getLocaleLongDate (Date.getLocaleLongDate method) . . . . . . 334 getLocaleShortDate (Date.getLocaleShortDate method). . . . . . 334 getLocaleTime (Date.getLocaleTime method). . . . . . . . . . . . . . . . 335 getMilliseconds (Date.getMilliseconds method). . . . . . . . . . . . . . . 335 getMinutes (Date.getMinutes method) . . . . . . . . . . . . . . . . . . . . . . . 336 getMonth (Date.getMonth method) . . . . . . . . . . . . . . . . . . . . . . . . . 336 getSeconds (Date.getSeconds method) . . . . . . . .
ExtendedKey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362 SOFT1 (ExtendedKey.SOFT1 property) . . . . . . . . . . . . . . . . . . . . . .364 SOFT10 (ExtendedKey.SOFT10 property). . . . . . . . . . . . . . . . . . . .364 SOFT11 (ExtendedKey.SOFT11 property) . . . . . . . . . . . . . . . . . . . . .364 SOFT12 (ExtendedKey.SOFT12 property). . . . . . . . . . . . . . . . . . . .364 SOFT2 (ExtendedKey.SOFT2 property) . . . . . . . . . . . . . . . . . . . . .
LoadVars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390 addRequestHeader (LoadVars.addRequestHeader method) . . . . . . . . . . . . . . . . . . . 392 contentType (LoadVars.contentType property) . . . . . . . . . . . . . . . 394 decode (LoadVars.decode method) . . . . . . . . . . . . . . . . . . . . . . . . . 394 getBytesLoaded (LoadVars.getBytesLoaded method) . . . . . . . . 395 getBytesTotal (LoadVars.getBytesTotal method) . . . . . . . . . . . . .
round (Math.round method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 sin (Math.sin method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .426 sqrt (Math.sqrt method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427 SQRT1_2 (Math.SQRT1_2 property) . . . . . . . . . . . . . . . . . . . . . . . . .428 SQRT2 (Math.SQRT2 property). . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 tan (Math.tan method) . . . . . . . . . . .
hitArea (MovieClip.hitArea property). . . . . . . . . . . . . . . . . . . . . . . . . 480 hitTest (MovieClip.hitTest method) . . . . . . . . . . . . . . . . . . . . . . . . . . 480 lineStyle (MovieClip.lineStyle method) . . . . . . . . . . . . . . . . . . . . . . . 482 lineTo (MovieClip.lineTo method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 loadMovie (MovieClip.loadMovie method) . . . . . . . . . . . . . . . . . . . 484 loadVariables (MovieClip.loadVariables method). . . . . . . . . . . .
trackAsMenu (MovieClip.trackAsMenu property) . . . . . . . . . . . . . . 519 unloadMovie (MovieClip.unloadMovie method) . . . . . . . . . . . . . . 520 _url (MovieClip._url property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 _visible (MovieClip._visible property) . . . . . . . . . . . . . . . . . . . . . . . . .522 _width (MovieClip._width property). . . . . . . . . . . . . . . . . . . . . . . . . . .523 _x (MovieClip._x property) . . . . . . . . . . . . . . . . . . . . . . . . . .
registerClass (Object.registerClass method) . . . . . . . . . . . . . . . . . . 559 __resolve (Object.__resolve property) . . . . . . . . . . . . . . . . . . . . . . . . 560 toString (Object.toString method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 563 unwatch (Object.unwatch method) . . . . . . . . . . . . . . . . . . . . . . . . . . 565 valueOf (Object.valueOf method). . . . . . . . . . . . . . . . . . . . . . . . . . . . 565 watch (Object.watch method). . . . . . . . . . . . . . . . . . . .
start (Sound.start method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616 stop (Sound.stop method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617 Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618 addListener (Stage.addListener method) . . . . . . . . . . . . . . . . . . . . 620 align (Stage.align property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620 height (Stage.
_highquality (TextField._highquality property) . . . . . . . . . . . . . . . . . .661 hscroll (TextField.hscroll property) . . . . . . . . . . . . . . . . . . . . . . . . . . .661 html (TextField.html property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 662 htmlText (TextField.htmlText property) . . . . . . . . . . . . . . . . . . . . . . 663 length (TextField.length property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 663 maxChars (TextField.maxChars property) . . . . . . . . .
TextFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695 align (TextFormat.align property) . . . . . . . . . . . . . . . . . . . . . . . . . . . .697 blockIndent (TextFormat.blockIndent property) . . . . . . . . . . . . . . .698 bold (TextFormat.bold property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699 bullet (TextFormat.bullet property) . . . . . . . . . . . . . . . . . . . . . . . . . . 699 color (TextFormat.color property) . . . . .
XMLNode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . appendChild (XMLNode.appendChild method) . . . . . . . . . . . . . . . attributes (XMLNode.attributes property) . . . . . . . . . . . . . . . . . . . . childNodes (XMLNode.childNodes property) . . . . . . . . . . . . . . . . . cloneNode (XMLNode.cloneNode method) . . . . . . . . . . . . . . . . . . firstChild (XMLNode.firstChild property) . . . . . . . . . . . . . . . . . . . . .
Contents
CHAPTER 1 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.
#include directive #include "[path]filename.as" — Do not place a semicolon (;) at the end of the line that contains the #include statement. Compiler directive: includes the contents of the specified file, as if the commands in the file are part of the calling script. The #include directive is invoked at compile time. Therefore, if you make any changes to an external file, you must save the file and recompile any FLA files that use it.
Parameters - filename.asThe filename and optional path for the script to add to the Actions panel or to the current script; .as is the recommended filename extension. [path]filename.
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 #initclip code. This is an optional parameter. You must specify the value by using an integer literal (only decimal—not hexidecimal—values are allowed), and not by using a variable.
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 false A unique Boolean value that represents the opposite of true. Infinity Specifies the IEEE-754 value representing positive infinity. -Infinity Specifies the IEEE-754 value representing negative infinity. NaN A predefined variable with the IEEE-754 value for NaN (not a number).
Example This example shows how automatic data typing converts false to a number and to a string: var bool1:Boolean = Boolean(false); // converts it to the number 0 trace(1 + bool1); // outputs 1 // converts it to a string trace("String: " + bool1); // outputs String: false Infinity constant Specifies the IEEE-754 value representing positive infinity. The value of this constant is the same as Number.POSITIVE_INFINITY. Availability: ActionScript 1.0; Flash Lite 2.0 See also POSITIVE_INFINITY (Number.
newline constant Inserts a carriage return character (\r) that generates a blank line in text output generated by your code. Use newline to make space for information that is retrieved by a function or statement in your code. Availability: ActionScript 1.0; Flash Lite 1.1 Example The following example shows how newline displays output from the trace() statement on multiple lines.
true constant A unique Boolean value that represents the opposite of false. When automatic data typing converts true to a number, it becomes 1; when it converts true to a string, it becomes "true". Availability: ActionScript 1.0; Flash Lite 1.1 Example The following example shows the use of true in an if statement: var shouldExecute:Boolean; // ...
In files published for Flash Player 6 or earlier, the value of Number(undefined) is 0. In files published for Flash Player 7 or later, the value of Number(undefined) is NaN. The value undefined is similar to the special value null. When null and undefined are compared with the equality (==) operator, they compare as equal. However, when null and undefined are compared with the strict equality (===) operator, they compare as not equal. Availability: ActionScript 1.0; Flash Lite 1.
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 (Boolean(), int(), and so on), producing debugging information (trace()), and communicating with Flash Player or the browser (fscommand()).
Modifiers Signature Description fscommand(command:String, Lets a SWF file communicate with the Flash Lite player or the environment for a mobile device (such as an operating system). parameters:String) fscommand2(command:String, parameters:String) getProperty(my_mc:Object, property:Object) : Object Lets the SWF file communicate with the Flash Lite player or a host application on a mobile device. Deprecated since Flash Player 5.
Modifiers Signature Description int(value:Number) : 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. isFinite(expression:Object) : Boolean Evaluates expression and returns true if it is a finite number or false if it is infinity or negative infinity. isNaN(expression:Object) : Boolean Evaluates the parameter and returns true if the value is NaN (not a number).
Modifiers Signature Description mbchr(number:Number) Deprecated since Flash Player 5. This function was deprecated in favor of the String.fromCharCode() method. Converts an ASCII code number to a multibyte character. mblength(string:String) : Number Deprecated since Flash Player 5. This function was deprecated in favor of the String.length property. Returns the length of the multibyte character string. mbord(character:String) : Number Deprecated since Flash Player 5.
Modifiers Signature Description ord(character:String) : 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. parseFloat(string:String) : Number Converts a string to a floating-point number. parseInt(expression:String, Converts a string to an integer. [radix:Number]) : Number play() Moves the playhead forward in the Timeline. prevFrame() Sends the playhead to the previous frame.
Modifiers Signature Description stopDrag() Stops the current drag operation. String(expression:Object) : String Returns a string representation of the specified parameter. substring(string:String, Deprecated since Flash Player 5. This function was deprecated in favor of String.substr(). Extracts part of a string.
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 ■ an array with a specific length but whose elements have undefined values ■ an array whose elements have specific values.
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 .
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")); // output: false t
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 call() action, the variables are local and expire at the end of the current list. ■ If variables are not declared inside a block and the current action list was not executed with the call() action, the variables are interpreted as Timeline variables.
clearInterval function clearInterval(intervalID:Number) : Void Cancels an interval created by a call to setInterval(). Availability: ActionScript 1.0; Flash Lite 2.0 Parameters intervalID:Number - A numeric (integer) identifier returned from a call to setInterval(). Example The following example first sets and then clears an interval call: function callback() { trace("interval called: "+getTimer()+" ms.
Parameters target:Object - The target path of the movie clip to duplicate. This parameter can be either 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. newname:String - A unique identifier for the duplicated movie clip. - A unique depth level for the duplicated movie clip. The depth level is a stacking order for duplicated movie clips.
Parameters expression:String - The expression to convert into a string and encode in a URL-encoded format. Returns String - URL-encoded 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 %40 and the dot symbol (.) was replaced with %2E.
In Flash 5 or later, you cannot use eval() to dynamically set and retrieve the value of a variable or instance name, because you cannot useeval() on the left side of an equation. For example, replace the code eval ("var" + i) = "first"; with this: this["var"+i] = "first" or this: set ("var" + i, "first"); Availability: ActionScript 1.0; Flash Lite 1.0 - Flash Player 5 or later for full functionality.
fscommand function fscommand(command:String, parameters:String) : Void The fscommand() function lets a SWF file communicate with the Flash Lite player or the 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 launch application-path, arg1, This command launches another application on a mobile device.
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. The fscommand2() function is similar to the fscommand() function, with the following differences: ■ The fscommand2()function can take any number of arguments. By contrast, fscommand() can take only one argument.
Command Deprecated By GetTimeSeconds getSeconds() method of Date object GetTimeZoneOffset getTimeZoneOffset() method of Date object SetQuality MovieClip._quality Unescape unescape() global function Availability: ActionScript 1.0; Flash Lite 1.1 Parameters - A string passed to the host application for any use, or a command passed to the Flash Lite player. command:String parameters:String - A string passed to the host application for any use, or a value passed to the Flash Lite player.
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 Number - The number of milliseconds that have elapsed since the SWF file started playing. Example In the following example, the getTimer() and setInterval() functions are used to create a simple timer: this.createTextField("timer_txt", this.getNextHighestDepth(), 0, 0, 100, 22); function updateTimer():Void { timer_txt.
[optional] - A GET or POST method for sending variables. If there are no variables, omit this parameter. The GET method appends the variables to the end of the URL, and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for sending long strings of variables. method:String Example This example loads an image into a movie clip. When the image is clicked, a new URL is loaded in a new browser window.
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 String - A string containing Flash Player version and platform information.
Example In the following example, a document has two scenes: sceneOne and sceneTwo. Scene one contains a frame label on Frame 10 called newFrame and two buttons, myBtn_btn and myOtherBtn_btn. This ActionScript is placed on Frame 1, Scene 1 of the main Timeline. stop(); myBtn_btn.onRelease = function(){ gotoAndPlay("newFrame"); }; myOtherBtn_btn.onRelease = function(){ gotoAndPlay("sceneTwo", 1); }; When the user clicks the buttons, the playhead moves to the specified location and continues playing.
Example In the following example, a document has two scenes: sceneOne and sceneTwo. Scene one contains a frame label on Frame 10 called newFrame, and two buttons, myBtn_btn and myOtherBtn_btn. This ActionScript is placed on Frame 1, Scene 1 of the main Timeline: stop(); myBtn_btn.onRelease = function(){ gotoAndStop("newFrame"); }; myOtherBtn_btn.onRelease = function(){ gotoAndStop("sceneTwo", 1); }; When the user clicks the buttons, the playhead moves to the specified location and stops.
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 Math.floor() if the value parameter is positive and Math.ceil() if the value parameter is negative. Availability: ActionScript 1.0; Flash Lite 1.0 Parameters value:Number - A number to be rounded to an integer.
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 true if the value is NaN(not a number). This function is useful for checking whether a mathematical expression evaluates successfully to a number. Availability: ActionScript 1.0; Flash Lite 2.
The following example shows how you can use isNAN() to check whether a mathematical expression contains an error: var dividend:Number; var divisor:Number; divisor = 1; trace( isNaN(dividend/divisor) ); // output: true // The output is true because the variable dividend is undefined. // Do not use isNAN() to check for division by 0 because it will return false. // A positive number divided by 0 equals Infinity (Number.POSITIVE_INFINITY). // A negative number divided by 0 equals -Infinity (Number.
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 MovieClipLoader.loadClip() instead of this function.
Example Usage 1: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called mySquare that already exists on the Stage: 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.
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 loadMovie() instead of loadMovieNum(). Flash Player has a stacking order of levels starting with level 0. These levels are like layers of acetate; they are transparent except for the objects on each level.
method:String [optional] - Specifies an HTTP method for sending variables. The parameter must be the string GET or POST . If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables. Example The following example loads the JPEG image tim.jpg into level 2 of Flash Player: loadMovieNum("http://www.
If you want to load variables into a specific level, use loadVariablesNum() instead of 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 issuing this call is running in a web browser, url must be in the same domain as the SWF file; for details, see the Description section. url:String target:Object - The target path to a movie clip that receives the loaded variables.
See also loadVariablesNum function, loadMovie function, loadMovieNum function, getURL function, loadMovie (MovieClip.loadMovie method), loadVariables (MovieClip.loadVariables method), load (LoadVars.load method) loadVariablesNum function loadVariablesNum(url:String, level:Number [, method:String]) : Void Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, ASP, PHP, or a Perl script, and sets the values for variables in a Flash Player level.
method:String [optional] - Specifies an HTTP method for sending variables. The parameter must be the string GET or POST . If there are no variables to be sent, omit this parameter. The GET method appends the variables to the end of the URL and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for long strings of variables. Example The following example loads information from a text file called params.
Availability: ActionScript 1.0; Flash Lite 1.0 Parameters number:Number - The number to convert to a multibyte character. 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. Returns the length of the multibyte character string. Availability: ActionScript 1.0; Flash Lite 1.0 Parameters string:String - The string to measure.
Returns Number - The converted character. 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; Flash Lite 1.0 Parameters value:String - The multibyte string from which to extract a new multibyte string.
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.
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(); if (init == undefined) { this.createEmptyMovieClip("nextscene_mc", this.getNextHighestDepth()); nextscene_mc.createTextField("nextscene_txt", this.getNextHighestDepth(), 200, 0, 100, 22); nextscene_mc.nextscene_txt.autoSize = true; nextscene_mc.nextscene_txt.
Number function Number(expression) : Number Converts the parameter expression to a number and returns a value as described in the following list: ■ If expression is a number, the return value is expression. ■ If expression is a Boolean value, the return value is 1 if expression is true, 0 if expression is false. ■ If expression is a string, the function attempts to parse expression as a decimal number with an optional trailing exponent (that is, 1.57505e-3).
Object function Object( [value] ) : Object Creates a new empty object or converts the specified number, string, or Boolean value to an object. This command is equivalent to creating an object using the Object constructor (see "Constructor for the Object class"). Availability: ActionScript 1.0; Flash Lite 2.0 Parameters value:Object [optional] - A number, string, or Boolean value. Returns Object - An object.
Parameters mouseEvent:Object - A mouseEvent is a trigger called an event . When the event occurs, the statements following it within curly braces ({ }) execute. Any of the following values can be specified for the mouseEvent parameter: The mouse button is pressed while the pointer is over the button. ■ press ■ release ■ releaseOutside While the pointer is over the button, the mouse button is pressed, rolled outside the button area, and released.
Example In the following script, the startDrag() function executes when the mouse is pressed, and 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, Key onClipEvent handler onClipEvent(movieEvent:Object) { // your statements here } Triggers actions defined for a specific instance of a movie clip. Availability: ActionScript 1.
■ mouseDown The action is initiated when the left mouse button is pressed. Note: This event is supported in Flash Lite only if System.capabilities.hasMouse is true or System.capabilities.hasStylus is true. ■ The action is initiated when the left mouse button is released. Note: This event is supported in Flash Lite only if System.capabilities.hasMouse is true or System.capabilities.hasStylus is true.
See also Key, _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; Flash Lite 1.0 Parameters character:String - The character to convert to an ASCII code number. Returns Number - The ASCII code number of the specified character.
Example The following examples use the parseFloat() function to evaluate various types of numbers: 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.
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 radix parameter 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 representation
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 myBtn_btn and the following ActionScript is placed on a frame in the Timeline for that button, the playhead is sent to the previous frame: stop(); this.myBtn_btn.onRelease = function(){ prevFrame(); }; See also nextFrame function, prevFrame (MovieClip.
Returns Number - A random integer. Example The following use of random() returns a value of 0, 1, 2, 3, or 4: 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 or the instance name of a movie clip created with MovieClip.attachMovie(), MovieClip.duplicateMovieClip(), or MovieClip.createEmptyMovieClip().
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, ...
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 setInterval() calls the callback1() function, which contains a trace() statement. The second call to setInterval() passes the "interval called" string to the function callback2() as a parameter.
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 any setInterval() function running within it. Always remove the setInterval() function by using clearInterval() when you have finished using it, as shown in the following example: // create an event listener object for our MovieClipLoader instance var listenerObjectbject = new Object(); listenerObject.
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+" is "+getTimer()/1000+" seconds old, happy birthday.
See also getProperty function startDrag function startDrag(target:Object [, lock:Boolean, left:Number, top:Number, right:Number, bottom:Number]) : Void Makes the target movie clip draggable while the movie plays. Only one movie clip can be dragged at a time. After a startDrag() operation is executed, the movie clip remains draggable until it is explicitly stopped by stopDrag() or until a startDrag() action for another movie clip is called. Note: This method is supported in Flash Lite only if System.
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) stopAllSounds function stopAllSounds() : Void Stops all sounds currently playing in a SWF file without stopping the playhead.
/* 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 stopDrag() : Void Stops the current drag operation. Note: This method is supported in Flash Lite only if System.capabilities.hasMouse is true or System.
String function String(expression:Object) : String Returns a string representation of the specified parameter, as described in the following list: ■ If expression is a number, the return string is a text representation of the number. ■ If expression is a string, the return string is expression. ■ If expression is an object, the return value is a string representation of the object generated by calling the string property for the object or by calling Object.toString() if no such property exists.
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 string:String index:Number - The string from which to extract the new string. - The number of the first character to extract.
Returns String - A string containing the target path of the specified object. Example The following example traces the target path of a movie clip as soon as it loads: this.createEmptyMovieClip("myClip_mc", this.getNextHighestDepth()); trace(targetPath(myClip_mc)); // _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 the with statement.
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") { gotoAndPlay(2); } } The following example uses dot (.) notation to achieve the same results: on(release) { _parent.ball.
Example The following code could be applied to a button that, when clicked, would toggle antialiasing 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 trace() function and write that output to the log file. Statement; evaluates the expression and displays the result in the Output panel in test mode.
Example The following example uses a trace() statement to display in the Output panel the methods 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 error_txt.condenseWhite = false ... error_txt.maxscroll = 1 error_txt.
unloadMovie function unloadMovie(target:MovieClip) : Void unloadMovie(target:String) : Void Removes a movie clip that was loaded by means of loadMovie() from Flash Player. To unload a movie clip that was loaded by means of loadMovieNum(), use unloadMovieNum() instead of unloadMovie(). Availability: ActionScript 1.0; Flash Lite 1.1 Parameters target - The target path of a movie clip. This parameter can be either a String (e.g. "my_mc") or a direct reference to the movie clip instance (e.g. my_mc).
Availability: ActionScript 1.0; Flash Lite 1.1 Parameters level:Number - The level (_level N ) of a loaded movie. Example The following example loads an image into a SWF file. When you click unload_btn, the loaded content is removed. loadMovieNum("yourimage.jpg", 1); unload_btn.onRelease = function() { unloadMovieNum(1); } See also loadMovieNum function, unloadMovie function, loadMovie (MovieClip.
Modifiers Property Description _capCompoundSound Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the System.capabilities.hasCompoundSound property. Indicates whether Flash Lite can process compound sound data. _capEmail Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the System.capabilities.hasEmail property. Indicates whether the Flash Lite client can send email messages by using the GetURL() ActionScript command.
Modifiers 94 Property Description _capSMAF Deprecated since Flash Lite Player 2.0. This 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; if not, this variable is undefined. _capSMS Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the System.capabilities.hasSMS property.
Modifiers Property Description _parent Specifies or returns a reference to the movie clip or object that contains the current movie clip or object. _quality Sets or retrieves the rendering quality used for a movie clip. _root Specifies or returns a reference to the root movie clip Timeline. scroll 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.
_cap4WayKeyAS property _cap4WayKeyAS Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the System.capabilities.has4WayKeyAS property. 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).
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. This variable defines whether the Flash Lite player supports this ability on the current handset. Availability: ActionScript 1.
See also capabilities (System.capabilities) _capLoadData property _capLoadData Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the System.capabilities.hasDataLoading property. Numeric variable; indicates whether the host application can dynamically load additional data through calls to the loadMovie(), loadMovieNum(), loadVariables(), and loadVariablesNum() functions. If so, this variable is defined and has a value of 1; if not, this variable is undefined.
Example If the device can play MFi sound data, the following example sets canMFi to 1: 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. This action was deprecated in favor of the System.capabilities.hasMIDI property.
Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the System.capabilities.hasMMS property. Numeric variable; indicates whether Flash Lite can send Multimedia Messaging Service (MMS) messages by using the GetURL() ActionScript command. If so, this variable is defined and has a value of 1; if not, this variable is undefined. Availability: ActionScript 1.0; Flash Lite 1.1 Example The following example sets canMMS to 1 in Flash Lite 1.1, but leaves it undefined in Flash Lite 1.
Example The following example sets canSMAF to 1 in Flash Lite 1.1, but leaves it undefined in Flash 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 tellTarget("buttons") { gotoAndPlay(2); } } See also capabilities (System.capabilities) _capSMS property _capSMS Deprecated since Flash Lite Player 2.0.
See also capabilities (System.capabilities) _capStreamSound property _capStreamSound Deprecated since Flash Lite Player 2.0. This action was deprecated in favor of the System.capabilities.hasStreamingAudio property. 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; Flash Lite 1.
If the global _focusrect property is set to false, the default behavior for all buttons and 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 _focusrect to true. To restore full keyboard functionality for a specific button or movieclip, you can override this global property by using either Button._focusrect or MovieClip._focusrect.
_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.
_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. Availability: ActionScript 1.0; Flash Lite 1.
Example The following example stops the playhead in the main timeline of the SWF file sub.swf that is loaded into _level9. The sub.swf file contains animation and is in the same directory as the document that contains the following ActionScript: loadMovieNum("sub.swf", 9); myBtn_btn.onRelease = function() { _level9.stop(); }; You could replace _level9.stop() in the previous example with the following code: _level9.
Example In the following example, there is a movie clip on the Stage with the instance name square_mc. Within that movie clip is another movie clip with an instance name circle_mc. The following ActionScript lets you modify the circle_mc parent instance (which is square_mc) when the circle is clicked. When you are working with relative addressing (using _parent instead of _root), it might be easier to use the Insert Target Path button in the Actions panel at first. this.square_mc.circle_mc.
_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 _root, _level1 is returned. Specifying _root is the same as using the deprecated slash notation (/) to specify an absolute path within the current level.
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. The scroll property is useful for directing users to a specific paragraph in a long passage or creating scrolling text fields. This property can be retrieved and modified.
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 _soundbuftime property is set to buffer the MP3 for 10 seconds. A new Sound object instance is created for the MP3. // create text fields to hold debug information. this.createTextField("counter_txt", this.getNextHighestDepth(), 0, 0, 100, 22); this.createTextField("debug_txt", this.
Because this is evaluated in the context of the script that contains it, you can't use this in a 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"; function conctStr(x:String):String { return x+x; } function addStr():String { return str; } } Then, in a FLA or AS file, add the following ActionScript: var obj:ApplyThis = new ApplyThis(); var abj:ApplyThis = new ApplyThis(); abj.
Example In the following example, the keyword this references the Circle object: 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. // sets the alpha property of the current movie clip to 20 this._alpha = 20; In the following statement inside a MovieClip.
Operator Description = (assignment) Assigns the value of expression2 (the parameter on the right) to the variable, array element, or property in expression1. & (bitwise AND) Converts expression1 and expression2 to 32-bit unsigned integers, and performs a Boolean AND operation on each bit of the integer parameters. &= (bitwise AND assignment) Assigns expression1 the value of expression1& expression2.
Operator Description ^ (bitwise XOR) Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression2 , but not both, are 1. ^= (bitwise XOR assignment) Assigns expression1 the value of expression1 ^ expression2. /* (block comment delimiter) Indicates one or more lines of script comments. , (comma) Evaluates expression1 , then expression2 , and so on.
Operator Description gt (greater than (strings)) Deprecated since Flash Player 5. This operator was deprecated in favor of the > (greater than) operator. Compares the string representation of expression1 with the string representation of expression2 and returns true if expression1 is greater than expression2, false otherwise.
Operator Description le (less than or equal to Deprecated since Flash Player 5. This operator was deprecated in Flash 5 in favor of the <= (less than or equal to) operator. Returns true if expression1 is less than or equal to expression2, false otherwise. (strings)) // (line comment delimiter) Indicates the beginning of a script comment. && (logical AND) Performs a Boolean operation on the values of one or both of the expressions. and (logical AND) Deprecated since Flash Player 5.
Operator Description {} (object initializer) Creates a new object and initializes it with the specified name and value property pairs. () (parentheses) Performs a grouping operation on one or more parameters, performs sequential evaluation of expressions, or surrounds one or more parameters and passes them as parameters to a function outside the parentheses.
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 var1 = 1 + 2 // output: 3). For Flash Lite 1.x, you must use the add operator to concatenate strings. Availability: ActionScript 1.0; Flash Lite 1.0 - In Flash 4, + is a numeric operator only.
Usage 3: Variables associated with dynamic and input text fields have the data type String. In the following example, the variable deposit is an input text field on the Stage. After a user enters a deposit amount, the script attempts to add deposit to oldBalance. However, because deposit is a String data type, the script concatenates (combines to form one string) the variable values rather than summing them. var oldBalance:Number = 1345.23; var currentBalance = deposit_txt.
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; var y:Number = 10; x += y; trace(x); // output: 15 See also + addition operator [] array access operator myArray = [ a0, a1,...
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. The following lines of code send the number 6 to the Output panel.
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 employee_array and uses the trace() statement to send the elements to the Output panel.
= assignment operator expression1 = expression2 Assigns the value of expression2 (the parameter on the right) to the variable, array element, or property in expression1. Assignment can be either by value or by reference. Assignment by value copies the actual value of expression2 and stores it in expression1. Assignment by value is used when a variable is assigned a number or string literal. Assignment by reference stores a reference to expression2 in expression1.
The following example uses assignment by reference to create a new object, and assign a reference to that object to the variable mercury. Assignment by value is then used to assign the value of 3030 to the diameter property of the mercury object: var mercury:Object = new Object(); mercury.diameter = 3030; // in miles trace (mercury.
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. However, Flash Lite 1.x supports the AND (&) operator for concatenating strings. Operands expression1 : Number - A number. expression2 : Number - A number. Returns Number - The result of the bitwise operation.
&= bitwise AND assignment operator expression1 &= expression2 Assigns expression1 the value of expression1& expression2. For example, the following two expressions are equivalent: x &= y; x = x & y; Availability: ActionScript 1.0; Flash Lite 2.0 Operands expression1 : Number - A number. expression2 : Number - A number. Returns Number - The value of expression1 & expression2 .
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.
<<= bitwise left shift and assignment operator expression1 <<= expression2 This operator performs a bitwise left shift (<<=) operation and stores the contents as a result in expression1. The following two expressions are equivalent: A <<= BA = (A << B) Availability: ActionScript 1.0; Flash Lite 2.0 Operands expression1 : Number - A number or expression to be shifted left. expression2 : Number - A number or expression that converts to an integer from 0 to 31.
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. 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.
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 expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point.
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 expression1 the value of expression1 | expression2. For example, the following two statements are equivalent: x |= y; and x = x | y; Availability: ActionScript 1.0; Flash Lite 2.0 Operands expression1 : Number - A number or variable.
>> bitwise right shift operator expression1 >> expression2 Converts expression1 and expression2 to 32-bit integers, and shifts all the bits in expression1 to the right by the number of places specified by the integer that results from the conversion of expression2 . Bits that are shifted off the right end are discarded.
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.
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 >> bitwise right shift operator >>> bitwise unsigned right shift operator expression1 >>> expression2 The same as the bitwise right shift (>>) operator except that it does not preserve the sign of the
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.
^ bitwise XOR operator expression1 ^ expression2 Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression2, but not both, are 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point. The result is a new 32-bit integer.
^= bitwise XOR assignment operator expression1 ^= expression2 Assigns expression1 the value of expression1 ^ expression2. For example, the following two statements are equivalent: x ^= y x = x ^ y Availability: ActionScript 1.0; Flash Lite 2.0 Operands expression1 : Number - Integers and variables. expression2 : Number - Integers and variables. Returns Number - The result of the bitwise operation.
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 singleline comments. Use the /* comment delimiter to identify comments on multiple successive lines. Leaving off the closing tag (*/) when using this form of comment delimiter returns an error message.
Operands expression1 : Number - An expression to be evaluated. expression2 : Number - An expression to be evaluated. expressionN : Number - Any number of additional expressions to be evaluated. Returns Object - The value of expression1, expression2, and so on.
The following example is identical to the previous example except for the addition of the parentheses () operator and illustrates once again that, when used with the parentheses () operator, the comma (,) operator returns the value of the last expression in the series: var v:Number = 0; var z:Number = 0; v = (v + 4, z++, v + 6); trace(v); // output: 6 trace(z); // output: 1 See also () parentheses operator add concatenation (strings) operator string1 add string2 Deprecated since Flash Player 5.
?: conditional operator expression1 ? expression2 : expression3 Instructs Flash to evaluate expression1, and if the value of expression1 is true, it returns the value of expression2; otherwise it returns the value of expression3. Availability: ActionScript 1.0; Flash Lite 1.0 Operands - expression1 An expression that evaluates to a Boolean value; usually a comparison expression, such as x < 5. expression1 : Object expression2 : Object - Values of any type. expression3 : Object - Values of any type.
-- decrement operator --expression expression-- A pre-decrement and post-decrement unary operator that subtracts 1 from the expression . The expression can be a variable, element in an array, or property of an object. The predecrement form of the operator (--expression) subtracts 1 from expression and returns the result. The post-decrement form of the operator (expression--) subtracts 1 from the expression and returns the initial value of expression (the value prior to the subtraction).
Operands expression : Number - A number or a variable that evaluates to a number. Returns Number - The floating-point result of the operation. Example The following statement divides the current width and height of the Stage, and then displays the result in the Output panel. trace(Stage.width/2); trace(Stage.height/2); For a default Stage width and height of 550 x 400, the output is 275 and 150.
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. Availability: ActionScript 1.0; Flash Lite 1.
The following example creates a new movie clip within the _root scope. Then a text field is created inside the movie clip called container_mc. The text field's autoSize property is set to true and then populated with the current date. this.createEmptyMovieClip("container_mc", this.getNextHighestDepth()); this.container_mc.createTextField("date_txt", this.getNextHighestDepth(), 0, 0, 100, 22); this.container_mc.date_txt.autoSize = true; this.container_mc.date_txt.text = new Date(); The dot (.
Example The following example uses the equality (==) operator with an if 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"; trace(x == y); // output: true var x:String = "5"; var y:String = "66"; trace(x == y); // output: false var x:String = "chris"; var y:String = "steve"; trace(x == y); // output: false The following examples show comparison
Compares two expressions for equality and returns a value of true if the string representation of expression1 is equal to the string representation of expression2, false otherwise. Availability: ActionScript 1.0; Flash Lite 1.0 Operands expression1 : Object - Numbers, strings, or variables. expression2 : Object - Numbers, strings, or variables. Returns Boolean - The result of the comparison.
Example In the following example, the greater than (>) operator is used to determine whether the value of the text field score_txt is greater than 90: 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. This operator was deprecated in favor of the > (greater than) 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. The following illustrates the conversion of a Flash 4 file containing a numeric quality comparison.
Returns Boolean - The result of the comparison. See also >= greater than or equal to operator ++ increment operator ++expression expression++ A pre-increment and post-increment unary operator that adds 1 to expression . The expression can be a variable, element in an array, or property of an object. The preincrement form of the operator (++expression) adds 1 to expression and returns the result.
Example The following example uses ++ as a post-increment operator to make a while loop run five 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 */ The following example uses ++ as a pre-increment operator: var a:Array = new Array(); var i:Number = 0; while (i < 10) { a.push(++i); } trace(a.
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 expression1 is equal to expression2 , the result is false. As with the equality (==) operator, the definition of equal depends on the data types being compared, as illustrated in the following list: ■ Numbers, strings, and Boolean values are compared by value.
The following example illustrates the use of the inequality (!=) operator in an if statement: var a:String = "David"; var b:String = "Fool"; if (a != b) { trace("David is not a fool"); } The following example illustrates comparison by reference with two functions: var a:Function = function() { trace("foo"); }; var b:Function = function() { trace("foo"); }; a(); // foo b(); // foo trace(a != b); // true a = b; a(); // foo b(); // foo trace(a != b); // false // trace statement output: foo foo true foo foo fa
Tests for the exact opposite of the equality (==) operator. If expression1 is equal to expression2, the result is false. As with the equality (==)operator, the definition of equal depends on the data types being compared: ■ Numbers, strings, and Boolean values are compared by value. ■ Objects, arrays, and functions are compared by reference. ■ Variables are compared by value or by reference depending on their type. Availability: ActionScript 1.0; Flash Lite 1.
Returns - If object is an instance of or a subclass of classConstructor, instanceof returns true, otherwise it returns false. Also, _global instanceof Object returns false. Boolean See also typeof operator < less than operator expression1 < expression2 Compares two expressions and determines whether expression1 is less than expression2; if so, the operator returns true. If expression1 is greater than or equal to expression2, the operator returns false.
Example The following examples show true and false returns for both numeric and string 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" < "abc"); // true trace("A" < "a"); // true lt less than (strings) operator expression1 lt expression2 Deprecated since Flash Player 5. This operator was deprecated in favor of the < (less than) 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. The following illustrates the conversion of a Flash 4 file containing a numeric quality comparison.
Operands expression1 : Object - Numbers, strings, or variables. expression2 : Object - Numbers, strings, or variables. Returns Boolean - The result of the comparison. See also <= less than or equal to operator // line comment delimiter operator // comment Indicates the beginning of a script comment. Any characters that appear between the comment delimiter (//) and the end-of-line character are interpreted as a comment and ignored by the ActionScript interpreter. Availability: ActionScript 1.
Performs a Boolean operation on the values of one or both of the expressions. Evaluates expression1 (the expression on the left side of the operator) and returns false if the expression evaluates to false. If expression1 evaluates to true, expression2 (the expression on the right side of the operator) is evaluated. If expression2 evaluates to true, the final result is true; otherwise, it is false.
and logical AND operator condition1 and condition2 Deprecated since Flash Player 5. Macromedia recommends that you use the logical AND (&&) operator. Performs a logical AND (&&) operation in Flash Player 4. If both expressions evaluate to true, the entire expression is true. Availability: ActionScript 1.0; Flash Lite 1.0 Operands condition1 : Boolean - condition1,condition2 Conditions or expressions that evaluate to true or false.
Example In the following example, the variable happy is set to false. The if condition evaluates the condition !happy, and if the condition is true, the trace() statement sends a string to the Output panel. var happy:Boolean = false; if (!happy) { trace("don't worry, be happy"); //traces don't worry, be happy } The statement traces because !false equals true.
|| logical OR operator expression1 || expression2 Evaluates expression1 (the expression on the left side of the operator) and returns true if the expression evaluates to true. If expression1 evaluates to false, expression2 (the expression on the right side of the operator) is evaluated. If expression2 evaluates to false, the final result is false; otherwise, it is true. If you use a function call as expression2, the function will not be executed by that call if expression1 evaluates to true.
The following example demonstrates how using a function call as expression2 can lead to unexpected results. If the expression on the left of the operator evaluates to true, that result is returned without evaluating the expression on the right (the function fx2() is not called).
% modulo operator expression1 % expression2 Calculates the remainder of expression1 divided by expression2. If either of the expression parameters are non-numeric, the modulo (%) operator attempts to convert them to numbers. The expression can be a number or string that converts to a numeric value. The sign of the result of modulo operation matches the sign of the dividend (the first number). For example, -4 % 3 and -4 % -3 both evaluate to -1. Availability: ActionScript 1.0; Flash Lite 1.
Availability: ActionScript 1.0; Flash Lite 1.0 - In Flash 4 files, the % operator is expanded in the SWF file as x - int(x/y) * y and may not be as fast or as accurate in later versions of Flash Player. Operands expression1 : Number - A number or expression that evaluates to a number. expression2 : Number - A number or expression that evaluates to a number. Returns Number - The result of the arithmetic operation.
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 expression1 the value of expression1 * expression2. For example, the following two expressions are equivalent: x *= y x = x * y Availability: ActionScript 1.0; Flash Lite 1.
new operator new constructor() Creates a new, initially anonymous, object and calls the function identified by the constructor parameter. The new operator passes to the function any optional parameters in parentheses, as well as the newly created object, which is referenced using the keyword this. The constructor function can then use this to set the variables of the object. Availability: ActionScript 1.0; Flash Lite 2.0 Operands - A function followed by any optional parameters in parentheses.
Operands expression1 : Object - Numbers, strings, or variables. expression2 : Object - Numbers, strings, or variables. Returns Boolean - Returns true if expression1 is not equal to expression2; false otherwise. See also != inequality operator {} object initializer operator object = { name1 : value1 , name2 : value2 ,... nameN : valueN } {expression1; [...expressionN]} Creates a new object and initializes it with the specified name and value property pairs.
The following example creates an object account and initializes the properties name, address, city, state, zip, and balance with accompanying values: var account:Object = {name:"Macromedia, Inc.", address:"600 Townsend Street", city:"San Francisco", state:"California", zip:"94103", balance:"1000"}; for (i in account) { trace("account.
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. Usage 2: Evaluates a series of expressions, separated by commas, in sequence, and returns the result of the final expression.
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 if both expressions, including their data types, are equal. The definition of equal depends on the data type of the parameter: ■ Numbers and Boolean values are compared by value and are considered equal if they have the same value.
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); // true // Automatic data typing in this example converts 5 to "5" var string1:String = "5"; var num:Number = 5; trace(string1 == num); // true trace(string1 === num); // false // Automatic data typing in this exa
!== 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. If expression1 is equal to expression2, and their data types are equal, the result is false.
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. Availability: ActionScript 1.0; Flash Lite 1.0 Operands text : String - A sequence of zero or more characters.
Availability: ActionScript 1.0; Flash Lite 1.0 Operands expression1 : Number - A number or expression that evaluates to a number. expression2 : Number - A number or expression that evaluates to a number. Returns Number - An integer or floating-point number. Example Usage 1: The following statement reverses the sign of the expression 2 + 3: trace(-(2+3)); // output: -5 Usage 2: The following statement subtracts the integer 2 from the integer 5: trace(5-2); // output: 3 The result, 3, is an integer.
Example The following example uses the subtraction assignment (-=) operator to subtract 10 from 5 and assign the result to the variable x: 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"; var y:String = "10"; x -= y; trace(x); // output: -5 See also - subtraction operator : type operator [ modifiers ] var variableName : type function functionName () : type { ...
Example Usage 1: The following example declares a public variable named userName whose type is 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 randomInt() that takes a parameter named integer of type Number: function randomInt(integer:Number):Number { return Math.round(Math.
Expression Type Result Button object Text field object Number number Boolean boolean Object object Function function See also instanceof operator void operator void expression The void operator evaluates an expression and then discards its value, returning undefined. The void operator is often used in comparisons using the == operator to test for undefined values. Availability: ActionScript 1.0; Flash Lite 2.0 Operands expression : Object - An expression to be evaluated.
Statement Description class Defines a custom class, which lets you instantiate objects that share methods and properties that you define. 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. default Defines the default case for a switch statement.
Statement Description public Specifies that a variable or function is available to any caller. return Specifies the value returned by a function. set Permits implicit setting of properties associated with objects based on classes you have defined in external class files. set variable Assigns a value to a variable. static Specifies that a variable or function is created only once per class rather than being created in every object based on that class.
Example The following example uses the break statement to exit an otherwise infinite loop: var i:Number = 0; while (true) { trace(i); if (i >= 10) { break; // this will terminate/exit the loop } i++; } which traces the following output: 0 1 2 3 4 5 6 7 8 9 10 See also for statement case statement case expression : statement(s) Defines a condition for the switch statement.
Parameters expression:String - Any expression. Example The following example defines conditions for the switch statement thisMonth. If thisMonth equals the expression in the case statement, the statement executes. var thisMonth:Number = new Date().
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. If a class is within a package, the class declaration must use the fully qualified class name of the form base.sub1.sub2.MyClass.
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; this.
In an external script file or in the Actions panel, use the new 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.
In a for loop, continue causes the Flash interpreter to skip the rest of the loop body. In the following example, if the i modulo 3 equals 0, then the trace(i) statement is skipped: trace("example 3"); for (var i = 0; i < 10; i++) { if (i % 3 == 0) { continue; } trace(i); } In the following for..
Example In the following example, the expression A does not equal the expressions B or D, so the statement following the default keyword is run and the trace() statement is sent to the Output panel. var dayOfWeek:Number = new Date().
The delete operator can fail and return false if the reference parameter does not exist or cannot be deleted. You cannot delete predefined objects and properties, nor can you delete variables that are declared within a function with the var statement. You cannot use the delete operator to remove movie clips. Availability: ActionScript 1.0; Flash Lite 2.0 Returns Boolean - A Boolean value. Parameters reference:Object - The name of the variable or object to eliminate.
Usage 4: The following example shows the behavior of delete on object references: 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); //output: ref2.name Jody If ref1 had not been copied into ref2, the object would have been deleted when ref1 was deleted because there would be no references to it.
Example The following example uses a do..while loop to evaluate whether a condition is true, and traces myVar until myVar is greater than 5. When myVar is greater than 5, the loop ends. var myVar:Number = 0; do { trace(myVar); myVar++; } while (myVar < 5); /* output: 0 1 2 3 4 */ See also break statement dynamic statement dynamic class className [ extends superClass ] [ implements interfaceName[, interfaceName...
Example In the following example, class Person2 has not yet been marked as dynamic, so calling an 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; this.
else statement if (condition){ statement(s); } else { statement(s); } Specifies the statements to run if the condition in the if statement returns false. The curly braces ({}) used to enclose the block of statements to be executed by the else statement are not necessary if only one statement will execute. Availability: ActionScript 1.0; Flash Lite 1.0 Parameters condition:Boolean - An expression that evaluates to true or false.
Parameters condition:Boolean - An expression that evaluates to true or false. Example The following example uses else if statements to compare score_txtto a specified value: if (score_txt.text>90) { trace("A"); } else if (score_txt.text>75) { trace("B"); } else if (score_txt.
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"); } function reverse():Void { trace("[Vehicle] reverse"); } } The following example shows a second AS file, called Car.
The following example instantiates a Car object, calls a method defined in the Vehicle class (start()), then calls the method overridden by the Car class (stop()), and finally calls a method from the Car class (activateCarAlarm()): var myNewCar:Car = new Car(2, "Red", true); myNewCar.start(); // output: [Vehicle] start myNewCar.stop(); // output: [Car] stop with anti-lock brakes myNewCar.
for statement for(init; condition; next) { statement(s); } Evaluates the init (initialize) expression once and then starts a looping sequence. The looping sequence begins by evaluating the condition expression. If the condition expression evaluates to true, statement is executed and the next expression is evaluated. The looping sequence then begins again with the evaluation of the condition expression.
for..in statement for (variableIterant in object) { ] statement(s); } Iterates over the properties of an object or elements in an array and executes the statement for each property or element. Methods of an object are not enumerated by the for..in action. Some properties cannot be enumerated by the for..in action. For example, movie clip properties, such as _x and _y, are not enumerated. In external class files, static members are not enumerable, unlike instance members. The for..
The following example shows using for..in to iterate over the elements of an array: 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 typeof operator with for..
You can use this statement to define a function with the specified functionname, parameters, and statement(s). When a script calls a function, the statements in the function's definition are executed. Forward referencing is permitted; within the same script, a function may be declared after it is called. A function definition replaces any prior definition of the same function. You can use this syntax wherever a statement is permitted.
The following function creates a LoadVars object and loads params.txt into the SWF file. When the file successfully loads, variables loaded traces: 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.
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 get method to return the value of the property. See also addProperty (Object.addProperty method) if statement if(condition) { statement(s); } Evaluates a condition to determine the next action in a SWF file.
The following example uses an if statement to evaluate how long it takes a user to click the submit_btninstance in a SWF file. If a user clicks the button more than 10 seconds after the SWF file plays, the condition evaluates to true and the message inside the curly braces ({}) appears in a text field that's created at runtime (using createTextField()). If the user clicks the button less than 10 seconds after the SWF file plays, the condition evaluates to false and a different message appears. this.
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. Lets you access classes without specifying their fully qualified names. For example, if you want to use a custom class macr.util.users.
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. Defines an interface.
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()); // 15 trace(mvar.n(7)); // 49 trace(mvar.
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, and String. This keyword indicates to the compiler that no function implementation is required, and that no bytecode should be generated for it.
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.
Example The following example demonstrates how you can hide certain properties within a class using the private keyword. Create a new AS file called Login.as. 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.
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. Availability: ActionScript 2.0; Flash Lite 2.0 Parameters name:String - The name of the variable or function that you want to specify as public.
Availability: ActionScript 1.0; Flash Lite 2.0 Returns String - The evaluated expression parameter, if provided. Parameters - A string, number, Boolean, array, or object to evaluate and return as a value of the function. This parameter is optional. expression Example The following example uses the return statement inside the body of the sum() function to return the added value of the three parameters. The next line of code calls sum() and assigns the returned value to the variable newValue.
Example The following example creates a Login class that demonstrates how the set 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; } public function set username(param_username:String):Void { this.
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 set statement. If you use this statement to set a variable to a value whose data type is different from the data type associated with the variable in a class file, no compiler error is generated.
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.
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 superclass version of a method, and can optionally pass parameters (arg1 .
switch statement switch (expression){caseClause: [defaultClause:] } Creates a branching structure for ActionScript statements. As with the if statement, the switch statement tests a condition and executes statements if the condition returns a value oftrue. All switch statements should include a default case. The default case should include a break statement that prevents a fall-through error if another case is added later. When a case falls through, it doesn't have a break statement.
See also === strict equality operator throw statement throw expression Generates, or throws, an error that can be handled, or caught, by a catch{} code block. If an exception is not caught by a catch block, the string representation of the thrown value is sent to the Output panel. Typically, you throw instances of the Error class or its subclasses (see the Example section). Availability: ActionScript 1.0; Flash Lite 2.0 Parameters expression:Object - An ActionScript expression or object.
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); error_txt.autoSize = true; error_txt.text = e.toString(); } See also Error try..catch..finally statement try {// ... try block ... } finally { // ... finally block ...
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 catch block that handles the corresponding error is executed. If an exception that is not of the specified type is thrown, the catch block does not execute and the exception is automatically thrown out of the try block to a catch handler that matches it.
In the following example, the finally block is used to delete an ActionScript object, 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; var account:Account = new Account(); try { var returnVal = account.
The following example shows a try code block with multiple, typed catch code blocks. Depending on the type of error that occurred, the try code block throws a different type of object. In this case, myRecordSet is an instance of a (hypothetical) class named RecordSet whose sortRows() method can throw two types of errors, RecordSetException and MalformedRecord. In the following example, the RecordSetException and MalformedRecord objects are subclasses of the Error class.
Finally, in another AS file or FLA script, the following code invokes the sortRows() method on an instance of the RecordSet class. It defines catch blocks for each type of error that is thrown by sortRows() import RecordSet; var myRecordSet:RecordSet = new RecordSet(); try { myRecordSet.sortRows(); trace("everything is fine"); } catch (e:RecordSetException) { trace(e.toString()); } catch (e:MalformedRecord) { trace(e.toString()); } See also Error var statement var variableName [= value1][...
Parameters variableName:String - An identifier. Example The following ActionScript creates a new array of product names. Array.push adds an element onto the end of the array. If you want to use strict typing, it is essential that you use the var keyword. Without var before product_array, you get errors when you try to use strict typing. var product_array:Array = new Array("MX 2004", "Studio", "Dreamweaver", "Flash", "ColdFusion", "Contribute", "Breeze"); product_array.
Parameters condition:Boolean - An expression that evaluates to true or false. Example In the following example, the while statement is used to test an expression. When the value of i is less than 20, the value of i is traced. When the condition is no longer true, the loop exits. var i:Number = 0; while (i < 20) { trace(i); i += 3; } The following result is displayed in the Output panel.
The scope chain used by the with statement to resolve identifiers starts with the first item in the following list and continues to the last item: ■ The object specified in the object parameter in the innermost with statement. ■ The object specified in the object parameter in the outermost with statement. ■ The Activation object. (A temporary object that is automatically created when a function is called that holds the local variables called in the function.
The with statement is useful for accessing multiple items in a scope chain list simultaneously. In the following example, the built-in Math object is placed at the front of the scope chain. Setting Math as a default object resolves the identifiers cos, sin, and PI to Math.cos, Math.sin, and Math.PI, respectively.
Command Description GetMaxSignalLevel Returns the maximum signal strength level as a numeric value. GetMaxVolumeLevel Returns the maximum volume level of the device as a numeric value. GetNetworkConnectionName Returns the name of the active or default network connection. GetNetworkConnectStatus Returns a value that indicates the current network connection status.
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. If duration is zero, the backlight behavior immediately reverts to the default behavior.
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. Command Parameters GetBatteryLevel None. Value Returned -1: Not supported Other numeric values: The current battery level. Availability: ActionScript 1.0; Flash Lite 1.
Some sample results and the devices they signify follow: D506i A Mitsubishi 506i phone. DFOMA1 A Mitsubishi FOMA1 phone. F506i A Fujitsu 506i phone. FFOMA1 A Fujitsu FOMA1 phone. N506i An NEC 506i phone. NFOMA1 An NEC FOMA1 phone. Nokia3650 A Nokia 3650 phone. p506i A Panasonic 506i phone. PFOMA1 A Panasonic FOMA1 phone. SH506i A Sharp 506i phone. SHFOMA1 A Sharp FOMA1 phone. SO506i A Sony 506iphone.
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. Other values: The maximum battery level. Availability: ActionScript 1.0; Flash Lite 1.
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.
GetNetworkConnectStatus fscommand2 Command GetNetworkConnectStatus Returns a value that indicates the current network connection status. Command GetNetworkConnectStatus Parameters Value Returned None -1: Not supported. 0: There is currently an active network connection. 1: The device is attempting to connect to the network. 2: There is currently no active network connection. 3: The network connection is suspended. 4: The network connection cannot be determined. Availability: ActionScript 1.
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 -1: Not supported 0: Unknown generation of mobile wireless network 1: 2G 2: 2.5G 3: 3G Availability: ActionScript 1.0; Flash Lite 2.
GetNetworkRequestStatus fscommand2 Command GetNetworkRequestStatus Returns a value indicating the status of the most recent HTTP request. Command Parameters Value Returned GetNetworkRequestStatus None -1: The command is not supported. 0: 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. 1: There is a pending request, and a network connection is being established.
case 2: _root.myText break; case 3: _root.myText break; case 4: _root.myText break; case 5: _root.myText break; case 6: _root.myText break; case 7: _root.myText break; case 8: _root.myText break; case 9: _root.myText break; case 10: _root.
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; case 3: _root.
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 -1: Not supported. 0: Device is operating on battery power. 1: Device is operating on an external power source. Availability: ActionScript 1.0; Flash Lite 1.
GetTotalPlayerMemory fscommand2 Command GetTotalPlayerMemory Returns the total amount of heap memory, in kilobytes, allocated to Flash Lite. Command Parameters Value Returned GetTotalPlayerMemory None -1: Not supported. 0 or positive value: Total kilobytes of heap memory. Availability: ActionScript 1.0; Flash Lite 1.
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). Command Parameters Value Returned Quit None -1: Not supported. Availability: ActionScript 1.0; Flash Lite 1.
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 SetFocusRectColor None -1: Not supported 0: Indeterminable 1: Success Availability: ActionScript 1.0; Flash Lite 2.
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) Alpha Alphabetic characters only Alphanumeric (A to Z, a to z) Alphanumeric Alphanumeric characters Latin only (0 to 9, A to Z, a to z) Latin Latin characters only (alphanumeric and punctuation) NonLatin Non-Latin characters only NoRestriction (for e
For backward compatibility with Flash Lite 1.1, the SOFT1 soft key is always mapped to the left key on the handset, and the SOFT2 soft key is always mapped to the right key on the handset. For the SOFT3 soft key and higher, the locations are dependent on each handset. The arguments for this command specify the text to be displayed for the corresponding soft keys.
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. Command Parameters Value Returned StartVibrate time_on Amount of time, in milliseconds (to a maximum of 5 seconds), that the vibration is on.
ActionScript language elements
2 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. If you are not sure to which class a certain method or property belongs, you can look it up in the Index.
Property summary Modifiers Property Description callee:Object A reference to the currently executing function. caller:Object A reference to the function that called the currently executing function, or null if it wasn't called from another function. length:Number The number of arguments passed to the function. Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.
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. An indexed array is an object whose properties are identified by a number representing their position in the array.
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.
Property summary Modifiers Property Description static CASEINSENSITIVE:Number Represents case-insensitive sorting. static DESCENDING:Number Represents a descending sort order. length:Number A non-negative integer specifying the number of elements in the array. static NUMERIC:Number Represents numeric sorting instead of string-based sorting. static RETURNINDEXEDARRAY:Number Represents the option to return an indexed array as a result of calling the sort() or sortOn() method.
Method summary Modifiers Signature Description concat([value:Object]) : Array Concatenates the elements specified in the parameters with the elements in an array and creates a new array. join([delimiter:String]) : String Converts the elements in an array to strings, inserts the specified separator between the elements, concatenates them, and returns the resulting string. pop() : Object Removes the last element from an array and returns the value of that element.
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.
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 go_gos_array with an initial length of 5: var go_gos_array:Array = new Array("Belinda", "Gina", "Kathy", "Charlotte", "Jane"); trace(go_gos_array.length); // Returns 5. trace(go_gos_array.join(", ")); // Displays elements.
Concatenates the elements specified in the parameters with the elements in an array and creates a new array. If the value parameters specify an array, the elements of that array are concatenated, rather than the array itself. The array my_array is left unchanged. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters [optional] - Numbers, elements, or strings to be concatenated in a new array. If you don't pass any values, a duplicate of my_array is created.
DESCENDING (Array.DESCENDING property) public static DESCENDING : Number Represents a descending sort order. You can use this constant for the options parameter in the sort() or sortOn() method. The value of this constant is 2. Availability: ActionScript 1.0; Flash Lite 2.0 See also sort (Array.sort method), sortOn (Array.sortOn method) join (Array.
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 (,). var a_nested_array:Array = new Array(["Europa", "Io", "Callisto"], ["Titan", "Rhea"]); trace(a_nested_array.join(" + ")); // Returns Europa,Io,Callisto + Titan,Rhea. See also split (String.
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. A numeric sort treats the elements as numbers so that 3 will be placed before 10.
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 value:Object - One or more values to append to the array. Returns Number - An integer representing the length of the new array. Example The following example creates the array myPets_array with two elements, cat and dog. The second line adds two elements to the array.
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); // Displays 1,2,3,4,5,6. numbers_array.reverse(); trace(numbers_array); // Displays 6,5,4,3,2,1. shift (Array.shift method) public shift() : Object Removes the first element from an array and returns that element.
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 slice. If start is a negative number, the starting point begins at the end of the array, where -1 is the last element. startIndex:Number endIndex:Number [optional] - A number specifying the index of the ending point for the slice.
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, Array.sort() works as described in the following list: ■ Sorting is case-sensitive (Z precedes a). ■ Sorting is ascending (a precedes b).
Note: Array.sort() is defined in ECMA-262, but the array sorting options introduced in 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 following list: Array ■ If you specify a value of 4 or Array.UNIQUESORT for the options parameter and two or more elements being sorted have identical sort fields, Flash returns a value of 0 and does not modify the array.
} } 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.
You can use the options parameter to override the default sort behavior. If you want to sort a simple array (for example, an array with only one field), or if you want to specify a sort order that the options parameter doesn't support, use Array.sort(). To pass multiple flags, separate them with the bitwise OR (|) operator: my_array.sortOn(someFieldName, Array.DESCENDING | Array.NUMERIC); Availability: ActionScript 1.0; Flash Lite 2.
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
// 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 // 4 Performing a numeric sort on the age field produces the following results: my_array.sortOn("age", Array.NUMERIC); // my_array[0].age = 3 // my_array[1].
Parameters - An integer that specifies the index of the element in the array where 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). startIndex:Number [optional] - An integer that specifies the number of elements to be deleted. This number includes the element specified in the startIndex parameter.
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 Array.join() method. Availability: ActionScript 1.0; Flash Lite 2.0 Returns String - A string. Example The following example creates my_array and converts it to a string.
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 value:Object - One or more numbers, elements, or variables to be inserted at the beginning of the array. Returns Number - An integer representing the new length of the array. Example The following example shows the use of the Array.
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 Boolean([value:Object]) Creates a Boolean object. Method summary Modifiers Signature Description toString() : String Returns the string representation ("true" or "false") of the Boolean object.
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 ("true" or "false") of the Boolean object. Availability: ActionScript 1.0; Flash Lite 2.0 Returns String - A string; "true" or "false".
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. Button instance names are displayed in the Movie Explorer and in the Insert Target Path dialog box in the Actions panel. The Button class inherits from the Object class. Availability: ActionScript 1.0; Flash Lite 2.
Property summary Modifiers Property Description _alpha:Number The alpha transparency value of the button specified by my_btn. enabled:Boolean A Boolean value that specifies whether a button is enabled. _focusrect:Boolean A Boolean value that specifies whether a button has a yellow rectangle around it when it has input focus. _height:Number The height of the button, in pixels. _highquality:Number Deprecated since Flash Player 7. This property was deprecated in favor of Button._quality.
Modifiers Property Description _visible:Boolean A Boolean value that indicates whether the button specified by my_btn is visible. _width:Number The width of the button, in pixels. _x:Number An integer that sets the x coordinate of a button relative to the local coordinates of the parent movie clip. _xmouse:Number [read-only] Returns the x hasMouse is true relative to the button.
Event Description onKillFocus = Invoked when a button loses keyboard focus. function(newFocus:Object) {} onPress = function() {} Invoked when a button is pressed. onRelease = function() {} Invoked when a button is released. 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. onRollOut = function() {} Invoked when the button loses focus.
Example The following code sets the _alpha property of a button named myBtn_btn to 50% when the 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; }; See also _alpha (MovieClip._alpha property), _alpha (TextField._alpha property) enabled (Button.
_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 _focusrect property. By default, the _focusrect property of a button instance is null; the button instance does not override the global _focusrect property.
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. Availability: ActionScript 1.0; Flash Lite 2.0 Returns Number - The depth of the button instance.
_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 my_btn to a specified width and height. my_btn._width = 500; my_btn._height = 200; _highquality (Button._highquality property) public _highquality : Number Deprecated since Flash Player 7. This property was deprecated in favor of Button._quality.
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); } } onDragOut (Button.onDragOut handler) onDragOut = function() {} Invoked when the user presses the mouse button over the button and then drags the pointer outside of the button.
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. Note: The onDragOver Event Handler is supported for Flash Lite 2.0 only if System.capabilities.hasMouse is true or System.capabilities.hasStylus is true. Availability: ActionScript 1.0; Flash Lite 2.
Example In the following example, a function that sends text to the Output panel is defined for the onKeyDown handler. Create a button called my_btn on the Stage, and enter the following ActionScript in a frame on the Timeline: my_btn.onKeyDown = function() { trace("onKeyDown: "+this._name+" (Key: "+getKeyPressed()+")"); }; function getKeyPressed():String { var theKey:String; switch (Key.getAscii()) { case Key.BACKSPACE : theKey = "BACKSPACE"; break; case Key.
Example In the following example, a function that sends text to the Output panel is defined for the onKeyDown handler. Create a button called my_btn on the Stage, and enter the following ActionScript in a frame on the Timeline: my_btn.onKeyDown = function() { trace("onKeyDown: "+this._name+" (Key: "+getKeyPressed()+")"); }; my_btn.onKeyUp = function() { trace("onKeyUp: "+this._name+" (Key: "+getKeyPressed()+")"); }; function getKeyPressed():String { var theKey:String; switch (Key.getAscii()) { case Key.
Parameters newFocus:Object - The object that is receiving the focus. Example The following example demonstrates how statements can be executed when a button loses focus. Create a button instance on the Stage called my_btn and add the following ActionScript to Frame 1 of the Timeline: this.createTextField("output_txt", this.getNextHighestDepth(), 0, 0, 300, 200); output_txt.wordWrap = true; output_txt.multiline = true; output_txt.border = true; my_btn.onKillFocus = function() { output_txt.
Example In the following example, a function that sends a trace() statement to the Output panel is defined for the onRelease handler: 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. You must define a function that is executed when the event handler is invoked.
Example In the following example, a function that sends a trace() statement to the Output panel is defined for the onRollOut handler: 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. Invoked when the pointer moves over a button area.
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 and btn2_btn, and enter the following ActionScript in Frame 1 of the Timeline: Selection.setFocus(btn1_btn); trace(Selection.getFocus()); btn2_btn.onSetFocus = function(oldFocus) { trace(oldFocus._name + "lost focus"); }; Test the SWF file by pressing Control+Enter.
_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 _quality property. The _quality property can be set to the following values: ■ "LOW" Low rendering quality. Graphics are not anti-aliased, and bitmaps are not smoothed. ■ "MEDIUM" Medium rendering quality. Graphics are anti-aliased using a 2 x 2 pixel grid, but bitmaps are not smoothed.
Example The following example rotates two buttons on the Stage. Create two buttons on the Stage called control_btn and my_btn. Make sure that my_btn is not perfectly round, so you can see it rotating. Then enter the following ActionScript in Frame 1 of the Timeline: var control_btn:Button; var my_btn:Button; control_btn.onRelease = function() { my_btn._rotation += 10; }; Now create another button on the Stage called myOther_btn, making sure it isnt perfectly round (so you can see it rotate).
tabEnabled (Button.tabEnabled property) public tabEnabled : Boolean Specifies whether my_btn is included in automatic tab ordering. It is undefined by default. If the tabEnabled property is undefined or true, the object is included in automatic tab ordering. If the tabIndex property is also set to a value, the object is included in custom tab ordering as well. If tabEnabled is false, the object is not included in automatic or custom tab ordering, even if the tabIndex property is set.
The tabIndex property may be a non-negative integer. The objects are ordered according to their tabIndex properties, in ascending order. An object with a tabIndex value of 1 precedes an object with a tabIndex value of 2. If two objects have the same tabIndex value, the one that precedes the other in the tab ordering is undefined. The custom tab ordering defined by the tabIndex property is flat. This means that no attention is paid to the hierarchical relationships of objects in the SWF file.
Example Add a button instance to the Stage with an instance name my_btn and add the following code 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 my_mc. Delete the existing ActionScript in Frame 1 of the Timeline and replace it with: my_mc.my_btn.onRelease = function(){ trace(this.
Example The following example demonstrates how to track two buttons as a menu. Place two button instances called one_btn and two_btn on the stage. Enter the following ActionScript in the 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"); }; two_btn.
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 my_btn is visible. Buttons that are not visible (_visible property set to false) are disabled. Availability: ActionScript 1.0; Flash Lite 2.0 Example Create two buttons on the Stage with the instance names myBtn1_btn and myBtn2_btn.
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). If the button is inside a movie clip that has transformations, the button is in the local coordinate system of the enclosing movie clip.
Example The following example displays the x coordinate of the mouse position for the Stage and a button called my_btn that is placed on the Stage. Enter the following ActionScript in Frame 1 of the Timeline: this.createTextField("mouse_txt", 999, 5, 5, 150, 40); mouse_txt.html = true; mouse_txt.wordWrap = true; mouse_txt.border = true; mouse_txt.autoSize = true; mouse_txt.selectable = false; // var mouseListener:Object = new Object(); mouseListener.
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; }; See also _x (Button._x property), _y (Button._y property), _yscale (Button._yscale property) _y (Button._y property) public _y : Number The y coordinate of the button relative to the local coordinates of the parent movie clip.
_ymouse (Button._ymouse property) public _ymouse : Number [read-only] Returns the y coordinate of the mouse position relative to the button. Note: The _ymouse property is supported for Flash Lite 2.0 only if or System.capabilities.hasStylus is true. System.capabilities.hasMouse 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 my_btn that is placed on the Stage.
_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 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.
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.
Property summary Modifiers Property Description static audioMIMETypes:Array [read-only] Returns an array of MIME types for audio codecs supported by a mobile device. static avHardwareDisable:Boolean [read-only] A Boolean value that specifies whether access to the user's camera and microphone has been administratively prohibited (true) or allowed (false).
Modifiers Property Description static hasEmbeddedVideo:Boolean [read-only] A Boolean value that is true if the player is running on a mobile device that supports embedded video; false otherwise. static hasMappableSoftKeys:Boolean Returns true if the mobile device allows you to reset or reassign softkey labels and handle events from those softkeys. static hasMFI:Boolean [read-only] Returns true if the mobile device is capable of playing sound data in the MFI audio format.
Modifiers Property Description static hasScreenPlayback:Boolean [read-only] A Boolean value that is true if the player supports the playback of screen broadcast applications that are being run through Flash Media Server; false otherwise. static hasSharedObjects:Boolean [read-only] Returns true if the Flash Lite content playing back in an application can access the Flash Lite version of shared objects.
Modifiers static Property Description localFileReadDisable:Boolean [read- A Boolean value that indicates whether read access to the user's hard disk has been administratively prohibited (true) or allowed (false). only] static MIMETypes:Array [read-only] Returns an array that contains all MIME types that the loadMovie function, Sound and Video objects support. static os:String [read-only] A string that indicates the current operating system.
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.
has4WayKeyAS (capabilities.has4WayKeyAS property) public static has4WayKeyAS : Boolean [read-only] A Boolean value that is true if the Flash Lite player executes the ActionScript code associated 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 true, when one of the four-way keys is pressed, the player first looks for a handler for that key. If none is found, Flash performs control navigation.
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 true if the player can encode an audio stream, such as that coming from a microphone; false otherwise. The server string is AE. Note: For Flash Lite 2.0, the value returned is always false.
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 true if the Flash Lite player can dynamically load additional data through calls to specific functions. You can call the following specific functions: ■ loadMovie() ■ loadMovieNum() ■ loadVariables() ■ loadVariablesNum() ■ XML.parseXML() ■ Sound.
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 true if the player is running on a mobile device that supports embedded video; false otherwise. The server string is EV. Availability: ActionScript 1.0; Flash Lite 2.
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 true if the mobile device is capable of playing sound data in the MIDI audio format. 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.hasMIDI); hasMMS (capabilities.
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 true if the player is running on a system that has an MP3 decoder; false otherwise. The server string is MP3. Availability: ActionScript 1.0; Flash Lite 2.
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 true if the player supports the development of screen broadcast applications to be run through Flash Media Server; false otherwise. The server string is SB. Note: For Flash Lite 2.0, the value returned is always false. Availability: ActionScript 1.
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 true if the mobile device is capable of playing sound data in the SMAF audio format. Otherwise, this property returns false. Availability: ActionScript 1.0; Flash Lite 2.
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 true if the player can play streaming video; false otherwise. The server string is SV. Availability: ActionScript 1.0; Flash Lite 2.
Specifies if the Flash Player can encode a video stream. A Boolean value that is true if the player can encode a video stream, such as that coming from a web camera; false otherwise. The server string is VE. Note: For Flash Lite 2.0, the value returned is always false. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasVideoEncoder); imageMIMETypes (capabilities.
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. The languages themselves are named with the English tags. For example, fr specifies French.
Language Tag Simplified Chinese zh-CN Spanish es Swedish sv Traditional Chinese zh-TW Turkish tr 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.
MIMETypes (capabilities.MIMETypes property) public static MIMETypes : Array [read-only] Returns an array that contains all MIME types that the loadMovie function, Sound and 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); os (capabilities.os property) public static os : String [read-only] A string that indicates the current operating system.
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 R (which returns both the width and height of the screen). Availability: ActionScript 1.0; Flash Lite 2.
version (capabilities.version property) public static version : String [read-only] A string that contains the Flash Player platform and version information (for example, "WIN 7,1,0,0"). The server string is V. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example traces the value of this read-only property: trace(System.capabilities.version); videoMIMETypes (capabilities.
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 Color(target:Object) Creates a Color object for the movie clip specified by the target_mc parameter. Method summary Modifiers Signature Description getRGB() : Number Returns the R+G+B combination currently in use by the color object.
Parameters target:Object - The instance name of a movie clip. Example The following example creates a Color object called my_color for the movie clip my_mc and 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. Availability: ActionScript 1.0; Flash Lite 2.
Returns Object - An object whose properties contain the current offset and percentage values for the specified color. Example The following example gets the transform object, and then sets new percentages for colors and alpha of my_mc relative to their current values. To see this code work, place a multicolored movie clip on the Stage with the instance name my_mc.
setTransform (Color.setTransform method) public setTransform(transformObject:Object) : Void Sets color transform information for a Color object. The colorTransformObject parameter is a generic object that you create from the new Object constructor. It has parameters specifying the percentage and offset values for the red, green, blue, and alpha (transparency) components of a color, entered in the format 0xRRGGBBAA.
Example This example creates a new Color object for a target SWF file, creates a generic object called myColorTransform with the properties defined above, and uses the setTransform() method to pass the colorTransformObject to a Color object.
■ 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 the current date and time should have a daylight saving time bias applied.
Method summary Modifiers 326 Signature Description getDate() : Number Returns the day of the month (an integer from 1 to 31) of the specified Date object according to local time. getDay() : Number Returns the day of the week (0 for Sunday, 1 for Monday, and so on) of the specified Date object according to local time. getFullYear() : Number Returns the full year (a four-digit number, such as 2000) of the specified Date object, according to local time.
Modifiers Signature Description getSeconds() : Number Returns the seconds (an integer from 0 to 59) of the specified Date object, according to local time. getTime() : Number Returns the number of milliseconds since midnight January 1, 1970, universal time, for the specified Date object. getTimezoneOffset() : Number Returns the difference, in minutes, between the computer's local time and universal time.
Modifiers Signature Description getYear() : Number Returns the year of the specified Date object, according to local time. setDate(date:Number) : Number Sets the day of the month for the specified Date object, according to local time, and returns the new time in milliseconds. setFullYear(year:Number, Sets the year of the specified Date object, according to local time and returns the new time in milliseconds.
Modifiers Signature Description setUTCHours(hour:Number, Sets the hour for the specified Date object in universal time and returns the new time in milliseconds.
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. The Date() constructor takes up to seven parameters (year, month, ..., millisecond) to specify a date and time to the millisecond.
hour:Number [optional] - An integer from 0 (midnight) to 23 (11 p.m.). minute:Number [optional] - An integer from 0 to 59. second:Number [optional] - An integer from 0 to 59. millisecond:Number [optional] - An integer from 0 to 999 of milliseconds.
Example The following example creates a new Date object and concatenates the returned values of Date.getMonth(), Date.getDate(), and 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) getDay (Date.
Returns Number - An integer representing the year. Example The following example uses the constructor to create a Date object. The trace statement shows the value returned by the getFullYear() method. var my_date:Date = new Date(); trace(my_date.getYear()); // displays 104 trace(my_date.getFullYear()); // displays current year getHours (Date.getHours method) public getHours() : Number Returns the hour (an integer from 0 to 23) of the specified Date object, according to local time.
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 String - A string representing the current date, in long form, formatted according to the currently defined locale.
Example The following example uses the constructor to create a Date object based on the current time. It also uses the getLocaleShortDate() method to return the current date, in short form, formatted according to the currently defined locale, as follows: var my_date:Date = new Date(); trace(my_date.getLocaleShortDate()); The following are sample return values that getLocaleLongDate() returns: 10/16/2005 16-10-2005 getLocaleTime (Date.
Returns Number - An integer. Example The following example uses the constructor to create a Date object based on the current time and uses the getMilliseconds() method to return the milliseconds value from that object: var my_date:Date = new Date(); trace(my_date.getMilliseconds()); getMinutes (Date.getMinutes method) public getMinutes() : Number Returns the minutes (an integer from 0 to 59) of the specified Date object, according to local time.
Example The following example uses the constructor to create a Date object based on the current time and uses the getMonth() method to return the month value from that object: 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 getMonth() method to display the current month as a numeric value, and display the name of the month. var my_date:Date = new Date(); trace(my_date.
Availability: ActionScript 1.0; Flash Lite 2.0 Returns Number - An integer. Example The following example uses the constructor to create a Date object based on the current time, and uses the getTime() method to return the number of milliseconds since midnight January 1, 1970: var my_date:Date = new Date(); trace(my_date.getTime()); getTimezoneOffset (Date.
Returns Number - An integer. Example The following example creates a new Date object and uses Date.getUTCDate() and Date.getDate(). The value returned by Date.getUTCDate() can differ from the value returned by Date.getDate(), depending on the relationship between your local time zone and universal time. var my_date:Date = new Date(2004,8,25); trace(my_date.getUTCDate()); // output: 25 See also getDate (Date.getDate method) getUTCDay (Date.
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 Number - An integer. Example The following example creates a new Date object and uses Date.getUTCFullYear() and Date.getFullYear(). The value returned by Date.getUTCFullYear() may differ from the value returned by Date.
Example The following example creates a new Date object and uses Date.getUTCHours() and Date.getHours(). The value returned by Date.getUTCHours() may differ from the value returned by Date.getHours(), depending on the relationship between your local time zone and universal time. var today_date:Date = new Date(); trace(today_date.getHours()); // display based on local timezone trace(today_date.getUTCHours()); // display equals getHours() plus or minus 12 See also getHours (Date.
Returns Number - An integer. Example The following example creates a new Date object and uses getUTCMinutes() to return the 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. Availability: ActionScript 1.0; Flash Lite 2.0 Returns Number - An integer.
Returns Number - An integer. Example The following example creates a new Date object and uses getUTCSeconds() to return the 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 Date according to universal time (UTC). The year is the full year minus 1900. For example, the year 2000 is represented as 100. Availability: ActionScript 1.0; Flash Lite 2.
Returns Number - An integer. Example The following example creates a Date object with the month and year set to May 2004. The Date.getYear() method returns 104, and Date.getFullYear() returns 2004: var today_date:Date = new Date(2004,4); trace(today_date.getYear()); // output: 104 trace(today_date.getFullYear()); // output: 2004 See also getFullYear (Date.getFullYear method) setDate (Date.
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 month and date parameters are specified, they are set to local time. Local time is determined by the operating system on which Flash Player is running. Calling this method does not modify the other fields of the specified Date object but and Date.
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; Flash Lite 2.0 Parameters hour:Number - An integer from 0 (midnight) to 23 (11 p.m.). Returns Number - An integer.
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 Date.setMilliseconds() to change the milliseconds value to 575: var my_date:Date = new Date(2004,4,15,8,30,0,250); trace(my_date.getMilliseconds()); // output: 250 my_date.setMilliseconds(575); trace(my_date.getMilliseconds()); // output: 575 setMinutes (Date.
Parameters month:Number - An integer from 0 (January) to 11 (December). date:Number [optional] - An integer from 1 to 31. If you omit this parameter, the date field of the specified Date object will not be modified. Returns Number - An integer. Example The following example initially creates a new Date object, setting the date to May 15, 2004, and uses Date.setMonth() to change the date to June 15, 2004: var my_date:Date = new Date(2004,4,15); trace(my_date.getMonth()); //output: 4 my_date.
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 millisecond:Number - A number; an integer value where 0 is midnight on January 1, universal time. Returns Number - An integer. Example The following example initially creates a new Date object, setting the time and date to 8:00 a.m.
Returns Number - An integer. Example The following example initially creates a new Date object with today's date, uses Date.setUTCDate() to change the date value to 10, and changes it again to 25: var my_date:Date = new Date(); my_date.setUTCDate(10); trace(my_date.getUTCDate()); // output: 10 my_date.setUTCDate(25); trace(my_date.getUTCDate()); // output: 25 See also getUTCDay (Date.getUTCDay method), getDay (Date.getDay method) setUTCFullYear (Date.
Example The following example initially creates a new Date object with today's date, uses Date.setUTCFullYear() to change the year value to 2001, and changes the date to May 25, 1995: var my_date:Date = new Date(); my_date.setUTCFullYear(2001); trace(my_date.getUTCFullYear()); // output: 2001 my_date.setUTCFullYear(1995, 4, 25); trace(my_date.getUTCFullYear()); // output: 1995 trace(my_date.getUTCMonth()); // output: 4 trace(my_date.getUTCDate()); // output: 25 See also getUTCDay (Date.
Example The following example initially creates a new Date object with today's date, uses Date.setUTCHours() to change the time to 8:30 a.m., and changes the time again to 5:30:47 p.m.: var my_date:Date = new Date(); my_date.setUTCHours(8,30); trace(my_date.getUTCHours()); // output: 8 trace(my_date.getUTCMinutes()); // output: 30 my_date.setUTCHours(17,30,47); trace(my_date.getUTCHours()); // output: 17 trace(my_date.getUTCMinutes()); // output: 30 trace(my_date.
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 minute:Number - An integer from 0 to 59. [optional] - An integer from 0 to 59. If you omit this parameter, the seconds field of the specified Date object will not be modified.
Parameters month:Number - An integer from 0 (January) to 11 (December). date:Number [optional] - An integer from 1 to 31. If you omit this parameter, the date field of the specified Date object will not be modified. Returns Number - An integer. Example The following example initially creates a new Date object, setting the date to May 15, 2004, and uses Date.setMonth() to change the date to June 15, 2004: var today_date:Date = new Date(2004,4,15); trace(today_date.
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 Date.setSeconds() to change the time to 8:30:45 a.m.: var my_date:Date = new Date(2004,4,15,8,0,0); trace(my_date.getUTCSeconds()); // output: 0 my_date.setUTCSeconds(45); trace(my_date.getUTCSeconds()); // output: 45 setYear (Date.
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 String - A string. Example The following example returns the information in the dateOfBirth_date Date object as a string. The output from the trace statements are in local time and vary accordingly. For Pacific Daylight Time the output is seven hours earlier than universal time: Mon Aug 12 18:15:00 GMT-0700 1974.
Returns Number - An integer. Example The following example creates a new maryBirthday_date Date object defined in universal time. This is the universal time variation of the example used for the new Date constructor 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. var maryBirthday_date:Date = new Date(Date.UTC(1974, 7, 12)); trace(maryBirthday_date); valueOf (Date.
Property summary Modifiers Property Description message:String Contains the message associated with the Error object. name:String Contains the name of the Error object. 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 Error([message:String]) Creates a new Error object.
Error constructor public Error([message:String]) Creates a new Error object. If message is specified, its value is assigned to the objects Error.message property. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters message:String [optional] - A string associated with the Error object.
Example In the following example, a function throws a specified message depending on the parameters entered into theNum. If two numbers can be divided, SUCCESS and the number are shown. 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."); } else if (num2 == 0) { throw new Error("cannot divide by zero.
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.
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 Key.getCode() method. 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 Key.getCode() method to get the key code for the key that was pressed: var myListener = new Object(); myListener.
See also getCode (Key.getCode method) Property summary Modifiers Property Description static SOFT1:String The key code value for the SOFT1 soft key. static SOFT10:String The key code value for the SOFT10 soft key. static SOFT11:String The key code value for the SOFT11 soft key. static SOFT12:String The key code value for the SOFT12 soft key. static SOFT2:String The key code value for the SOFT2 soft key. static SOFT3:String The key code value for the SOFT3 soft key.
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(); myListener.onKeyDown = function () { var keyCode = Key.getCode(); switch (keyCode) { case ExtendedKey.
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) public static SOFT3 : String The key code value for the SOFT3 soft key. Availability: ActionScript 2.0; Flash Lite 2.0 SOFT4 (ExtendedKey.
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; Flash Lite 2.
Method summary Modifiers Signature Description apply(thisObject:Object, Specifies the value of thisObject to be used within any function that ActionScript calls. [argArray:Array]) call(thisObject:Object, [parameter1:Object]) Invokes the function represented by a Function object. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.
Example The following function invocations are equivalent: Math.atan2(1, 0) Math.atan2.apply(null, [1, 0]) The following simple example shows how apply() passes an array of parameters: function theFunction() { trace(arguments); } // create a new array to pass as a parameter to apply() var firstArray:Array = new Array(1,2,3); theFunction.apply(null,firstArray); // outputs: 1,2,3 // create a second array to pass as a parameter to apply() var secondArray:Array = new Array("a", "b", "c"); theFunction.
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. The function call operator produces code that is concise and readable.
Example The following example uses Function.call() to make a function behave as a method of 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); The trace() statement displays: this == obj? true See also apply (Function.
Property summary Modifiers Property Description static BACKSPACE:Number The key code value for the Backspace key (8). static CAPSLOCK:Number The key code value for the Caps Lock key (20). static CONTROL:Number The key code value for the Control key (17). static DELETEKEY:Number The key code value for the Delete key (46). static DOWN:Number The key code value for the Down Arrow key (40). static END:Number The key code value for the End key (35).
Method summary Modifiers Signature Description static addListener(listener:Object) : Registers an object to receive onKeyDown and onKeyUp notification. Void static getAscii() : Number Returns the ASCII code of the last key pressed or released. static getCode() : Number Returns the key code value of the last key pressed. static isDown(code:Number) : Boolean Returns true if the key specified in code is pressed; false otherwise.
Example The following example creates a new listener object and defines a function for onKeyDown and onKeyUp. The last line uses addListener() to register the listener with the Key object so that it can receive notification from the key down and key up events. var myListener:Object = new Object(); myListener.onKeyDown = function () { trace ("You pressed a key."); } myListener.onKeyUp = function () { trace ("You released a key."); } Key.addListener(myListener); See also getCode (Key.
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; Flash Lite 2.0 DELETEKEY (Key.DELETEKEY property) public static DELETEKEY : Number The key code value for the Delete key (46). Availability: ActionScript 1.0; Flash Lite 2.
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; Flash Lite 2.
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; Flash Lite 2.0 Example The following example moves a movie clip called car_mc a constant distance (10) when you press the arrow keys. The car_mc instance stops when you press Enter and delete the onEnterFrame event.
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. When you press Escape, the Output panel displays information that includes how long it took you to press the key. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.
Example The following example calls the getAscii() method any time a key is pressed. The example creates a listener object named keyListener and defines a function that responds to the onKeyDown event by calling Key.getAscii(). The keyListener object is then registered to the Key object, which broadcasts the onKeyDown message whenever a key is pressed while the SWF file plays. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { trace("The ASCII code for the last key typed is: "+Key.
Example The following example calls the getCode() method any time a key is pressed. The example creates a listener object named keyListener and defines a function that responds to the onKeyDown event by calling Key.getCode(). The keyListener object is then registered to the Key object, which broadcasts the onKeyDown message whenever a key is pressed while the SWF file plays. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { // Compare return value of getCode() to constant if (Key.
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 car_mc at the x and y 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 car_id, and add the following ActionScript to Frame 1 of the Timeline: this.attachMovie("car_id", "car_mc", this.getNextHighestDepth(), {_x:0, _y:0}); car_mc.
Example The following example creates a new listener object and defines a function for onKeyDown. The last line uses addListener() to register the listener with the Key object so that it can receive notification from the key down event and display information in the Output panel. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.INSERT)) { trace("You pressed the Insert key."); } }; Key.addListener(keyListener); isDown (Key.
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 car_mc a constant distance (10) when you press the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage identifier of horn_id for this example. var DISTANCE:Number = 10; var horn_sound:Sound = new Sound(); horn_sound.
_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. Objects are added and removed from this array by calls to the addListener() and removelistener() methods. Availability: ActionScript 1.0; Flash Lite 2.
onKeyUp (Key.onKeyUp event listener) onKeyUp = function() {} Notified when a key is released. To use onKeyUp, you must create a listener object. You can then define a function for onKeyUp and use addListener() to register the listener with the Key object, as shown in the following example: var keyListener:Object = new Object(); keyListener.onKeyDown = function() { trace("DOWN -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey: "+chr(Key.getAscii())); }; keyListener.
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 car_mc when you press the Page Down and Page Up keys. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.PGDN)) { car_mc._rotation += 5; } else if (Key.isDown(Key.PGUP)) { car_mc._rotation -= 5; } }; Key.addListener(keyListener); removeListener (Key.
Example The following example moves a movie clip called car_mc using the Left and Right arrow keys. The listener is removed when you press Escape, and car_mc no longer moves. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { switch (Key.getCode()) { case Key.LEFT : car_mc._x -= 10; break; case Key.RIGHT : car_mc._x += 10; break; case Key.ESCAPE : Key.removeListener(keyListener); } }; Key.addListener(keyListener); RIGHT (Key.
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 car_mc when you press Shift. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.SHIFT)) { car_mc._xscale = 2; car_mc.
Example The following example moves a movie clip called car_mc a constant distance (10) when you press the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a linkage identifier of horn_id for this example. var DISTANCE:Number = 10; var horn_sound:Sound = new Sound(); horn_sound.attachSound("horn_id"); var keyListener_obj:Object = new Object(); keyListener_obj.onKeyDown = function() { switch (Key.getCode()) { case Key.SPACE : horn_sound.start(); break; case Key.
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; Flash Lite 2.0 Example The following example moves a movie clip called car_mc a constant distance (10) when you press the arrow keys. A sound plays when you press the Spacebar.
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.
Property summary Modifiers Property Description contentType:String The MIME type that is sent to the server when you call LoadVars.send() or LoadVars.sendAndLoad(). loaded:Boolean A Boolean value that indicates whether a load or sendAndLoad operation has completed, undefined by default. Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.
Method summary Modifiers Signature Description addRequestHeader(header:Object, Adds or changes HTTP request headers (such as Content-Type or SOAPAction) sent with POST actions. headerValue:String) : Void decode(queryString:String) : Void Converts the variable string to properties of the specified LoadVars object. getBytesLoaded() : Number Returns the number of bytes downloaded by LoadVars.load() or LoadVars.sendAndLoad().
Adds or changes HTTP request headers (such as Content-Type or SOAPAction) sent with POST actions. In the first usage, you pass two strings to the method: header and headerValue. In the second usage, you pass an array of strings, alternating header names and header values. If multiple calls are made to set the same header name, each successive value will replace the value set in the previous call.
contentType (LoadVars.contentType property) public contentType : String The MIME type that is sent to the server when you call LoadVars.send() or LoadVars.sendAndLoad(). The default is application/x-www-form-urlencoded. 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. var my_lv:LoadVars = new LoadVars(); trace(my_lv.
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() or LoadVars.sendAndLoad(). This method returns undefined if no load operation is in progress or if a load operation has not yet begun. Availability: ActionScript 1.0; Flash Lite 2.0 Returns Number - An integer.
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() or LoadVars.sendAndLoad(). This method returns undefined if no load operation is in progress or if a load operation has not started.
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.
Parameters url:String - A string; the URL from which to download the variables. If the SWF file issuing this call is running in a web browser, url must be in the same domain as the SWF file; for details, see the Description section. Returns - false if no parameter (null) is passed; true otherwise. Use the onLoad() event handler to check the success of loaded data.
loaded (LoadVars.loaded property) public loaded : Boolean A Boolean value that indicates whether a load or sendAndLoad operation has completed, undefined by default. When a LoadVars.load() or LoadVars.sendAndLoad() operation is started, the loaded property is set to false; when the operation completes, the loaded property is set to true. If the operation has not completed or has failed with an error, the loaded property remains set to false. This property is similar to the XML.loadedproperty.
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 src parameter passed to the function assigned to LoadVars.
onLoad (LoadVars.onLoad handler) onLoad = function(success:Boolean) {} Invoked when a LoadVars.load() or LoadVars.sendAndLoad() operation has ended. If the 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 undefined by default. This event handler is similar to XML.onLoad. Availability: ActionScript 1.0; Flash Lite 2.
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), load (LoadVars.load method), sendAndLoad (LoadVars.sendAndLoad method) send (LoadVars.
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 url:String - A string; the URL to which to upload variables. - A string; the browser window or frame in which any response will appear. You can enter the name of a specific window or select from the following reserved target names: target:String specifies the current frame in the current window.
sendAndLoad (LoadVars.sendAndLoad method) public sendAndLoad(url:String, target:Object, [method:String]) : Boolean Posts variables in the my_lv object to the specified URL. The server response is downloaded, parsed as variable data, and the resulting variables are placed in the target object. Variables are posted in the same manner as LoadVars.send(). Variables are downloaded into in the same manner as LoadVars.load().
Example For the following example, add a TextInput instance called name_ti, a TextArea instance called result_ta, and a Button instance called submit_button to the Stage. When the user clicks the Login button instance in the following example, two LoadVars objects are created: send_lv and result_lv. The send_lv object copies the name from the name_ti instance and sends the data to greeting.cfm.
Returns String - A string. Example The following example instantiates a new LoadVars() object, creates two properties, and uses toString() to return a string containing both properties in URL encoded format: var my_lv:LoadVars = new LoadVars(); my_lv.name = "Gary"; my_lv.age = 26; trace (my_lv.toString()); //output: age=26&name=Gary Locale (mx.lang.Locale) Object | +-mx.lang.Locale public class Locale extends Object The mx.lang.
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 static Signature Description addDelayedInstance(instance:Object, Add the {instance, string ID} pair into the internal array for later use.
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 - addXMLPath (Locale.
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 Load the specified language xml file. Availability: ActionScript 2.0; Flash Lite 2.
Parameters langCode:String - A String representing a language code. 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 The Math class is a top-level class whose methods and properties you can use without using a constructor.
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 nonemulated math functions that Flash Player 5 supports. Property summary Modifiers Property Description static E:Number A mathematical constant for the base of natural logarithms, expressed as e.
Method summary Modifiers Signature Description static abs(x:Number) : Number Computes and returns an absolute value for the number specified by the parameter x. static acos(x:Number) : Number Computes and returns the arc cosine of the number specified in the parameter x, in radians. static asin(x:Number) : Number Computes and returns the arc sine for the number specified in the parameter x, in radians.
Modifiers Signature Description static sin(x:Number) : Number Computes and returns the sine of the specified angle in radians. static sqrt(x:Number) : Number Computes and returns the square root of the specified number. static tan(x:Number) : Number Computes and returns the tangent of the specified angle. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.
acos (Math.acos method) public static acos(x:Number) : Number Computes and returns the arc cosine of the number specified in the parameter x, 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 nonemulated math functions that Flash Player 5 supports. Parameters x:Number - A number from -1.0 to 1.0. Returns Number - A number; the arc cosine of the parameter x.
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.
atan2 (Math.atan2 method) public static atan2(y:Number, x:Number) : Number Computes and returns the angle of the point y/x 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; Flash Lite 2.
Returns Number - An integer that is both closest to, and greater than or equal to, parameter x. 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. To calculate a radian, see the description of the Math class entry. Availability: ActionScript 1.0; Flash Lite 2.
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. Availability: ActionScript 1.0; Flash Lite 2.
Parameters x:Number - The exponent; a number or expression. Returns Number - A 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 x.
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 nonemulated math functions that Flash Player 5 supports. Example This example traces the value of Math.LN10. trace(Math.LN10); // output: 2.
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 (Math.E), expressed as log10e, with an approximate value of 0.4342944819032518. The Math.
max (Math.max method) public static max(x:Number, y:Number) : Number Evaluates x and y 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 nonemulated math functions that Flash Player 5 supports. Parameters x:Number - A number or expression. y:Number - A number or expression. Returns Number - A number.
Returns Number - A number. Example The following example displays Sat Dec 25 00:00:00 GMT-0700 2004, which is the smaller 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()); See also max (Math.max method) PI (Math.
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 x to the power of y. 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 nonemulated math functions that Flash Player 5 supports. Parameters x:Number - A number to be raised to a power.
random (Math.random method) public static random() : Number Returns a pseudo-random number n, where 0 <= n < 1. The number returned is a pseudorandom number because it is not generated by a truly random natural phenomenon such as radioactive decay. 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 nonemulated math functions that Flash Player 5 supports.
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 Computes and returns the sine of the specified angle in radians.
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); mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.sin(Math.
Example The following example uses Math.pow and Math.sqrt to calculate the length of a line. 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); var nextDepth:Number = canvas_mc.getNextHighestDepth(); var line_mc:MovieClip = canvas_mc.
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 nonemulated math functions that Flash Player 5 supports. Example This example traces the value of Math.SQRT2. trace(Math.SQRT2); // Output: 1.4142135623731 tan (Math.
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); mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.sin(Math.
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 onMouseDown = function() {} Notified when the mouse button is pressed. onMouseMove = function() {} Notified when the mouse moves. onMouseUp = function() {} Notified when the mouse button is released.
addListener (Mouse.addListener method) public static addListener(listener:Object) : Void Registers an object to receive notifications of the onMouseDown, onMouseMove, and onMouseUp listeners. The listener parameter should contain an object that has a defined method for at least one of the listeners.
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), onMouseUp (Mouse.
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; this.orig_x = _xmouse; this.orig_y = _ymouse; this.target_mc = canvas_mc.createEmptyMovieClip("", canvas_mc.getNextHighestDepth()); }; mouseListener.
onMouseMove (Mouse.onMouseMove event listener) onMouseMove = function() {} Notified when the mouse moves. To use the onMouseMove listener, you must create a listener object. You can then define a function for onMouseMove and use addListener() to register the listener with the Mouse object, as shown in the following code: var someListener:Object = new Object(); someListener.onMouseMove = function () { ... }; Mouse.
The following example sets the x and y positions of the pointer_mc movie clip instance to the x and y 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 pointer_id. Then add the following ActionScript code to Frame 1 of the Timeline: this.attachMovie("pointer_id", "pointer_mc", this.getNextHighestDepth()); var mouseListener:Object = new Object(); mouseListener.
Example The following example uses the mouse pointer as a tool to draw lines using onMouseMove and 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(); mouseListener.onMouseDown = function() { this.isDrawing = true; canvas_mc.lineStyle(2, 0xFF0000, 100); canvas_mc.moveTo(_xmouse, _ymouse); }; mouseListener.
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. Add the following ActionScript to Frame 1 of the Timeline: this.createClassObject(mx.controls.Button, "clear_button", this.
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. You do not use a constructor method to create a new movie clip.
Property summary Modifiers 440 Property Description _alpha:Number The alpha transparency value of the movie clip. _currentframe:Number [read-only] Returns the number of the frame in which the playhead is located in the movie clip's Timeline. _droptarget:String [read-only] Returns the absolute path in slashsyntax notation of the movie clip instance on which this movie clip was dropped. enabled:Boolean A Boolean value that indicates whether a movie clip is enabled.
Modifiers Property Description _rotation:Number Specifies the rotation of the movie clip, in degrees, from its original orientation. _soundbuftime:Number Specifies the number of seconds a sound prebuffers before it starts to stream. tabChildren:Boolean Determines whether the children of a movie clip are included in the automatic tab ordering. tabEnabled:Boolean Specifies whether the movie clip is included in automatic tab ordering.
Modifiers Property Description _ymouse:Number [read-only] Indicates the y coordinate of the mouse position. _yscale:Number Sets the vertical scale (percentage) of 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), prototype (Object.prototype property), __resolve (Object.
Event Description onReleaseOutside = function() {} Invoked when the mouse button is pressed inside the movie clip area and then released outside the movie clip area. onRollOut = function() {} Invoked when the pointer moves outside a movie clip area. onRollOver = function() {} Invoked when the pointer moves over a movie clip area. onSetFocus = Invoked when a movie clip receives input focus.
Method summary Modifiers Signature Description attachMovie(id:String, name:String, Takes a symbol from the library and depth:Number, [initObject:Object]) attaches it to the movie clip. : MovieClip beginFill(rgb:Number, [alpha:Number]) : Void beginGradientFill(fillType:String, colors:Array, alphas:Array, Indicates the beginning of a new drawing path. Indicates the beginning of a new drawing path.
Modifiers Signature Description getBytesLoaded() : Number Returns the number of bytes that have already loaded (streamed) for the movie clip. getBytesTotal() : Number Returns the size, in bytes, of the movie clip. getDepth() : Number Returns the depth of the movie clip instance. getInstanceAtDepth(depth:Number) : Determines if a particular depth is already occupied by a movie clip. MovieClip getNextHighestDepth() : Number Determines a depth value that you can pass to MovieClip.
Modifiers Signature Description lineStyle(thickness:Number, Specifies a line style that Flash uses for subsequent calls to lineTo() and curveTo() until you call lineStyle() with different parameters. rgb:Number, alpha:Number, pixelHinting:Boolean, noScale:String, capsStyle:String, jointStyle:String, miterLimit:Number) : Void 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).
Modifiers Signature Description startDrag([lockCenter:Boolean], Lets the user drag the specified movie clip. [left:Number], [top:Number], [right:Number], [bottom:Number]) : Void stop() : Void Stops the movie clip currently playing. stopDrag() : Void Ends a MovieClip.startDrag() method.
Example The following code sets the _alpha property of a dynamically created movie clip named triangle to 50% when the mouse rolls over the movie clip. Add the following ActionScript to your FLA or AS file: this.createEmptyMovieClip("triangle", this.getNextHighestDepth()); triangle.beginFill(0x0000FF, 100); triangle.moveTo(10, 10); triangle.lineTo(10, 100); triangle.lineTo(100, 10); triangle.lineTo(10, 10); triangle.onRollOver = function() { this._alpha = 50; }; triangle.onRollOut = function() { this.
[optional] - (Supported for Flash Player 6 and later) An object containing properties with which to populate the newly attached movie clip. This parameter allows dynamically created movie clips to receive clip parameters. If initObject is not an object, it is ignored. All properties of initObject are copied into the new instance. The properties specified with initObject are available to the constructor function. initObject:Object Returns MovieClip - A reference to the newly created instance.
Example The following example creates a square with red fill on the Stage: this.createEmptyMovieClip("square_mc", this.getNextHighestDepth()); square_mc.beginFill(0xFF0000); square_mc.moveTo(10, 10); square_mc.lineTo(100, 10); square_mc.lineTo(100, 100); square_mc.lineTo(10, 100); square_mc.lineTo(10, 10); square_mc.endFill(); An example is also in the drawingapi.fla file in the ActionScript samples folder.
Parameters fillType:String - Either the string "linear" or the string "radial". colors:Array - An array of RGB hex color values to be used in the gradient (for example, red is 0xFF0000, blue is 0x0000FF, and so on). - An array of alpha values for the corresponding colors in the colors array; valid values are 0-100. If the value is less than 0, Flash uses 0. If the value is greater than 100, Flash uses 100. alphas:Array - An array of color distribution ratios; valid values are 0-255.
This code draws the following image on the screen: ■ matrixType, x, y, w, h, r.
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 MovieClip.lineStyle().
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.
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 ecreateTextField() method to create text fields while a SWF file plays. The depth parameter determines the new text field's depth level (z-order position) in the movie clip. Each depth level can contain only one object.
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; Flash Lite 2.0 Parameters instanceName:String depth:Number - A string that identifies the instance name of the new text field. - A positive integer that specifies the depth of the new text field.
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), getNextHighestDepth (MovieClip.
Parameters controlX:Number - An integer that specifies the horizontal position of the control point relative to the registration point of the parent movie clip. controlY:Number - An integer that specifies the vertical position of the control point relative to the registration point of the parent movie clip. - An integer that specifies the horizontal position of the next anchor point relative to the registration point of the parent movie clip.
The following script uses the curveTo() method and the Math class to create a circle: this.createEmptyMovieClip("circle2_mc", 2); circle2_mc.lineStyle(0, 0x000000); drawCircle(circle2_mc, 100, 100, 100); function drawCircle(mc:MovieClip, x:Number, y:Number, r:Number):Void { 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, '+y); mc.curveTo(-Math.tan(Math.PI/8)*r+x, r+y, -Math.sin(Math.PI/4)*r+x, Math.
_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 _droptarget property always returns a path that starts with a slash (/). To compare the _droptarget property of an instance to a reference, use the eval() function to convert the returned value from slash syntax to a dot-syntax reference (ActionScript 2.0 does not support slash syntax.
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 duplicateMovieClip() method is called. Variables in the parent movie clip are not copied into the duplicate movie clip.
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); duplicate = container.duplicateMovieClip("clip-" + i, i, {_y:newY}); trace(duplicate); // _level0.clip-[number] } function setUpContainer():MovieClip { var mc:MovieClip = this.
The enabled property only governs the button-like properties of a movie clip. You can change the enabled property at any time; the modified movie clip is immediately enabled or disabled. The enabled property can be read out of a prototype object. If enabled is set to false, the object is not included in automatic tab ordering. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example disables the circle_mc movie clip when the user clicks it: circle_mc.
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 undefined or false, a movie clip cannot receive input focus unless it is a button. If the focusEnabled property value is true, a movie clip can receive input focus even if it is not a button. Availability: ActionScript 1.0; Flash Lite 2.
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 mc1_mc, mc2_mc, and mc3_mc, and add the following ActionScript to Frame 1 of the Timeline: mc1_mc._focusrect = true; mc2_mc._focusrect = false; mc3_mc._focusrect = true; mc1_mc.onRelease = traceOnRelease; mc3_mc.onRelease = traceOnRelease; function traceOnRelease() { trace(this.
Example The following example uses the _framesloaded property to start a SWF file when all the frames are loaded. If all the frames aren't loaded, the _xscale property of the bar_mc movie 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); bar_mc._xscale = pctLoaded; Add the following code to Frame 2: if (this._framesloaded < this.
Example The following example creates a movie clip called square_mc. The code draws a square for that movie clip and uses MovieClip.getBounds() to display the coordinate values of the instance in the Output panel. this.createEmptyMovieClip("square_mc", 1); square_mc._x = 10; square_mc._y = 10; square_mc.beginFill(0xFF0000); square_mc.moveTo(0, 0); square_mc.lineTo(100, 0); square_mc.lineTo(100, 100); square_mc.lineTo(0, 100); square_mc.lineTo(0, 0); square_mc.endFill(); var bounds_obj:Object = square_mc.
Example The following example uses the _framesloaded property to start a SWF file when all the frames are loaded. If all the frames aren't loaded, the _xscale property of the loader movie 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); bar_mc._xscale = pctLoaded; Add the following code to Frame 2: if (this._framesloaded
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
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 MovieClip.attachMovie(), MovieClip.
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(), MovieClip.
Example The following example draws thre movie clip instances, using the getNextHighestDepth() method as the depth parameter of the createEmptyMovieClip() method, and labels each movie clip them with its depth: for (i = 0; i < 3; i++) { drawClip(i); } function drawClip(n:Number):Void { this.createEmptyMovieClip("triangle" + n, this.getNextHighestDepth()); var mc:MovieClip = eval("triangle" + n); mc.beginFill(0x00aaFF, 100); mc.lineStyle(4, 0xFF0000, 100); mc.moveTo(0, 0); mc.lineTo(100, 100); mc.
Returns Number - An integer that specifies the Flash Player version that was targeted when the SWF file loaded into the movie clip was published. Example The following example creates a new container and outputs the value of getSWFVersion(). It then uses MovieClipLoader to load an external SWF file that was published to Flash Player 7 and outputs the value of getSWFVersion() after the onLoadInit handler is triggered. var container:MovieClip = this.createEmptyMovieClip("container", this.
Parameters url:String - The URL from which to obtain the document. window:String [optional] - A parameter specifying the name, frame, or expression that specifies the window or HTML frame that the document is loaded into. You can also use one of the following reserved target names: _self specifies the current frame in the current window, _blank specifies a new window, _parent specifies the parent of the current frame, and _top specifies the top-level frame in the current window.
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. In other words, it represents how far to the right the point lies. For example, if x = 50, the point lies 50 pixels to the right of the top-left corner.
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 object specifies the x and y coordinates as properties. pt:Object Example Add the following ActionScript to a FLA or AS file in the same directory as an image called photo1.jpg: this.createTextField("coords_txt", this.getNextHighestDepth(), 10, 10, 100, 22); coords_txt.
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; Flash Lite 2.0 Parameters - A number representing the frame number, or a string representing the label of the frame, to which the playhead is sent.
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; Flash Lite 2.0 Parameters frame:Object - The frame number to which the playhead is sent.
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); image_mcl.loadClip("example.
hitArea (MovieClip.hitArea property) public hitArea : Object Designates another movie clip to serve as the hit area for a movie clip. If the hitArea property does not exist or is null or undefined, the movie clip itself is used as the hit area. The value of the hitArea property may be a reference to a movie clip object. You can change the hitArea property at any time; the modified movie clip immediately takes on the new hit area behavior.
Usage 2: Evaluates the bounding boxes of the target and specified instance, and returns true if they overlap or intersect at any point. Parametersx: Number The x coordinate of the hit area on the Stage. y: Number The y coordinate of the hit area on the Stage. The x and y coordinates are defined in the global coordinate space. shapeFlag: Boolean A Boolean value specifying whether to evaluate the entire shape of the specified instance (true), or just the bounding box (false).
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 lineTo() and curveTo() until you call lineStyle() with different parameters. You can call lineStyle() in the middle of drawing a path to specify different styles for different line segments within a path.
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).
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. Tip: To monitor the progress of the download, use the MovieClipLoader.
Parameters url:String - The absolute or relative URL of the SWF or JPEG file to be loaded. A relative path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// or file:///. method:String [optional] - Specifies an HTTP method for sending or loading variables. The parameter must be the string GET or POST. If no variables are to be sent, omit this parameter.
The loadVariables method can also be used to update variables in the active movie clip with new values. The loadVariables method requires that the text of the URL be in the standard MIME format: application/x-www-form-urlencoded (CGI script format). In SWF files running in a version earlier than Flash Player 7, url must be in the same superdomain as the SWF file that is issuing this call. A superdomain is derived by removing the left-most component of a file's URL. For example, a SWF file at www.someDomain.
Example The following example loads information from a text file called params.txtinto the target_mc movie clip that is created by using createEmptyMovieClip(). The setInterval() function 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()); target_mc.loadVariables("params.txt"); function checkParamsLoaded() { if (target_mc.done == undefined) { trace("not yet.
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 topleft corner of the movie clip. In other words, it represents how far to the right the point lies. For example, if x = 50, the point lies 50 pixels to the right of the top-left corner.
Parameters pt:Object - The name or identifier of an object created with the Object class, specifying the x and y coordinates as properties. Example The following example converts x and y coordinates of the my_mc object, from the movie clip's (local) coordinates to the Stage (global) coordinates. The center point of the movie clip is reflected after you click and drag the instance. this.createTextField("point_txt", this.
If you don't have access to Chess.fla (for example, if you are loading Chess.swf from someone else's site into chess_mc), you can set the Chess.swf _lockroot property when you load it. Place the following ActionScript on the main Timeline of Games.fla: chess_mc._lockroot = true; In this case, Chess.swf can be published for any version of Flash Player, as long as Games.swf is published for Flash Player 7 or later. When calling loadMovie(), set the MovieClip.
The lockroot.swf file has _lockroot applied to it, and nolockroot.swf does not. After the files are loaded, each file dumps variables from their _root scopes. Place the following ActionScript on the main Timeline of a FLA document: this.createEmptyMovieClip("lockroot_mc", this.getNextHighestDepth()); lockroot_mc.loadMovie("lockroot.swf"); this.createEmptyMovieClip("nolockroot_mc", this.getNextHighestDepth()); nolockroot_mc.loadMovie("nolockroot.
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 (MovieClip.attachMovie method), loadMovie (MovieClip.loadMovie method), onLoadInit (MovieClipLoader.onLoadInit event listener) moveTo (MovieClip.
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.
Example The following example uses _framesloaded and nextFrame()to load content into a SWF 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); } Then, add the following code (and the content you want to load) on Frame 3: stop(); See also nextFrame function, prevFrame function, prevFrame (MovieClip.prevFrame method) onData (MovieClip.
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. // The following function is triggered for each instance of symbol_mc // when it receives data. symbol_mc.
Example The following example defines a function for the onDragOut method that sends a 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. You must define a function that executes when the event handler is invoked.
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; Flash Lite 2.0 Example The following example defines a function for the onEnterFrame event handler that sends a trace() action to the Output panel: my_mc.onEnterFrame = function () { trace ("onEnterFrame called"); } onKeyDown (MovieClip.
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, key was pressed is displayed in the Output panel. However, this does not occur after you move the mouse, because the movie clip loses focus. Therefore, you should use Key.onKeyDown in most cases. See also getAscii (Key.getAscii method), getCode (Key.
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.
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. This handler can be used only with movie clips for which you have a symbol in the library that is associated with a class.
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. Note: This event handler is supported in Flash Lite only if System.capabilities.hasMouse is true or System.capabilities.hasStylus is true. Availability: ActionScript 1.0; Flash Lite 2.
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. Note: This event handler is supported in Flash Lite only if System.capabilities.hasMouse is true or System.capabilities.hasStylus is true. Availability: ActionScript 1.0; Flash Lite 2.
Example The following example defines a function for the onRelease method that sends a 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. You must define a function that executes when the event handler is invoked.
Example The following example defines a function for the onRollOut method that sends a 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.
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 and other_mc are on the Stage. Add the following ActionScript to your AS or FLA document: my_mc.onRelease = Void; other_mc.onRelease = Void; my_mc.
You can use _parent to move up multiple levels in the display list as in the following: 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. Create a movie clip with the instance name my_mc, and add it to the main Timeline. Add the following ActionScript to your FLA or AS file: my_mc.
Use the following ActionScript to play the Timeline of a movie clip in a SWF file. This ActionScript is for a button called my_btn on the main Timeline that plays a movie clip called animation_mc: animation_mc.stop(); my_btn.onRelease = function(){ animation_mc.play(); }; See also play function, gotoAndPlay (MovieClip.gotoAndPlay method), gotoAndPlay function prevFrame (MovieClip.prevFrame method) public prevFrame() : Void Sends the playhead to the previous frame and stops it.
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 _quality property. The _quality property can be set to the following values: Value Description Graphic Anti-Aliasing "LOW" Low rendering quality. Graphics are not anti-aliased. "MEDIUM" Medium rendering quality.
removeMovieClip (MovieClip.removeMovieClip method) public removeMovieClip() : Void Removes a movie clip instance created with duplicateMovieClip(), MovieClip.duplicateMovieClip(), MovieClip.createEmptyMovieClip(), or 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 MovieClip.
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; return randNum; } var bugNum:Number = 0; addBug_btn.onRelease = addBug; function addBug() { var thisBug:MovieClip = this._parent.
Example The following example creates a triangle movie clip instance dynamically. When you run 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.
Parameters mc:Object - The instance name of a movie clip to be a mask. This can be a String or a MovieClip. Example The following code uses the circleMask_mc movie clip to mask the theMaskee_mc movie 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.
left:Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip. [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip. top:Number [optional] - Value relative to the coordinates of the movie clip's parent that specify a constraint rectangle for the movie clip.
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 MovieClip.startDrag() method. A movie clip that was made draggable with that method remains draggable until a stopDrag() method is added, or until another movie clip becomes draggable. Only one movie clip is draggable at a time.
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 the target parameter, or with the movie clip that currently occupies the depth level specified in the target parameter. Both movie clips must have the same parent movie clip.
tabChildren (MovieClip.tabChildren property) public tabChildren : Boolean Determines whether the children of a movie clip are included in the automatic tab ordering. If the tabChildren property is undefined or true, the children of a movie clip are included in automatic tab ordering. If the value of tabChildren is false, the children of a movie clip are not included in automatic tab ordering. The default value is undefined. Availability: ActionScript 1.0; Flash Lite 2.
tabEnabled (MovieClip.tabEnabled property) public tabEnabled : Boolean Specifies whether the movie clip is included in automatic tab ordering. It is undefined by default. If the tabEnabled property is undefined, the object is included in automatic tab ordering only if it defines at least one movie clip handler, such as MovieClip.onRelease. If tabEnabled is true, the object is included in automatic tab ordering.
The tabIndex property must be a positive integer. The objects are ordered according to their tabIndex properties, in ascending order. An object with a tabIndex value of 1 precedes an object with a tabIndex value of 2. The custom tab ordering disregards the hierarchical relationships of objects in a SWF file. All objects in the SWF file with tabIndex properties are placed in the tab order. Do not use the same tabIndex value for multiple objects. Availability: ActionScript 1.0; Flash Lite 2.
_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 prev_mc button moves the playhead to the previous frame, and the next_mc button moves the playhead to the next frame.
You can change the trackAsMenu property at any time; the modified movie clip immediately takes on the new behavior. Note: This property is supported in Flash Lite only if System.capabilities.hasMouse is true or System.capabilities.hasStylus is true. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example sets the trackAsMenu property for three movie clips on the Stage. Click a movie clip and release the mouse button on a second movie clip to see which instance receives the event.
Example The following example unloads a movie clip instance called box when a user clicks the box 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(); }; See also removeMovieClip (MovieClip.removeMovieClip method), attachMovie (MovieClip.attachMovie method), loadMovie (MovieClip.
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); _visible (MovieClip.
_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()); triangle.beginFill(0x0000FF, 100); triangle.moveTo(100, 100); triangle.lineTo(100, 150); triangle.lineTo(150, 100); triangle.lineTo(100, 100); trace(triangle.
_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 is or System.capabilities.hasStylus is true. 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 (_level0) and in relation to a movie clip on the Stage called my_mc: this.createTextField("mouse_txt", this.
Example The following example creates a movie clip called box_mc at runtime. The Drawing API is 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. this.createEmptyMovieClip("box_mc", 1); box_mc._x = 100; box_mc.
_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). If the movie clip is inside another movie clip that has transformations, the movie clip is in the local coordinate system of the enclosing movie clip.
See also Mouse, _xmouse (MovieClip._xmouse property) _yscale (MovieClip._yscale property) public _yscale : Number Sets the vertical scale (percentage) of the movie clip as applied from the registration point of the movie clip. The default registration point is (0,0). Scaling the local coordinate system affects the _x and _y property settings, which are defined in whole pixels.
See also _x (MovieClip._x property), _xscale (MovieClip._xscale property), _y (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. To use MovieClipLoader features, use MovieClipLoader.loadClip() instead of loadMovie() or MovieClip.
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 onLoadComplete = function(listenerObject, Invoked when a file loaded with MovieClipLoader.loadClip() is completely downloaded. [target_mc]) {} onLoadError = function(target_mc, errorCode) {} Invoked when a file loaded with MovieClipLoader.
Method summary Modifiers Signature Description addListener(listener:Object) : Registers an object to receive notification when a MovieClipLoader event handler is invoked. Boolean getProgress(target:Object) : Object loadClip(url:String, target:Object) : Boolean Returns the number of bytes loaded and total number of bytes for a file that is being loaded by using MovieClipLoader.loadClip(); for compressed movies, the getProgress method reflects the number of compressed bytes.
Parameters listener:Object - An object that listens for a callback notification from the MovieClipLoader event handlers. Returns - A Boolean value. The return value is true if the listener was established successfully; otherwise the return value is false. Boolean Example The following example loads an image into a movie clip called image_mc. The movie clip instance is rotated and centered on the Stage, and both the Stage and movie clip have a stroke drawn around their perimeters. this.
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 MovieClipLoader.loadClip(); for compressed movies, the getProgress method reflects the number of compressed bytes. The getProgress method lets you explicitly request this information, instead of (or in addition to) writing a MovieClipLoader.onLoadProgress listener function. Availability: ActionScript 1.
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.
You can use the loadClip() method to load one or more files into a single movie clip or level; MovieClipLoader listener objects are passed to the loading target movie clip instance as a parameter. Alternatively, you can create a different MovieClipLoader object for each file that you load. Use MovieClipLoader.unloadClip() to remove movies or images loaded with this method or to cancel a load operation that is in progress. MovieClipLoader.getProgress() and MovieClipLoaderListener.
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.
When you use the onLoadComplete and onLoadInit events with the MovieClipLoader class, it's important to understand how this differs from the way they work with your SWF file. The onLoadComplete event is called after the SWF or JPEG file is loaded, but before the application is initialized. At this point you cannot access the loaded movie clip's methods and properties, and because of this you cannot call a function, move to a specific frame, and so on.
onLoadError (MovieClipLoader.onLoadError event listener) onLoadError = function(target_mc, errorCode) {} Invoked when a file loaded with MovieClipLoader.loadClip() has failed to load. This 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 target_mc identifies the movie clip this call is being made for.
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.
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.
Parameterstarget_mc: MovieClip [optional] A movie clip loaded by a MovieClipLoader.loadClip() method. loadedBytes: Number The number of bytes that had been loaded when the listener was invoked. totalBytes: Number The total number of bytes in the file being loaded. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters target_mc: [optional] - A movie clip loaded by a MovieClipLoader.loadClip() method. loadedBytes: totalBytes: - The number of bytes that had been loaded when the listener was invoked.
onLoadStart (MovieClipLoader.onLoadStart event listener) onLoadStart = function([target_mc]) {} Invoked when a call to MovieClipLoader.loadClip() has successfully begun to download a file. Call this listener on a listener object that you add using MovieClipLoader.addListener(). The value for target_mc identifies the movie clip this call is being made for. This parameter is useful if you are loading multiple files with the same set of listeners.
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 MovieClipLoader event handler was invoked.
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.
Example The following example loads an image into a movie clip called image_mc. If you click the 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; target_mc._y = 100; target_mc.onRelease = function() { trace("Unloading clip..."); trace("\t name: "+target_mc.
The following example assigns the value of the MIN_VALUE property to a variable declared 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 Description static MAX_VALUE:Number The largest representable number (doubleprecision IEEE-754).
Method summary Modifiers Signature Description toString(radix:Number) : String Returns the string representation of the specified Number object (myNumber). valueOf() : Number Returns the primitive value type of the specified Number object. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.
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 (NaN). Availability: ActionScript 1.0; Flash Lite 2.
Number constructor public Number(num:Object) Creates a new Number object. The new Number constructor is primarily used as a placeholder. A Number object is not the same as the Number() function that converts a parameter to a primitive value. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters num:Object - The numeric value of the Number object being created or a value to be converted to a number. The default value is 0 if value is not provided.
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 conversion. If you do not specify the radix parameter, the default value is 10. radix:Number Returns String - A string.
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). Property summary Modifiers static Property Description constructor:Object Reference to the constructor function for a given object instance.
Modifiers Signature Description isPrototypeOf(theClass:Object) : Indicates whether an instance of the Object class is in the prototype chain of the object specified as an argument. Boolean static registerClass(name:String, theClass:Function) : Boolean Associates a movie clip symbol with an ActionScript object class. toString() : String Converts the specified object to a string and returns it. unwatch(name:String) : Boolean Removes a watchpoint that Object.watch() created.
If invoked incorrectly, Object.addProperty() can fail with an error. The following table describes errors that can occur: Error condition What happens name is not a valid property name; for example, Returns false and the property is not added. an empty string. getter is not a valid function object. Returns false and the property is not added. setter is not a valid function object. Returns false and the property is not added. Availability: ActionScript 1.0; Flash Lite 2.0 - In ActionScript 2.
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.
The following example shows how to use the implicit getter and setter functions available in ActionScript 2.0. Rather than defining the Book function and editing Book.prototype, you define the Book class in an external file named Book.as. The following code must be in a separate external file named Book.as that contains only this class definition and resides within the Flash application's classpath: class Book { var books:Number; function set bookcount(numBooks:Number):Void { this.
If you use the instanceof operator, you can also determine if an object belongs to a specified class: var my_str:String = new String("sven"); trace(my_str instanceof String); //output: true However, in the following example the Object.constructor property converts primitive data types (such as the string literal seen here) into wrapper objects. The instanceof operator does not perform any conversion, as seen in the following example: var my_str:String = "sven"; trace(my_str.
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: true if the property specified by the name parameter is enumerable. Boolean Example The following example creates a generic object, adds a property to the object, then checks whether the object is enumerable. By way of contrast, the example also shows that a built-in property, the Array.
Returns Boolean - A Boolean value: true if the object is in the prototype chain of the object specified by the theClass parameter; false otherwise. Object constructor public Object() Creates an Object object and stores a reference to the object's constructor method in the object's constructor property. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a generic object named myObject: var myObject:Object = new Object(); __proto__ (Object.
The following trace statements show that the __proto_ property of both instances refers to the prototype property of the Circle class. 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.
The following trace statement shows how you can use the prototype property and the __proto__ property together to move two levels up the inheritance hierarchy (or prototype chain). The Circle.prototype.__proto__ property contains a reference to the superclass of the Shape class. trace(Circle.prototype.__proto__ == Shape.prototype); // Output: true See also __proto__ (Object.__proto__ property) registerClass (Object.
Parameters name:String - String; the linkage identifier of the movie clip symbol or the string identifier for the ActionScript class. - A reference to the constructor function of the ActionScript class or to unregister the symbol. theClass:Function null Returns - A Boolean value: if the class registration succeeds, a value of true is returned; false otherwise. Boolean See also attachMovie (MovieClip.attachMovie method), duplicateMovieClip (MovieClip.duplicateMovieClip method) __resolve (Object.
Usage 1: the following example uses __resolve to build an object where every undefined 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!"; }; trace (myObject.property1); // output: Hello, world! trace (myObject.property2); // output: Hello, world! Usage 2: the following example uses __resolve as a functor, which is a function that generates functions.
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(); // does not call __resolve because it is now defined myObject.someOtherMethod(); // calls __resolve myObject.
// 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; } var f:Function = function () { arguments.unshift(name); this.myFunction.
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(); trace(myDate.toString()); // output: [current date and time] // Array.
// 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()); // output: A vehicle that is red and has 2 doors unwatch (Object.unwatch method) public unwatch(name:String) : Boolean Removes a watchpoint that Object.watch() created. This method returns a value of true if the watchpoint is successfully removed, false otherwise.
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. The valueOf() method returns the primitive value in milliseconds. Third, create a new Array object containing two simple elements.
You can use the return statement in your callback method definition to affect the value of the property you are watching. The value returned by your callback method is assigned to 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 newVal parameter. ■ If you are modifying the value of the property, return your own value.
userData:Object [optional] - An arbitrary piece of ActionScript data that is passed to the callback method. If the userData parameter is omitted, undefined is passed to the callback method. Returns Boolean - A Boolean value: true if the watchpoint is created successfully, false otherwise. Example The following example uses watch() to check whether the speed property exceeds the speed limit: // Create a new object var myObject:Object = new Object(); // Add a property that tracks speed myObject.
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__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) security (System.
Method summary Modifiers Signature Description static allowDomain(domain1:String) : Void Lets SWF files and HTML files in 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. allowInsecureDomain(domain:String) : Lets SWF files and HTML files in the identified domains access objects and variables in the calling SWF file, which is hosted using the HTTPS protocol.
Also, for files running in Flash Player 7 or later, you can't use this method to let SWF files hosted using a secure protocol (HTTPS) allow access from SWF files hosted in nonsecure protocols; you must use System.security.allowInsecureDomain() instead. Occasionally, you might encounter the following situation: You load a child SWF file from a different domain and want to allow the child SWF file to script the parent SWF file, but you don't know the final domain from which the child SWF file will originate.
See also onLoadComplete (MovieClipLoader.onLoadComplete event listener), _parent (MovieClip._parent property), _url (MovieClip._url property), allowInsecureDomain (security.allowInsecureDomain method) allowInsecureDomain (security.allowInsecureDomain method) public static allowInsecureDomain(domain:String) : Void Lets SWF files and HTML files in the identified domains access objects and variables in the calling SWF file, which is hosted using the HTTPS protocol.
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. // This SWF file is at https://myEducationSite.somewhere.com/mathTest.swf // Concept files are at http://myEducationSite.somewhere.com System.security.
You can use loadPolicyFile() to load any number of policy files. When considering a 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 loadPolicyFile() authorizes a request, Flash Player consults the original default location, / crossdomain.xml.
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.
Method summary Modifiers Signature Description static addListener(listener:Object) : Void Registers an object to receive keyboard focus change notifications. static getFocus() : String Returns a string specifying the target path of the object that has focus. static removeListener(listener:Object) : Removes an object previously registered with Selection.addListener().
Example In the following example, you create two input text fields at runtime, setting the borders for each text field to true. This code creates a new (generic) ActionScript object named focusListener. This object defines for itself an onSetFocus property, to which it assigns a function. The function takes two parameters: a reference to the text field that lost focus, and one to the text field that gained focus.
Returns String - A string or 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. Then add the following ActionScript to your AS or FLA file. var focus_ta:mx.controls.TextArea; my_mc.onRelease = function() {}; my_btn.
Parameters oldfocus: [optional] - The object losing focus. newfocus: [optional] - The object receiving focus. 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); this.createTextField("two_txt", 2, 0, 25, 100, 22); this.createTextField("three_txt", 3, 0, 50, 100, 22); this.
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 listener:Object - The object that will no longer receive focus notifications. Returns - If listener was successfully removed, the method returns a true value.
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 newFocus parameter. You can use dot or slash notation to specify the path. You can also use a relative or absolute path. If you are using ActionScript 2.0, you must use dot notation. If null is passed, the current focus is removed. Availability: ActionScript 1.0; Flash Lite 2.
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.
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. The Flash application can save the last search the user made and prefill the forms the next time the SWF file is played.
Example In the following example, a SWF file creates a listener function named Prefs and then creates a shared object. The player calls the loadCompletePrefs function when the data is available. function loadCompletePrefs (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.
Property summary Modifiers Property Description data:Object The collection of attributes assigned to the 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 onStatus = function(infoObject:Object) {} Invoked every time an error, warning, or informational note is posted for a shared object.
Method summary Modifiers Signature Description static addListener(objectName:String, Creates an event listener that the Flash Lite player invokes when the player has loaded the shared object data from the device. notifyFunction:Function) : Void clear() : Void Purges all the data from the shared object and deletes the shared object from the disk. flush(minDiskSpace:Number) : Writes shared object to a local, persistent file.
Availability: ActionScript 2.0; Flash Lite 2.0 Parameters objectName:String - A string that represents the name of the shared object. - The name of a function the player calls to notify the application that the getLocal() method has executed and the data is finished loading. notifyFunction:Function clear (SharedObject.clear method) public clear() : Void Purges all the data from the shared object and deletes the shared object from the disk. The reference to my_so is still active, and my_so is now empty.
Note: For Flash Lite, if the shared object listener has not been invoked, the data property 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"; var my_so:SharedObject = SharedObject.getLocal("superfoo"); my_so.data.itemNumbers = items_array; my_so.data.adminPrivileges = currentUserIsAdmin; my_so.data.
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 my_so (for the complete example, see SharedObject.getLocal()): var my_so:SharedObject = SharedObject.getLocal("savedText"); // myText is an input text field and inputText is a dynamic text field. myText.text = my_so.data.
Returns Object - A Boolean value, true or false; or a string value of "pending". The flush() method returns pending for most requests, with the following exceptions: ■ If there is no need to write data (that is, the data has already been written), flush() returns true. ■ If the minimumDiskSpace parameter exceeds the maximum space available for a SWF file, or the remaining space available for a SWF file, or if there was an error processing the request, flush() returns false.
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, getLocal() creates one. This method is a static method of the SharedObject class. Note: In Flash Lite, a shared object cannot be shared between two SWF files. To assign the object to a variable, use syntax like the following var so:SharedObject = SharedObject.
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.
If the shared object listener has not yet been called, getSize() returns 0. For details about using the listener, see the addListener() method. Availability: ActionScript 1.0; Flash Lite 2.0 Returns Number - A numeric value specifying the size of the shared object, in bytes.
The following events notify you when certain SharedObject activities occur: Code property Level property Meaning SharedObject.Flush.Failed Error SharedObject.flush() method that returned "pending" has failed (the user did not allot additional disk space for the shared object when Flash Player showed the Local Storage Settings dialog box). SharedObject.Flush.Success Status SharedObject.
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."; break; } See also getLocal (SharedObject.getLocal method), onStatus (System.onStatus handler) removeListener (SharedObject.
Availability: ActionScript 1.0; Flash Lite 2.0 Property summary Modifiers Property Description duration:Number [read-only] The duration of a sound, in milliseconds. id3:Object [read-only] Provides access to the metadata that is part of an MP3 file. position:Number [read-only] The number of milliseconds a sound has been playing. Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.
Method summary Modifiers Signature Description attachSound(id:String) : Void Attaches the sound specified in the id parameter to the specified Sound object. getBytesLoaded() : Number Returns the number of bytes loaded (streamed) for the specified Sound object. getBytesTotal() : Number Returns the size, in bytes, of the specified Sound object. getPan() : Number Returns the pan level set in the last setPan() call as an integer from 100 (left) to +100 (right).
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.
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+" ms ("+Math.round(totalSeconds)+" seconds)"); var minutes:Number = Math.floor(totalSeconds/60); var seconds = Math.
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.
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) this.createTextField("status_txt", this.getNextHighestDepth(), 10, 50, 300, 40); status_txt.autoSize = true; status_txt.
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 Number - An integer indicating the total size, in bytes, of the specified Sound object. Example For a sample usage of this method, see Sound.getBytesLoaded(). See also getBytesLoaded (Sound.getBytesLoaded method) getPan (Sound.
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(); } else { output.text = "loading failure"; } }; my_sound.loadSound("song1.mp3",false); See also setPan (Sound.setPan method) getTransform (Sound.
transform_mc.transform_txt.html = true; var knob_ll:MovieClip = transform_mc.attachMovie("knob_id", transform_mc.getNextHighestDepth(), {_x:0, _y:30}); var knob_lr:MovieClip = transform_mc.attachMovie("knob_id", transform_mc.getNextHighestDepth(), {_x:30, _y:30}); var knob_rl:MovieClip = transform_mc.attachMovie("knob_id", transform_mc.getNextHighestDepth(), {_x:60, _y:30}); var knob_rr:MovieClip = transform_mc.attachMovie("knob_id", transform_mc.getNextHighestDepth(), {_x:90, _y:30}); knob_ll.
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 = ""; transform_mc.
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(); my_sound.loadSound("song3.mp3", true); this.createEmptyMovieClip("knob_mc", this.getNextHighestDepth()); knob_mc.left = knob_mc._x; knob_mc.right = knob_mc.left+100; knob_mc.top = knob_mc.
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 Sound.attachSound() or Sound.loadSound() contains ID3 tags, you can query these properties. Only ID3 tags that use the UTF-8 character set are supported. Flash Player 6 (6.0.40.0) and later use the Sound.id3 property to support ID3 1.
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 TYER Year WXXX URL link frame Flash Player 6 supported several ID31.0 tags.
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) public loadSound(url:String, isStreaming:Boolean) : Void Loads an MP3 file into a Sound object.
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 Sound.attachSound() or Sound.loadSound(). This handler provides access to ID3 data without polling. If both ID3 1.0 and ID3 2.0 tags are present in a file, this handler is called twice. Availability: ActionScript 1.
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 Sound.onSoundComplete). You should define this handler before you call mySound.loadSound(). Availability: ActionScript 1.
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. Availability: ActionScript 1.0; Flash Lite 2.0 Example Usage 1: The following example uses an anonymous function: var my_sound:Sound = new Sound(); my_sound.
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, pan determines which speaker (left or right) the sound plays through. Note: Flash Lite 2.0 supports this method for native Flash sound only. The sound formats that are specific to a host device are not supported. Availability: ActionScript 1.
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 use setTransform() to play mono sounds as stereo, play stereo sounds as mono, and to add interesting effects to sounds. Note: Flash Lite 2.0 supports this method for native Flash sound only. The sound formats that are specific to a host device are not supported.
Example The following example illustrates a setting that can be achieved by using setTransform(), but cannot be achieved by using setVolume() or setPan(), even if they are combined. The following code creates a new soundTransformObject object and sets its properties so that sound from both channels plays in the left channel only . var mySoundTransformObject:Object = new Object(); mySoundTransformObject.ll = 100; mySoundTransformObject.lr = 100; mySoundTransformObject.rr = 0; mySoundTransformObject.
Parameters value:Number - A number from 0 to 100 representing a volume level. 100 is full volume and 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]) Creates a new Sound object for a specified movie clip. If you do not specify a target instance, the Sound object controls all of the sounds in the movie.
Parameters [optional] - A parameter that lets you start playing the sound at a 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 secondOffset parameter. The sound is not delayed 15 seconds, but rather starts playing at the 15-second mark. secondOffset:Number [optional] - A parameter that lets you specify the number of times the sound should play consecutively. This parameter is not available if the sound is a streaming sound.
Parameters [optional] - A parameter specifying a specific sound to stop playing. The parameter must be enclosed in quotation marks (" "). linkageID:String idName Example The following example uses two buttons, stop_btn and play_btn, to control the playback of 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(); my_sound.loadSound("song1.mp3", true); stop_btn.
Property summary Modifiers Property Description static align:String Indicates the current alignment of the SWF file in the player or browser. static height:Number Property (read-only); indicates the current height, in pixels, of the Stage. static scaleMode:String Indicates the current scaling of the SWF file within Flash Player. static width:Number Property (read-only); indicates the current width, in pixels, of the Stage. Properties inherited from class Object constructor (Object.
addListener (Stage.addListener method) public static addListener(listener:Object) : Void Detects when a SWF file is resized (but only if Stage.scaleMode = "noScale"). The addListener() method doesn't work with the default movie clip scaling setting (showAll) or other scaling settings (exactFit and noBorder). To use addListener(), you must first create a listener object. Stage listener objects receive notification from Stage.onResize. Availability: ActionScript 1.0; Flash Lite 2.
The following table lists the values for the align property. Any value not listed here centers the SWF file in Flash player or browser area, which is the default setting. Value Vertical Horizontal "T" top center "B" bottom center "L" center left "R" center right "TL" top left "TR" top right "BL" bottom left "BR" bottom right Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example demonstrates different alignments of the SWF file.
Example This example creates a new listener object called stageListener. It then uses myListener to call onResize and define a function that will be called when onResize is triggered. Finally, the code adds the myListener object to the callback list of the Stage object. Listener objects allow multiple objects to listen for resize notifications. this.createTextField("stageSize_txt", this.getNextHighestDepth(), 10, 10, 100, 22); var stageListener:Object = new Object(); stageListener.
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 listener:Object - An object added to an object's callback list with addListener(). Returns Boolean - A Boolean value. Example The following example displays the Stage dimensions in a dynamically created text field. When you resize the Stage, the values in the text field update.
scaleMode (Stage.scaleMode property) public static scaleMode : String Indicates the current scaling of the SWF file within Flash Player. The scaleMode property 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. The scaleMode property can use the values "exactFit", "showAll", "noBorder", and Any other value sets the scaleMode property to the default "showAll". "noScale".
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); indicates the current width, in pixels, of the Stage.
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 String() function.
Constructor summary Signature Description String(value:String) Creates a new String object. Method summary Modifiers static Signature Description charAt(index:Number) : String Returns the character in the position specified by the parameter index. charCodeAt(index:Number) : Number Returns a 16-bit integer from 0 to 65535 that represents the character specified by index.
Modifiers Signature Description substr(start:Number, length:Number) : Returns the characters in a string from the index specified in the start parameter through the number of characters specified in the length parameter. String substring(start:Number, end:Number) : String Returns a string comprising the characters between the points specified by the start and end parameters. toLowerCase() : String Returns a copy of the String object, with all uppercase characters converted to lowercase.
Parameters index:Number - An integer specifying the position of a character in the string. The first character is indicated by 0, and the last character is indicated by my_str.length-1. Returns - The character at the specified index. Or an empty String if the specified index is outside the range of this String's indeces. String Example In the following example, this method is called on the first letter of the string "Chris": var my_str:String = "Chris"; var firstChar_str:String = my_str.
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, my_str, is unchanged. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters value:Object - value1[,...valueN] Zero or more values to be concatenated. Returns String - A string. Example The following example creates two strings and combines them using String.
indexOf (String.indexOf method) public indexOf(value:String, [startIndex:Number]) : Number Searches the string and returns the position of the first occurrence of value found at or after startIndex within the calling string. This index is zero-based, meaning that the first character in a string is considered to be at index 0--not index 1. If value is not found, the method returns -1. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters value:String - A string; the substring to search for.
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 startIndex within the calling string. This index is zero-based, meaning that the first character in a string is considered to be at index 0--not index 1. If value is not found, the method returns -1. Availability: ActionScript 1.0; Flash Lite 2.
length (String.length property) public length : Number An integer specifying the number of characters in the specified String object. Because all string indexes are zero-based, the index of the last character for any string x is x.length - 1. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a new String object and uses String.length to count the number of characters: var my_str:String = "Hello world!"; trace(my_str.
slice (String.slice method) public slice(start:Number, end:Number) : String Returns a string that includes the start character and all characters up to, but not including, the end character. The original String object is not modified. If the end parameter is not specified, the end of the substring is the end of the string. If the character indexed by start is the same as or to the right of the character indexed by end, the method returns an empty string. Availability: ActionScript 1.0; Flash Lite 2.
trace("slice(1,1): "+my_str.slice(1, 1)); // slice(1,1): trace("slice(3,2): "+my_str.slice(3, 2)); // slice(3,2): trace("slice(-2,2): "+my_str.slice(-2, 2)); // slice(-2,2): // slices that omit the end parameter use String.length, which equals 5 trace("slice(0): "+my_str.slice(0)); // slice(0): Lorem trace("slice(3): "+my_str.slice(3)); // slice(3): em An example is also in the Strings.fla file in the ActionScript samples folder.
Example The following example returns an array with five elements: var my_str:String = "P,A,T,S,Y"; var my_array:Array = my_str.split(","); for (var i = 0; i
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. Availability: ActionScript 1.0; Flash Lite 2.0 Parameters value:String - The initial value of the new String object. substr (String.
Example The following example creates a new string, my_str and uses substr() to return the second word in the string; first, using a positive start parameter, and then using a negative start parameter: var my_str:String = new String("Hello world"); var mySubstring:String = new String(); mySubstring = my_str.substr(6,5); trace(mySubstring); // output: world mySubstring = my_str.substr(-5,5); trace(mySubstring); // output: world An example is also in the Strings.fla file in the ActionScript samples folder.
Example The following example shows how to use substring(): var my_str:String = "Hello world"; var mySubstring:String = my_str.substring(6,11); trace(mySubstring); // output: world The following example shows what happens if a negative start parameter is used: var my_str:String = "Hello world"; var mySubstring:String = my_str.substring(-5,5); trace(mySubstring); // output: Hello An example is also in the Strings.fla file in the ActionScript samples folder.
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.
toUpperCase (String.toUpperCase method) public toUpperCase() : String Returns a copy of the String object, with all lowercase characters converted to uppercase. The original value is unchanged. Availability: ActionScript 1.0; Flash Lite 2.0 Returns String - A string. Example The following example creates a string with all lowercase characters and then creates a copy of that string using toUpperCase(): var lowerCase:String = "lorem ipsum dolor"; var upperCase:String = lowerCase.
Example The following example creates a new instance of the String object and then shows that the valueOf method returns a reference to the primitive value, rather than an instance of the object. var str:String = new String("Hello World"); var value:String = str.
Event summary Event Description onStatus = function(infoObject:Object) {} Event handler: provides a super event handler 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), unwatch (Object.
Example The following example shows how to create a System.onStatus() function to process 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.
If you set System.useCodepage to true, remember that the traditional code page of the operating system running the player must include the characters used in your external text file in order for the text to display. For example, if you load an external 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.
See also Object, createTextField (MovieClip.createTextField method) Property summary Modifiers Property Description _alpha:Number Sets or retrieves the alpha transparency value of the text field. autoSize:Object Controls automatic sizing and alignment of text fields. background:Boolean Specifies if the text field has a background fill. backgroundColor:Number The color of the text field background. border:Boolean Specifies if the text field has a border.
Modifiers Property Description maxChars:Number Indicates the maximum number of characters that the text field can contain. maxhscroll:Number [read-only] Indicates the maximum value of TextField.hscroll. maxscroll:Number [read-only] Indicates the maximum value of TextField.scroll. multiline:Boolean Indicates whether the text field is a multiline text field. _name:String The instance name of the text field.
Modifiers Property Description _url:String [read-only] Retrieves the URL of the SWF file that created the text field. variable:String The name of the variable that the text field is associated with. _visible:Boolean A Boolean value that indicates whether the text field my_txt is visible. _width:Number The width of the text field, in pixels. wordWrap:Boolean A Boolean value that indicates if the text field has word wrap.
Event summary Event Description onChanged = function(changedField:TextField) {} Event handler/listener; invoked when the content of a text field changes. onKillFocus = function(newFocus:Object) {} Invoked when a text field loses keyboard focus. onScroller = function(scrolledField:TextField) {} Event handler/listener; invoked when one of the text field scroll properties changes. onSetFocus = function(oldFocus:Object) {} Invoked when a text field receives keyboard focus.
Modifiers Signature Description setNewTextFormat(tf:TextFormat) : Sets the default new text format of a text field. Void setTextFormat([beginIndex:Number], [endIndex:Number], textFormat:TextFormat) : Void Applies the text formatting specified by the textFormat parameter to some or all of the text in a text field. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.
Returns Boolean - Example The following example defines an onChanged handler for the input text field my_txt. It then defines a new listener object, txtListener, and defines an onChanged handler for that object. This handler will be invoked when the text field my_txt is changed. The final line of code calls TextField.addListener to register the listener object txtListener with the text field my_txt so that it will be notified when my_txt changes. this.createTextField("my_txt", this.
Example The following code sets the _alpha property of a text field named my_txt to 20%. Create a new font symbol in the library by selecting New Font from the Library options menu. Then set the linkage of the font to my font.Set the linkage for a font symbol to my font. Add the following ActionScript to your FLA or ActionScript file: var my_fmt:TextFormat = new TextFormat(); my_fmt.font = "my font"; // where 'my font' is the linkage name of a font in the Library this.createTextField("my_txt", this.
If autoSize is set to "center", then the text is treated as center-justified text, meaning any 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, "\n" or "\r"), then the bottom side will also be resized to fit the next line of text. If wordWrap is also set to true, then only the bottom side of the text field will be resized and the left and right sides will remain fixed. Availability: ActionScript 1.
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 true, the text field has a background fill. If false, the text field has no background fill. Availability: ActionScript 1.0; Flash Lite 2.
border (TextField.border property) public border : Boolean Specifies if the text field has a border. If true, the text field has a border. If false, the text field has no border. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field called my_txt, sets the border property to true, and displays some text in the field. this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 320, 240); my_txt.border = true; my_txt.
All the text between lines TextField.scroll and TextField.bottomScroll is currently 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 and bottomScroll properties for the text field are then traced for the comment_txt field. this.createTextField("comment_txt", this.getNextHighestDepth(), 0, 0, 160, 120); comment_txt.
Example The following example creates two text fields, called first_txt and second_txt. The white 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); first_txt.html = true; first_txt.multiline = true; first_txt.wordWrap = true; first_txt.condenseWhite = false; first_txt.border = true; first_txt.
Example In this example, you need to create a dynamic text field called my_txt, and then use the following ActionScript to embed fonts and rotate the text field. The string my font refers to a font symbol in the library, with the linkage identifier name my font. The example assumes that you have a font symbol in the library called my font, with linkage properties set as follows: the identifier set to my font and Export for ActionScript and Export in First Frame selected.
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 getNewTextFormat() is invoked, the TextFormat object returned has all of its properties defined. No property is null. Availability: ActionScript 1.0; Flash Lite 2.0 Returns TextFormat - A TextFormat object.
■ Usage 3:my_textField.getTextFormat(beginIndex:Number,endIndex:Number) Returns a TextFormat object containing formatting information for the span of text from beginIndex to endIndex. Only properties that are common to all of the text in the 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. Availability: ActionScript 1.0; Flash Lite 2.
_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 Deprecated since Flash Player 7. This property was deprecated in favor of TextField._quality. Specifies the level of anti-aliasing applied to the current SWF file.
Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example scrolls the my_txt text field horizontally using two buttons called scrollLeft_btn and scrollRight_btn. The amount of scroll appears in a text field called scroll_txt. Add the following ActionScript to your FLA or ActionScript file: this.createTextField("scroll_txt", this.getNextHighestDepth(), 10, 10, 160, 20); this.createTextField("my_txt", this.getNextHighestDepth(), 10, 30, 160, 22); my_txt.border = true; my_txt.
Example The following example creates a text field that sets the html property to true. HTMLformatted text appears in the text field. this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 160, 22); my_txt.html = true; my_txt.htmlText = " this is bold text "; See also htmlText (TextField.htmlText property) htmlText (TextField.htmlText property) public htmlText : String If the text field is an HTML text field, this property contains the HTML representation of the text field's contents.
Example The following example outputs the number of characters in the date_txt text field, which 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.
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 my_txt. Create two buttons, scrollUp_btn and scrollDown_btn, to scroll the text field. Add the following ActionScript to your FLA or ActionScript file. this.createTextField("scroll_txt", this.getNextHighestDepth(), 10, 10, 160, 20); this.
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; myText.wordWrap = true; myText.multiline = true; _name (TextField._name property) public _name : String The instance name of the text field.
A reference to the text field instance is passed as a parameter to the onChanged handler. You can capture this data by putting a parameter in the event handler method. For example, the following code uses textfield_txt as the parameter that is passed to the onChanged event handler. The parameter is then used in a trace() statement to send the instance name of the text field to the Output panel: this.createTextField("myInputText_txt", 99, 10, 10, 300, 20); myInputText_txt.border = true; myInputText_txt.
Example The following example creates two text fields called first_txt and second_txt. When you 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); first_txt.border = true; first_txt.type = "input"; this.createTextField("second_txt", 2, 10, 40, 300, 20); second_txt.border = true; second_txt.type = "input"; first_txt.
is called whether the scroll position changed because of a users interaction with the text field, or programmatic changes. The onChanged handler fires only if a user 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. onScroller Availability: ActionScript 1.0; Flash Lite 2.
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 oldFocus parameter is the object that loses the focus. For example, if the user presses the Tab key to move the input focus from a button to a text field, oldFocus contains the button instance.
Example The following ActionScript creates two text fields and outputs information about the _parent of each object. The first text field, first_txt, is created on the main Timeline. The second text field, second_txt, is created inside the movie clip called holder_mc. this.createTextField("first_txt", this.getNextHighestDepth(), 10, 10, 160, 22); first_txt.border = true; trace(first_txt._name+"'s _parent is: "+first_txt._parent); this.createEmptyMovieClip("holder_mc", this.getNextHighestDepth()); holder_mc.
Example The following example creates two text fields: username_txt and password_txt. Text is entered into both text fields; however, password_txt has the password property set to true. Therefore, the characters display as asterisks instead of as characters in the password_txt field. this.createTextField("username_txt", this.getNextHighestDepth(), 10, 10, 100, 22); username_txt.border = true; username_txt.type = "input"; username_txt.maxChars = 16; username_txt.text = "hello"; this.
Example The following example sets the rendering quality to LOW: 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 TextField.onChanged or TextField.onScroller.
}; 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 MovieClip.createTextField(). When you call this method, the text field is removed. This method is similar to MovieClip.
Parameters beginIndex:Number endIndex:Number newText:String - The start index value for the replacement range. - The end index value for the replacement range. - The text to use to replace the specified range of characters. Example The following example creates a text field called my_txt and assigns the text dog@house.net to the field. The indexOf() method is used to find the first occurrence of the specified symbol (@).
Example In this example, you need to create a dynamic text field called my_txt, and then use the following ActionScript to embed fonts and rotate the text field. The string my font refers to a font symbol in the library, with a linkage identifier of my font. var my_fmt:TextFormat = new TextFormat(); my_fmt.font = "my font"; this.createTextField("my_txt", this.getNextHighestDepth(), 10, 10, 160, 120); my_txt.wordWrap = true; my_txt.embedFonts = true; my_txt.text = "Hello world"; my_txt.
Example The following example sets the maximum value for the scrolling text field my_txt. Create two buttons, scrollUp_btn and scrollDown_btn, to scroll the text field. Add the following ActionScript to your FLA or ActionScript file. this.createTextField("scroll_txt", this.getNextHighestDepth(), 10, 10, 160, 20); this.createTextField("my_txt", this.getNextHighestDepth(), 10, 30, 320, 240); my_txt.multiline = true; my_txt.wordWrap = true; for (var i = 0; i<10; i++) { my_txt.
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); date_txt.autoSize = true; date_txt.selectable = true; var date_interval:Number = setInterval(updateTime, 500, date_txt); function updateTime(my_txt:TextField) { my_txt.text = new Date().
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.
Availability: ActionScript 1.0; Flash Lite 2.0 Parameters [optional] - An integer that specifies the first character of the desired text span. If you do not specify beginIndex and endIndex, the TextFormat is applied to the entire TextField. beginIndex:Number endIndex:Number [optional] - An integer that specifies the first character after the desired text span. If you specify beginIndex but do not specify endIndex, the TextFormat is applied to the single character specified by beginIndex.
_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 _soundbuftime. Setting this property for a TextField object actually sets the global property. For more information and an example, see _soundbuftime.
Example The following example creates a new text field at runtime, called news_txt. Three buttons on the Stage, css1_btn, css2_btn and clearCss_btn, are used to change the style sheet that is applied to news_txt, or clear the style sheet from the text field. Add the following ActionScript to your FLA or ActionScript file: this.createTextField("news_txt", this.getNextHighestDepth(), 0, 0, 300, 200); news_txt.wordWrap = true; news_txt.multiline = true; news_txt.
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; font-family: Arial,Helvetica,sans-serif; font-size: 18px; font-weight: bold; display: block; } // in styles2.css .important { color: #FF00FF; } .bold { font-weight: bold; } .
Example The following example creates several text fields, called one_txt, two_txt, three_txt and four_txt. The three_txt text field has the tabEnabled property set to false, so it is excluded from the automatic tab ordering. this.createTextField("one_txt", this.getNextHighestDepth(), 10, 10, 100, 22); one_txt.border = true; one_txt.type = "input"; this.createTextField("two_txt", this.getNextHighestDepth(), 10, 40, 100, 22); two_txt.border = true; two_txt.type = "input"; this.
The custom tab ordering defined by the tabIndex property is flat. This means that no attention is paid to the hierarchical relationships of objects in the SWF file. All objects in the SWF file with tabIndex properties are placed in the tab order, and the tab order is determined by the order of the tabIndex values. If two objects have the same tabIndex value, the one that goes first is undefined. You should not use the same tabIndex value for multiple objects. Availability: ActionScript 1.0; Flash Lite 2.
Example The following ActionScript creates a text field called my_txt and outputs the target path of 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. Lines are separated by the carriage return character ("\r", ASCII 13).
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 (#000000) and white, at the opposite end of the color system, is (#FFFFFF). Availability: ActionScript 1.0; Flash Lite 2.
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.
_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. this.createTextField("my_txt", 1, 10, 10, 100, 22); trace(my_txt._url); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace(target_mc.
_visible (TextField._visible property) public _visible : Boolean A Boolean value that indicates whether the text field my_txt is visible. Text fields that are not visible (_visible property set to false) are disabled. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field called my_txt. A button called visible_btn toggles the visibility of my_txt. this.createTextField("my_txt", 1, 10, 10, 200, 22); my_txt.background = true; my_txt.
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; height_txt.onChanged = function() { my_txt._height = this.
_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). If the text field is inside a movie clip that has transformations, the text field is in the local coordinate system of the enclosing movie clip.
Example The following example creates three text fields on the Stage. The mouse_txt instance displays the current position of the mouse in relation to the Stage. The textfield_txt instance displays the current position of the mouse pointer in relation to the my_txt instance. Add the following ActionScript to a FLA or ActionScript file: this.createTextField("mouse_txt", this.getNextHighestDepth(), 10, 10, 200, 22); mouse_txt.border = true; this.createTextField("textfield_txt", this.
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.
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. The default registration point is (0,0). Availability: ActionScript 1.0; Flash Lite 2.0 Example See the example for TextField._xscale. See also _x (TextField.
Property summary Modifiers 696 Property Description align:String A string that indicates the alignment of the paragraph. blockIndent:Number A number that indicates the block indentation in points. bold:Boolean A Boolean value that specifies whether the text is boldface. bullet:Boolean A Boolean value that indicates that the text is part of a bulleted list. color:Number A number that indicates the color of text. font:String A string that specifies the name of the font for text.
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 TextFormat([font:String], [size:Number], Creates a TextFormat object with the specified properties.
The default value is null, which indicates that the property is undefined. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field with a border and uses TextFormat.align to center the text. var my_fmt:TextFormat = new TextFormat(); my_fmt.align = "center"; this.createTextField("my_txt", 1, 100, 100, 300, 100); my_txt.multiline = true; my_txt.wordWrap = true; my_txt.border = true; my_txt.text = "this is my first text field object text"; my_txt.
bold (TextFormat.bold property) public bold : Boolean A Boolean value that specifies whether the text is boldface. The default value is null, which indicates that the property is undefined. If the value is true, the text is boldface. Note: For Arabic, Hebrew, and Thai, this property works for paragraph-level formatting only. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field that includes characters in boldface.
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(); my_fmt.bullet = true; this.createTextField("my_txt", 1, 100, 100, 300, 100); my_txt.multiline = true; my_txt.wordWrap = true; my_txt.border = true; my_txt.
font (TextFormat.font property) public font : String A string that specifies the name of the font for text. The default value is null, which indicates 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. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field and sets the font to Courier. this.createTextField("mytext",1,100,100,100,100); mytext.
If you are creating a text field based on the text metrics, use textFieldHeight rather than height and textFieldWidth rather than 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. The default value for leading is 2. Availability: ActionScript 1.0; Flash Lite 2.0 - The width parameter is supported in Flash Player 7.
// Create a TextFormat object, // and apply its properties. var my_fmt:TextFormat = new TextFormat(); with (my_fmt) { font = "Arial"; bold = true; } // Obtain metrics information for the text string // with the specified formatting. var metrics:Object = my_fmt.getTextExtent(my_str); // Create a text field just large enough to display the text. this.createTextField("my_txt", this.getNextHighestDepth(), 100, 100, metrics.textFieldWidth, metrics.textFieldHeight); my_txt.border = true; my_txt.
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 null, which indicates that the property is undefined. 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); mytext.multiline = true; mytext.wordWrap = true; mytext.
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 null, which indicates that the property is undefined. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example creates a text field and sets the leading to 10. var my_fmt:TextFormat = new TextFormat(); my_fmt.leading = 10; this.createTextField("my_txt", 1, 100, 100, 100, 100); my_txt.multiline = true; my_txt.
rightMargin (TextFormat.rightMargin property) public rightMargin : Number The right margin of the paragraph, in points. The default value is null, which indicates that 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); mytext.multiline = true; mytext.wordWrap = true; mytext.border = true; var myformat:TextFormat = new TextFormat(); myformat.
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 (null), the default tab stop is 4 (average character width). Note: For Flash Lite, this property works for embedded fonts only. This property is not supported for Arabic, Hebrew, and Thai. Availability: ActionScript 1.0; Flash Lite 2.
Example The following example creates a text field with a hyperlink to the Macromedia website. The example uses TextFormat.target to display the Macromedia website in a new browser window. var myformat:TextFormat = new TextFormat(); myformat.url = "http://www.macromedia.com"; myformat.target = "_blank"; this.createTextField("mytext",1,100,100,200,100); mytext.multiline = true; mytext.wordWrap = true; mytext.border = true; mytext.html = true; mytext.text = "Go to Macromedia.com"; mytext.
[optional] - The URL to which the text in this text format hyperlinks. If url is an empty string, the text does not have a hyperlink. url:String target:String [optional] - The target window where the hyperlink is displayed. If the target window is an empty string, the text is displayed in the default target window _self. If the url parameter is set to an empty string or to the value null, you can get or set this property, but the property will have no effect.
underline (TextFormat.underline property) public underline : Boolean A Boolean value that indicates whether the text that uses this text format is underlined (true) or not (false). This underlining is similar to that produced by the tag, but the latter is not true underlining, because it does not skip descenders correctly. The default value is null, which indicates that the property is undefined. Note: For Arabic, Hebrew, and Thai, this property works for paragraph-level formatting only.
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). The player for Flash Lite 2.
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 onStatus = function(infoObject:Object) {} Callback handler that can be invoked by the device to indicate status or error conditions.
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 play (Video.play method) onStatus (Video.
pause (Video.pause method) public pause() : Void Stops playback of the video and continues to render the current frame onscreen. A subsequent call to Video.resume() resumes playback from the current position. Availability: ActionScript 2.0; Flash Lite 2.0 Example The following example stops the video that is playing in a Video object (called my_video) when the user clicks the close_btn instance. // video1 is the name of a Video object on Stage video1.pause() See also play (Video.play method) play (Video.
resume (Video.resume method) public resume() : Void Calling this method resumes playback of the video. If Video.pause() was previously called, playback begins from the current position. If Video.stop() was previously called, playback begins from the first frame. Availability: ActionScript 2.0; Flash Lite 2.0 Example The following example resumes the video that is playing in a Video object called video1. video1.resume() See also pause (Video.pause method) stop (Video.
XML 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 new XML() to create an XML object before calling any method of the XML class. An XML document is represented in Flash by the XML class. Each element of the hierarchical document is represented by an XMLNode object.
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.
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 onData = function(src:String) {} Invoked when XML text has been completely downloaded from the server, or when an error occurs downloading XML text from a server. onLoad = function(success:Boolean) {} Invoked by Flash Player when an XML document is received from the server.
Modifiers Signature Description parseXML(value:String) : Void Parses the XML text specified in the value parameter, and populates the specified XML object with the resulting XML tree. send(url:String, [target:String], method:String) : Boolean sendAndLoad(url:String, resultXML:XML) : Void Encodes the specified XML object into an XML document, and sends it to the specified URL using the POST method in a browser.
If multiple calls are made to set the same header name, each successive value replaces the value set in the previous call.
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.
Example The following example creates three XML nodes using the createElement() method: // 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); element1.appendChild(element2); element1.
Example The following example creates two XML text nodes using the createTextNode() method, 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"); var element3:XMLNode = doc.createElement("element3"); // place the new nodes into the XML tree doc.appendChild(element1); element1.appendChild(element2); element1.
If no DOCTYPE declaration was encountered during a parse operation, the XML.docTypeDecl property is set to undefined. The XML.toString() method outputs the contents of XML.docTypeDecl immediately after the XML declaration stored in XML.xmlDecl, and before any other text in the XML object. If XML.docTypeDecl is undefined, no DOCTYPE declaration is output. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example uses the XML.
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.
Usage 1: You can set the ignoreWhite property for individual XML objects, as the following code shows: my_xml.ignoreWhite = true; Usage 2: You can set the default ignoreWhite property for XML objects, as the following code shows: XML.prototype.ignoreWhite = true; Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example loads an XML file with a text node that contains only white space; the foyer tag comprises fourteen space characters.
// set the ignoreWhite property to false (default value) flooring.ignoreWhite = false; ... // output (line breaks added for clarity): ceramic tile linoleum The XML_blogTracker.fla and XML_languagePicker.fla files in the ActionScript samples folder also contain a code example.
You can define a custom function that executes when the onLoad event handler of the XML 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 located. If the SWF file that issues this call is running in a web browser, url must be in the same domain as the SWF file; for details, see the Description section.
loaded (XML.loaded property) public loaded : Boolean Indicates if the XML document has successfully loaded. If there is no custom onLoad() event handler defined for the XML object, then this property is set to true when the documentloading process initiated by the XML.load() call has completed successfully; otherwise, it is false. However, if you define a custom behavior for the onLoad() event handler for the XML object, be sure to set onload in that function. Availability: ActionScript 1.0; Flash Lite 2.
Availability: ActionScript 1.0; Flash Lite 2.0 Parameters src:String - A string or undefined; the raw data, usually in XML format, that is sent by the 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); } else { this.parseXML(src); this.loaded = true; this.onLoad(true); } } You can override the XML.onData event handler to intercept the XML text without parsing it.
Example The following example includes ActionScript for a simple e-commerce storefront application. The sendAndLoad() method transmits an XML element that contains the user's name and password, and uses an XML.onLoad handler to process the reply from the server. var login_str:String = ""; var my_xml:XML = new XML(login_str); var myLoginReply_xml:XML = new XML(); myLoginReply_xml.ignoreWhite = true; myLoginReply_xml.
Example The following example creates and parses an XML packet: var xml_str:String = " San Francisco" // 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(); my2_xml.parseXML(xml_str); trace(my2_xml.firstChild.attributes.name); // output: California send (XML.
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("Ernie 13045"); my_xml.contentType = "text/xml"; my_xml.send("http://www.flash-mx.com/mm/highscore.cfm", "_blank"); Press F12 to test this example in a browser. See also sendAndLoad (XML.sendAndLoad method) sendAndLoad (XML.
Parameters url:String - A string; the destination URL for the specified XML object. If the SWF file issuing this call is running in a web browser, url must be in the same domain as the SWF file; for details, see the Description section. - A target XML object created with the XML constructor method that will receive the return information from the server. resultXML:XML Example The following example includes ActionScript for a simple e-commerce storefront application. The XML.
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. ■ -2 A CDATA section was not properly terminated. ■ -3 The XML declaration was not properly terminated. ■ -4 The DOCTYPE declaration was not properly terminated. ■ -5 A comment was not properly terminated.
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; case -8 : errorMessage = "An attribute value was not properly terminated."; break; case -9 : errorMessage = "A start-tag was not matched with an end-tag.
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 source parameter, and populates the newly created XML object with the resulting XML document tree: var other_xml:XML = new XML("San Francisco"); See also createElement (XML.createElement method), createTextNode (XML.createTextNode method) xmlDecl (XML.
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.
Property summary Modifiers Property Description attributes:Object An object containing all of the attributes of the specified XML instance. childNodes:Array [read-only] An array of the specified XML object's children. firstChild:XMLNode [read-only] Evaluates the specified XML object and references the first child in the parent node's child list. lastChild:XMLNode [read-only] An XMLNode value that references the last child in the node's child list.
Method summary Modifiers Signature Description appendChild(newChild:XMLNode) : Void Appends the specified node to the XML object's child list. cloneNode(deep:Boolean) : XMLNode Constructs and returns a new XML node of the same type, name, value, and attributes as the specified XML object. hasChildNodes() : Boolean Specifies whether or not the XML object has child nodes. insertBefore(newChild:XMLNode, Inserts a newChild node into the XML object's child list, before the insertPoint node.
Parameters - An XMLNode that represents the node to be moved from its current location to the child list of the my_xml object. newChild:XMLNode Example This example does the following things in the order shown: ■ Creates two empty XML documents, doc1 and doc2. ■ Creates a new node using the createElement() method, and appends it, using the appendChild() method, to the XML document named doc1. ■ Shows how to move a node using the appendChild() method, by moving the root node from doc1 to doc2.
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.
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"); var middle:XMLNode = doc.createElement("middle"); var youngest:XMLNode = doc.createElement("youngest"); // add the rootNode as the root of the XML document tree doc.
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 deep is set to true, all child nodes are recursively cloned, resulting in an exact copy of the original object's document tree. The clone of the node that is returned is no longer associated with the tree of the cloned item. Consequently, nextSibling, parentNode, and previousSibling all have a value of null.
// insert the clone node into rootNode between the middle and youngest nodes rootNode.insertBefore(middle2, youngest); trace(rootNode); // output (with line breaks added): // // // // // // // create a copy of rootNode using cloneNode() to demonstrate a deep copy var rootClone:XMLNode = rootNode.cloneNode(true); // insert the clone, which contains all child nodes, to rootNode rootNode.
Example The following example shows how to use XML.firstChild to loop through a node's 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"); var middle:XMLNode = doc.createElement("middle"); var youngest:XMLNode = doc.createElement("youngest"); // add the rootNode as the root of the XML document tree doc.
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 Boolean - true if the specified XMLNode has one or more child nodes; otherwise false. Example The following example creates a new XML packet.
Parameters newChild:XMLNode - The XMLNode object to be inserted. insertPoint:XMLNode - The XMLNode object that will follow the newChild node after the method is invoked. Example The following inserts a new XML node between two existing nodes: var my_xml:XML = new XML("1\n3"); var insertPoint:XMLNode = my_xml.lastChild; var newNode:XML = new XML("2\n"); my_xml.insertBefore(newNode, insertPoint); trace(my_xml); See also XML, cloneNode (XMLNode.cloneNode method) lastChild (XMLNode.
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: The following example creates a new XML packet and uses the XML.
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 null if the node does not have a next sibling node. This property cannot be used to manipulate child nodes; use the appendChild(), insertBefore(), and removeNode() methods to manipulate child nodes. Availability: ActionScript 1.0; Flash Lite 2.0 Example The following example is an excerpt from the example for the XML.
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); // create an XML text node using createTextNode() var myTextNode:XMLNode = doc.createTextNode("textNode"); // place the new node into the XML tree myNode.appendChild(myTextNode); trace(myNode.
nodeType (XMLNode.nodeType property) public nodeType : Number [read-only] A nodeType value, either 1 for an XML element or 3 for a text node. The nodeType is a numeric value from the NodeType enumeration in the W3C DOM Level 1 recommendation: www.w3.org/tr/1998/REC-DOM-Level-1-19981001/level-onecore.html.
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 nodeType is 3, and the nodeValue is the text of the node.
// 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 firstChild property and firstChild.nodeValue. When you use firstChild to display contents of the node, it maintains the & entity. However, when you explicitly use nodeValue, it converts to the ampersand character (&). var my_xml:XML = new XML("mortongood&evil"); trace("using firstChild:"); for (var i = 0; i
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 node var rootNode:XMLNode = my_xml.firstChild; // first child of the root is the node var targetNode:XMLNode = rootNode.firstChild; trace("the parent node of '"+targetNode.nodeName+"' is: "+targetNode.parentNode.nodeName); trace("contents of the parent node are:\n"+targetNode.
See also lastChild (XMLNode.lastChild property), appendChild (XMLNode.appendChild method), insertBefore (XMLNode.insertBefore method), removeNode (XMLNode.removeNode method), XML 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.
For top-level XML objects (those created with the constructor), the XML.toString() method outputs the document's XML declaration (stored in the XML.xmlDecl property), followed by the document's DOCTYPE declaration (stored in the XML.docTypeDecl property), followed by the text representation of all XML nodes in the object. The XML declaration is not output if the XML.xmlDecl property is undefined. The DOCTYPE declaration is not output if the XML.docTypeDecl property is undefined.
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.
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. Availability: ActionScript 1.0; Flash Lite 2.0 get (XMLUI.
ActionScript classes
3 CHAPTER 3 Deprecated ActionScript The evolution of ActionScript has deprecated many elements of the language. This section lists the deprecated items and suggests alternatives when available. 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.
Modifiers Function Name Description mbchr(number:Number) Deprecated since Flash Player 5. This function was deprecated in favor of the String.fromCharCode() method. mblength(string:String)Number Deprecated since Flash Player 5. This function was deprecated in favor of the methods and properties of the String class. mbord(character:String)Numb er Deprecated since Flash Player 5. This function was deprecated in favor of String.charCodeAt().
Deprecated Property summary Modifiers Property Name Description Button._highquality Deprecated since Flash Player 7. This property was deprecated in favor of Button._quality. MovieClip._highquality Deprecated since Flash Player 7. This property was deprecated in favor of MovieClip._quality. TextField._highquality Deprecated since Flash Player 7. This property was deprecated in favor of TextField._quality. _highquality Deprecated since Flash Player 5.
Operator Description eq (equality (strings)) Deprecated since Flash Player 5. This operator was deprecated in favor of the == (equality) operator. ge (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. gt (greater than (strings)) Deprecated since Flash Player 5. This operator was deprecated in favor of the > (greater than) operator.
4 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.
Unsupported Global Functions asfunction, MMExecute, print, printAsBitmap, printAsBitmapNum, printNum, updateAfterEvent Unsupported Event Handlers onUpdate, Mouse.
Index Symbols 126, 128, 155, 156 ! logical NOT operator 160 != inequality operator 152 !== strict inequality operator 173 " string delimiter operator 174 #endinitclip directive 23 #include directive 24 #initclip directive 25 $version property 95 % modulo operator 164 %= modulo assignment operator 164 & bitwise AND operator 124 && logical AND operator 158 &= bitwise AND assignment operator 126 () parentheses operator 169 * multiplication operator 165 *= multiplication assignment operator 166 + addition opera
_rotation property 287, 510, 675 _soundbuftime property 109, 288, 512, 681 _target property 290, 518, 685 _totalframes property 519 _url property 292, 521, 689 _visible property 293, 522, 690 _width property 293, 523, 690 _x property 294, 523, 692 _xmouse property 294, 524, 692 _xscale property 295, 524, 693 _y property 296, 526, 694 _ymouse property 297, 526, 694 _yscale property 298, 527, 695 {} object initializer operator 168 | bitwise OR operator 130 |= bitwise OR assignment operator 131 || logical OR o
Button _alpha property 274 _focusrect property 276 _height property 278 _highquality property 278 _name property 278 _parent property 286 _quality property 287 _rotation property 287 _soundbuftime property 288 _target property 290 _url property 292 _visible property 293 _width property 293 _x property 294 _xmouse property 294 _xscale property 295 _y property 296 _ymouse property 297 _yscale property 298 enabled property 275 getDepth() method 277 tabEnabled property 289 tabIndex property 289 trackAsMenu prop
class dispatched by Button 279, 280, 281, 282, 283, 284, 285 dispatched by Key 383, 384 dispatched by LoadVars 400, 401 dispatched by Mouse 433, 435, 436 dispatched by MovieClip 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505 dispatched by MovieClipLoader 535, 537, 538, 539, 541 dispatched by Selection 578 dispatched by SharedObject 593 dispatched by Sound 610, 611, 612 dispatched by Stage 622 dispatched by System 643 dispatched by TextField 666, 667, 668, 670 dispatched by Video 713 dispatched b
default statement 186 delete statement 187 DELETEKEY property 374 DESCENDING property 254 do..
getMilliseconds() method 335 getMinutes() method 336 getMonth() method 336 GetNetworkConnectionName command 231 GetNetworkConnectStatus command 232 GetNetworkGeneration command 233 GetNetworkName command 233 GetNetworkRequestStatus command 234 GetNetworkStatus command 235 getNewTextFormat() method 659 getNextHighestDepth() method 471 getPan() method 602 GetPlatform command 236 GetPowerSource command 237 getProgress() method 532 getProperty function 48 getRGB() method 321 getSeconds() method 337 GetSignalLev
implements statement 202 import statement 203 indent property 704 indexOf() method 631 Infinity constant 28 initialize() method 409 INSERT property 380 insertBefore() method 747 instanceof operator 154 int function 54 interface statement 204 intrinsic statement 206 isDebugger property 314 isDown() method 381 isFinite function 54 isNaN function 55 isPropertyEnumerable() method 555 isPrototypeOf() method 556 italic property 704 J join() method 254 K Key _listeners property 383 addListener() method 372 BACKS
LoadVars() constructor 399 Locale addDelayedInstance() method 408 addXMLPath() method 408 checkXMLStatus() method 408 initialize() method 409 loadLanguageXML() method 409 loadString() method 409 setDefaultLang() method 409 setLoadCallback() method 410 Locale class 406 localFileReadDisable property 316 localToGlobal() method 487 log() method 420 LOG10E property 421 LOG2E property 421 lt less than (strings) operator 156 M Math abs() method 413 acos() method 414 asin() method 414 atan() method 415 atan2() met
createTextField() method 455 curveTo() method 457 duplicateMovieClip() method 461 enabled property 462 endFill() method 463 focusEnabled property 464 getBounds() method 466 getBytesLoaded() method 467 getBytesTotal() method 468 getDepth() method 469 getInstanceAtDepth() method 470 getNextHighestDepth() method 471 getSWFVersion() method 472 getURL() method 473 globalToLocal() method 474 gotoAndPlay() method 477 gotoAndStop() method 478 hitArea property 480 hitTest() method 480 lineStyle() method 482 lineTo()
toString() method 549 valueOf() method 549 Number class 544 Number function 68 Number() constructor 548 NUMERIC property 256 O Object __proto__ property 557 __resolve property 560 addProperty() method 551 constructor property 554 hasOwnProperty() method 555 isPropertyEnumerable() method 555 isPrototypeOf() method 556 Object() constructor 557 prototype property 558 registerClass() method 559 toString() method 563 unwatch() method 565 valueOf() method 565 watch() method 566 Object class 550 Object function 6
removeListener() method 385, 437, 542, 580, 595, 623, 673 removeMovieClip function 77 removeMovieClip() method 509 removeNode() method 756 removeTextField() method 674 replaceText() method 674 ResetSoftKeys command 239 resume() method 715 return statement 209 RETURNINDEXEDARRAY property 257 reverse() method 258 RIGHT property 386 rightMargin property 706 round() method 425 S scaleMode property 624 screenOrientation property 317 screenResolutionX property 318 screenResolutionY property 318 scroll property 1
SOFT9 property 366 softKeyCount property 318 sort() method 260 sortOn() method 262 Sound attachSound() method 598 duration property 598 getBytesLoaded() method 600 getBytesTotal() method 602 getPan() method 602 getTransform() method 603 getVolume() method 605 id3 property 607 loadSound() method 609 position property 612 setPan() method 613 setTransform() method 613 setVolume() method 615 Sound() constructor 616 start() method 616 stop() method 617 Sound class 595 onID3 event 610 onLoad event 611 onSoundComp
TextField _alpha property 651 _height property 661 _highquality property 661 _name property 666 _parent property 670 _quality property 672 _rotation property 675 _soundbuftime property 681 _target property 685 _url property 689 _visible property 690 _width property 690 _x property 692 _xmouse property 692 _xscale property 693 _y property 694 _ymouse property 694 _yscale property 695 addListener() method 650 autoSize property 652 background property 654 backgroundColor property 654 border property 655 border
U undefined constant 30 underline property 710 unescape function 90 UNIQUESORT property 267 unloadClip() method 543 unloadMovie function 91 unloadMovie() method 520 unloadMovieNum function 91 unshift() method 268 unwatch() method 565 UP property 389 url property 710 useCodepage property 644 UTC() method 356 V valueOf() method 270, 357, 549, 565, 641 var statement 221 variable property 689 version property 319 Video close() method 713 pause() method 714 play() method 714 resume() method 715 stop() method 71