Page 2
If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
CHAPTER 1 ActionScript language elements This section provides syntax, usage information, and code samples for global functions and properties (those elements that do not belong to an ActionScript class); compiler directives; and for the constants, operators, statements, and keywords used in ActionScript and defined in the ECMAScript (ECMA-262) edition 4 draft language specification.
The global Include directory, which is one of the following: --Windows 2000 or Windows XP: C:\Documents and Settings\user \Local Settings\ Application Data\Macromedia\Flash 8\language\Configuration\Include --Macintosh OS X: Hard Drive/Users/Library/Application Support/Macromedia/Flash 8/language/Configuration/Include The Flash 8 program\language\First Run\Include directory; if you save a file here, it is copied to the global Include directory the next time you start Flash.
Parameters The filename and optional path for the script to [path]filename.as:String filename.as add to the Actions panel or to the current script; .as is the recommended filename extension. Example The following examples show various ways of specifying a path for a file to be included in your script: // Note that #include statements do not end with a semicolon (;) // AS file is in same directory as FLA file or script...
Page 34
Do not place a semicolon (;) at the end of the line that contains the #initclip directive. Availability: ActionScript 1.0; Flash Player 6.0 Parameters [optional] - A non-negative integer that specifies the execution order of blocks order:Number code. This is an optional parameter. You must specify the value by using an #initclip integer literal (only decimal values are allowed, not hexadecimal), and not by using a variable.
Constants A constant is a variable used to represent a property whose value never changes. This section describes global constants that are available to every script. Constants summary Modifiers Constant Description A unique Boolean value that represents the opposite false of true.
// converts it to a string trace("String: " + bool1); // outputs String: false Infinity constant Specifies the IEEE-754 value representing positive infinity. The value of this constant is the same as Number.POSITIVE_INFINITY Availability: ActionScript 1.0; Flash Player 5 See also POSITIVE_INFINITY (Number.POSITIVE_INFINITY property) -Infinity constant Specifies the IEEE-754 value representing negative infinity.
Example The following example shows how displays output from the statement on newline trace() multiple lines. var myName:String = "Lisa", myAge:Number = 30; trace(myName+myAge); trace("-----"); trace(myName+newline+myAge); // output: Lisa30 ----- Lisa See also trace function null constant A special value that can be assigned to variables or returned by a function if no data was provided.
true constant A unique Boolean value that represents the opposite of . When automatic data typing false converts to a number, it becomes 1; when it converts to a string, it becomes true true "true" Availability: ActionScript 1.0; Flash Player 5 Example The following example shows the use of in an...
Page 39
In files published for Flash Player 6 or earlier, the value of . In files Number(undefined) published for Flash Player 7 or later, the value of Number(undefined) The value is similar to the special value . When undefined null null undefined compared with the equality ( ) operator, they compare as equal.
Global Functions This section contains a set of built-in functions that are available in any part of a SWF file where ActionScript is used. These global functions cover a wide variety of common programming tasks such as working with data types ( , and so on), Boolean() int()
Page 41
Deprecated since Flash Player 5. This function, along length(expression:St with all the string functions, has been deprecated. ring, Macromedia recommends that you use the methods variable:Object) of the String class and the String.length property to perform the same operations. Returns the length of the specified string or variable.
Page 42
Modifiers Signature Description Loads a SWF or JPEG file into Flash Player while the loadMovie(url:String original SWF file plays. , target:Object, [method:String]) Loads a SWF or JPEG file into a level in Flash Player loadMovieNum(url:Str while the originally loaded SWF file plays. ing, level:Number, [method:String]) Reads data from an external file, such as a text file or...
Page 43
Modifiers Signature Description Creates a new empty object or converts the specified Object([value:Object number, string, or Boolean value to an object. Specifies the mouse event or keypress that triggers on(mouseEvent:Object an action. Triggers actions defined for a specific instance of a onClipEvent(movieEve movie clip.
Page 44
Extracts part of a string. count:Number) Returns a string containing the target path of targetPath(targetObj movieClipObject. ect:Object) Deprecated since Flash Player 5. Macromedia tellTarget(target:St recommends that you use dot (.) notation and the ring, statement(s)) with statement. Applies the instructions specified in the statements parameter to the Timeline specified in the target parameter.
Modifiers Signature Description Evaluates the expression and outputs the result. trace(expression:Obj ect) Evaluates the parameter x as a string, decodes the unescape(string:Stri string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string. Removes a movie clip that was loaded by means of unloadMovie(target:O loadMovie() from Flash Player.
Parameters [optional] - A positive integer that specifies the number of elements in numElements:Number the array. You can specify either or the list of elements, but not both. numElements [optional] - One or more parameters, elementN:Object element0, element1, ... , , the values of which can be of any type.
Parameters - An identifier for a function. function:String - A string that is passed to the function named in the parameter:String function parameter. Example In the following example, the function is defined. The TextField object list_txt is playMP3() created and set so HTML text can be rendered. The text Track 1 and Track 2 are links inside the text field.
Page 48
is a string, the return value is as follows: expression In files published for Flash Player 6 and earlier, the string is first converted to a number. The value is if the number is not 0, otherwise the return value is true false In files published for Flash Player 7 and later, the result is...
This example shows a significant difference between use of the function and the Boolean() Boolean class. The function creates a Boolean value, and the Boolean class creates Boolean() a Boolean object. Boolean values are compared by value, and Boolean objects are compared by reference.
chr function chr(number:Number) : String Deprecated since Flash Player 5. This function was deprecated in favor of String.fromCharCode() Converts ASCII code numbers to characters. Availability: ActionScript 1.0; Flash Player 4 Parameters - An ASCII code number. number:Number Returns - The character value of the specified ASCII code. String Example The following example converts the number 65 to the letter A and assigns it to the variable...
You must clear the interval when you have finished using the function. Create a button called and use the following ActionScript to clear clearInt_btn setInterval() clearInt_btn.onRelease = function(){ clearInterval( intervalID ); trace("cleared interval"); See also setInterval function duplicateMovieClip function duplicateMovieClip(target:String, newname:String, depth:Number) : Void duplicateMovieClip(target:MovieClip, newname:String, depth:Number) : Void Creates an instance of a movie clip while the SWF file is playing.
Example In the following example, a new movie clip instance is created called An image is img_mc. loaded into the movie clip, and then the clip is duplicated. The duplicated clip is img_mc called , and this new clip is moved on the Stage so it does not overlap the original newImg_mc clip, and the same image is loaded into the second clip.
Example The following code produces the result someuser%40somedomain%2Ecom var email:String = "someuser@somedomain.com"; trace(escape(email)); In this example, the at symbol ( ) was replaced with and the dot symbol ( ) was replaced with . This is useful if you're trying to pass information to a remote server and the data has special characters in it (for example, ), as shown in the following code: &...
Lets the SWF file communicate with either Flash Player or the program that is hosting Flash Player, such as a web browser. You can also use the function to pass messages to fscommand() Macromedia Director, or to Visual Basic (VB), Visual C++, and other programs that can host ActiveX controls. ActionScript language elements...
Page 55
function lets a SWF file communicate with a script in a web page. fscommand() However, script access is controlled by the web page's setting. (You set allowScriptAccess this attribute in the HTML code that embeds the SWF file—for example, in the PARAM for Internet Explorer or the tag for Netscape.
Page 56
HTML page is in an untrusted sandbox. For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis ActionScript language elements...
Page 57
Director. For fscommand() more information, see the Director Support Center at www.macromedia.com/support/ director. Usage 4: In VisualBasic, Visual C++, and other programs that can host ActiveX controls, sends a VB event with two strings that can be handled in the environment's fscommand() programming language.
You must add a function to the web page that contains the SWF file. This function, , waits for an call. When myDocument_DoFSCommand() fscommand() fscommand() triggered in Flash (for example, when a user clicks the button), the command parameter strings are passed to the function.
Returns - The value of the specified property. Object Example The following example creates a new movie clip and shows the alpha value someClip_mc ) for the movie clip in the Output panel: _alpha someClip_mc this.createEmptyMovieClip("someClip_mc", 999); trace("The alpha of "+getProperty(someClip_mc, _name)+" is: "+getProperty(someClip_mc, _alpha));...
Page 60
This example loads an image into a movie clip. When the image is clicked, a new URL is loaded in a new browser window. var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc:MovieClip) { target_mc.onRelease = function() { getURL("http://www.macromedia.com/software/flash/flashpro/", "_blank"); var logo:MovieClipLoader = new MovieClipLoader(); logo.addListener(listenerObject); logo.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.createEmptyMovieClip("macromedia_mc", this.getNextHighestDepth()));...
= "Gus"; var lastName:String = "Richardson"; var age:Number = 92; myBtn_btn.onRelease = function() { getURL("http://www.macromedia.com", "_blank", "GET"); The following ActionScript uses to send variables in the HTTP header. Make sure you POST test your documents in a browser window, because otherwise your variables are sent using var firstName:String = "Gus";...
See also os (capabilities.os property) version (capabilities.version property) gotoAndPlay function gotoAndPlay([scene:String], frame:Object) : Void Sends the playhead to the specified frame in a scene and plays from that frame. If no scene is specified, the playhead goes to the specified frame in the current scene. You can use the scene parameter only on the root Timeline, not within Timelines for movie clips or other objects in the document.
gotoAndStop function gotoAndStop([scene:String], frame:Object) : Void Sends the playhead to the specified frame in a scene and stops it. If no scene is specified, the playhead is sent to the frame in the current scene.You can use the parameter only on scene the root Timeline, not within Timelines for movie clips or other objects in the document.
{ statement(s); Deprecated since Flash Player 5. This function has been deprecated. Macromedia recommends that you use the property. MovieClip._framesloaded Checks whether the contents of a specific frame are available locally. Use ifFrameLoaded start playing a simple animation while the rest of the SWF file downloads to the local computer.
isFinite function isFinite(expression:Object) : Boolean Evaluates and returns if it is a finite number or if it is infinity or expression true false negative infinity. The presence of infinity or negative infinity indicates a mathematical error condition such as division by 0. Availability: ActionScript 1.0;...
Deprecated since Flash Player 5. This function, along with all the string functions, has been deprecated. Macromedia recommends that you use the methods of the String class and the property to perform the same operations. String.length Returns the length of the specified string or variable.
Returns - The length of the specified string or variable. Number Example The following example returns the length of the string "Hello": length("Hello"); result is 5. See also " string delimiter operator String length (String.length property) loadMovie function loadMovie(url:String, target:Object, [method:String]) : Void loadMovie(url:String, target:String, [method:String]) : Void Loads a SWF, JPEG, GIF, or PNG file into a movie clip in Flash Player while the original SWF file is playing.
Page 68
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 3 - The ability to load JPEG files is available as of Flash Player 6.
Page 69
Example Usage 1: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called that already exists on the Stage: mySquare loadMovie("circle.swf", mySquare); // equivalent statement (Usage 1): loadMovie("circle.swf", _level0.mySquare); // equivalent statement (Usage 2): loadMovie("circle.swf", "mySquare"); The following example loads the SWF file circle.swf from the same directory, but replaces the main movie clip instead of the movie clip:...
loadMovieNum function loadMovieNum(url:String, level:Number, [method:String]) : Void Loads a SWF, JPEG, GIF, or PNG file into a level while the original SWF file is playing. Support for unanimated GIF files, PNG files, and progressive JPEG files is added in Flash Player 8.
Page 71
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 4 - Flash 4 files opened in Flash 5 or later are converted to use the correct syntax.
(a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables: company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103 In SWF files running in a version earlier than Flash Player 7, must be in the same superdomain as the SWF file that is issuing this call.
Page 73
Parameters - An absolute or relative URL where the variables are located. If the SWF file url:String issuing this call is running in a web browser, must be in the same domain as the SWF file; for details, see the Description section. - The target path to a movie clip that receives the loaded variables.
(a standard format used by CGI scripts). Any number of variables can be form-urlencoded specified. For example, the following phrase defines several variables: company=Macromedia&address=601+Townsend&city=San+Francisco&zip=94103 In SWF files running in a version of the player earlier than Flash Player 7, must be in the same superdomain as the SWF file that is issuing this call.
Example The following example loads information from a text file called params.txt into the main Timeline of the SWF at level 2 in Flash Player. The variable names of the text fields must match the variable names in the params.txt file. The function is used to setInterval() check the progress of the data being loaded into the SWF.
See also fromCharCode (String.fromCharCode method) mblength function mblength(string:String) : Number Deprecated since Flash Player 5. This function was deprecated in favor of the methods and properties of the String class. Returns the length of the multibyte character string. Availability: ActionScript 1.0; Flash Player 4 Parameters - The string to measure.
ActionScript script to call a JSAPI command directly. If you in a script on Frame 1 of your file, the command executes when the SWF MMExecute() file is loaded. For more information on the JSAPI, see www.macromedia.com/go/jsapi_info_en. Global Functions...
Page 78
Availability: ActionScript 1.0; Flash Player 7 Parameters - Any command that you can use in a Flash JavaScript (JSFL) file. command:String Returns - A string representation of the result, if any, sent by the JavaScript statement. String Example The following command will output the number of items in the library of the current document to the trace window.
nextFrame function nextFrame() : Void Sends the playhead to the next frame. Availability: ActionScript 1.0; Flash Player 2 Example In the following example, when the user presses the Right or Down arrow key, the playhead goes to the next frame and stops. If the user presses the Left or Up arrow key, the playhead goes to the previous frame and stops.
Example In the following example, when a user clicks the button that is created at runtime, the playhead is sent to Frame 1 of the next scene. Create two scenes, and enter the following ActionScript on Frame 1 of Scene 1. stop();...
Page 81
is a string, the function attempts to parse as a decimal expression expression number with an optional trailing exponent (that is, 1.57505e-3). , the return value is expression , the return value is as follows: expression undefined - In files published for Flash Player 6 or earlier, the result is 0. - In files published for Flash Player 7 or later, the result is Availability: ActionScript 1.0;...
Example In the following example, a new empty object is created, and then the object is populated with values: var company:Object = new Object(); company.name = "Macromedia, Inc."; company.address = "600 Townsend Street"; company.city = "San Francisco"; company.state = "CA";...
Page 83
Parameters is a trigger called an event . When the event occurs, the mouseEvent:Object mouseEvent statements following it within curly braces ({ }) execute. Any of the following values can be specified for the parameter: mouseEvent The mouse button is pressed while the pointer is over the button. press The mouse button is released while the pointer is over the button.
onClipEvent handler onClipEvent(movieEvent:Object) { // your statements here Triggers actions defined for a specific instance of a movie clip. Availability: ActionScript 1.0; Flash Player 5 Parameters - The is a trigger called an event . When the event occurs, movieEvent:Object movieEvent the statements following it within curly braces ({}) are executed.
Example The following example uses with the movie event and is designed to onClipEvent() keyDown be attached to a movie clip or button. The movie event is usually used with one or keyDown more methods and properties of the Key object. The following script uses Key.getCode() find out which key the user has pressed;...
Returns - The ASCII code number of the specified character. Number See also String charCodeAt (String.charCodeAt method) parseFloat function parseFloat(string:String) : Number Converts a string to a floating-point number. The function reads, or parses, and returns the numbers in a string until it reaches a character that is not a part of the initial number. If the string does not begin with a number that can be parsed, returns .
parseInt function parseInt(expression:String, [radix:Number]) : Number Converts a string to an integer. If the specified string in the parameters cannot be converted to a number, the function returns . Strings beginning with 0x are interpreted as hexadecimal numbers. Integers beginning with 0 or specifying a radix of 8 are interpreted as octal numbers. White space preceding valid integers is ignored, as are trailing nonnumeric characters.
See also parseFloat function play function play() : Void Moves the playhead forward in the Timeline. Availability: ActionScript 1.0; Flash Player 2 Example In the following example, there are two movie clip instances on the Stage with the instance names .
See also nextFrame function prevFrame (MovieClip.prevFrame method) prevScene function prevScene() : Void Sends the playhead to Frame 1 of the previous scene. Availability: ActionScript 1.0; Flash Player 2 See also nextScene function print function print(target:Object, boundingBox:String) : Void Prints the movie clip according to the boundaries specified in the parameter ( target bmovie...
Page 90
Parameters - The instance name of a movie clip to print. By default, all of the frames in target:Object the target instance can be printed. If you want to print specific frames in the movie clip, assign frame label to those frames. - A modifier that sets the print area of the movie clip.
Example The following example prints all of the printable frames in with a print area holder_mc defined by the bounding box of the frame: this.createEmptyMovieClip("holder_mc", 999); holder_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg"); this.myBtn_btn.onRelease = function() { printAsBitmap(this._parent.holder_mc, "bframe"); See also print function printAsBitmapNum function printNum function PrintJob printAsBitmapNum function printAsBitmapNum(level:Number, boundingBox:String) : Void...
- A modifier that sets the print area of the movie clip. Enclose this boundingBox:String parameter in quotation marks (" or '), and specify one of the following values: Designates the bounding box of a specific frame in a movie clip as the print area bmovie for all of the printable frames in the movie clip.
Availability: ActionScript 1.0; Flash Player 5 - If you are authoring for Flash Player 7 or later, you can create a PrintJob object, which gives you (and the user) more control over the printing process. For more information, see the PrintJob class entry. Parameters - The level in Flash Player to print.
Example The following use of returns a value of 0, 1, 2, 3, or 4: random() random(5); See also random (Math.random method) removeMovieClip function removeMovieClip(target:Object) Deletes the specified movie clip. Availability: ActionScript 1.0; Flash Player 4 Parameters - The target path of a movie clip instance created with target:Object or the instance name of a movie clip created with duplicateMovieClip()
setInterval function setInterval(functionReference:Function, interval:Number, [param1:Object, param2, ..., paramN]) : Number setInterval(objectReference:Object, methodName:String, interval:Number, [param1:Object, param2, ..., paramN]) : Number Calls a function or a method of an object at periodic intervals while a SWF file plays. You can to execute any function repetitively over time. setInterval() Use the following tips when working with setInterval()
Page 97
- The time in milliseconds between calls to the interval:Number functionReference function passed in. methodName is less than the SWF file's frame rate (for example, 10 frames per second [fps] is interval equal to 100 millisecond intervals), the interval function is called as close in time to the value as possible.
Page 98
Example 2: The following example is similar to the first, except that it calls before . This can help prevent unwanted loops and is clearInterval() setInterval() especially important in event-based systems where the initiating script can be executed multiple times before any particular interval has been cleared. var intervalId:Number;...
count++; In a new document, instantiate a new instance of the new class: var custom:CustomClass = new CustomClass(); See also clearInterval function updateAfterEvent function class statement setProperty function setProperty(target:Object, property:Object, expression:Object) : Void Changes a property value of a movie clip as the movie clip plays. Availability: ActionScript 1.0;...
showRedrawRegions function showRedrawRegions(enable:Boolean, [color:Number]) : Void Provides the ability for the debugger player to outline the regions of the screen that are being redrawn (that is, dirty regions that are being updated). The outlines can also be turned on with the Show Redraw Regions menu option. Availability: ActionScript 1.0;...
startDrag function startDrag(target:Object, [lock:Boolean, left:Number, top:Number, right:Number, bottom:Number]) : Void Makes the movie clip draggable while the movie plays. Only one movie clip can be target dragged at a time. After a operation is executed, the movie clip remains startDrag() draggable until it is explicitly stopped by or until a action for...
stop function stop() : Void Stops the SWF file that is currently playing. The most common use of this action is to control movie clips with buttons. Availability: ActionScript 1.0; Flash Player 2 See also gotoAndStop function gotoAndStop (MovieClip.gotoAndStop method) stopAllSounds function stopAllSounds() : Void Stops all sounds currently playing in a SWF file without stopping the playhead.
this.stop_mc.onRelease = function() { stopAllSounds(); See also Sound stopDrag function stopDrag() : Void Stops the current drag operation. Availability: ActionScript 1.0; Flash Player 4 Example The following code, placed in the main Timeline, stops the drag action on the movie clip instance when the user releases the mouse button: my_mc...
String function String(expression:Object) : String Returns a string representation of the specified parameter, as described in the following list: is a number, the return string is a text representation of the number. expression is a string, the return string is expression expression is an object, the return value is a string representation of the object...
substring function substring(string:String, index:Number, count:Number) : String Deprecated since Flash Player 5. This function was deprecated in favor of String.substr() Extracts part of a string. This function is one-based, whereas the String object methods are zero-based. Availability: ActionScript 1.0; Flash Player 4 Parameters - The string from which to extract the new string.
// _level0.myClip_mc See also eval function tellTarget function tellTarget(target:String) { statement(s); Deprecated since Flash Player 5. Macromedia recommends that you use dot (.) notation and statement. with Applies the instructions specified in the parameter to the Timeline specified in statements parameter.
The following example uses dot (.) notation to achieve the same results: on(release) { _parent.ball.gotoAndPlay(2); If you need to issue multiple commands to the ball instance, you can use the with action, as shown in the following statement: on(release) { with(_parent.ball) { gotoAndPlay(2);...
trace function trace(expression:Object) You can use Flash Debug Player to capture output from the function and display the trace() result. Use this statement to record programming notes or to display messages in the Output panel while testing a SWF file. Use the parameter to check whether a condition exists, expression or to display values in the Output panel.
unescape function unescape(string:String) : String Evaluates the parameter as a string, decodes the string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string. Availability: ActionScript 1.0; Flash Player 5 Parameters - A string with hexadecimal sequences to escape. string:String Returns - A string decoded from a URL-encoded parameter.
Example The following example creates a new movie clip called and loads an image into that pic_mc clip. It is loaded using the MovieClipLoader class. When you click the image, the movie clip unloads from the SWF file: var pic_mcl:MovieClipLoader = new MovieClipLoader(); pic_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", this.createEmptyMovieClip("pic_mc", this.getNextHighestDepth()));...
See also loadMovieNum function unloadMovie function loadMovie (MovieClip.loadMovie method) updateAfterEvent function updateAfterEvent() : Void Updates the display (independent of the frames per second set for the movie) when you call it within an handler or as part of a function or method that you pass to onClipEvent() setInterval().
Page 113
Global Properties summary Modifiers Property Description Lets you control screen reader accessibility options for _accProps SWF files, movie clips, buttons, dynamic text fields, and input text fields at runtime. Property (global); specifies whether a yellow rectangle _focusrect appears around the button or movie clip that has keyboard focus.
_accProps property _accProps.propertyName instanceName._accProps.propertyName Lets you control screen reader accessibilityoptions for SWF files, movie clips, buttons, dynamic text fields, and input textfields at runtime. Theseproperties override the corresponding settings available in the Accessibilitypanel during authoring. For changes to these properties to take effect,you must call Accessibility.updateProperties(). For information on the Accessibility panel, see "The Flash Accessibility panel"...
Page 115
To specify settings that correspond to the Tab index setting in the Accessibility panel, use the Button.tabIndex, MovieClip.tabIndex, or TextField.tabIndex properties. There is no way to specify an Auto Label setting at runtime. To refer to the object that represents the entire Flash document, omit the _accProps parameter.
Page 116
After you specify an accessibility property, you can't revert its value to avalue set in the Accessibility panel. However, you can set the property to itsdefault value ( for Boolean false values; empty strings for stringvalues) by deleting the property from the object, as _accProps shownin the following example:...
_focusrect property _focusrect = Boolean; Specifies whether a yellow rectangle appears around the button or movie clip that has keyboard focus. If is set to its default value of , then a yellow rectangle _focusrect true appears around the currently focused button or movie clip as the user presses the Tab key to navigate through objects in a SWF file.
_global property _global.identifier A reference to the global object that holds the core ActionScript classes, such as String, Object, Math, and Array. For example, you could create a library that is exposed as a global ActionScript object, similar to the Math or Date object. Unlike Timeline-declared or locally declared variables and functions, global variables and functions are visible to every Timeline and scope in the SWF file, provided they are not obscured by identifiers with the same names in inner scopes.
See also var statement set variable statement _highquality property _highquality Deprecated since Flash Player 5. This property was deprecated in favor of _quality Specifies the level of anti-aliasing applied to the current SWF file. Specify 2 (best quality) to apply high quality with bitmap smoothing always on. Specify 1 (high quality) to apply anti- aliasing;...
Example The following example stops the playhead in the main Timeline of the SWF file sub.swf that is loaded into . The sub.swf file contains animation and is in the same directory as _level9 the document that contains the following ActionScript: loadMovieNum("sub.swf", 9);...
Example In the following example, there is a movie clip on the Stage with the instance name . Within that movie clip is another movie clip with an instance name square_mc circle_mc The following ActionScript lets you modify the parent instance (which is circle_mc ) when the circle is clicked.
Page 122
Value Description Graphic Anti- Bitmap Smoothing Aliasing " " High rendering quality. Graphics are anti- Flash Player 8: Bitmaps are HIGH This setting is the aliased using a 4 x 4 smoothed based on the default rendering pixel grid. parameter used in smoothing quality setting that MovieClip.attachBitmap()
_root property _root.movieClip _root.action _root.property Specifies or returns a reference to the root movie clip Timeline. If a movie clip has multiple levels, the root movie clip Timeline is on the level containing the currently executing script. For example, if a script in level 1 evaluates is returned.
scroll property textFieldVariableName.scroll = x Deprecated since Flash Player 5. This property was deprecated in favor of TextField.scroll Controls the display of information in a text field associated with a variable. The scroll property defines where the text field begins displaying content; after you set it, Flash Player updates it as the user scrolls through the text field.
Example The following example streams an MP3 file and buffers the sound before it plays for the user. Two text fields are created at runtime to hold a timer and debugging information. The property is set to buffer the MP3 for 10 seconds. A new Sound object _soundbuftime instance is created for the MP3.
Page 126
Example Create an ActionsScript file named ApplyThis.as and then enter the following code: class ApplyThis { var str:String = "Defined in ApplyThis.as"; function conctStr(x:String):String { return x+x; function addStr():String { return str; Then, in a FLA or a separate ActionScript file, add the following code var obj:ApplyThis = new ApplyThis();...
In the following example, the keyword references the Circle object: this function Circle(radius:Number):Void { this.radius = radius; this.area = Math.PI*Math.pow(radius, 2); var myCircle = new Circle(4); trace(myCircle.area); In the following statement assigned to a frame inside a movie clip, the keyword this references the current movie clip.
Page 128
Operator Description Converts expression1 and expression2 to 32-bit unsigned & (bitwise AND) integers, and performs a Boolean AND operation on each bit of the integer parameters. Assigns expression1 the value of expression1& expression2. &= (bitwise AND assignment) Converts expression1 and expression2 to 32-bit integers, and <<...
Page 129
Evaluates expression1 , then expression2 , and so on. , (comma) Deprecated since Flash Player 5. Macromedia recommends that you (concatenation use the add (+) operator when creating content for Flash Player 5 or (strings)) later. This operator is not supported in Flash Player 8 or later.
Page 130
Performs a Boolean operation on the values of both expressions. && (logical AND) Deprecated since Flash Player 5. Macromedia recommends that you (logical AND) use the logical AND (&&) operator. Performs a logical AND (&&) operation in Flash Player 4.
Page 131
Operator Description Assigns expression1 the value of expression1 % expression2. (modulo assignment) Multiplies two numerical expressions. * (multiplication) Assigns expression1 the value of expression1 * expression2. (multiplication assignment) Creates a new, initially anonymous, object and calls the function identified by the constructor parameter. Deprecated since Flash Player 5.
+ addition operator expression1 + expression2 Adds numeric expressions or concatenates (combines) strings. If one expression is a string, all other expressions are converted to strings and concatenated. If both expressions are integers, the sum is an integer; if either or both expressions are floating-point numbers, the sum is a floating-point number.
Usage 3: Variables associated with dynamic and input text fields have the data type String. In the following example, the variable is an input text field on the Stage. After a user deposit enters a deposit amount, the script attempts to add .
Example Usage 1: This example uses the operator with a string expression and sends "My name is Gilbert" to the Output panel. var x1:String = "My name is "; x1 += "Gilbert"; trace(x1); // output: My name is Gilbert Usage 2: The following example shows a numeric use of the addition assignment ( operator: var x:Number = 5;...
Page 135
Usage 2: Surround the index of each element with brackets ([]) to access it directly; you can add a new element to an array, or you can change or retrieve the value of an existing element. The first index in an array is always 0, as shown in the following example: var my_array:Array = new Array();...
Page 136
Example The following example shows two ways to create a new empty Array object; the first line uses brackets ([]): var my_array:Array = []; var my_array:Array = new Array(); The following example creates an array called and uses the trace() statement employee_array to send the elements to the Output panel.
= assignment operator expression1 = expression2 Assigns the value of (the parameter on the right) to the variable, array element, expression2 or property in . Assignment can be either by value or by reference. Assignment expression1 by value copies the actual value of and stores it in .
The following example uses assignment by reference to create a new object, and assign a reference to that object to the variable . Assignment by value is then used to assign mercury the value of to the property of the object: 3030 diameter...
Operands - A number. expression1 : Number - A number. expression2 : Number Returns - The result of the bitwise operation. Number Example The following example compares the bit representation of the numbers and returns 1 only if both bits at the same position are 1. In this ActionScript, you add 13 (binary 1101) and 11 (binary 1011) and return 1 only in the position where both numbers have a 1.
Operands - A number. expression1 : Number - A number. expression2 : Number Returns - The value of Number expression1 & expression2 Example The following example assigns the value var x:Number = 15; var y:Number = 9; trace(x &= y); // output: 9 See also &...
Operands - A number or expression to be shifted left. expression1 : Number - A number or expression that converts to an integer from 0 to 31. expression2 : Number Returns - The result of the bitwise operation. Number Example In the following example, the integer 1 is shifted 10 bits to the left: The result x = 1 <<...
Returns - The result of the bitwise operation. Number Example In the following example, you use the bitwise left shift and assignment ( ) operator to shift <<= all bits one space to the left: var x:Number = 4; // shift all bits one slot to the left. x <<= 1;...
Page 143
Floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value via the two's complement notation, with the minimum being -2147483648 or 0x800000000;...
| bitwise OR operator expression1 | expression2 Converts to 32-bit unsigned integers, and returns a 1 in each expression1 expression2 bit position where the corresponding bits of either are 1. expression1 expression2 Floating-point numbers are converted to integers by discarding any digits after the decimal point.
|= bitwise OR assignment operator expression1 |= expression2 Assigns the value of . For example, the following expression1 expression1 | expression2 two statements are equivalent: x |= y; x = x | y; Availability: ActionScript 1.0; Flash Player 5 Operands - A number or variable.
>> bitwise right shift operator expression1 >> expression2 Converts to 32-bit integers, and shifts all the bits in expression1 expression2 to the right by the number of places specified by the integer that results from expression1 the conversion of . Bits that are shifted off the right end are discarded. To expression2 preserve the sign of the original , the bits on the left are filled in with 0 if the...
The following example shows the result of the previous example: var x:Number = 255; This is because 65535 decimal equals 1111111111111111 binary (sixteen 1s), 1111111111111111 binary shifted right by 8 bits is 11111111 binary, and 11111111 binary is 255 decimal. The most significant bit is 0 because the integers are 32-bit, so the fill bit is 0. The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right: var x:Number = -1 >>...
Example The following commented code uses the bitwise right shift and assignment ( ) operator. >>= function convertToBinary(numberToConvert:Number):String { var result:String = ""; for (var i = 0; i<32; i++) { // Extract least significant bit using bitwise AND var lsb:Number = numberToConvert & 1; // Add this bit to the result string result = (lsb ? "1"...
Returns - The result of the bitwise operation. Number Example The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right: var x:Number = -1 >>> 1; trace(x); // output: 2147483647 This is because -1 decimal is 11111111111111111111111111111111 binary (thirty-two 1s), and when you shift right (unsigned) by 1 bit, the least significant (rightmost) bit is discarded, and the most significant (leftmost) bit is filled with a 0.
Example See also >>> bitwise unsigned right shift operator >>= bitwise right shift and assignment operator ^ bitwise XOR operator expression1 ^ expression2 Converts to 32-bit unsigned integers, and returns a 1 in each expression1 expression2 bit position where the corresponding bits in , but not both, are expression1 expression2...
/*..*/ block comment delimiter operator /* comment */ /* comment comment */ Indicates one or more lines of script comments. Any characters that appear between the opening comment tag ( ) and the closing comment tag ( ), are interpreted as a comment and ignored by the ActionScript interpreter.
, comma operator (expression1 , expression2 [, expressionN... ]) Evaluates , then , and so on. This operator is primarily used with expression1 expression2 loop statement and is often used with the parentheses () operator. Availability: ActionScript 1.0; Flash Player 4 Operands - An expression to be evaluated.
() parentheses operator add concatenation (strings) operator string1 add string2 Deprecated since Flash Player 5. Macromedia recommends that you use the add ( ) operator when creating content for Flash Player 5 or later. This operator is not supported in Flash Player 8 or later.
Returns - The concatenated string. String See also + addition operator ?: conditional operator expression1 ? expression2 : expression3 Instructs Flash to evaluate , and if the value of , it returns expression1 expression1 true the value of ; otherwise it returns the value of expression2 expression3 Availability: ActionScript 1.0;...
-- decrement operator --expression expression-- A pre-decrement and post-decrement unary operator that subtracts 1 from the expression . The can be a variable, element in an array, or property of an object. The pre- expression decrement form of the operator ( ) subtracts 1 from and returns --expression...
Operands - A number or a variable that evaluates to a number. expression : Number Returns - The floating-point result of the operation. Number Example The following statement divides the current width and height of the Stage, and then displays the result in the Output panel.
See also / division operator . dot operator object.property_or_methodinstancename.variable instancename.childinstanceinstancename.childinstance.variable Used to navigate movie clip hierarchies to access nested (child) movie clips, variables, or properties. The dot operator is also used to test or set the properties of an object or top-level class, execute a method of an object or top-level class, or create a data structure.
The following example creates a new movie clip within the scope. Then a text field is _root created inside the movie clip called . The text field's property is set container_mc autoSize and then populated with the current date. true this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());...
Example The following example uses the equality ( operator with an statement: var a:String = "David", b:String = "David"; if (a == b) { trace("David is David"); The following examples show the results of operations that compare mixed types: var x:Number = 5; var y:String = "5";...
Compares two expressions for equality and returns a value of if the string representation true is equal to the string representation of otherwise. expression1 expression2 false Availability: ActionScript 1.0; Flash Player 4 Operands - Numbers, strings, or variables. expression1 : Object - Numbers, strings, or variables.
Example In the following example, the greater than ( ) operator is used to determine whether the value > of the text field is greater than 90: score_txt if (score_txt.text>90) { trace("Congratulations, you win!"); } else { trace("sorry, try again"); gt greater than (strings) operator expression1 gt expression2 Deprecated since Flash Player 5.
Availability: ActionScript 1.0; Flash Player 4 - In Flash 4, is a numeric operator. In Flash 5 > or later, the greater than or equal to ( ) operator is a comparison operator capable of >= handling various data types. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity.
Returns - The result of the comparison. Boolean See also >= greater than or equal to operator ++ increment operator ++expression expression++ A pre-increment and post-increment unary operator that adds 1 to . The expression can be a variable, element in an array, or property of an object. The pre- expression increment form of the operator ( ) adds 1 to...
Page 165
Example The following example uses ++ as a post-increment operator to make a loop run five while times: var i:Number = 0; while (i++ < 5) { trace("this is execution " + i); /* output: this is execution 1 this is execution 2 this is execution 3 this is execution 4 this is execution 5...
!= inequality operator expression1 != expression2 Tests for the exact opposite of the equality ( ) operator. If is equal to expression1 , the result is . As with the equality ( ) operator, the definition of equal expression2 false depends on the data types being compared, as illustrated in the following list: Numbers, strings, and Boolean values are compared by value.
== equality operator === strict equality operator <> inequality operator expression1 <> expression2 Deprecated since Flash Player 5. This operator has been deprecated. Macromedia recommends that you use the operator. != (inequality) Tests for the exact opposite of the equality ( ) operator.
Operands - A number, string, Boolean value, variable, object, array, or expression1 : Object function. - A number, string, Boolean value, variable, object, array, or expression2 : Object function. Returns - The Boolean result of the comparison. Boolean See also != inequality operator instanceof operator object instanceof classConstructor...
< less than operator expression1 < expression2 Compares two expressions and determines whether is less than ; if expression1 expression2 so, the operator returns . If is greater than or equal to , the true expression1 expression2 operator returns . String expressions are evaluated using alphabetical order; all capital false letters come before lowercase letters.
lt less than (strings) operator expression1 lt expression2 Deprecated since Flash Player 5. This operator was deprecated in favor of the (less than) < operator. Compares and returns is less than expression1 expression2 true expression1 otherwise. expression2 false Availability: ActionScript 1.0; Flash Player 4 Operands - Numbers, strings, or variables.
Returns - The Boolean result of the comparison. Boolean Example The following examples show results for both numeric and string true false comparisons: trace(5 <= 10); // true trace(2 <= 2); // true trace(10 <= 3); // false trace("Allen" <= "Jack"); // true trace("Jack"...
// line comment delimiter operator // comment Indicates the beginning of a script comment. Any characters that appear between the comment delimiter ( and the end-of-line character are interpreted as a comment and ignored by the ActionScript interpreter. Availability: ActionScript 1.0; Flash Player 1.0 Operands - Any characters.
=== strict equality operator and logical AND operator condition1 and condition2 Deprecated since Flash Player 5. Macromedia recommends that you use the logical AND operator. &&) Performs a logical AND ( operation in Flash Player 4. If both expressions evaluate to &&)
Returns - A Boolean result of the logical operation. Boolean See also && logical AND operator ! logical NOT operator ! expression Inverts the Boolean value of a variable or expression. If is a variable with the expression absolute or converted value , the value of .
not logical NOT operator not expression Deprecated since Flash Player 5. This operator was deprecated in favor of the ! (logical operator. NOT) Performs a logical NOT (!) operation in Flash Player 4. Availability: ActionScript 1.0; Flash Player 4 Operands - A variable or other expression that converts to a Boolean value.
Example The following example uses the logical OR ( ) operator in an statement. The second expression evaluates to so the final result is true, true var x:Number = 10; var y:Number = 250; var start:Boolean = false; if ((x > 25) || (y > 200) || (start)) { trace("the logical OR test passed");...
Availability: ActionScript 1.0; Flash Player 4 Operands - An expression that evaluates to condition1 : Boolean true false - An expression that evaluates to condition2 : Boolean true false Returns - The result of the logical operation. Boolean See also || logical OR operator | bitwise OR operator % modulo operator...
The first trace returns 2, rather than 12/5 or 2.4, because the modulo ( ) operator returns only the remainder. The second trace returns 0.0999999999999996 instead of the expected 0.1 because of the limitations of floating-point accuracy in binary computing. See also / division operator round (Math.round method)
* multiplication operator expression1 * expression2 Multiplies two numerical expressions. If both expressions are integers, the product is an integer. If either or both expressions are floating-point numbers, the product is a floating- point number. Availability: ActionScript 1.0; Flash Player 4 Operands - A number or expression that evaluates to a number.
Returns - The value of . If an expression cannot be converted Number expression1 * expression2 to a numeric value, it returns (not a number). Example Usage 1: The following example assigns the value 50 to the variable var x:Number = 5; var y:Number = 10;...
book1 = new Book("Confederacy of Dunces", 19.95); book2 = new Book("The Floating Opera", 10.95); The following example uses the operator to create an object with 18 elements: Array golfCourse_array = new Array(18); See also [] array access operator {} object initializer operator ne not equal (strings) operator expression1 ne expression2 Deprecated since Flash Player 5.
Page 182
= {name:"Macromedia, Inc.", address:"600 Townsend Street", city:"San Francisco", state:"California", zip:"94103", balance:"1000"}; for (i in account) { trace("account." + i + " = " + account[i]); The following example shows how array and object initializers can be nested within each other: var person:Object = {name:"Gina Vechio", children:["Ruby", "Chickie",...
The previous ActionScript example can also be written in the following format: var person:Object = new Object(); person.name = "Gina Vechio"; person.children = new Array("Ruby", "Chickie", "Puppa"); See also Object () parentheses operator (expression1 [, expression2]) ( expression1, expression2 ) function ( parameter1,..., parameterN ) Performs a grouping operation on one or more parameters, performs sequential evaluation of expressions, or surrounds one or more parameters and passes them as parameters to a function...
trace((2 + 3) * (4 + 5)); // Output: 45trace(2 + (3 * (4 + 5))); // // writes 29 trace(2 + (3 * (4 + 5))); // Output: 29trace(2+(3*4)+5); // writes 19 trace(2 + (3 * 4) + 5); // Output: 19 Usage 2: The following example evaluates the function , and then the function foo()
Page 185
- A number, string, Boolean value, variable, object, array, or expression2 : Object function. Returns - The Boolean result of the comparison. Boolean Example The comments in the following code show the returned value of operations that use the equality and strict equality operators: // Both return true because no conversion is done var string1:String = "5";...
See also ! logical NOT operator != inequality operator !== strict inequality operator && logical AND operator || logical OR operator == equality operator !== strict inequality operator expression1 !== expression2 Tests for the exact opposite of the strict equality ( )operator.
- subtraction operator (Negation) -expression (Subtraction) expression1 - expression2 Used for negating or subtracting. Usage 1: When used for negating, it reverses the sign of the numerical . Usage 2: expression When used for subtracting, it performs an arithmetic subtraction on two numerical expressions, subtracting from .
Operands - A number or expression that evaluates to a number. expression1 : Number - A number or expression that evaluates to a number. expression2 : Number Returns - The result of the arithmetic operation. Number Example The following example uses the subtraction assignment ( operator to subtract 10 from 5 and assign the result to the variable var x:Number = 5;...
Availability: ActionScript 1.0; Flash Player 6 Operands - An identifier for a variable. A native data type, class name variableName : Object type that you have defined, or interface name. An identifier for a function. functionName An identifier for a function parameter. parameter Example Usage 1: The following example declares a public variable named...
Returns representation of the type of . The following table shows the String String expression results of the operator on each type of typeof expression Expression Type Result String string Movie clip movieclip Button object Text field object Number number Boolean boolean Object...
Statements Statements are language elements that perform or specify an action. For example, the return statement returns a result as a value of the function in which it executes. The if statement evaluates a condition to determine the next action that should be taken. The switch statement creates a branching structure for ActionScript statements.
Page 193
Statement Description Comprises a set of statements that you define to perform a certain function task. Permits implicit getting of properties associated with objects based on classes you have defined in external class files. Evaluates a condition to determine the next action in a SWF file. Specifies that a class must define all the methods declared in the implements interface (or interfaces) being implemented.
break statement break Appears within a loop ( ) or within a block of statements for..in do..while while associated with a particular case within a statement. When used in a loop, the switch break statement instructs Flash to skip the rest of the loop body, stop the looping action, and execute the statement following the loop statement.
case statement case expression : statement(s) Defines a condition for the statement. If the parameter equals the switch expression parameter of the statement using strict equality ( ), then Flash Player expression switch will execute statements in the parameter until it encounters a statement statement(s) break...
class statement [dynamic] class className [ extends superClass ] [ implements interfaceName[, interfaceName... ] ] { // class definition here Defines a custom class, which lets you instantiate objects that share methods and properties that you define. For example, if you are developing an invoice-tracking system, you could create an invoice class that defines all the methods and properties that each invoice should have.
Page 197
Example The following example creates a class called Plant. The Plant constructor takes two parameters. // Filename Plant.as class Plant { // Define property names and types var leafType:String; var bloomSeason:String; // Following line is constructor // because it has the same name as the class function Plant(param_leafType:String, param_bloomSeason:String) { // Assign passed values to properties when new Plant object is created this.leafType = param_leafType;...
In an external script file or in the Actions panel, use the operator to create an ImageLoader object. var jakob_mc:MovieClip = this.createEmptyMovieClip("jakob_mc", this.getNextHighestDepth()); var jakob:ImageLoader = new ImageLoader("http://www.helpexamples.com/flash/ images/image1.jpg", jakob_mc, {_x:10, _y:10, _alpha:70, _rotation:-5}); See also dynamic statement continue statement continue Jumps past all remaining statements in the innermost loop and starts the next iteration of the loop as if control had passed through to the end of the loop normally.
Page 199
In the following loop, causes the Flash interpreter to skip the rest of the do..while continue loop body and jump to the bottom of the loop, where the condition is tested: trace("example 2"); var i:Number = 0; do { if (i % 3 == 0) { i++;...
default statement default: statements Defines the default case for a statement. The statements execute if the switch expression parameter of the statement doesn't equal (using the strict equality [ ] operation) switch any of the parameters that follow the keywords for a given expression case switch...
delete statement delete reference Destroys the object reference specified by the parameter, and returns if the reference true reference is successfully deleted; otherwise. This operator is useful for freeing memory false used by scripts. You can use the operator to remove references to objects. After all delete references to an object are removed, Flash Player removes the object and frees the memory used by that object.
Usage 3: The following example deletes an object property: var my_array:Array = new Array(); my_array[0] = "abc"; // my_array.length == 1 my_array[1] = "def"; // my_array.length == 2 my_array[2] = "ghi"; // my_array.length == 3 // my_array[2] is deleted, but Array.length is not changed delete my_array[2];...
Availability: ActionScript 1.0; Flash Player 4 Parameters - The condition to evaluate. The within the block of condition:Boolean statement(s) code are executed as long as the parameter evaluates to condition true Example The following example uses a loop to evaluate whether a condition is do..while true, traces...
Page 204
Subclasses of dynamic classes are also dynamic. Be sure to specify the type when declaring an object, as in the following: var x:MyClass = new MyClass(); If you do not specify the type when declaring an object (as in the following) then the object is considered dynamic: var x = new MyClass();...
If you add an undeclared function, , an error is generated, as shown in the following dance example: trace(""); craig.dance = true; for (i in craig) { trace("craig." + i + " = " + craig[i]); /* output: **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 14: There is no property with the name 'dance'.
Example In the following example, the condition is used to check whether the variable is else age_txt greater than or less than 18: if (age_txt.text>=18) { trace("welcome, user"); else { trace("sorry, junior"); userObject.minor = true; userObject.accessAllowed = false; In the following example, curly braces are not necessary because only one statement ({}) follows the...
Example The following example uses statements to compare to a specified value: else if score_txt if (score_txt.text>90) { trace("A"); else if (score_txt.text>75) { trace("B"); else if (score_txt.text>60) { trace("C"); else { trace("F"); See also if statement extends statement class className extends otherClassName {} interface interfaceName extends otherInterfaceName {} Defines a class that is a subclass of another class;...
Page 208
Example In the following example, the Car class extends the Vehicle class so that all of its methods, properties, and functions are inherited. If your script instantiates a Car object, methods from both the Car class and the Vehicle class can be used. The following example shows the contents of a file called Vehicle.as, which defines the Vehicle class: class Vehicle {...
Page 209
The following example instantiates a Car object, calls a method that is defined in the Vehicle class ( ), then calls the method that is overridden by the Car class ( ), and start() stop() finally calls a method from the Car class ( activateCarAlarm() var myNewCar:Car = new Car(2, "Red", true);...
for statement for(init; condition; next) { statement(s); Evaluates the (initialize) expression once and then starts a looping sequence. The init looping sequence begins by evaluating the expression. If the condition condition expression evaluates to true, is executed and the expression is evaluated. The statement next looping sequence then begins again with the evaluation of the...
for..in statement for (variableIterant in object) { statement(s); Iterates over the properties of an object or elements in an array and executes the statement for each property or element. Methods of an object are not enumerated by the for..in action. Some properties cannot be enumerated by the action.
The following example uses to iterate over the elements of an array: for..in var myArray:Array = new Array("one", "two", "three"); for (var index in myArray) trace("myArray["+index+"] = " + myArray[index]); // output: myArray[2] = three myArray[1] = two myArray[0] = one The following example uses the operator with to iterate over a particular...
Page 213
You can use this statement to define a with the specified function functionname , and . When a script calls a function, the statements in the parameters statement(s) function's definition are executed. Forward referencing is permitted; within the same script, a function may be declared after it is called.
The following function creates a LoadVars object and loads params.txt into the SWF file. When the file successfully loads, traces: variables loaded var myLV:LoadVars = new LoadVars(); myLV.load("params.txt"); myLV.onLoad = function(success:Boolean) { trace("variables loaded"); get statement function get property () { // your statements here Permits implicit getting of properties associated with objects based on classes you have defined in external class files.
Enter the following ActionScript in a frame on the Timeline: var giants:Team = new Team("San Fran", "SFO"); trace(giants.name); giants.name = "San Francisco"; trace(giants.name); /* output: San Fran San Francisco */ When you trace giants.name, you use the method to return the value of the property. See also addProperty (Object.addProperty method) if statement...
The following example uses an statement to evaluate how long it takes a user to click the instance in a SWF file. If a user clicks the button more than 10 seconds after the submit_btn SWF file plays, the condition evaluates to and the message inside the curly braces ( true appears in a text field that's created at runtime (using...
import statement import className import packageName.* Lets you access classes without specifying their fully qualified names. For example, if you want to use a custom class macr.util.users.UserClass in a script, you must refer to it by its fully qualified name or import it; if you import it, you can refer to it by the class name: // before importing var myUser:macr.util.users.UserClass = new macr.util.users.UserClass();...
interface statement interface InterfaceName [extends InterfaceName ] {} Defines an interface. An interface is similar to a class, with the following important differences: Interfaces contain only declarations of methods, not their implementation. That is, every class that implements an interface must provide an implementation for each method declared in the interface.
return 15; function n(x:Number):Number { return x * x; function o():Void { trace("o"); } // external script or Actions panel // script file mvar = new D(); trace(mvar.k()); // 15 trace(mvar.n(7)); // 49 trace(mvar.o()); // "o" interface Ic extends Ia { function p():Void;...
Page 220
keyword was created specifically to enable compile-time type checking for intrinsic built-in classes and objects, and global variables and functions. This keyword was not meant for general purpose use, but may be of some value to developers seeking to enable compile- time type checking with previously defined classes, especially if the classes are defined using ActionScript 1.0.
trace(myCircle.radius); trace(myCircle.getArea()); trace(myCircle.getDiameter()); See also class statement private statement class someClassName{ private var name; private function name() { // your statements here Specifies that a variable or function is available only to the class that declares or defines it or to subclasses of that class.
As the following code demonstrates, the constructor for the Beta class is able to access the property that is inherited from the Alpha class: privateProperty var myBeta:Beta = new Beta(); // Output: privateProperty is visible only within class and subclasses Attempts to access the variable from outside the Alpha class or a class that privateProperty...
jimmy.age = 27; jimmy.name = "jimmy"; If you change one of the public variables in the User class to a private variable, an error is generated when trying to access the property. See also private statement return statement return[expression] Specifies the value returned by a function. The statement evaluates return expression...
See also function statement set statement function set property(varName) { // your statements here Permits implicit setting of properties associated with objects based on classes you have defined in external class files. Using implicit set methods lets you modify the value of an object's property without accessing the property directly.
gus.username = "Rupert"; trace(gus.username); // output: Rupert In the following example, the function executes when the value is traced. The function triggers only when you pass it a value, as shown in the line: gus.username = "Rupert"; See also get statement set variable statement set("variableString",expression) Assigns a value to a variable.
Parameters - A string that names a variable to hold the value of the variableString:String parameter. expression Example In the following example, you assign a value to a variable. You are assigning the value of to the variable. "Jakob" name set("name", "Jakob");...
Example The following example demonstrates how you can use the keyword to create a static counter that tracks how many instances of the class have been created. Because the variable is static, it will be created only once for the entire class, not for every numInstances single instance.
Returns Both forms invoke a function. The function may return any value. Parameters - The method to invoke in the superclass. method:Function - Optional parameters that are passed to the superclass version of the method (syntax 1) argN or to the constructor function of the superclass (syntax 2). switch statement switch (expression){ caseClause:...
trace("you pressed E or e"); break; case "I" : case "i" : trace("you pressed I or i"); break; default : trace("you pressed some other key"); break; Key.addListener(listenerObj); See also === strict equality operator throw statement throw expression Generates, or throws, an error that can be handled, or caught, by a code block.
try { checkEmail("Joe Smith"); catch (e) { error_txt.text = e.toString(); In the following example, a subclass of the Error class is thrown. The function checkEmail() is modified to throw an instance of that subclass. // Define Error subclass InvalidEmailError // In InvalidEmailError.as: class InvalidEmailAddress extends Error { var message = "Invalid email address.";...
Page 231
Encloses a block of code in which an error can occur, and then respond to the error. If any code in the code block throws an error (using the statement), control passes to the throw block, if one exists, and then to the code block, if one exists.
Page 232
myFunction = function () { trace("this is myFunction"); try { myInterval = setInterval(this, "myFunction", 1000); throw new Error("my error"); catch (myError:Error) { trace("error caught: "+myError); finally { clearInterval(myInterval); trace("error is cleared"); In the following example, the block is used to delete an ActionScript object, finally regardless of whether or not an error occurred.
Page 233
var returnVal = account.getAccountInfo(); if (returnVal != 0) { throw new Error("Error getting account information."); trace("success"); catch (e) { this.createTextField("status_txt", this.getNextHighestDepth(), 0, 0, 100, 22); status_txt.autoSize = true; status_txt.text = e.toString(); The following example shows a code block with multiple, typed code blocks.
Finally, in another AS file or FLA script, the following code invokes the method sortRows() on an instance of the RecordSet class. It defines blocks for each type of error that is catch thrown by sortRows() import RecordSet; var myRecordSet:RecordSet = new RecordSet(); try { myRecordSet.sortRows();...
Parameters - An identifier. variableName:String Example The following ActionScript creates a new array of product names. adds an Array.push element onto the end of the array. If you want to use strict typing, it is essential that you use keyword. Without before , you get errors when you try to use product_array...
Parameters - An expression that evaluates to condition:Boolean true false Example In the following example, the statement is used to test an expression. When the value while is less than 20, the value of is traced. When the condition is no longer , the loop true exits.
Page 237
To find the value of an identifier in the parameter, ActionScript starts at the statement(s) beginning of the scope chain specified by the and searches for the identifier at each object level of the scope chain, in a specific order. The scope chain used by the statement to resolve identifiers starts with the first item in with...
Page 238
The following code snippet shows how to write the preceding code without using a with statement. someOther_mc._x = 50; someOther_mc._y = 100; someOther_mc.gotoAndStop(3); statement is useful for accessing multiple items in a scope chain list simultaneously. with In the following example, the built-in object is placed at the front of the scope chain.
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.
Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Indicates whether an accessibility aid is currently static isActive() : Boolean active and the player is communicating with it. Causes all changes to _accProps (accessibility static updateProperties() :...
Returns - A Boolean value: if the Flash Player is communicating with an accessibility Boolean true aid (usually a screen reader); otherwise. false Example The following example checks whether an accessibility aid is currently active: if (Accessibility.isActive()) { trace ("An accessibility aid is currently active"); } else { trace ("There is currently no active accessibility aid");...
See also isActive (Accessibility.isActive method) _accProps property hasAccessibility (capabilities.hasAccessibility property) arguments Object +-arguments public class arguments extends Object object is used to store and access a function's arguments. While inside the arguments function's body it can be accessed with the local variable.
Array Object +-Array public dynamic class Array extends Object The Array class lets you access and manipulate indexed arrays. An indexed array is an object whose properties are identified by a number representing their position in the array. This number is referred to as the index. All indexed arrays are zero-based, which means that the first element in the array is [0], the second element is [1], and so on.
Page 245
Availability: ActionScript 1.0; Flash Player 5 - Became a native object in Flash Player 6, which improved performance significantly. Example In the following example, my_array contains four months of the year: var my_array:Array = new Array(); my_array[0] = "January"; my_array[1] = "February"; my_array[2] = "March";...
Page 246
Method summary Modifiers Signature Description Concatenates the elements specified in the concat([value:Object parameters with the elements in an array and creates ]) : Array a new array. Converts the elements in an array to strings, inserts join([delimiter:Stri the specified separator between the elements, ng]) : String concatenates them, and returns the resulting string.
Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method) Array constructor public Array([value:Object]) Lets you create an array. You can use the constructor to create different types of arrays: an empty array, an array with a specific length but whose elements have undefined values, or an array whose elements have specific values.
if (my_array[0] == undefined) { // No quotation marks around undefined. trace("undefined is a special value, not a string"); } // Traces: undefined is a special value, not a string. Usage 3: The following example creates the new Array object with an initial go_gos_array length of 5:...
concat (Array.concat method) public concat([value:Object]) : Array Concatenates the elements specified in the parameters with the elements in an array and creates a new array. If the parameters specify an array, the elements of that array are value concatenated, rather than the array itself. The array is left unchanged.
trace(x_array[3]); // 1 trace(x_array[4]); // 2, 3 trace(x_array[5]); // 4 DESCENDING (Array.DESCENDING property) public static DESCENDING : Number In the sorting methods, this constant specifies descending sort order. You can use this constant for the parameter in the method. options sort() sortOn() The value of this constant is 2.
trace(a_array.join(" + ")); // Displays Earth + Moon + Sun. The following example creates a nested array that contains two arrays. The first array has three elements: Europa, Io, and Callisto. The second array has two elements: Titan and Rhea. It joins the array by using a plus sign (+), but the elements within each nested array remain separated by commas (,).
a,b,undefined,undefined,undefined,undefined,undefined,undefined,undefine // if the length property is now set to 5, the array will be truncated my_array.length = 5; trace(my_array.length); // my_array.length is updated to 5 trace(my_array); // outputs: a,b,undefined,undefined,undefined NUMERIC (Array.NUMERIC property) public static NUMERIC : Number In the sorting methods, this constant specifies numeric (instead of character-string) sorting. Including it in the parameter causes the methods to sort...
Example The following code creates the array array containing four elements, and then myPets_array removes its last element: var myPets_array:Array = new Array("cat", "dog", "bird", "fish"); var popped:Object = myPets_array.pop(); trace(popped); // Displays fish. trace(myPets_array); // Displays cat,dog,bird. See also push (Array.push method) shift (Array.shift method) unshift (Array.unshift...
RETURNINDEXEDARRAY (Array.RETURNINDEXEDARRAY property) public static RETURNINDEXEDARRAY : Number Specifies that a sort returns an indexed array as a result of calling the sort() sortOn() method. You can use this constant for the parameter in the options sort() sortOn() method. This provides preview or copy functionality by returning an array that represents the results of the sort and leaves the original array unmodified.
Example The following code creates the array and then removes the first element from myPets_array the array and assigns it to the variable shifted var myPets_array:Array = new Array("cat", "dog", "bird", "fish"); var shifted:Object = myPets_array.shift(); trace(shifted); // Displays "cat". trace(myPets_array);...
Example The following example creates an array of five pets and uses to populate a new array slice() that contains only four-legged pets: var myPets_array:Array = new Array("cat", "dog", "fish", "canary", "parrot"); var myFourLeggedPets_array:Array = new Array(); var myFourLeggedPets_array = myPets_array.slice(0, 2); trace(myFourLeggedPets_array);...
Page 257
Availability: ActionScript 1.0; Flash Player 5 - Array sorting option added in Flash Player 7. Parameters [optional] - A comparison function used to determine the sorting compareFunction:Object order of elements in an array. Given the elements A and B, the result of compareFunction can have one of the following three values: -1, if A should appear before B in the sorted sequence...
Page 258
Example Usage 1: The following example shows the use of with and without a value Array.sort() passed for options var fruits_array:Array = new Array("oranges", "apples", "strawberries", "pineapples", "cherries"); trace(fruits_array); // Displays oranges,apples,strawberries,pineapples,cherries. fruits_array.sort(); trace(fruits_array); // Displays apples,cherries,oranges,pineapples,strawberries. trace(fruits_array); // Writes apples,cherries,oranges,pineapples,strawberries.
sortOn (Array.sortOn method) public sortOn(fieldName:Object, [options:Object]) : Array Sorts the elements in an array according to one or more fields in the array. The array should have the following characteristics: The array is an indexed array, not an associative array. Each element of the array holds an object with one or more properties.
Page 260
Availability: ActionScript 1.0; Flash Player 6 - The options parameter was added in Flash Player 7. The ability to use different options parameters on multiple sort fields was added in Flash Player 8. Parameters - A string that identifies a field to be used as the sort value, or an array in fieldName:Object which the first element represents the primary sort field, the second represents the secondary sort field, and so on.
Performing a case-insensitive, descending sort on the password field produces the following results: my_array.sortOn("password", Array.CASEINSENSITIVE | Array.DESCENDING); // catchy // Bob // barb // abcd Performing a default sort on the age field produces the following results: my_array.sortOn("age"); // 29 // 3 // 35 // 4...
Page 263
Parameters - An integer that specifies the index of the element in the array where startIndex:Number the insertion or deletion begins. You can specify a negative integer to specify a position relative to the end of the array (for example, -1 is the last element of the array). [optional] - An integer that specifies the number of elements to be deleteCount:Number deleted.
toString (Array.toString method) public toString() : String Returns a string value representing the elements in the specified Array object. Every element in the array, starting with index 0 and ending with the highest index, is converted to a concatenated string and separated by commas. To specify a custom separator, use the method.
unshift (Array.unshift method) public unshift(value:Object) : Number Adds one or more elements to the beginning of an array and returns the new length of the array. Availability: ActionScript 1.0; Flash Player 5 Parameters - One or more numbers, elements, or variables to be inserted at the beginning value:Object of the array.
Parameters - The name of the listener object that receives event notification. listenerObj:Object Returns - Although this method technically returns a Boolean value, in practical terms it Boolean returns because it always returns the value Void true Example The following example is an excerpt from the full example provided in the entry for the method.
Parameters - The name of the event to broadcast. The name of any listener methods eventName:String must match this parameter in order to receive the broadcast event. You can pass arguments to the listener methods by including additional arguments after eventName Example The following example is an excerpt from the first full example provided in the entry for the...
Page 269
Parameters - An object to serve as a broadcasting object. obj:Object Example The following example creates a generic object, , and turns it into an event someObject broadcaster. The output should be the strings shown in the two statements: trace() var someObject:Object = new Object();...
_listeners (AsBroadcaster._listeners property) A list of references to all registered listener objects. This property is intended for internal use, and is not intended for direct manipulation. Objects are added to and removed from this array by calls to the methods. addListener() removelistener() You can call this property only from an object that was initialized by using the...
// cycle through all listener objects, listing all properties of each listener object for (var i:Number = 0; i < numListeners; i++) { trace("Listener " + i + " listens for these events:"); for (item in someObject._listeners[i]) { trace (" " + item + ": " + someObject._listeners[i][item]); See also initialize (AsBroadcaster.initialize method) removeListener (AsBroadcaster.removeListener...
See also addListener (AsBroadcaster.addListener method) initialize (AsBroadcaster.initialize method) BevelFilter (flash.filters.BevelFilter) Object +-flash.filters.BitmapFilter +-flash.filters.BevelFilter public class BevelFilter extends BitmapFilter The BevelFilter class lets you add a bevel effect to a variety of objects in Flash. A bevel effect gives objects such as buttons a three-dimensional look. You can customize the look of the bevel with different highlight and shadow colors, the amount of blur on the bevel, the angle of the bevel, the placement of the bevel, and a knockout effect.
Page 273
See also filters (MovieClip.filters property) cacheAsBitmap (MovieClip.cacheAsBitmap property) filters (Button.filters property) cacheAsBitmap (Button.cacheAsBitmap property) filters (TextField.filters property) applyFilter (BitmapData.applyFilter method) MovieClip Property summary Modifiers Property Description The angle of the bevel. angle:Number The amount of horizontal blur in pixels. blurX:Number The amount of vertical blur in pixels.
Page 274
Constructor summary Signature Description Initializes a new BevelFilter instance with the specified parameters. BevelFilter([distanc e:Number], [angle:Number], [highlightColor:Numb er], [highlightAlpha:Numb er], [shadowColor:Number] [shadowAlpha:Number] , [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [type:String], [knockout:Boolean]) Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : BevelFilter Methods inherited from class BitmapFilter...
angle (BevelFilter.angle property) public angle : Number The angle of the bevel. Valid values are from 0 to 360 degrees. The default value is 45. The angle value represents the angle of the theoretical light source falling on the object and determines the placement of the effect relative to the object.
BevelFilter constructor public BevelFilter([distance:Number], [angle:Number], [highlightColor:Number], [highlightAlpha:Number], [shadowColor:Number], [shadowAlpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [type:String], [knockout:Boolean]) Initializes a new BevelFilter instance with the specified parameters. Availability: ActionScript 1.0; Flash Player 8 Parameters [optional] - The offset distance of the bevel, in pixels (floating point). The distance:Number default value is 4.
Page 277
[optional] - The type of bevel. Valid values are , and type:String "inner" "outer" "full" The default value is "inner" [optional] - Applies a knockout effect ( ), which effectively makes the knockout:Boolean true object's fill transparent and reveals the background color of the document. The default value (no knockout).
rect.lineTo(w, h); rect.lineTo(0, h); rect.lineTo(0, 0); rect._x = 20; rect._y = 20; return rect; blurX (BevelFilter.blurX property) public blurX : Number The amount of horizontal blur in pixels. Valid values are from 0 to 255 (floating point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16, and 32) are optimized to render more quickly than other values.
var filter:BevelFilter = new BevelFilter(5, 45, 0xFFFF00, .8, 0x0000FF, .8, 20, 20, 1, 3, "inner", false); rect.filters = new Array(filter); return rect; blurY (BevelFilter.blurY property) public blurY : Number The amount of vertical blur in pixels. Valid values are from 0 to 255 (floating point). The default value is 4.
var filter:BevelFilter = new BevelFilter(5, 45, 0xFFFF00, .8, 0x0000FF, .8, 20, 20, 1, 3, "inner", false); rect.filters = new Array(filter); return rect; clone (BevelFilter.clone method) public clone() : BevelFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A new BevelFilter instance with all the same properties as flash.filters.BevelFilter...
distance (BevelFilter.distance property) public distance : Number The offset distance of the bevel. Valid values are in pixels (floating point). The default value is Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip instance distance ) when a user clicks it: rect...
highlightAlpha (BevelFilter.highlightAlpha property) public highlightAlpha : Number The alpha transparency value of the highlight color. The value is specified as a normalized value from 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. Availability: ActionScript 1.0;...
highlightColor (BevelFilter.highlightColor property) public highlightColor : Number The highlight color of the bevel. Valid values are in hexadecimal format, 0xRRGGBB. The default value is 0xFFFFFF. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip highlightColor instance ( ) when a user clicks it:...
knockout (BevelFilter.knockout property) public knockout : Boolean Applies a knockout effect ( ), which effectively makes the object's fill transparent and true reveals the background color of the document. The default value is (no knockout). false Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip instance...
quality (BevelFilter.quality property) public quality : Number The number of times to apply the filter. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality, and a value of 3 is high quality. Filters with lower values are rendered more quickly.
shadowAlpha (BevelFilter.shadowAlpha property) public shadowAlpha : Number The alpha transparency value of the shadow color. This value is specified as a normalized value from 0 to 1. For example, .25 sets a transparency value of 25%. The default value is 1. Availability: ActionScript 1.0;...
shadowColor (BevelFilter.shadowColor property) public shadowColor : Number The shadow color of the bevel. Valid values are in hexadecimal format, 0xRRGGBB. The default value is 0x000000. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip shadowColor instance ( ) when a user clicks it:...
strength (BevelFilter.strength property) public strength : Number The strength of the imprint or spread. Valid values are from 0 to 255. The larger the value, the more color is imprinted and the stronger the contrast between the bevel and the background.
type (BevelFilter.type property) public type : String The type of bevel. Valid values are , and "inner" "outer" "full" Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip instance ( type rect when a user clicks it: import flash.filters.BevelFilter;...
BitmapData (flash.display.BitmapData) Object +-flash.display.BitmapData public class BitmapData extends Object The BitmapData class lets you create arbitrarily sized transparent or opaque bitmap images and manipulate them in various ways at runtime. This class lets you separate bitmap rendering operations from the Flash Player internal display updating routines.
Page 292
See also attachBitmap (MovieClip.attachBitmap method) beginBitmapFill (MovieClip.beginBitmapFill method) Property summary Modifiers Property Description [read- The height of the bitmap image in pixels. height:Number only] The rectangle that defines the size and location of the rectangle:Rectangle [read-only] bitmap image. Defines whether the bitmap image supports per-pixel transparent:Boolean [read-only] transparency.
Page 293
Method summary Modifiers Signature Description Takes a source image and a filter object and applyFilter(sourceBi generates the filtered image. tmap:BitmapData, sourceRect:Rectangle , destPoint:Point, filter:BitmapFilter) : Number Returns a new BitmapData object that is a clone of clone() : BitmapData the original instance with an exact copy of the contained bitmap.
Page 294
Modifiers Signature Description Draws a source image or movie clip onto a destination draw(source:Object, image, using the Flash Player vector renderer. [matrix:Matrix], [colorTransform:Colo rTransform], [blendMode:Object], [clipRect:Rectangle] , [smooth:Boolean]) : Void Fills a rectangular area of pixels with a specified fillRect(rect:Rectan ARGB color.
Page 295
Modifiers Signature Description Performs per-channel blending from a source image merge(sourceBitmap:B to a destination image. itmapData, sourceRect:Rectangle , destPoint:Point, redMult:Number, greenMult:Number, blueMult:Number, alphaMult:Number) : Void Fills an image with pixels representing random noise. noise(randomSeed:Num ber, [low:Number], [high:Number], [channelOptions:Numb er], [grayScale:Boolean]) : Void Remaps the color channel values in an image that has paletteMap(sourceBit...
Page 296
Modifiers Signature Description Performs a pixel dissolve either from a source image pixelDissolve(source to a destination image or by using the same image. Bitmap:BitmapData, sourceRect:Rectangle , destPoint:Point, [randomSeed:Number], [numberOfPixels:Numb er], [fillColor:Number]) : Number Scrolls an image by a certain (x, y) pixel amount. scroll(x:Number, y:Number) : Void Sets the color of a single pixel of a BitmapData object.
applyFilter (BitmapData.applyFilter method) public applyFilter(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, filter:BitmapFilter) : Number Takes a source image and a filter object and generates the filtered image. This method relies on the behavior of built-in filter objects, which have code to determine the destination rectangle that is affected by an input source rectangle. After a filter is applied, the resulting image can be larger than the input image.
Page 298
ColorMatrixFilter — This filter can use source and destination images that are either opaque or transparent. DisplacementMapFilter — This filter can use source and destination images that are either opaque or transparent, but the source and destination image formats must be the same.
BitmapData constructor public BitmapData(width:Number, height:Number, [transparent:Boolean], [fillColor:Number]) Creates a BitmapData object with a specified width and height. If you specify a value for the parameter, every pixel in the bitmap is set to that color. fillColor By default, the bitmap is created as opaque, unless you pass the value for the true parameter.
trace(bitmap_1.width); // 100 trace(bitmap_1.height); // 80 trace(bitmap_1.transparent); // true var bitmap_2:BitmapData = new BitmapData(width, height); trace(bitmap_2.width); // 100 trace(bitmap_2.height); // 80 trace(bitmap_2.transparent); // true clone (BitmapData.clone method) public clone() : BitmapData Returns a new BitmapData object that is a clone of the original instance with an exact copy of the contained bitmap.
// >> height: 80 // >> width: 100 To further demonstrate the relationships between , and bitmap_1 bitmap_2 clonedBitmap the following example modifies the pixel value at (1, 1) of . Modifying pixel value at bitmap_1 (1, 1) demonstrates that the method creates an instance based on values of the clone() instance instead instead of refering to the values.
Example The following example shows how to apply a color transform operation to a BitmapData instance. import flash.display.BitmapData; import flash.geom.ColorTransform; var myBitmapData:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC); var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); mc.onPress = function() { myBitmapData.colorTransform(myBitmapData.rectangle, new ColorTransform(1, 0, 0, 1, 255, 0, 0, 0));...
Page 304
Parameters - The input bitmap image to use. The source sourceBitmap:flash.display.BitmapData image can be a different BitmapData object or it can refer to the current BitmapData object. - The source Rectangle object. If you only want to sourceRect:flash.geom.Rectangle copy channel data from a smaller area within the bitmap, specify a source rectangle that is smaller than the overall size of the BitmapData object.
copyPixels (BitmapData.copyPixels method) public copyPixels(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, [alphaBitmap:BitmapData], [alphaPoint:Point], [mergeAlpha:Boolean]) : Void Provides a fast routine to perform pixel manipulation between images with no stretching, rotation, or color effects. This method copies a rectangular area of a source image to a rectangular area of the same size at the destination point of the destination BitmapData object.
Example The following example shows how to copy pixels from one BitmapData instance to another. import flash.display.BitmapData; import flash.geom.Rectangle; import flash.geom.Point; var bitmapData_1:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC); var bitmapData_2:BitmapData = new BitmapData(100, 80, false, 0x00FF0000); var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());...
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); mc.onPress = function() { myBitmapData.dispose(); trace(myBitmapData.width); // -1 trace(myBitmapData.height); // -1 trace(myBitmapData.transparent); // -1 draw (BitmapData.draw method) public draw(source:Object, [matrix:Matrix], [colorTransform:ColorTransform], [blendMode:Object], [clipRect:Rectangle], [smooth:Boolean]) : Void Draws a source image or movie clip onto a destination image, using the Flash Player vector renderer.
Page 308
[optional] - A ColorTransform object that colorTransform:flash.geom.ColorTransform you use to adjust the color values of the bitmap. If no object is supplied, the bitmap image's colors will not be transformed. Set this parameter to a ColorTransform object created using the default constructor, if you must pass this parameter but you do new ColorTransform() not want to transform the image.
See also Rectangle (flash.geom.Rectangle) floodFill (BitmapData.floodFill method) public floodFill(x:Number, y:Number, color:Number) : Void Performs a flood fill operation on an image starting at an (x, y) coordinate and filling with a certain color. The method is similar to the paint bucket tool in various painting floodFill() programs.
generateFilterRect (BitmapData.generateFilterRect method) public generateFilterRect(sourceRect:Rectangle, filter:BitmapFilter) : Rectangle Determines the destination rectangle that the method call affects, given a applyFilter() BitmapData object, a source rectangle, and a filter object. For example, a blur filter normally affects an area larger than the size of the original image. A 100 x 200 pixel image that is being filtered by a default BlurFilter instance, where blurX = generates a destination rectangle of...
var filterRect:Rectangle = myBitmapData.generateFilterRect(myBitmapData.rectangle, filter); trace(filterRect); // (x=-31, y=-31, w=162, h=142) getColorBoundsRect (BitmapData.getColorBoundsRect method) public getColorBoundsRect(mask:Number, color:Number, [findColor:Boolean]) : Rectangle Determines a rectangular region that fully encloses all pixels of a specified color within the bitmap image. For example, if you have a source image and you want to determine the rectangle of the image that contains a nonzero alpha channel, you pass {mask: 0xFF000000, color: as parameters.
mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); myBitmapData.fillRect(new Rectangle(0, 0, 50, 40), 0x00FF0000); mc.onPress = function() { var colorBoundsRect:Rectangle = myBitmapData.getColorBoundsRect(0x00FFFFFF, 0x00FF0000, true); trace(colorBoundsRect); // (x=0, y=0, w=50, h=40) getPixel (BitmapData.getPixel method) public getPixel(x:Number, y:Number) : Number Returns an integer that reresents an RGB pixel value from a BitmapData object at a specific point (x, y).
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); trace("0x" + myBitmapData.getPixel(0, 0).toString(16)); // 0xcccccc See also getPixel32 (BitmapData.getPixel32 method) getPixel32 (BitmapData.getPixel32 method) public getPixel32(x:Number, y:Number) : Number Returns an ARGB color value that contains alpha channel data and RGB data. This method is similar to the method, which returns an RGB color without alpha channel data.
var green:String = (myBitmapData.getPixel32(0, 0) >> 8 & 0xFF).toString(16); trace(">> green: " + green); // cc var blue:String = (myBitmapData.getPixel32(0, 0) & 0xFF).toString(16); trace(">> blue: " + blue); // ee trace("0x" + alpha + red + green + blue); // 0xffaaccee See also getPixel (BitmapData.getPixel method) height (BitmapData.height property)
Page 316
If an image is an opaque image, it is considered a fully opaque rectangle for this method. Both images must be transparent images to perform pixel-level hit testing that considers transparency. When you are testing two transparent images, the alpha threshold parameters control what alpha channel values, from 0 to 255, are considered opaque.
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); merge (BitmapData.merge method) public merge(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, redMult:Number, greenMult:Number, blueMult:Number, alphaMult:Number) : Void Performs per-channel blending from a source image to a destination image. The following formula is used for each channel: new red dest = (red source * redMult) + (red dest * (256 - redMult) / 256; , and values are the multipliers used for each redMult...
Page 321
You can use this method for a variety of effects such as general palette mapping (taking one channel and converting it to a false color image). You can also use this method for a variety of advanced color manipulation algorithms, such as gamma, curves, levels, and quantizing. Availability: ActionScript 1.0;...
for(var i = 0; i < 255; i++) { redArray[i] = 0x00000000; greenArray[i] = 0x00000000; redArray[0xFF] = 0x0000FF00; greenArray[0xFF] = 0x00FF0000; myBitmapData.paletteMap(myBitmapData, new Rectangle(0, 0, 100, 40), new Point(0, 0), redArray, greenArray, null, null); perlinNoise (BitmapData.perlinNoise method) public perlinNoise(baseX:Number, baseY:Number, numOctaves:Number, randomSeed:Number, stitch:Boolean, fractalNoise:Boolean, [channelOptions:Number], [grayScale:Boolean], [offsets:Object]) : Void Generates a Perlin noise image.
Page 323
- Frequency to use in the y direction. For example, to generate a noise that is baseY:Number sized for a 64 x 128 image, pass 128 for the value. baseY - Number of octaves or individual noise functions to combine to create numOctaves:Number this noise.
Page 325
[optional] - The random seed to use to start the pixel dissolve. The randomSeed:Number default value is 0. [optional] - The default is 1/30 of the source area (width x height). numberOfPixels:Number [optional] - An ARGB color value that you use to fill pixels whose source fillColor:Number value equals its destination value.
rectangle (BitmapData.rectangle property) public rectangle : Rectangle [read-only] The rectangle that defines the size and location of the bitmap image. The top and left of the rectangle are 0; the width and height are equal to the width and height in pixels of the BitmapData object.
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); myBitmapData.fillRect(new Rectangle(0, 0, 25, 80), 0x00FF0000); mc.onPress = function() { myBitmapData.scroll(25, 0); setPixel (BitmapData.setPixel method) public setPixel(x:Number, y:Number, color:Number) : Void Sets the color of a single pixel of a BitmapData object. The current alpha channel value of the image pixel is preserved during this operation.
function sketch() { myBitmapData.setPixel(_xmouse, _ymouse, 0x000000); See also getPixel (BitmapData.getPixel method) setPixel32 (BitmapData.setPixel32 method) setPixel32 (BitmapData.setPixel32 method) public setPixel32(x:Number, y:Number, color:Number) : Void Sets the color and alpha transparency values of a single pixel of a BitmapData object. This method is similar to the method;...
function sketch() { myBitmapData.setPixel32(_xmouse, _ymouse, 0x00000000); See also getPixel32 (BitmapData.getPixel32 method) setPixel (BitmapData.setPixel method) threshold (BitmapData.threshold method) public threshold(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, operation:String, threshold:Number, [color:Number], [mask:Number], [copySource:Boolean]) : Number Tests pixel values in an image against a specified threshold and sets pixels that pass the test to new color values.
Page 330
- A rectangle that defnes the area of the source image sourceRect:flash.geom.Rectangle to use as input. - The point within the destination image (the current destPoint:flash.geom.Point BitmapData instance) that corresponds to upper-left corner of the source rectangle. - One of the following comparison operators, passed as a String: "<", operation:String "<=", ">", ">=", "==", "!="...
transparent (BitmapData.transparent property) public transparent : Boolean [read-only] Defines whether the bitmap image supports per-pixel transparency. You can set this value only when you construct a BitmapData object by passing in for the parameter. true transparent After you create a BitmapData object, you can check whether it supports per-pixel transparency by seeing if the value of the property is transparent...
BitmapFilter (flash.filters.BitmapFilter) Object +-flash.filters.BitmapFilter public class BitmapFilter extends Object The BitmapFilter base class for all image filter effects. The BevelFilter, BlurFilter, ColorMatrixFilter, ConvolutionFilter, DisplacementMapFilter, DropShadowFilter, GlowFilter, GradientBevelFilter, and GradientGlowFilter classes all extend the BitmapFilter class. You can apply these filter effects to bitmaps or MovieClip instances. You can create subclasses only for the preceding subclasses of the BitmapFilter class.
clone (BitmapFilter.clone method) public clone() : BitmapFilter Returns a BitmapFilter object that is an exact copy of the original BitmapFilter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A BitmapFilter object. flash.filters.BitmapFilter BlurFilter (flash.filters.BlurFilter) Object +-flash.filters.BitmapFilter +-flash.filters.BlurFilter public class BlurFilter extends BitmapFilter The BlurFilter class lets you apply a blur visual effect to a variety of objects in Flash.
Page 334
A filter is not applied if the resulting image exceeds 2880 pixels in width or height. If, for example, you zoom in on a large movie clip with a filter applied, the filter is turned off if the resulting image exceeds the limit of 2880 pixels. Availability: ActionScript 1.0;...
Example The following example instantiates a new constructor and applies it to a flat, BlurFilter rectangular shape: import flash.filters.BlurFilter; var rect:MovieClip = createRectangle(100, 100, 0x003366, "BlurFilterExample"); var blurX:Number = 30; var blurY:Number = 30; var quality:Number = 3; var filter:BlurFilter = new BlurFilter(blurX, blurY, quality); var filterArray:Array = new Array();...
quality (BlurFilter.quality property) public quality : Number The number of times to perform the blur. Valid values are from 0-15. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality. A value of 3 is high quality and approximates a Gaussian blur.
Boolean Object +-Boolean public class Boolean extends Object The Boolean class is a wrapper object with the same functionality as the standard JavaScript Boolean object. Use the Boolean class to retrieve the primitive data type or string representation of a Boolean object. You must use the constructor new to create a Boolean object before calling its Boolean()
Method summary Modifiers Signature Description Returns the string representation ("true" or toString() : String "false") of the Boolean object. Returns true if the primitive value type of the valueOf() : Boolean specified Boolean object is true; false otherwise. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty...
toString (Boolean.toString method) public toString() : String Returns the string representation ( ) of the Boolean object. "true" "false" Availability: ActionScript 1.0; Flash Player 5 Returns - A string; String "true" "false" Example This example creates a variable of type Boolean and uses to convert the value to a toString() string for use in the trace statement:...
Button Object +-Button public class Button extends Object All button symbols in a SWF file are instances of the object. You can give a button an Button instance name in the Property inspector, and use the methods and properties of the Button class to manipulate buttons with ActionScript.
Page 345
Modifiers Property Description Instance name of the button specified by my_btn. _name:String A reference to the movie clip or object that contains _parent:MovieClip the current movie clip or object. Property (global); sets or retrieves the rendering _quality:String quality used for a SWF file. The rotation of the button, in degrees, from its original _rotation:Number orientation.
Page 346
Modifiers Property Description The y coordinate of the button relative to the local _y:Number coordinates of the parent movie clip. [read- Indicates the y coordinate of the mouse position _ymouse:Number only] relative to the button. The vertical scale of the button as applied from the _yscale:Number registration point of the button, expressed as a percentage.
Event Description Invoked when the pointer moves over a button area. onRollOver function() {} Invoked when a button receives keyboard focus. onSetFocus function(oldFocu s:Object) {} Method summary Modifiers Signature Description Returns the depth of the button instance. getDepth() : Number Methods inherited from class Object addProperty (Object.addProperty method),...
blendMode (Button.blendMode property) public blendMode : Object The blend mode for the button. The blend mode affects the appearance of the button when it is in a layer above another object onscreen. Flash Player applies the property on each pixel of the button. Each pixel is blendMode composed of three constituent colors (red, green, and blue), and each constituent color has a value between 0x00 and 0xFF.
Page 349
Integer value String value Illustration Description Multiplies the values of the "multiply" button constituent colors by those of the background color, and then normalizes by dividing by 0xFF, resulting in darker colors. This is commonly used for shadows and depth effects. For example, if a constituent color (such as red) of one pixel in the button and the...
Page 350
Integer value String value Illustration Description Selects the darker of the "darken" constituent colors of the button and those of the background (the ones with the smaller values). This setting is commonly used for superimposing type. For example, if the button has a pixel with an RGB value of 0xFFCC33, and the background pixel has an RGB value of...
Page 351
Integer value String value Illustration Description Adds the values of the "add" constituent colors of the button to those of its background, and applies a ceiling of 0xFF. This setting is commonly used for animating a lightening dissolve between two objects. For example, if the button has a pixel with an RGB value of 0xAAA633, and the background...
Page 352
Integer value String value Illustration Description Applies the alpha value of each "alpha" pixel of the button to the background. This requires the "layer" to be applied to blendMode a parent button. For example, in the illustration, the parent button, which is a white background, has blendMode = "layer"...
If you attempt to set the property to any other value, Flash Player sets it to blendMode "normal" Availability: ActionScript 1.0; Flash Player 8 Example In the following example you can see that if you set the property to an integer, Flash Player converts the value to the corresponding string version: my_button.blendMode = 8;...
In the following cases a button does not use a bitmap, even if the property is cacheAsBitmap set to and instead renders from vector data: true When the bitmap is too large, that is, greater than 2880 pixels in either direction When the bitmap fails to allocate memory (due to an out of memory error) property is best used with buttons that have mostly static content and cacheAsBitmap...
//button code // the following function will not get called // because myBtn2_btn.enabled was set to false myBtn1_btn.onRelease = function() { trace( "you clicked : " + this._name ); myBtn2_btn.onRelease = function() { trace( "you clicked : " + this._name ); filters (Button.filters property) public filters : Array An indexed array containing each filter object currently associated with the button.
Page 356
To clear the filters for a button, set to an empty array ( filters At load time, if a button has an associated filter, it is marked to cache itself as a transparent bitmap. From this point forward, as long as the button has a valid filter list, the player caches the button as a bitmap.
_focusrect (Button._focusrect property) public _focusrect : Boolean A Boolean value that specifies whether a button has a yellow rectangle around it when it has keyboard focus. This property can override the global property. By default, the _focusrect property of a button instance is null; meaning, the button instance does not _focusrect override the global property.
Returns - The depth of the button instance. Number Example If you create on the Stage, you can trace their depth using the myBtn1_btn myBtn2_btn following ActionScript: trace(myBtn1_btn.getDepth()); trace(myBtn2_btn.getDepth()); If you load a SWF file called buttonMovie.swf into this document, you could trace the depth of a button, , inside that SWF file using another button in the main SWF file: myBtn4_btn...
_highquality (Button._highquality property) public _highquality : Number Deprecated since Flash Player 7. This property was deprecated in favor of Button._quality Specifies the level of anti-aliasing applied to the current SWF file. Specify 2 (best quality) to apply high quality with bitmap smoothing always on. Specify 1 (high quality) to apply anti- aliasing;...
Example The following example assigns a ContextMenu object to a button instance named . The ContextMenu object contains a single menu item (labeled "Save...") with an myBtn_btn associated callback handler function named doSave Add the button instance to the Stage and name it myBtn_btn. var menu_cm:ContextMenu = new ContextMenu();...
onDragOut (Button.onDragOut handler) onDragOut = function() {} Invoked when the mouse button is clicked over the button and the pointer then dragged outside of the button. You must define a function that executes when the event handler is invoked. Availability: ActionScript 1.0; Flash Player 6 Example The following example demonstrates how you can execute statements when the pointer is dragged off a button.
See also onDragOut (Button.onDragOut handler) onKeyDown (Button.onKeyDown handler) onKeyDown = function() {} Invoked when a button has keyboard focus and a key is pressed. The event onKeyDown handler is invoked with no parameters. You can use the Key.getAscii() methods to determine which key was pressed. You must define a function Key.getCode() that executes when the event handler is invoked.
onKeyUp (Button.onKeyUp handler) onKeyUp = function() {} Invoked when a button has input focus and a key is released. The event handler is onKeyUp invoked with no parameters. You can use the methods Key.getAscii() Key.getCode() to determine which key was pressed. Availability: ActionScript 1.0;...
onKillFocus (Button.onKillFocus handler) onKillFocus = function(newFocus:Object) {} Invoked when a button loses keyboard focus. The handler receives one onKillFocus parameter, , which is an object representing the new object receiving the focus. If no newFocus object receives the focus, contains the value newFocus null Availability: ActionScript 1.0;...
Example In the following example, a function that sends a trace() statement to the Output panel is defined for the handler: onPress my_btn.onPress = function () { trace ("onPress called"); onRelease (Button.onRelease handler) onRelease = function() {} Invoked when a button is released. You must define a function that executes when the event handler is invoked.
onRollOut (Button.onRollOut handler) onRollOut = function() {} Invoked when the pointer moves outside a button area. You must define a function that executes when the event handler is invoked. Availability: ActionScript 1.0; Flash Player 6 Example In the following example, a function that sends a trace() statement to the Output panel is defined for the handler: onRollOut...
Example The following example demonstrates how you can execute statements when the user of a SWF file moves focus from one button to another. Create two buttons, btn1_btn btn2_btn and enter the following ActionScript in Frame 1 of the Timeline: Selection.setFocus(btn1_btn);...
_quality (Button._quality property) public _quality : String Property (global); sets or retrieves the rendering quality used for a SWF file. Device fonts are always aliased and therefore are unaffected by the property. _quality property can be set to the following values: _quality "...
Example The following example rotates two buttons on the Stage. Create two buttons on the Stage called . Make sure that is not perfectly round, so you can control_btn my_btn my_btn see it rotating. Then enter the following ActionScript in Frame 1 of the Timeline: var control_btn:Button;...
The area below the rectangle The area in the lower-right corner outside the rectangle You can think of the eight regions outside of the center (defined by the rectangle) as a picture frame that has special rules applied to it when the button is scaled. When the property is set and a button is scaled, all text and gradients are scaled scale9Grid...
tabEnabled (Button.tabEnabled property) public tabEnabled : Boolean Specifies whether is included in automatic tab ordering. It is by default. my_btn undefined If the property is , the object is included in automatic tab tabEnabled undefined true ordering. If the property is also set to a value, the object is included in custom tab tabIndex ordering as well.
property may be a non-negative integer. The objects are ordered according to tabIndex their properties, in ascending order. An object with a value of precedes tabIndex tabIndex an object with a value of . If two objects have the same value, the one tabIndex tabIndex...
Example Add a button instance to the Stage with an instance name and add the following code my_btn to Frame 1 of the Timeline: trace(my_btn._target); //displays /my_btn Select my_btn and convert it to a movie clip. Give the new movie clip an instance name .
Example The following example demonstrates how to track two buttons as a menu. Place two button instances on the Stage called . Enter the following ActionScript in the one_btn two_btn Timeline: var one_btn:Button; var two_btn:Button; one_btn.trackAsMenu = true; two_btn.trackAsMenu = true one_btn.onRelease = function() { trace("clicked one_btn");...
var my_str:String = String(url_array.pop()); output_txt.text = unescape(my_str); When you click each button, the file name of the SWF containing the buttons displays in the Output panel. useHandCursor (Button.useHandCursor property) public useHandCursor : Boolean A Boolean value that, when set to (the default), indicates whether a pointing hand (hand true cursor) displays when the mouse rolls over a button.
Example Create two buttons on the Stage with the instance names myBtn1_btn myBtn2_btn Enter the following ActionScript in Frame 1 of the Timeline: myBtn1_btn.onRelease = function() { this._visible = false; trace("clicked "+this._name); myBtn2_btn.onRelease = function() { this._alpha = 0; trace("clicked "+this._name); Notice how you can still click after the alpha is set to 0.
_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).
table_str += "<b>Stage</b>\t"+"x:"+_xmouse+"\t"+"y:"+_ymouse+newline; table_str += "<b>Button</ b>\t"+"x:"+my_btn._xmouse+"\t"+"y:"+my_btn._ymouse+newline; table_str += "</textformat>"; mouse_txt.htmlText = table_str; Mouse.addListener(mouseListener); See also _ymouse (Button._ymouse property) _xscale (Button._xscale property) public _xscale : Number The horizontal scale of the button as applied from the registration point of the button, expressed as a percentage.
The y coordinate of the button relative to the local coordinates of the parent movie clip. If a button is in the main Timeline, its coordinate system refers to the upper left corner of the Stage as (0, 0). If the button is inside another movie clip that has transformations, the button is in the local coordinate system of the enclosing movie clip.
mouse_txt.htmlText = table_str; Mouse.addListener(mouseListener); See also _xmouse (Button._xmouse property) _yscale (Button._yscale property) public _yscale : Number The vertical scale of the button as applied from the registration point of the button, expressed as a percentage. The default registration point is (0,0). Availability: ActionScript 1.0;...
Camera extends Object The Camera class is primarily for use with Macromedia Flash Communication Server, but can be used in a limited way without the server. The Camera class lets you capture video from a video camera attached to the computer that is running Macromedia Flash Player—for example, to monitor a video feed from a web camera...
Page 382
Modifiers Property Description A numeric value that specifies the amount of motion motionLevel:Number [read-only] required to invoke Camera.onActivity(true). The number of milliseconds between the time the motionTimeOut:Number [read-only] camera stops detecting motion and the time Camera.onActivity (false) is invoked. [read- A Boolean value that specifies whether the user has muted:Boolean only]...
Method summary Modifiers Signature Description Returns a reference to a Camera object for capturing static get([index:Number]) video. : Camera Sets the camera capture mode to the native mode that setMode([width:Numbe best meets the specified requirements. r], [height:Number], [fps:Number], [favorArea:Boolean]) : Void Specifies how much motion is required to invoke setMotionLevel([moti Camera.onActivity(true).
Example This example detects the amount of motion the camera detects using the activityLevel property and a ProgressBar instance. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
Example The following example changes the maximum amount of bandwidth used by the camera feed. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
Example The following example detects the rate in frames per second that the camera captures data, using the property and a ProgressBar instance. Create a new video instance by currentFps selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
Example The following example detects the rate in frames per second that the camera captures data, using the property and a ProgressBar instance. Create a new video instance by currentFps selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
Page 388
When a SWF file tries to access the camera returned by , Flash Player displays a Camera.get() Privacy dialog box that lets the user choose whether to allow or deny access to the camera. (Make sure your Stage size is at least 215 x 138 pixels; this is the minimum size Flash requires to display the dialog box.) When the user responds to this dialog box, the event handler returns an...
Returns - If is not specified, this method returns a reference to the default camera or, if Camera index it is in use by another application, to the first available camera. (If there is more than one camera installed, the user may specify the default camera in the Flash Player Camera Settings panel.) If no cameras are available or installed, the method returns .
Example The following code displays the current width, height and FPS of a video instance in a Label component instance on the Stage. Create a new video instance by selecting New Video from the Library options menu. Add an instance to the Stage and give it the instance name .
cameras_txt.html = true; cameras_txt.border = true; cameras_txt.wordWrap = true; cameras_txt.multiline = true; for (var i = 0; i<Camera.names.length; i++) { cameras_txt.htmlText += "<li><u><a href=\"asfunction:changeCamera,"+i+"\">"+Camera.names[i]+"</a></u></ li>"; function changeCamera(index:Number) { my_cam = Camera.get(index); my_video.attachVideo(my_cam); camera_lbl.text = my_cam.index+". "+my_cam.name; method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later.
Page 392
var motion_pb:mx.controls.ProgressBar; motion_pb.mode = "manual"; motion_pb.label = "Motion: %3%%"; var motionLevel_lbl:mx.controls.Label; // configure the NumericStepper component instance var motionLevel_nstep:mx.controls.NumericStepper; motionLevel_nstep.minimum = 0; motionLevel_nstep.maximum = 100; motionLevel_nstep.stepSize = 5; motionLevel_nstep.value = my_cam.motionLevel; // Continuously update the progress of the ProgressBar component instance to the activityLevel // of the current Camera instance, which is defined in my_cam this.onEnterFrame = function() {...
motionTimeOut (Camera.motionTimeOut property) public motionTimeOut : Number [read-only] The number of milliseconds between the time the camera stops detecting motion and the time is invoked. The default value is 2000 (2 seconds). Camera.onActivity (false) To set this value, use Camera.setMotionLevel() Availability: ActionScript 1.0;...
See also setMotionLevel (Camera.setMotionLevel method) onActivity (Camera.onActivity handler) muted (Camera.muted property) public muted : Boolean [read-only] A Boolean value that specifies whether the user has denied access to the camera ( ) or true allowed access ( ) in the Flash Player Privacy Settings panel. When this value changes, false is invoked.
name (Camera.name property) public name : String [read-only] A string that specifies the name of the current camera, as returned by the camera hardware. Availability: ActionScript 1.0; Flash Player 6 Example The following example displays the name of the default camera in a text field. In Windows, this name is the same as the device name listed in the Scanners and Cameras Control Panel.
Calling the property requires an extensive examination of the hardware, and it Camera.names may take several seconds to build the array. In most cases, you can just use the default camera. The correct syntax is . To assign the return value to a variable, use syntax Camera.names like .
Example The following example displays true or false in the Output panel when the camera starts or stops detecting motion: // Assumes a Video object named "myVideoObject" is on the Stage active_cam = Camera.get(); myVideoObject.attachVideo(active_cam); active_cam.setMotionLevel(10, 500); active_cam.onActivity = function(mode) trace(mode);...
Example The following ActionScript is used to display a message whenever the user allows or denies access to the camera: var my_cam:Camera = Camera.get(); var my_video:Video; my_video.attachVideo(my_cam); my_cam.onStatus = function(infoObj:Object) { switch (infoObj.code) { case 'Camera.Muted' : trace("Camera access is denied"); break;...
quality_nstep.minimum = 0; quality_nstep.maximum = 100; quality_nstep.stepSize = 5; quality_nstep.value = my_cam.quality; function changeQuality() { my_cam.setQuality(my_cam.bandwidth, quality_nstep.value); quality_nstep.addEventListener("change", changeQuality); See also setQuality (Camera.setQuality method) setMode (Camera.setMode method) public setMode([width:Number], [height:Number], [fps:Number], [favorArea:Boolean]) : Void Sets the camera capture mode to the native mode that best meets the specified requirements. If the camera does not have a native mode that matches all the parameters you pass, Flash selects a capture mode that most closely synthesizes the requested mode.
Page 400
[optional] - A Boolean value that specifies how to manipulate the width, favorArea:Boolean height, and frame rate if the camera does not have a native mode that meets the specified requirements. The default value is , which means that maintaining capture size is true favored;...
setMotionLevel (Camera.setMotionLevel method) public setMotionLevel([motionLevel:Number], [timeOut:Number]) : Void Specifies how much motion is required to invoke . Optionally Camera.onActivity(true) sets the number of milliseconds that must elapse without activity before Flash considers motion to have stopped and invokes Camera.onActivity(false) Video can be displayed regardless of the value of the sensitivity parameter. This parameter determines only when and under waht circumstances Camera.onActivity invoked -- not whether video is actually being captured or displayed.
Example The following example sends messages to the Output panel when video activity starts or stops. Change the motion sensitivity value of 30 to a higher or lower number to see how different values affect motion detection. // Assumes a Video object named "myVideoObject" is on the Stage active_cam = Camera.get();...
To specify that both bandwidth and quality are equally important, pass numeric values for both parameters. Flash will transmit video that achieves the specified quality and that doesn't exceed the specified bandwidth. If necessary, Flash will reduce the frame rate to maintain picture quality without exceeding the specified bandwidth.
You can send capabilities information using a HTTP method. The following POST example shows a server string for a computer that has MP3 support, 1600 x 1200 pixel resolution, is running Windows XP, and Flash Player 8 (8.0.0.0): A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=f&PR=t&SP=t& SB=f&DEB=t&V=WIN%208%2C0%2C0%2C0&M=Macromedia%20Windows& ActionScript classes...
Page 405
R=1600x1200&DP=72&COL=color&AR=1.0&OS=Windows%20XP& L=en&PT=External&AVD=f&LFD=f&WD=f" All properties of the object are read-only. System.capabilities Availability: ActionScript 1.0; Flash Player 6 Property summary Modifiers Property Description A Boolean value that specifies whether access to the static avHardwareDisable:Bo [read-only] user's camera and microphone has been olean administratively prohibited (true) or allowed (false).
Page 406
(true) or allowed (false). A string that indicates the manufacturer of Flash static manufacturer:String [read-only] Player, in the format "Macromedia OSName" (OSName could be "Windows", "Macintosh", "Linux", or "Other OS Name"). [read-only] A string that indicates the current operating system. static...
Availability: ActionScript 1.0; Flash Player 6 Example The following example traces the value of this read-only property: trace(System.capabilities.hasAccessibility); See also isActive (Accessibility.isActive method) updateProperties (Accessibility.updateProperties method) hasAudio (capabilities.hasAudio property) public static hasAudio : Boolean [read-only] Specifies if the system has audio capabilities. A Boolean value that is if the player is true running on a system that has audio capabilities;...
hasEmbeddedVideo (capabilities.hasEmbeddedVideo property) public static hasEmbeddedVideo : Boolean [read-only] A Boolean value that is if the player is running on a system that supports embedded true video; otherwise. The server string is false Availability: ActionScript 1.0; Flash Player 6,0,65,0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasEmbeddedVideo);...
hasPrinting (capabilities.hasPrinting property) public static hasPrinting : Boolean [read-only] A Boolean value that is if the player is running on a system that supports printing; true otherwise. The server string is false Availability: ActionScript 1.0; Flash Player 6,0,65,0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasPrinting);...
hasStreamingAudio (capabilities.hasStreamingAudio property) public static hasStreamingAudio : Boolean [read-only] A Boolean value that is if the player can play streaming audio; otherwise. The true false server string is Availability: ActionScript 1.0; Flash Player 6,0,65,0 Example The following example traces the value of this read-only property: trace(System.capabilities.hasStreamingAudio);...
isDebugger (capabilities.isDebugger property) public static isDebugger : Boolean [read-only] A Boolean value that indicates whether the player is an officially released version ( ) or a false special debugging version ( ). The server string is true Availability: ActionScript 1.0; Flash Player 6 Example The following example traces the value of this read-only property: trace(System.capabilities.isDebugger);...
Language German Hungarian Italian Japanese Korean Norwegian Other/unknown Polish Portuguese Russian Simplified Chinese zh-CN Spanish Swedish Traditional Chinese zh-TW Turkish Availability: ActionScript 1.0; Flash Player 6 - Behavior changed in Flash Player 7. Example The following example traces the value of this read-only property: trace(System.capabilities.language);...
The following example traces the value of this read-only property: trace(System.capabilities.localFileReadDisable); manufacturer (capabilities.manufacturer property) public static manufacturer : String [read-only] A string that indicates the manufacturer of Flash Player, in the format " " Macromedia OSName could be " ", " ", , or " "). The server...
Example The following example traces the value of this read-only property: trace(System.capabilities.pixelAspectRatio); playerType (capabilities.playerType property) public static playerType : String [read-only] A string that indicates the type of player. This property can have one of the following values: for the Flash StandAlone Player "StandAlone"...
The following example traces the value of this read-only property: trace(System.capabilities.screenResolutionY); serverString (capabilities.serverString property) public static serverString : String [read-only] A URL-encoded string that specifies values for each property. System.capabilities The following example shows a URL-encoded string: A=t&SA=t&SV=t&EV=t&MP3=t&AE=t&VE=t&ACC=f&PR=t&SP=t& SB=f&DEB=t&V=WIN%208%2C0%2C0%2C0&M=Macromedia%20Windows& R=1600x1200&DP=72&COL=color&AR=1.0&OS=Windows%20XP& ActionScript classes...
L=en&PT=External&AVD=f&LFD=f&WD=f Availability: ActionScript 1.0; Flash Player 6 Example The following example traces the value of this read-only property: trace(System.capabilities.serverString); version (capabilities.version property) public static version : String [read-only] A string containing the Flash Player platform and version information (for example, "WIN ).
Page 418
Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Constructor summary Signature Description Class Deprecated. Color(target:Object) Creates a Color object for the movie clip specified by the target_mc parameter. Method summary Modifiers Signature Description...
Color constructor public Color(target:Object) Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class. Creates a Color object for the movie clip specified by the parameter. You can then target_mc use the methods of that Color object to change the color of the entire target movie clip. Availability: ActionScript 1.0;...
Example The following code retrieves the RGB value for the Color object , converts the value my_color to a hexadecimal string, and assigns it to the variable. To see this code work, add a myValue movie clip instance to the Stage, and give it the instance name my_mc var my_color:Color = new Color(my_mc);...
setRGB (Color.setRGB method) public setRGB(offset:Number) : Void Deprecated since Flash Player 8. The Color class has been deprecated in favor of the flash.geom.ColorTransform class. Specifies an RGB color for a Color object. Calling this method overrides any previous settings. Color.setTransform() Availability: ActionScript 1.0;...
Page 422
is the offset for the green component (-255 to 255). is the percentage for the blue component (-100 to 100). is the offset for the blue component (-255 to 255). is the percentage for alpha (-100 to 100). is the offset for alpha (-255 to 255). You create a parameter as follows: colorTransformObject...
See also Object ColorMatrixFilter (flash.filters.ColorMatrixFilter) Object +-flash.filters.BitmapFilter +-flash.filters.ColorMatrixFilter public class ColorMatrixFilter extends BitmapFilter The ColorMatrixFilter class lets you apply a 4 x 5 matrix transformation on the RGBA color and alpha values of every pixel on the input image to produce a result with a new set of RGBA color and alpha values.
Page 424
This filter separates each source pixel into its red, green, blue, and alpha components as srcR, srcG, srcB, srcA. As a final step, it combines each color component back into a single pixel and writes out the result. The calculations are performed on unmultiplied color values. If the input graphic consists of premultiplied color values, those values are automatically converted into unmultiplied color values for this operation.
Page 425
listener.image = image; listener.onMouseMove = function() { var xPercent:Number = 1 - (_xmouse/Stage.width); var yPercent:Number = 1 - (_ymouse/Stage.height); var matrix:Array = new Array(); matrix = matrix.concat([yPercent, 0, 0, 0, 0]); // red matrix = matrix.concat([0, xPercent, 0, 0, 0]); // green matrix = matrix.concat([0, 0, xPercent, 0, 0]);...
var filter:ColorMatrixFilter = new ColorMatrixFilter(matrix); trace("filter: " + filter.matrix); var clonedFilter:ColorMatrixFilter = filter.clone(); matrix = clonedFilter.matrix; matrix[2] = 1; clonedFilter.matrix = matrix; trace("clonedFilter: " + clonedFilter.matrix); ColorMatrixFilter constructor public ColorMatrixFilter(matrix:Array) Initializes a new ColorMatrixFilter instance with the specified parameters. Availability: ActionScript 1.0; Flash Player 8 Parameters - An array of 20 elements arranged in a 4 x 5 matrix.
ColorTransform (flash.geom.ColorTransform) Object +-flash.geom.ColorTransform public class ColorTransform extends Object The ColorTransform class lets you mathematically adjust all of the color values in a movie clip. The color adjustment function or color transformation can be applied to all four channels: red, green, blue, and alpha transparency. When a ColorTransform object is applied to a movie clip, a new value for each color channel is calculated like this: New red value = (old red value *...
Page 429
Property summary Modifiers Property Description A decimal value that is multiplied by the alpha alphaMultiplier:Numb transparency channel value. A number from -255 to 255 that is added to the alpha alphaOffset:Number transparency channel value after it has been multiplied by the alphaMultiplier value. A decimal value that is multiplied by the blue channel blueMultiplier:Numbe value.
Page 430
Constructor summary Signature Description Creates a ColorTransform object for a display object with the ColorTransform([redM specified color channel values and alpha values. ultiplier:Number], [greenMultiplier:Num ber], [blueMultiplier:Numb er], [alphaMultiplier:Num ber], [redOffset:Number], [greenOffset:Number] [blueOffset:Number], [alphaOffset:Number] Method summary Modifiers Signature Description Applies a second, additive color transformation to the concat(second:ColorT movie clip.
alphaMultiplier (ColorTransform.alphaMultiplier property) public alphaMultiplier : Number A decimal value that is multiplied by the alpha transparency channel value. If you set the alpha transparency value of a movie clip directly by using the property, it affects the value of the property of that MovieClip._alpha alphaMultiplier...
alphaOffset (ColorTransform.alphaOffset property) public alphaOffset : Number A number from -255 to 255 that is added to the alpha transparency channel value after it has been multiplied by the value. alphaMultiplier Availability: ActionScript 1.0; Flash Player 8 Example The following example creates the ColorTransform object and adjusts its colorTrans value from 0 to -128.
Example The following example creates the ColorTransform object and adjusts its colorTrans value from 1 to .5. blueMultiplier import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans:ColorTransform = new ColorTransform(); trace(colorTrans.blueMultiplier); // 1 colorTrans.blueMultiplier = .5; trace(colorTrans.blueMultiplier); // .5 var rect:MovieClip = createRectangle(20, 80, 0x0000FF); var trans:Transform = new Transform(rect);...
[optional] - The offset for the green color channel value (-255 to 255). greenOffset:Number The default value is 0. [optional] - The offset for the blue color channel value (-255 to 255). blueOffset:Number The default value is 0. [optional] - The offset for alpha transparency channel value (-255 to alphaOffset:Number 255).
Page 436
Example The following example concatenates the ColorTransform object colorTrans_2 resulting in a full red offset combined with a .5 alpha multiplier. colorTrans_1 import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans_1:ColorTransform = new ColorTransform(1, 1, 1, 1, 255, 0, 0, trace(colorTrans_1); // (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=255, greenOffset=0, blueOffset=0, alphaOffset=0) var colorTrans_2:ColorTransform = new ColorTransform(1, 1, 1, .5, 0, 0, 0,...
greenMultiplier (ColorTransform.greenMultiplier property) public greenMultiplier : Number A decimal value that is multiplied by the green channel value. Availability: ActionScript 1.0; Flash Player 8 Example The following example creates the ColorTransform object and adjusts its colorTrans from 1 to .5. greenMultiplier import flash.geom.ColorTransform;...
Example The following example creates the ColorTransform object and adjusts its colorTrans value from 0 to 255. greenOffset import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans:ColorTransform = new ColorTransform(); trace(colorTrans.greenOffset); // 0 colorTrans.greenOffset = 255; trace(colorTrans.greenOffset); // 255 var rect:MovieClip = createRectangle(20, 80, 0x000000); var trans:Transform = new Transform(rect);...
scope = (scope == undefined) ? this : scope; var depth:Number = scope.getNextHighestDepth(); var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; rgb (ColorTransform.rgb property) public rgb : Number The RGB color value for a ColorTransform object. When you set this property, it changes the three color offset values ( redOffset , and...
var depth:Number = scope.getNextHighestDepth(); var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; toString (ColorTransform.toString method) public toString() : String Formats and returns a string that describes all of the properties of the ColorTransform object. Availability: ActionScript 1.0;...
ContextMenu Object +-ContextMenu public dynamic class ContextMenu extends Object The ContextMenu class provides runtime control over the items in the Flash Player context menu, which appears when a user right-clicks (Windows) or Control-clicks (Macintosh) on Flash Player. You can use the methods and properties of the ContextMenu class to add custom menu items, control the display of the built-in context menu items (for example, Zoom In and Print), or create copies of menus.
Page 443
See also ContextMenuItem menu (Button.menu property) menu (MovieClip.menu property) menu (TextField.menu property) Property summary Modifiers Property Description An object that has the following Boolean properties: builtInItems:Object zoom, quality, play, loop, rewind, forward_back, and print. An array of ContextMenuItem objects. customItems:Array Properties inherited from class Object constructor (Object.constructor property),...
Method summary Modifiers Signature Description Creates a copy of the specified ContextMenu object. copy() : ContextMenu Hides all built-in menu items (except Settings) in the hideBuiltInItems() : specified ContextMenu object. Void Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable...
In the next example, a loop enumerates through all names and values of the built-in for..in menu items of the ContextMenu object, my_cm var my_cm:ContextMenu = new ContextMenu(); for(eachProp in my_cm.builtInItems) { var propName = eachProp; var propValue = my_cm.builtInItems[propName]; trace(propName + ": "...
function itemHandler(obj, item) { //...put code here... trace("selected!"); this.menu = my_cm; When the user right-clicks or Control-clicks the Stage, the custom menu is displayed. See also menu (Button.menu property) onSelect (ContextMenu.onSelect handler) customItems (ContextMenu.customItems property) hideBuiltInItems (ContextMenu.hideBuiltInItems method) menu (MovieClip.menu property) menu (TextField.menu property) copy (ContextMenu.copy method)
for (var i in my_cm.customItems) { trace("my_cm-> "+my_cm.customItems[i].caption); customItems (ContextMenu.customItems property) public customItems : Array An array of ContextMenuItem objects. Each object in the array represents a context menu item that you have defined. Use this property to add, remove, or modify these custom menu items.
hideBuiltInItems (ContextMenu.hideBuiltInItems method) public hideBuiltInItems() : Void Hides all built-in menu items (except Settings) in the specified ContextMenu object. If the Flash Debug Player is running, the Debugging menu item shows, although it is dimmed for SWF files that don't have remote debugging enabled. This method hides only menu items that appear in the standard context menu;...
Parameters - A reference to the object (movie clip, button, or selectable text field) that was item:Object under the mouse pointer when the Flash Player context menu was invoked and whose menu property is set to a valid ContextMenu object. - A reference to the ContextMenu object assigned to the property of item_menu:Object...
Page 450
Menu items are compared without regard to case, punctuation, or white space. None of the following words can appear in a custom item: Macromedia, Flash Player, or Settings.
Constructor summary Signature Description Creates a new ContextMenuItem object that can be added to ContextMenuItem(caption:Str the ContextMenu.customItems array. ing, callbackFunction:Function, [separatorBefore:Boolean], [enabled:Boolean], [visible:Boolean]) Method summary Modifiers Signature Description Creates and returns a copy of the specified copy() : ContextMenuItem object. ContextMenuItem Methods inherited from class Object addProperty (Object.addProperty...
ContextMenuItem constructor public ContextMenuItem(caption:String, callbackFunction:Function, [separatorBefore:Boolean], [enabled:Boolean], [visible:Boolean]) Creates a new ContextMenuItem object that can be added to the array. ContextMenu.customItems Availability: ActionScript 1.0; Flash Player 7 Parameters - A string that specifies the text associated with the menu item. caption:String - A function that you define, which is called when the menu callbackFunction:Function...
copy (ContextMenuItem.copy method) public copy() : ContextMenuItem Creates and returns a copy of the specified ContextMenuItem object. The copy includes all properties of the original object. Availability: ActionScript 1.0; Flash Player 7 Returns - A ContextMenuItem object. ContextMenuItem Example This example creates a new ContextMenuItem object named with the caption original_cmi Pause and a callback handler set to the function...
Example The following example creates two new context menu items: Start and Stop. When the user selects Start, the number of milliseconds from when the SWF file started is traced. Start is then disabled in the menu. When Stop is selected, the number of milliseconds that have elapsed since the SWF file started is traced.
Parameters - A reference to the object (movie clip, Timeline, button, or selectable text field) obj:Object on which the user right or Control clicked. - A reference to the selected ContextMenuItem object. menuItem:Object Example The following example determines over what type of object the context menu was invoked. var my_cmi:ContextMenu = new ContextMenu();...
Example This example creates three menu items, labeled Open, Save, and Print. A separator bar divides the Save and Print items. The menu items are then added to the ContextMenu object's array. Finally, the menu is attached to the current Timeline of the SWF file. customItems var my_cm:ContextMenu = new ContextMenu();...
stopMenuItem.visible = false; function startHandler(obj, item) { trace("Starting... "+getTimer()+"ms"); startMenuItem.visible = false; stopMenuItem.visible = true; this.menu = my_cm; ConvolutionFilter (flash.filters.ConvolutionFilter) Object +-flash.filters.BitmapFilter +-flash.filters.ConvolutionFilter public class ConvolutionFilter extends BitmapFilter The ConvolutionFilter class applies a matrix convolution filter effect. A convolution combines pixels in the input image with neighboring pixels to produce an image. A wide variety of imaging operations can be achieved through convolutions, including blurring, edge detection, sharpening, embossing, and beveling.
Page 458
A matrix convolution is based on an n x m matrix, which describes how a given pixel value in the input image is combined with its neighboring pixel values to produce a resulting pixel value. Each result pixel is determined by applying the matrix to the corresponding source pixel and its neighboring pixels.
Page 459
Property summary Modifiers Property Description The alpha transparency value of the substitute color. alpha:Number Bias to add to the result of the matrix transformation. bias:Number Indicates whether the image should be clamped. clamp:Boolean The hexadecimal color to substitute for pixels that are color:Number off the source image.
myBitmapData.noise(128, 0, 255, 1 | 2 | 4 | 8, false); mc.onPress = function() { myBitmapData.applyFilter(myBitmapData, new Rectangle(0, 0, 98, 78), new Point(2, 2), filter); bias (ConvolutionFilter.bias property) public bias : Number Bias to add to the result of the matrix transformation. The default is 0. Availability: ActionScript 1.0;...
Example The following example changes the property of from its default value of clamp filter true false import flash.filters.ConvolutionFilter; import flash.display.BitmapData; import flash.geom.Rectangle; import flash.geom.Point; var clamp:Boolean = false; var filter:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 0, true, clamp, 0x00FF00, 1);...
Page 463
var filter_1:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9); var filter_2:ConvolutionFilter = filter_1; var clonedFilter:ConvolutionFilter = filter_1.clone(); trace(filter_1 == filter_2); // true trace(filter_1 == clonedFilter); // false for(var i in filter_1) { trace(">> " + i + ": " + filter_1[i]); // >>...
filter_1.bias = 20; trace(filter_1.bias); // 20 trace(filter_2.bias); // 20 trace(clonedFilter.bias); // 0 color (ConvolutionFilter.color property) public color : Number The hexadecimal color to substitute for pixels that are off the source image. This is an RGB value with no alpha component. The default is 0. Availability: ActionScript 1.0;...
ConvolutionFilter constructor public ConvolutionFilter(matrixX:Number, matrixY:Number, matrix:Array, [divisor:Number], [bias:Number], [preserveAlpha:Boolean], [clamp:Boolean], [color:Number], [alpha:Number]) Initializes a ConvolutionFilter instance with the specified parameters. Availability: ActionScript 1.0; Flash Player 8 Parameters - The x dimension of the matrix (the number of columns in the matrix). matrixX:Number The default value is 0.
The following example creates a ConvolutionFilter object with the four required parameters , and matrixX matrixY matrix divisor import flash.filters.ConvolutionFilter; import flash.display.BitmapData; var matrixX:Number = 3; var matrixY:Number = 3; var matrix:Array = [1, 1, 1, 1, 1, 1, 1, 1, 1]; var divisor:Number = 9;...
mc.attachBitmap(myBitmapData, this.getNextHighestDepth()); myBitmapData.noise(128); mc.onPress = function() { var newDivisor:Number = 6; filter.divisor = newDivisor; myBitmapData.applyFilter(myBitmapData, myBitmapData.rectangle, new Point(0, 0), filter); matrix (ConvolutionFilter.matrix property) public matrix : Array An array of values used for matrix transformation; returns a copy. The number of items in the array must equal matrixX*matrixY property cannot be changed by directly modifying the values (for example,...
matrixX (ConvolutionFilter.matrixX property) public matrixX : Number The x dimension of the matrix (the number of columns in the matrix). The default value is 0. Availability: ActionScript 1.0; Flash Player 8 Example The following example displays the property of matrixX filter import flash.filters.ConvolutionFilter;...
Example The following example changes the property of from its default value preserveAlpha filter true false import flash.filters.ConvolutionFilter; import flash.display.BitmapData; var preserveAlpha:Boolean = false; var filter:ConvolutionFilter = new ConvolutionFilter(3, 3, [1, 1, 1, 1, 1, 1, 1, 1, 1], 9, 0, preserveAlpha); var myBitmapData:BitmapData = new BitmapData(100, 80, true, 0xCCFF0000);...
Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Reads the contents of the custom action XML static get(name:String) : definition file named name. String Installs a new custom action XML definition file static install(name:String,...
Parameters - The name of the custom action definition to retrieve. name:String Returns - If the custom action XML definition is located, returns a string; otherwise, returns String undefined Example The following example lists the custom actions in a ComboBox instance, and gets the custom action when a Button instance is clicked.
Page 472
Parameters - The name of the custom action definition to install. name:String - The text of the XML definition to install. data:String Returns - A Boolean value of if an error occurs during installation; otherwise, a value Boolean false is returned to indicate that the custom action has been successfully installed. true Example The following example installs information into the Actions panel from an XML file.
list (CustomActions.list method) public static list() : Array Returns an Array object containing the names of all the custom actions that are registered with the Flash authoring tool. The elements of the array are simple names, without the .xml file extension, and without any directory separators (for example, ":", "/", or "\"). If there are no registered custom actions, returns a zero-length array.
uninstall (CustomActions.uninstall method) public static uninstall(name:String) : Boolean Removes the Custom Actions XML definition file named name The name of the definition file must be a simple filename, without the .xml file extension, and without any directory separators (':', '/' or '\'). Availability: ActionScript 1.0;...
Date Object +-Date public class Date extends Object The Date class lets you retrieve date and time values relative to universal time (Greenwich mean time, now called universal time or UTC) or relative to the operating system on which Flash Player is running. The methods of the Date class are not static but apply only to the individual Date object specified when the method is called.
Page 476
Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Constructor summary Signature Description Constructs a new Date object that holds the specified date and time. Date([yearOrTimevalu e:Number], [month:Number], [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number]...
Page 477
Method summary Modifiers Signature Description Returns the day of the month (an integer from 1 to 31) getDate() : Number of the specified Date object according to local time. Returns the day of the week (0 for Sunday, 1 for getDay() : Number Monday, and so on) of the specified Date object according to local time.
Page 478
Modifiers Signature Description Returns the minutes (an integer from 0 to 59) of the getUTCMinutes() : specified Date object, according to universal time. Number Returns the month (0 [January] to 11 [December]) of getUTCMonth() : the specified Date object, according to universal time. Number Returns the seconds (an integer from 0 to 59) of the getUTCSeconds() :...
Page 479
Modifiers Signature Description Sets the year for the specified Date object (my_date) setUTCFullYear(year: in universal time and returns the new time in Number, milliseconds. [month:Number], [date:Number]) : Number Sets the hour for the specified Date object in universal setUTCHours(hour:Num time and returns the new time in milliseconds. ber, [minute:Number], [second:Number],...
Modifiers Signature Description Returns the number of milliseconds between midnight static UTC(year:Number, on January 1, 1970, universal time, and the time month:Number, specified in the parameters. [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number] ) : Number Returns the number of milliseconds since midnight valueOf() : Number January 1, 1970, universal time, for this Date.
Page 481
In the third line, a Date object is created with year, month, and date parameters passed to it, resulting in the time 09:30:15 GMT (+ 0 milliseconds) March 6, 1965. Note that since the year parameter is specified as a two-digit integer, it is interpreted as 1965. In the fourth line, only one parameter is passed, which is a time value representing the number of milliseconds before or after 0:00:00 GMT January 1, 1970;...
See also getMonth (Date.getMonth method) getDate (Date.getDate method) getFullYear (Date.getFullYear method) getDate (Date.getDate method) public getDate() : Number Returns the day of the month (an integer from 1 to 31) of the specified Date object according to local time. Local time is determined by the operating system on which Flash Player is running.
Example The following example creates a new Date object and uses to determine the current getDay() day of the week var dayOfWeek_array:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); var today_date:Date = new Date(); var day_str:String = dayOfWeek_array[today_date.getDay()]; trace("Today is "+day_str);...
Example The following example uses the constructor to create a Date object based on the current time and uses the method to display hour values from that object: getHours() var my_date:Date = new Date(); trace(my_date.getHours()); var my_date:Date = new Date(); var hourObj:Object = getHoursAmPm(my_date.getHours());...
getMinutes (Date.getMinutes method) public getMinutes() : Number Returns the minutes (an integer from 0 to 59) of the specified Date object, according to local time. Local time is determined by the operating system on which Flash Player is running. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer.
var monthNames_array:Array = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); return monthNames_array[month]; getSeconds (Date.getSeconds method) public getSeconds() : Number Returns the seconds (an integer from 0 to 59) of the specified Date object, according to local time.
getTimezoneOffset (Date.getTimezoneOffset method) public getTimezoneOffset() : Number Returns the difference, in minutes, between the computer's local time and universal time. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer. Number Example The following example returns the difference between the local daylight saving time for San Francisco and universal time.
See also getDate (Date.getDate method) getUTCDay (Date.getUTCDay method) public getUTCDay() : Number Returns the day of the week (0 for Sunday, 1 for Monday, and so on) of the specified Date object, according to universal time. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer.
Example The following example creates a new Date object and uses Date.getUTCFullYear() . The value returned by may differ from the Date.getFullYear() Date.getUTCFullYear() value returned by if today's date is December 31 or January 1 Date.getFullYear() depending on the relationship between your local time zone and universal time. var today_date:Date = new Date();...
getUTCMilliseconds (Date.getUTCMilliseconds method) public getUTCMilliseconds() : Number Returns the milliseconds (an integer from 0 to 999) of the specified Date object, according to universal time. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer. Number Example The following example creates a new Date object and uses to return getUTCMilliseconds() the milliseconds value from the Date object.
Returns - An integer. Number Example The following example creates a new Date object and uses Date.getUTCMonth() . The value returned by can differ from the value Date.getMonth() Date.getUTCMonth() returned by if today's date is the first or last day of a month depending on Date.getMonth() the relationship between your local time zone and universal time.
Returns - An integer. Number Example The following example creates a new Date object and uses Date.getUTCFullYear() . The value returned by may differ from the Date.getFullYear() Date.getUTCFullYear() value returned by if today's date is December 31 or January 1 Date.getFullYear() depending on the relationship between your local time zone and universal time.
setDate (Date.setDate method) public setDate(date:Number) : Number Sets the day of the month for the specified Date object, according to local time, and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running. Availability: ActionScript 1.0;...
[optional] - A number from 1 to 31. If you omit this parameter, the date field date:Number of the specified Date object will not be modified. Returns - An integer. Number Example The following example initially creates a new Date object, setting the date to May 15, 2004, and uses to change the date to May 15, 2002: Date.setFullYear()
setMilliseconds (Date.setMilliseconds method) public setMilliseconds(millisecond:Number) : Number Sets the milliseconds for the specified Date object according to local time and returns the new time in milliseconds. Local time is determined by the operating system on which Flash Player is running. Availability: ActionScript 1.0;...
Example The following example initially creates a new Date object, setting the time and date to 8:00 a.m. on May 15, 2004, and then uses to change the time to 8:30 a.m.: Date.setMinutes() var my_date:Date = new Date(2004,4,15,8,0); trace(my_date.getMinutes()); // output: 0 my_date.setMinutes(30);...
Parameters - An integer from 0 to 59. second:Number Returns - An integer. Number Example The following example initially creates a new Date object, setting the time and date to 8:00:00 a.m. on May 15, 2004, and uses to change the time to 8:00:45 Date.setSeconds() a.m.: var my_date:Date = new Date(2004,4,15,8,0,0);...
setUTCDate (Date.setUTCDate method) public setUTCDate(date:Number) : Number Sets the date for the specified Date object in universal time and returns the new time in milliseconds. Calling this method does not modify the other fields of the specified Date object, but can report a new value if the day of the Date.getUTCDay() Date.getDay()
Parameters - An integer that represents the year specified as a full four-digit year, such as year:Number 2000. [optional] - An integer from 0 (January) to 11 (December). If you omit this month:Number parameter, the month field of the specified Date object will not be modified. [optional] - An integer from 1 to 31.
[optional] - A number; an integer from 0 to 59. If you omit this parameter, second:Number the seconds field of the specified Date object will not be modified. [optional] - A number; an integer from 0 to 999. If you omit this millisecond:Number parameter, the milliseconds field of the specified Date object will not be modified.
Example The following example initially creates a new Date object, setting the date to 8:30 a.m. on May 15, 2004 with the milliseconds value set to 250, and uses Date.setUTCMilliseconds() to change the milliseconds value to 575: var my_date:Date = new Date(2004,4,15,8,30,0,250); trace(my_date.getUTCMilliseconds());...
setUTCMonth (Date.setUTCMonth method) public setUTCMonth(month:Number, [date:Number]) : Number Sets the month, and optionally the day, for the specified Date object in universal time and returns the new time in milliseconds. Calling this method does not modify the other fields of the specified Date object, but might report a new Date.getUTCDay()
[optional] - An integer from 0 to 999. If you omit this parameter, the millisecond:Number milliseconds field of the specified Date object will not be modified. Returns - An integer. Number Example The following example initially creates a new Date object, setting the time and date to 8:00:00 a.m.
trace(my_date.getYear()); // output: 103 trace(my_date.getFullYear()); // output: 2003 toString (Date.toString method) public toString() : String Returns a string value for the specified date object in a readable format. Availability: ActionScript 1.0; Flash Player 5 Returns - A string. String Example The following example returns the information in the Date object as a dateOfBirth_date...
Returns - An integer. Number Example The following example creates a new Date object defined in universal maryBirthday_date time. This is the universal time variation of the example used for the constructor new Date method. The output is in local time and varies accordingly. For Pacific Daylight Time the output is seven hours earlier than UTC: Sun Aug 11 17:00:00 GMT-0700 1974.
Page 506
To apply filters to movie clips at runtime, use the property. Setting the filters filters property of an object does not modify the object and can be undone by clearing the filters property. To apply filters to BitmapData instances, use the method.
Page 507
Property summary Modifiers Property Description Specifies the alpha transparency value to use for out- alpha:Number of-bounds displacements. Specifies what color to use for out-of-bounds color:Number displacements. Describes which color channel to use in the map componentX:Number image to displace the x result. Describes which color channel to use in the map componentY:Number image to displace the y result.
clone (DisplacementMapFilter.clone method) public clone() : DisplacementMapFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A new DisplacementMapFilter instance with all flash.filters.DisplacementMapFilter the same properties as the original one. Example The following example creates three DisplacementMapFilter objects and compares them: is created by using the constructor;...
var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial", true); var filter_1:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000); var filter_2:DisplacementMapFilter = filter_1; var clonedFilter:DisplacementMapFilter = filter_1.clone(); trace(filter_1.mode); // wrap trace(filter_2.mode); // wrap trace(clonedFilter.mode); // wrap filter_1.mode = "ignore";...
Page 513
Example The following example modifies the out-of-range property on the existing MovieClip color when a user clicks it. filteredMc 0x00FF00 import flash.filters.DisplacementMapFilter; import flash.display.BitmapData; import flash.geom.Point; import flash.geom.Matrix; import flash.geom.ColorTransform; var filteredMc:MovieClip = createDisplacementMapRectangle(); filteredMc.onPress = function() { var filter:DisplacementMapFilter = this.filters[0]; filter.scaleY = 25;...
var bmp:BitmapData = new BitmapData(w, h, true, bgColor); bmp.draw(mc, new Matrix(), new ColorTransform(), "normal", bmp.rectangle, true); mc.attachBitmap(bmp, this.getNextHighestDepth()); return bmp; function createTextBlock():MovieClip { var txtBlock:MovieClip = this.createEmptyMovieClip("txtBlock", this.getNextHighestDepth()); txtBlock.createTextField("txt", this.getNextHighestDepth(), 0, 0, 300, 80); txtBlock.txt.text = "watch the text bend with the displacement map"; return txtBlock;...
Page 515
function createDisplacementMapRectangle():MovieClip { var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial"); var filter:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000); var txtBlock:MovieClip = createTextBlock(); txtBlock._x = 30; txtBlock._y = 30; txtBlock.filters = new Array(filter); return txtBlock; function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1);...
componentY (DisplacementMapFilter.componentY property) public componentY : Number Describes which color channel to use in the map image to displace the y result. Possible values are 1 (red), 2 (green), 4 (blue), and 8 (alpha). Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on the existing MovieClip...
Page 518
- Describes which color channel to use in the map image to displace the componentX:Number x result. Possible values are the following: (red) (green) (blue) (alpha) - Describes which color channel to use in the map image to displace the componentY:Number y result.
Page 519
import flash.filters.DisplacementMapFilter; import flash.display.BitmapData; import flash.geom.Point; import flash.geom.Matrix; import flash.geom.ColorTransform; var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial"); var mapPoint:Point = new Point(-30, -30); var componentX:Number = 1; var componentY:Number = 1; var scaleX:Number = 10; var scaleY:Number = 10; var mode:String = "wrap"; var color:Number = 0x000000;...
function createTextBlock():MovieClip { var txtBlock:MovieClip = this.createEmptyMovieClip("txtBlock", this.getNextHighestDepth()); txtBlock.createTextField("txt", this.getNextHighestDepth(), 0, 0, 300, 80); txtBlock.txt.text = "watch the text bend with the displacement map"; return txtBlock; mapBitmap (DisplacementMapFilter.mapBitmap property) public mapBitmap : BitmapData A BitmapData object containing the displacement map data. property cannot be changed by directly modifying its value.
Page 521
txtBlock._x = 30; txtBlock._y = 30; txtBlock.filters = new Array(filter); return txtBlock; function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1); var matrix:Matrix = new Matrix(); matrix.createGradientBox(w, h, 0, 0, 0); mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad");...
mapPoint (DisplacementMapFilter.mapPoint property) public mapPoint : Point value that contains the offset of the upper-left corner of the target flash.geom.Point movie clip from the upper-left corner of the map image. property cannot be changed by directly modifying its value. Instead, you must mapPoint get a reference to , make the change to the reference, and then set...
mode (DisplacementMapFilter.mode property) public mode : String The mode for the filter. Possible values are the following: — Wraps the displacement value to the other side of the source image. This is the "wrap" default value. — Clamps the displacement value to the edge of the source image. "clamp"...
function createTextBlock():MovieClip { var txtBlock:MovieClip = this.createEmptyMovieClip("txtBlock", this.getNextHighestDepth()); txtBlock.createTextField("txt", this.getNextHighestDepth(), 0, 0, 300, 80); txtBlock.txt.text = "watch the text bend with the displacement map"; return txtBlock; scaleY (DisplacementMapFilter.scaleY property) public scaleY : Number The multiplier to use to scale the y displacement result from the map calculation. Availability: ActionScript 1.0;...
Page 529
The use of filters depends on the object to which you apply the filter: To apply filters to movie clips, text fields, and buttons at runtime, use the filters property. Setting the property of an object does not modify the object and can be filters undone by clearing the property.
Page 530
Property summary Modifiers Property Description The alpha transparency value for the shadow color. alpha:Number The angle of the shadow. angle:Number The amount of horizontal blur. blurX:Number The amount of vertical blur. blurY:Number The color of the shadow. color:Number The offset distance for the shadow, in pixels. distance:Number Indicates whether or not the object is hidden.
var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; blurX (DropShadowFilter.blurX property) public blurX : Number The amount of horizontal blur. Valid values are 0 to 255 (floating point). The default value is 4.
return art; blurY (DropShadowFilter.blurY property) public blurY : Number The amount of vertical blur. Valid values are 0 to 255 (floating point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values.
clone (DropShadowFilter.clone method) public clone() : DropShadowFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A new DropShadowFilter instance with all the flash.filters.DropShadowFilter properties of the original one. Example The following example creates three DropShadowFilter objects and compares them; is created by using the DropShadowFilter constructor;...
var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); var w:Number = 100; var h:Number = 100; art.beginFill(0x003366); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array();...
Page 539
[optional] - The amount of vertical blur. Valid values are 0 to 255 (floating blurY:Number point). The default value is 4. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values. [optional] - The strength of the imprint or spread.
art._x = 20; art._y = 20; var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; knockout (DropShadowFilter.knockout property) public knockout : Boolean Applies a knockout effect ( ), which effectively makes the object's fill transparent and true reveals the background color of the document.
var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; quality (DropShadowFilter.quality property) public quality : Number The number of times to apply the filter. Valid values are 0 to 15. The default value is 1, which is equivalent to low quality.
var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; strength (DropShadowFilter.strength property) public strength : Number The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the shadow and the background.
return art; Error Object +-Error public class Error extends Object Contains information about an error that occurred in a script. You create an Error object using the constructor function. Typically, you a new Error object from within a Error throw code block that is then caught by a code block.
Method summary Modifiers Signature Description Returns the string "Error" by default or the value toString() : String contained in Error.message, if defined. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString...
message (Error.message property) public message : String Contains the message associated with the Error object. By default, the value of this property is " ". You can specify a property when you create an Error object by passing the Error message error string to the constructor function.
Example In the following example, a function throws a specified error depending on the two numbers that you try to divide. Add the following ActionScript to Frame 1 of the Timeline: function divideNumber(numerator:Number, denominator:Number):Number { if (isNaN(numerator) || isNaN(denominator)) { throw new Error("divideNum function requires two numeric parameters.");...
Example In the following example, a function throws an error (with a specified message) if the two strings that are passed to it are not identical: function compareStrings(str1_str:String, str2_str:String):Void { if (str1_str != str2_str) { throw new Error("Strings do not match."); try { compareStrings("Dog", "dog");...
Page 550
ExternalInterface is supported in the following combinations of browser and operating system: Browser Operating System Internet Explorer 5.0 Windows and higher Netscape 8.0 and Windows Macintosh higher Mozilla 1.7.5 and Windows Macintosh higher Firefox 1.0 and higher Windows Macintosh Safari 1.3 and higher Macintosh ExternalInterface requires the user's web browser to support either ActiveX or the NPRuntime API that is exposed by some browsers for plugin scripting.
Method summary Modifiers Signature Description Registers an ActionScript method as callable from static addCallback(methodNa the container. me:String, instance:Object, method:Function) : Boolean Calls a function exposed by the Flash Player static call(methodName:Stri container, passing 0 or more arguments. [parameter1:Object]) : Object Methods inherited from class Object addProperty (Object.addProperty method),...
Page 552
0, 0, 200, 50); txtField.border = true; txtField.text = wasSuccessful.toString(); function goToMacromedia() { txtField.text = "http://www.macromedia.com"; getURL("http://www.macromedia.com", "_self"); For the previous example to work properly, you should copy and paste the following code into the containing HTML page. This code relies on the...
</form> <script> function callExternalInterface() { thisMovie("externalInterfaceExample").goHome(); function thisMovie(movieName) { if (navigator.appName.indexOf("Microsoft") != -1) { return window[movieName] else { return document[movieName] </script> available (ExternalInterface.available property) public static available : Boolean [read-only] Indicates whether this player is in a container that offers an external interface. If the external interface is available, this property is ;...
Page 554
If the container is hosting the Netscape plug-in, you can either write custom support for the new NPRuntime interface or embed an HTML control and embed Flash Player within the HTML control. If you embed an HTML control, you can communicate with Flash Player through a JavaScript interface that talks to the native container application.
mc.lineTo(0, 0); mcFmt = new TextFormat(); mcFmt.align = "center"; mcFmt.bold = true; mc.createTextField("mcTxt", depth, 0, 0, width, height); mc.mcTxt.text = "Call JS Function"; mc.mcTxt.setTextFormat(mcFmt); return mc; For the previous example to work properly, you should be copy and paste the following code into the containing HTML page.
Page 556
During an upload operation, all of the properties of a FileReference object are populated by calls to . During a download FileReference.browse() FileReferenceList.browse() operation, the property is populated when has been invoked; all other name onSelect properties are populated when has been invoked.
Page 557
Example The following example creates a FileReference object that prompts the user to select an image or text file to be uploaded. It also listens for any possible event. import flash.net.FileReference; var allTypes:Array = new Array(); var imageTypes:Object = new Object(); imageTypes.description = "Images (*.jpg, *.jpeg, *.gif, *.png)";...
Page 558
trace("onIOError: " + file.name); listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse(allTypes); See also FileReferenceList (flash.net.FileReferenceList) Property summary Modifiers Property Description The creation date of the file on the local disk. creationDate:Date [read-only] [read-...
Page 559
Event summary Event Description Invoked when the user dismisses the file-browsing dialog box. onCancel function(fileRef :FileReference) Invoked when the upload or download operation has successfully onComplete completed. function(fileRef :FileReference) Invoked when an upload fails because of an HTTP error. onHTTPError function(fileRef :FileReference, httpError:Number...
Constructor summary Signature Description Creates a new FileReference object. FileReference() Method summary Modifiers Signature Description Registers an object to receive notification when a addListener(listener FileReference event listener is invoked. :Object) : Void Displays a file-browsing dialog box in which the user browse([typelist:Arr can select a local file to upload.
= function(file:FileReference):Void { trace("onComplete: " + file.name); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); browse (FileReference.browse method) public browse([typelist:Array]) : Boolean Displays a file-browsing dialog box in which the user can select a local file to upload. The dialog box is native to the user's operating system.
Page 562
Parameters [optional] - An array of file types used to filter the files displayed in the typelist:Array dialog box. If you omit this parameter, all files are displayed. If you include this parameter, the array must contain one or more elements enclosed in curly braces { }. You can use one of two formats for the array: A list of file type descriptions followed by their Windows file extensions only.
Returns - Returns if the parameters are valid and the file-browsing dialog box is Boolean true displayed. Returns if the dialog box is not displayed, if another browse session is already false in progress, or if you use the parameter but fail to provide a description or typelist extension string in any element in the array.
>= (bytesTotal / 2)) { file.cancel(); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); creationDate (FileReference.creationDate property) public creationDate : Date [read-only] The creation date of the file on the local disk. If the FileReference object has not been...
See also browse (FileReference.browse method) creator (FileReference.creator property) public creator : String [read-only] The Macintosh creator type of the file. In Windows, this property is . If the null FileReference object has not been populated, a call to get the value of this property returns null Availability: ActionScript 1.0;...
Page 566
For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 8 Parameters - The URL of the file to download to the local computer.
Page 567
Returns - A value of if the dialog box in which a user can select a file is displayed. If the Boolean true dialog box is not displayed, the method returns . The dialog box could fail to be false displayed for any of the following reasons: You did not pass a value for the parameter.
modificationDate (FileReference.modificationDate property) public modificationDate : Date [read-only] The date that the file on the local disk was last modified. If the FileReference object has not been populated, a call to get the value of this property returns null Availability: ActionScript 1.0; Flash Player 8 Example The following example retrieves the of a file selected by the user.
Cancel or presses the Escape key after the dialog box is displayed. import flash.net.FileReference; var listener:Object = new Object(); listener.onCancel = function(file:FileReference):Void { trace("onCancel"); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; if(!fileRef.download(url, "FlashPlatform.pdf")) { trace("dialog box failed to open."); ActionScript classes...
= new Object(); listener.onComplete = function(file:FileReference):Void { trace("onComplete: " + file.name); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); onHTTPError (FileReference.onHTTPError event listener) onHTTPError = function(fileRef:FileReference, httpError:Number) {} Invoked when an upload fails because of an HTTP error.
Page 572
Parameters - The File Reference object that initiated the fileRef:flash.net.FileReference operation. - The HTTP error that caused this upload to fail. For example, an httpError:Number of 404 indicates that a page is not found. HTTP error values can be found in httpError sections 10.4 and 10.5 of the HTTP specification at ftp://ftp.isi.edu/in-notes/rfc2616.txt.
trace("onIOError: " + file.name); listener.onSecurityError = function(file:FileReference, errorString:String):Void { trace("onSecurityError: " + file.name + " errorString: " + errorString); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); fileRef.browse(); onIOError (FileReference.onIOError event listener) onIOError = function(fileRef:FileReference) {} Invoked when an input/output error occurs. This listener is invoked when the upload or download fails for any of the following reasons: An input/output error occurs while the player is reading, writing, or transmitting the file.
The following example traces a message when the event is triggered. onOpen import flash.net.FileReference; var listener:Object = new Object(); listener.onOpen = function(file:FileReference):Void { trace("onOpen: " + file.name); var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); ActionScript classes...
See also onSecurityError (FileReference.onSecurityError event listener) onSecurityError = function(fileRef:FileReference, errorString:String) {} Invoked when an upload or download fails because of a security error. The calling SWF file may have tried to access a SWF file outside its domain and does not have permission to do so. You can try to remedy this error by using a cross-domain policy file.
Parameters - The FileReference object that initiated the operation. fileRef:flash.net.FileReference Example The following example traces a message within the event listener. onSelect import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(file:FileReference):Void { trace("onSelect: " + file.name); if(!file.upload("http://www.yourdomain.com/ yourUploadHandlerScript.cfm")) { trace("Upload dialog failed to open.");...
= new Object(); listener.onCancel = function(file:FileReference):Void { trace(file.removeListener(this)); // true var fileRef:FileReference = new FileReference(); fileRef.addListener(listener); var url:String = "http://www.macromedia.com/platform/whitepapers/ platform_overview.pdf"; fileRef.download(url, "FlashPlatform.pdf"); size (FileReference.size property) public size : Number [read-only] The size of the file on the local disk, in bytes. If the FileReference object has not been...
type (FileReference.type property) public type : String [read-only] The file type. In Windows, this property is the file extension. On the Macintosh, this property is the four-character file type. If the FileReference object has not been populated, a call to get the value of this property returns null Availability: ActionScript 1.0;...
Page 581
For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 8...
Page 582
You can send data to the server with the call by appending parameters to the URL; upload() for example, http://www.myserver.com/upload.cgi?userID=jdoe On some browsers, URL strings are limited in length. Lengths greater than 256 characters may fail on some browsers or servers. Returns - A value of in any of the following situations:...
FileReferenceList (flash.net.FileReferenceList) Object +-flash.net.FileReferenceList public class FileReferenceList extends Object The FileReferenceList class provides a means to let users select one or more files for uploading. A FileReferenceList object represents a group of one or more local files on the user's disk as an array of FileReference objects.
Method summary Modifiers Signature Description Registers an object to receive notification when a addListener(listener FileReferenceList event listener is invoked. :Object) : Void Displays a file-browsing dialog box in which the user browse([typelist:Arr can select one or more local files to upload. ay]) : Boolean Removes an object from the list of objects that receive removeListener(liste...
var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); browse (FileReferenceList.browse method) public browse([typelist:Array]) : Boolean Displays a file-browsing dialog box in which the user can select one or more local files to upload. The dialog box is native to the user's operating system. When you call this method and the user successfully selects files, the property of this FileReferenceList object is fileList...
Page 589
A list of file type descriptions followed by their Windows file extensions and their Macintosh file types. Each element in the array must contain a string that describes the file type; a semicolon- delimited list of Windows file extensions, with a wildcard (*) character preceding each extension;...
textTypes.extension = "*.txt; *.rtf"; allTypes.push(textTypes); var fileRef:FileReferenceList = new FileReferenceList(); fileRef.browse(allTypes); See also browse (FileReference.browse method) FileReference (flash.net.FileReference) fileList (FileReferenceList.fileList property) public fileList : Array An array of FileReference objects. When the method has been called and the user has selected FileReferenceList.browse() one or more files from the dialog box opened by , this property is populated with an...
var fileRef:FileReferenceList = new FileReferenceList(); fileRef.addListener(listener); fileRef.browse(); See also FileReference (flash.net.FileReference) upload (FileReference.upload method) browse (FileReferenceList.browse method) FileReferenceList constructor public FileReferenceList() Creates a new FileReferenceList object. This object contains nothing until you call browse() on it. When you call on the FileReference object, the property of the browse() fileList...
onCancel (FileReferenceList.onCancel event listener) onCancel = function(fileRefList:FileReferenceList) {} Invoked when the user dismisses the file-browsing dialog box. (This dialog box is displayed when you call the , or FileReferenceList.browse() FileReference.browse() methods.) FileReference.download() Availability: ActionScript 1.0; Flash Player 8 Parameters - The FileReferenceList object that initiated fileRefList:flash.net.FileReferenceList the operation.
Parameters - The FileReferenceList object that initiated fileRefList:flash.net.FileReferenceList the operation. Example The following example demonstrates the listener. onSelect import flash.net.FileReferenceList; import flash.net.FileReference; var listener:Object = new Object(); listener.onSelect = function(fileRefList:FileReferenceList) { trace("onSelect"); var list:Array = fileRefList.fileList; var item:FileReference; for(var i:Number = 0; i < list.length; i++) { item = list[i];...
Parameters - An object that listens for a callback notification from the listener:Object FileReferenceList event listeners. Returns - Returns if the object is removed. Otherwise, this method returns Boolean true false Example The following example demonstrates the method. removeListener import flash.net.FileReferenceList; var listener:Object = new Object();...
Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Specifies the value of thisObject to be used within apply(thisObject:Obj any function that ActionScript calls. ect, [argArray:Array]) : Void Invokes the function represented by a Function...
Page 596
Parameters - The object to which myFunction is applied. thisObject:Object [optional] - An array whose elements are passed to myFunction as argArray:Array parameters. Example The following function invocations are equivalent: Math.atan2(1, 0) Math.atan2.apply(null, [1, 0]) The following simple example shows how passes an array of parameters: apply() function theFunction() {...
// use apply() to set the value of this to be myObj and send secondArray theFunction.apply(myObj,secondArray); // output: // this == myObj? true // arguments: a,b,c See also call (Function.call method) call (Function.call method) public call(thisObject:Object, [parameter1:Object]) : Object Invokes the function represented by a Function object. Every function in ActionScript is represented by a Function object, so all functions support this method.
Returns Object Example The following example uses to make a function behave as a method of Function.call() another object, without storing the function in the object: function myObject() { function myMethod(obj) { trace("this == obj? " + (this == obj)); var obj:Object = new myObject();...
Page 599
You can also apply filter effects to images and video during authoring. For more information, see your authoring documentation. If you apply a filter to a movie clip or button, the property of the movie clip cacheAsBitmap or button is set to .
Constructor summary Signature Description Initializes a new GlowFilter instance with the specified parameters. GlowFilter([color:Nu mber], [alpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [inner:Boolean], [knockout:Boolean]) Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : GlowFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty...
Example The following example changes the property on an existing movie clip when a user alpha clicks it. import flash.filters.GlowFilter; var mc:MovieClip = createGlowFilterRectangle("GlowFilterAlpha"); mc.onRelease = function() { var filter:GlowFilter = this.filters[0]; filter.alpha = .4; this.filters = new Array(filter); function createGlowFilterRectangle(name:String):MovieClip { var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Example The following example changes the property on an existing movie clip when a user blurX clicks it. import flash.filters.GlowFilter; var mc:MovieClip = createGlowFilterRectangle("GlowFilterBlurX"); mc.onRelease = function() { var filter:GlowFilter = this.filters[0]; filter.blurX = 20; this.filters = new Array(filter); function createGlowFilterRectangle(name:String):MovieClip { var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Example The following example changes the property on an existing movie clip when a user blurY clicks it. import flash.filters.GlowFilter; var mc:MovieClip = createGlowFilterRectangle("GlowFilterBlurY"); mc.onRelease = function() { var filter:GlowFilter = this.filters[0]; filter.blurY = 20; this.filters = new Array(filter); function createGlowFilterRectangle(name:String):MovieClip { var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Page 604
Example The following example creates three GlowFilter objects and compares them: filter_1 created by using the GlowFilter constructor; is created by setting it equal to filter_2 ; and is created by cloning . Notice that although filter_1 clonedFilter filter_1 evaluates as being equal to , even though it contains the filter_2 filter_1...
To further demonstrate the relationships between , and filter_1 filter_2 clonedFilter the following example modifies the property of . Modifying knockout filter_1 knockout demonstrates that the method creates a new instance based on the values of clone() instead of pointing to them in reference. filter_1 import flash.filters.GlowFilter;...
rect.beginFill(0x003366); rect.lineTo(w, 0); rect.lineTo(w, h); rect.lineTo(0, h); rect.lineTo(0, 0); rect._x = 20; rect._y = 20; var filter:GlowFilter = new GlowFilter(0x000000, .8, 16, 16, 1, 3, false, false); var filterArray:Array = new Array(); filterArray.push(filter); rect.filters = filterArray; return rect; GlowFilter constructor public GlowFilter([color:Number], [alpha:Number], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [inner:Boolean], [knockout:Boolean])
Page 607
[optional] - Specifies whether the glow is an inner glow. The value inner:Boolean true indicates an inner glow. The default is , an outer glow (a glow around the outer edges of false the object). [optional] - Specifies whether the object has a knockout effect. The value knockout:Boolean makes the object's fill transparent and reveals the background color of the document.
mc._y = 20; return mc; inner (GlowFilter.inner property) public inner : Boolean Specifies whether the glow is an inner glow. The value indicates an inner glow. The true default is , an outer glow (a glow around the outer edges of the object). false Availability: ActionScript 1.0;...
knockout (GlowFilter.knockout property) public knockout : Boolean Specifies whether the object has a knockout effect. A value of makes the object's fill true transparent and reveals the background color of the document. The default is false knockout effect). Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on an existing movie clip when a user...
quality (GlowFilter.quality property) public quality : Number The number of times to apply the filter. Valid values are 0 to 15. The default value is 1, which is equivalent to low quality. A value of 2 is medium quality, and a value of 3 is high quality. Filters with lower values are rendered more quickly.
strength (GlowFilter.strength property) public strength : Number The strength of the imprint or spread. The higher the value, the more color is imprinted and the stronger the contrast between the glow and the background. Valid values are 0 to 255. The default is 2.
GradientBevelFilter (flash.filters.GradientBevelFilter) Object +-flash.filters.BitmapFilter +-flash.filters.GradientBevelFilter public class GradientBevelFilter extends BitmapFilter The GradientBevelFilter class lets you apply a gradient bevel effect to various objects in Flash. A gradient bevel is a beveled edge, enhanced with gradient color, on the outside, inside, or top of an object.
Page 613
See also ratios (GradientBevelFilter.ratios property) applyFilter (BitmapData.applyFilter method) BevelFilter (flash.filters.BevelFilter) filters (Button.filters property) cacheAsBitmap (Button.cacheAsBitmap property) cacheAsBitmap (MovieClip.cacheAsBitmap property) filters (MovieClip.filters property) filters (TextField.filters property) Property summary Modifiers Property Description An array of alpha transparency values for the alphas:Array corresponding colors in the colors array. The angle, in degrees.
Page 614
Constructor summary Signature Description Initializes the filter with the specified parameters. GradientBevelFilter( [distance:Number], [angle:Number], [colors:Array], [alphas:Array], [ratios:Array], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [type:String], [knockout:Boolean]) Method summary Modifiers Signature Description Returns a copy of this filter object. clone() : GradientBevelFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty...
alphas (GradientBevelFilter.alphas property) public alphas : Array An array of alpha transparency values for the corresponding colors in the array. Valid colors values for each element in the array are 0 to 1. For example, .25 sets a transparency value of 25%.
var filter:GradientBevelFilter = new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 2, "inner", false); art.filters = new Array(filter); return art; See also colors (GradientBevelFilter.colors property) ratios (GradientBevelFilter.ratios property) angle (GradientBevelFilter.angle property) public angle : Number The angle, in degrees. Valid values are 0 to 360. The default is 45. The angle value represents the angle of the theoretical light source falling on the object.
art.filters = new Array(filter); return art; clone (GradientBevelFilter.clone method) public clone() : GradientBevelFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns - A new GradientBevelFilter instance with all the flash.filters.GradientBevelFilter same properties as the original GradientBevelFilter instance. Example The following example creates two rectangle shapes.
function getNewFilter():GradientBevelFilter { var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; return new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 2, "inner", false); colors (GradientBevelFilter.colors property) public colors : Array An array of RGB hexadecimal color values to use in the gradient.
art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; var filter:GradientBevelFilter = new GradientBevelFilter(5, 225, colors, alphas, ratios, 5, 5, 5, 3, "inner", false); art.filters = new Array(filter); return art;...
Page 623
[optional] - The strength of the imprint or spread. The higher the value, strength:Number the more color is imprinted and the stronger the contrast between the bevel and the background. Valid values are 0 to 255. A value of 0 means that the filter is not applied. The default value is 1.
Example The following example demonstrates how to set the property on an existing object. knockout import flash.filters.GradientBevelFilter; var mc:MovieClip = setUpFilter("knockoutExample"); mc.onRelease = function() { var arr:Array = this.filters; arr[0].knockout = true; this.filters = arr; function setUpFilter(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Page 626
Example The following example demonstrates how to set the property on an existing object. quality import flash.filters.GradientBevelFilter; var mc:MovieClip = setUpFilter("qualityExample"); mc.onRelease = function() { var arr:Array = this.filters; arr[0].quality = 1; // low quality this.filters = arr; function setUpFilter(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
ratios (GradientBevelFilter.ratios property) public ratios : Array An array of color distribution ratios for the corresponding colors in the array. Valid colors values for each element in the array are 0 to 255. property cannot be changed by directly modifying its values. Instead, you must ratios get a reference to , make the change to the reference, and then set...
Page 628
Keep in mind that the spread of the colors in the gradient varies based on the values of the , and properties, as well as the values. blurX blurY strength quality ratios Availability: ActionScript 1.0; Flash Player 8 Example The following example demonstrates how to set the property on an existing entity.
Example The following example demonstrates how to set the property on an existing object. strength import flash.filters.GradientBevelFilter; var mc:MovieClip = setUpFilter("strengthExample"); mc.onRelease = function() { var arr:Array = this.filters; arr[0].strength = 1; this.filters = arr; function setUpFilter(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Example The following example demonstrates how to set the property on an existing object. type import flash.filters.GradientBevelFilter; var mc:MovieClip = setUpFilter("typeExample"); mc.onRelease = function() { var arr:Array = this.filters; arr[0].type = "outer"; this.filters = arr; function setUpFilter(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Page 632
The GradientGlowFilter class lets you apply a gradient glow effect to a variety of objects in Flash. A gradient glow is a realistic-looking glow with a color gradient that you can control. You can apply a gradient glow around the inner or outer edge of an object or on top of an object.
Page 633
Property summary Modifiers Property Description An array of alpha transparency values for the alphas:Array corresponding colors in the colors array. The angle, in degrees. angle:Number The amount of horizontal blur. blurX:Number The amount of vertical blur. blurY:Number An array of colors that defines a gradient. colors:Array The offset distance of the glow.
Example The following example changes the property on an existing movie clip when a user angle clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowAngle"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.distance = 50; filter.angle = 90; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Example The following example changes the property on an existing movie clip when a user blurX clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowBlurX"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.blurX = 255; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Example The following example changes the property on an existing movie clip when a user blurY clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowBlurY"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.blurY = 255; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Page 639
Example The following example creates three GradientGlowFilter objects and compares them; is created by using the GradientGlowFilter construtor; is created by filter_1 filter_2 setting it equal to ; and, is created by cloning . Notice that filter_1 clonedFilter filter_1 although evaluates as being equal to , even though it filter_2...
// >> distance: 0 To further demonstrate the relationships between , and filter_1 filter_2 clonedFilter the following example below modifies the property of . Modifying knockout filter_1 demonstrates that the method creates a new instance based on the values knockout clone() instead of pointing to them in reference.
Page 641
Example The following example changes the property on an existing movie clip when a user colors clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowColors"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; var colors:Array = filter.colors; colors.pop(); colors.push(0xFF00FF); filter.colors = colors; this.filters = new Array(filter);...
distance (GradientGlowFilter.distance property) public distance : Number The offset distance of the glow. The default value is 4. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the property on an existing movie clip when a user distance clicks it.
GradientGlowFilter constructor public GradientGlowFilter([distance:Number], [angle:Number], [colors:Array], [alphas:Array], [ratios:Array], [blurX:Number], [blurY:Number], [strength:Number], [quality:Number], [type:String], [knockout:Boolean]) Initializes the filter with the specified parameters. Availability: ActionScript 1.0; Flash Player 8 Parameters [optional] - The offset distance of the glow. The default is 4. distance:Number [optional] - The angle, in degrees.
Page 644
[optional] - The placement of the filter effect. Possible values are: type:String : Glow on the outer edge of the object "outer" : Glow on the inner edge of the object; the default "inner" : Glow on top of the object "full"...
function createRectangle(w:Number, h:Number, bgColor:Number, name:String):MovieClip { var mc:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); mc.beginFill(bgColor); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc._x = 20; mc._y = 20; return mc; knockout (GradientGlowFilter.knockout property) public knockout : Boolean Specifies whether the object has a knockout effect. A knockout effect makes the object's fill transparent and reveals the background color of the document.
art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var colors:Array = [0xFFFFFF, 0xFF0000, 0xFFFF00, 0x00CCFF]; var alphas:Array = [0, 1, 1, 1]; var ratios:Array = [0, 63, 126, 255]; var filter:GradientGlowFilter = new GradientGlowFilter(0, 45, colors, alphas, ratios, 55, 55, 2.5, 2, "outer", false); var filterArray:Array = new Array();...
Page 648
In the following code and image, a filter is applied to a black circle movie clip, with the type set to . For instructional purposes, the first color in the array, pink, has an "full" colors value of 1, so it shows against the white document background. (In practice, you alpha probably would not want the first color showing in this way.) Note the last color in the array, yellow, obscures the black circle to which the filter is applied:...
Page 649
If you make two small changes in the code, the effect of the glow can be very different, even with the same arrays. Set the alpha value of the first color in the array to ratios colors 0, to make the filter blend in with the document's white background; and set the type property to .
Example The following example changes the property on an existing movie clip when a user strength clicks it. import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowStrength"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.strength = 1; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
Page 652
Example The following example changes the property on an existing movie clip when a user clicks type import flash.filters.GradientGlowFilter; var mc:MovieClip = createGradientGlowRectangle("GlowType"); mc.onRelease = function() { var filter:GradientGlowFilter = this.filters[0]; filter.type = "inner"; filter.strength = 1; this.filters = new Array(filter); function createGradientGlowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth());...
IME (System.IME) Object +-System.IME public class IME extends Object The IME class lets you directly manipulate the operating system's input method editor (IME) in the Flash Player application that is running on a client computer. You can determine whether an IME is installed, whether or not the IME is enabled, and which IME is enabled. You can disable or enable the IME in the Flash Player application, and you can perform other limited functions, depending on the operating system.
Page 654
Capability Windows Macintosh OSX Macintosh Classic Linux/Solaris XIM Get IME conversion Yes ** mode System.IME.getConver sionMode() Send IME the string to be Yes * converted System.IME. setCompositionString() Get from IME the original Yes * string before conversion System.IME.addListen er() listener.onIMECompos ition() System.IME.removeLis tener()
Page 655
Property summary Modifiers Property Description A string with the value "ALPHANUMERIC_FULL" for use static ALPHANUMERIC_FULL:St with setConversionMode() and ring getConversionMode(). A string with the value "ALPHANUMERIC_HALF" for use static ALPHANUMERIC_HALF:St with setConversionMode() and ring getConversionMode(). A string with the value "CHINESE" for use with static CHINESE:String setConversionMode() and getConversionMode().
Method summary Modifiers Signature Description Registers an object to receive notification when an static addListener(listener IME event handler is invoked by the :Object) : Void onIMEComposition event. Instructs the IME to select the first candidate for the static doConversion() : current composition string.
Parameters - An object, with an (readingString) method, that listener:Object onIMEComposition listens for a callback notification from the IME event handlers. The reading string passed to this method is in the composition mode of the IME. For example, if the user enters text in Hiragana and then selects a Kanji candidate, the reading string is the original Hiragana.
Example The following example sets the IME to if the system has an Input ALPHANUMERIC_FULL Method Editor (IME) installed ( System.capabilities.hasIME if(System.capabilities.hasIME) { trace(System.IME.getConversionMode()); System.IME.setConversionMode(System.IME.ALPHANUMERIC_FULL); trace(System.IME.getConversionMode()); See also setConversionMode (IME.setConversionMode method) getConversionMode (IME.getConversionMode method) hasIME (capabilities.hasIME property) ALPHANUMERIC_HALF (IME.ALPHANUMERIC_HALF property) public static ALPHANUMERIC_HALF : String A string with the value for use with...
CHINESE (IME.CHINESE property) public static CHINESE : String A string with the value for use with "CHINESE" setConversionMode() . This constant is used with simplified and traditional Chinese IMEs. getConversionMode() Availability: ActionScript 1.0; Flash Player 8 Example The following example sets the IME to if the system has an Input Method Editor CHINESE (IME) installed (...
mc.onPress = function() { if(System.capabilities.hasIME) { Selection.setFocus(mc.txt); System.IME.setCompositionString(mc.txt.text); trace(System.IME.doConversion()); getConversionMode (IME.getConversionMode method) public static getConversionMode() : String Indicates the conversion mode of the current IME. Availability: ActionScript 1.0; Flash Player 8 Returns - The conversion mode. Possible values are IME mode string constants that indicate String the conversion mode: ALPHANUMERIC_FULL...
See also ALPHANUMERIC_FULL (IME.ALPHANUMERIC_FULL property) ALPHANUMERIC_HALF (IME.ALPHANUMERIC_HALF property) CHINESE (IME.CHINESE property) JAPANESE_HIRAGANA (IME.JAPANESE_HIRAGANA property) JAPANESE_KATAKANA_FULL (IME.JAPANESE_KATAKANA_FULL property) JAPANESE_KATAKANA_HALF (IME.JAPANESE_KATAKANA_HALF property) KOREAN (IME.KOREAN property) UNKNOWN (IME.UNKNOWN property) getEnabled (IME.getEnabled method) public static getEnabled() : Boolean Indicates whether the system IME is enabled. An enabled IME performs multibyte input; a disabled IME performs alphanumeric input.
Example The following example sets the IME to if the system has an Input JAPANESE_HIRAGANA Method Editor (IME) installed ( System.capabilities.hasIME if(System.capabilities.hasIME) { trace(System.IME.getConversionMode()); System.IME.setConversionMode(System.IME.JAPANESE_HIRAGANA); trace(System.IME.getConversionMode()); See also setConversionMode (IME.setConversionMode method) getConversionMode (IME.getConversionMode method) JAPANESE_KATAKANA_FULL (IME.JAPANESE_KATAKANA_FULL property) public static JAPANESE_KATAKANA_FULL : String A string with the value for use with "JAPANESE_KATAKANA_FULL"...
JAPANESE_KATAKANA_HALF (IME.JAPANESE_KATAKANA_HALF property) public static JAPANESE_KATAKANA_HALF : String A string with the value for use with "JAPANESE_KATAKANA_HALF" setConversionMode() . This constant is used with Japanese IMEs. getConversionMode() Availability: ActionScript 1.0; Flash Player 8 Example The following example sets the IME to if the system has an Input JAPANESE_KATAKANA_HALF Method Editor (IME) installed (...
See also setConversionMode (IME.setConversionMode method) getConversionMode (IME.getConversionMode method) onIMEComposition (IME.onIMEComposition event listener) onIMEComposition = function([readingString:String]) {} Notified when the IME composition string is being set. To use this listener, you must create a listener object. You can then define a function for this listener and use IME.addListener() to register the listener with the IME object, as in the following code: var someListener:Object = new Object();...
mc.txt.text = "Click this text to add a listener."; mc.onPress = function() { if(System.capabilities.hasIME) { Selection.setFocus(mc.txt); System.IME.setCompositionString(mc.txt.text); See also addListener (IME.addListener method) setCompositionString (IME.setCompositionString method) removeListener (IME.removeListener method) public static removeListener(listener:Object) : Boolean Removes a listener object that was previously registered to an instance with IME.addListener() Availability: ActionScript 1.0;...
mc.txt.border = true; mc.txt.background = true; mc.txt.autoSize = "left"; mc.txt.text = "Click this text to add and remove a listener."; mc.onPress = function() { if(System.capabilities.hasIME) { Selection.setFocus(mc.txt); System.IME.setCompositionString(mc.txt.text); setCompositionString (IME.setCompositionString method) public static setCompositionString(composition:String) : Boolean Sets the IME composition string. When this string is set, the user can select IME candidates before committing the result to the text field that currently has focus.
setConversionMode (IME.setConversionMode method) public static setConversionMode(mode:String) : Boolean Sets the conversion mode of the current IME. Availability: ActionScript 1.0; Flash Player 8 Parameters - The conversion mode. Possible values are the IME mode string constants: mode:String ALPHANUMERIC_FULL ALPHANUMERIC_HALF CHINESE JAPANESE_HIRAGANA JAPANESE_KATAKANA_FULL JAPANESE_KATAKANA_HALF KOREAN...
setEnabled (IME.setEnabled method) public static setEnabled(enabled:Boolean) : Boolean Enables or disables the system IME. An enabled IME performs multibyte input; a disabled IME performs alphanumeric input. Availability: ActionScript 1.0; Flash Player 8 Parameters - Set to to enable the system IME, to disable it.
Example The following example sets the IME to if the system has an Input Method Editor UNKNOWN (IME) installed ( System.capabilities.hasIME if(System.capabilities.hasIME) { trace(System.IME.getConversionMode()); System.IME.setConversionMode(System.IME.UNKNOWN); trace(System.IME.getConversionMode()); See also getConversionMode (IME.getConversionMode method) Object +-Key public class Key extends Object The Key class is a top-level class whose methods and properties you can use without a constructor.
Page 670
Property summary Modifiers Property Description The key code value for the Backspace key (8). static BACKSPACE:Number The key code value for the Caps Lock key (20). static CAPSLOCK:Number The key code value for the Control key (17). static CONTROL:Number The key code value for the Delete key (46). static DELETEKEY:Number The key code value for the Down Arrow key (40).
Page 671
Event summary Event Description Notified when a key is pressed. onKeyDown function() {} Notified when a key is released. onKeyUp function() {} Method summary Modifiers Signature Description Registers an object to receive onKeyDown and static addListener(listener onKeyUp notification. :Object) : Void Returns the ASCII code of the last key pressed or static getAscii() : Number...
addListener (Key.addListener method) public static addListener(listener:Object) : Void Registers an object to receive notification. When a key is pressed or onKeyDown onKeyUp released, regardless of the input focus, all listening objects registered with addListener() have either their method or method invoked. Multiple objects can listen onKeyDown onKeyUp for keyboard notifications.
Example The following example creates a new listener object and defines a function for onKeyDown The last line uses to register the listener with the Key object so that it can addListener() receive notification from the key down event. var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.CAPSLOCK)) { trace("you pressed the Caps Lock key.");...
DELETEKEY (Key.DELETEKEY property) public static DELETEKEY : Number The key code value for the Delete key (46). Availability: ActionScript 1.0; Flash Player 5 Example The following example lets you draw lines with the mouse pointer using the Drawing API and listener objects.
DOWN (Key.DOWN property) public static DOWN : Number The key code value for the Down Arrow key (40). Availability: ActionScript 1.0; Flash Player 5 Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key.
ENTER (Key.ENTER property) public static ENTER : Number The key code value for the Enter key (13). Availability: ActionScript 1.0; Flash Player 5 Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key. The instance stops when you press Enter and deletes the car_mc event.
ESCAPE (Key.ESCAPE property) public static ESCAPE : Number The key code value for the Escape key (27). Availability: ActionScript 1.0; Flash Player 5 Example The following example sets a timer. When you press Escape, the Output panel displays information that includes how long it took you to press the key. var keyListener:Object = new Object();...
Example The following example calls the method any time a key is pressed. The example getAscii() creates a listener object named and defines a function that responds to the keyListener event by calling .The object is then registered to onKeyDown Key.getAscii() keyListener object, which broadcasts the...
Page 680
Returns - The key code of the last key pressed. This method returns 0 if no key was pressed or Number released, or if the key code is not accessible for security reasons. Example The following example calls the method any time a key is pressed. The example getCode() creates a listener object named and defines a function that responds to the...
HOME (Key.HOME property) public static HOME : Number The key code value for the Home key (36). Availability: ActionScript 1.0; Flash Player 5 Example The following example attaches a draggable movie clip called at the x and y car_mc coordinates of 0,0. When you press the Home key, returns to 0,0.
Example The following example creates a new listener object and defines a function for onKeyDown The last line uses to register the listener with the Key object so that it can addListener() receive notification from the key down event and display information in the Output panel. var keyListener:Object = new Object();...
Returns - The value if the key specified in is pressed; otherwise. Boolean true keycode false Example The following script lets the user control a movie clip's ( ) location: car_mc car_mc.onEnterFrame = function() { if (Key.isDown(Key.RIGHT)) { this._x += 10; } else if (Key.isDown(Key.LEFT)) { this._x -= 10;...
Page 684
Example The following example calls the method any time a key is pressed and executes isToggled() a trace statement any time the Caps Lock key is toggled to an active state. The example creates a listener object named and defines a function that responds to the keyListener onKeyDown event by calling...
LEFT (Key.LEFT property) public static LEFT : Number The key code value for the Left Arrow key (37). Availability: ActionScript 1.0; Flash Player 5 Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key.
Example The following example shows how to use the property to ascertain the number of length listener objects currently registered to the Key object. var myListener:Object = new Object(); myListener.onKeyDown = function () { trace ("You pressed a key."); Key.addListener(myListener); trace(Key._listeners.length);...
onKeyUp (Key.onKeyUp event listener) onKeyUp = function() {} Notified when a key is released. To use , you must create a listener object. You can onKeyUp then define a function for and use to register the listener with the onKeyUp addListener() Key object, as shown in the following example: var keyListener:Object = new Object();...
PGUP (Key.PGUP property) public static PGUP : Number The key code value for the Page Up key (33). Availability: ActionScript 1.0; Flash Player 5 Example The following example rotates a movie clip called when you press the Page Down or car_mc Page Up key.
break; case Key.RIGHT : car_mc._x += 10; break; case Key.ESCAPE : Key.removeListener(keyListener); Key.addListener(keyListener); RIGHT (Key.RIGHT property) public static RIGHT : Number The key code value for the Right Arrow key (39). Availability: ActionScript 1.0; Flash Player 5 Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key.
SHIFT (Key.SHIFT property) public static SHIFT : Number The key code value for the Shift key (16). Availability: ActionScript 1.0; Flash Player 5 Example The following example scales when you press Shift. car_mc var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.SHIFT)) { car_mc._xscale = 2;...
break; case Key.RIGHT : car_mc._x += DISTANCE; break; case Key.DOWN : car_mc._y += DISTANCE; break; Key.addListener(keyListener_obj); TAB (Key.TAB property) public static TAB : Number The key code value for the Tab key (9). Availability: ActionScript 1.0; Flash Player 5 Example The following example creates a text field, and displays the date in the text field when you press Tab.
Example The following example moves a movie clip called a constant distance (10) when you car_mc press an arrow key. A sound plays when you press the Spacebar. For this example, give a sound in the library a linkage identifier of horn_id var DISTANCE:Number = 10;...
Page 693
The LoadVars class lets you send all the variables in an object to a specified URL and to load all the variables at a specified URL into an object. It also lets you send specific variables, rather than all variables, which can make your application more efficient. You can use the handler to ensure that your application runs when data is loaded, and not LoadVars.onLoad before.
Page 694
Constructor summary Signature Description Creates a LoadVars object. LoadVars() Method summary Modifiers Signature Description Adds or changes HTTP request headers (such as addRequestHeader(hea Content-Type or SOAPAction) sent with POST der:Object, actions. headerValue:String) : Void Converts the variable string to properties of the decode(queryString:S specified LoadVars object.
addRequestHeader (LoadVars.addRequestHeader method) public addRequestHeader(header:Object, headerValue:String) : Void Adds or changes HTTP request headers (such as ) sent with Content-Type SOAPAction actions. In the first usage, you pass two strings to the method: POST header . In the second usage, you pass an array of strings, alternating header names and headerValue header values.
See also addRequestHeader (XML.addRequestHeader method) contentType (LoadVars.contentType property) public contentType : String The MIME type that is sent to the server when you call LoadVars.send() . The default is application/x-www-form-urlencoded. LoadVars.sendAndLoad() Availability: ActionScript 1.0; Flash Player 6 Example The following example creates a LoadVars object and displays the default content type of the data that is sent to the server.
for (var prop in my_lv) { trace(prop+" -> "+my_lv[prop]); See also onData (LoadVars.onData handler) parseXML (XML.parseXML method) getBytesLoaded (LoadVars.getBytesLoaded method) public getBytesLoaded() : Number Returns the number of bytes downloaded by LoadVars.load() . This method returns if no load operation is in LoadVars.sendAndLoad() undefined progress or if a load operation has not yet begun.
loadvars_pb.setProgress(my_lv.getBytesLoaded(), my_lv.getBytesTotal()); delete timer_mc.onEnterFrame; if (success) { trace("LoadVars loaded successfully."); } else { trace("An error occurred while loading variables."); my_lv.load("[place a valid URL pointing to a text file here]"); See also load (LoadVars.load method) sendAndLoad (LoadVars.sendAndLoad method) getBytesTotal (LoadVars.getBytesTotal method) public getBytesTotal() : Number Returns the total number of bytes downloaded by LoadVars.load()
if (lvBytesTotal != undefined) { trace("Loaded "+lvBytesLoaded+" of "+lvBytesTotal+" bytes."); loadvars_pb.setProgress(lvBytesLoaded, lvBytesTotal); my_lv.onLoad = function(success:Boolean) { loadvars_pb.setProgress(my_lv.getBytesLoaded(), my_lv.getBytesTotal()); delete timer_mc.onEnterFrame; if (success) { trace("LoadVars loaded successfully."); } else { trace("An error occurred while loading variables."); my_lv.load("[place a valid URL pointing to a text file here]"); See also load (LoadVars.load method) sendAndLoad (LoadVars.sendAndLoad method)
Page 700
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis For Flash Player 7 and later websites can permit cross-domain access to a resource via a cross- domain policy file.
For another example, see the guestbook.fla file in the ActionScript samples folder. Here are some typical paths to this folder: Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/ Samples/ActionScript See also load (XML.load method) loaded (LoadVars.loaded property)
LoadVars constructor public LoadVars() Creates a LoadVars object. You can then use the methods of that LoadVars object to send and load data. Availability: ActionScript 1.0; Flash Player 6 Example The following example creates a LoadVars object called my_lv var my_lv:LoadVars = new LoadVars(); onData (LoadVars.onData handler) onData = function(src:String) {} Invoked when data has completely downloaded from the server or when an error occurs while...
return; content_ta.text = src; my_lv.load("content.txt", my_lv, "GET"); See also onLoad (LoadVars.onLoad handler) onLoad (LoadVars.onLoad handler) load (LoadVars.load method) sendAndLoad (LoadVars.sendAndLoad method) onHTTPStatus (LoadVars.onHTTPStatus handler) onHTTPStatus = function(httpStatus:Number) {} Invoked when Flash Player receives an HTTP status code from the server. This handler lets you capture and act on HTTP status codes.
See also onHTTPStatus (XML.onHTTPStatus handler) load (LoadVars.load method) sendAndLoad (LoadVars.sendAndLoad method) onLoad (LoadVars.onLoad handler) onLoad = function(success:Boolean) {} Invoked when a operation has ended. If the LoadVars.load() LoadVars.sendAndLoad() operation was successful, is populated with variables downloaded by the operation, and my_lv these variables are available when this handler is invoked.
To view a more robust example, see the login.fla file in the ActionScript samples folder. Here are some typical paths to this folder: Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/ Samples/ActionScript See also onLoad (XML.onLoad handler) loaded (LoadVars.loaded property)
Page 707
For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 6 Parameters - A string;...
For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis For Flash Player 7 and later: Websites can permit cross-domain access to a resource via a cross-domain policy file.
Page 709
To view a more robust example, see the login.fla file in the ActionScript samples folder. Typical paths to the ActionScript samples folder are: Windows: boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/ Samples/ActionScript LoadVars...
See also send (LoadVars.send method) load (LoadVars.load method) sendAndLoad (XML.sendAndLoad method) toString (LoadVars.toString method) public toString() : String Returns a string containing all enumerable variables in , in the MIME content my_lv encoding application/x-www-form-urlencoded. Availability: ActionScript 1.0; Flash Player 6 Returns - A string.
Page 711
The primary methods used to send and receive data are LocalConnection.send() . At its most basic, your code will implement the following LocalConnection.connect() commands; notice that both the LocalConnection.send() commands specify the same connection name, LocalConnection.connect() lc_name // Code in the receiving SWF file this.createTextField("result_txt", 1, 10, 10, 100, 22);...
Page 712
Event summary Event Description Invoked whenever receiving_lc receives a request to invoke a method allowDomain from a sending LocalConnection object. function([sendin gDomain:String]) Invoked whenever receiving_lc, which is in a SWF file hosted at a domain allowInsecureDom using a secure protocol (HTTPS), receives a request to invoke a method from a sending LocalConnection object that is in a SWF file hosted at a function([sendin nonsecure protocol.
Method summary Modifiers Signature Description Closes (disconnects) a LocalConnection object. close() : Void Prepares a LocalConnection object to receive connect(connectionNa commands from a LocalConnection.send() me:String) : Boolean command (called the sending LocalConnection object). Returns a string representing the domain of the domain() : String location of the current SWF file.
Page 714
to explicitly permit LocalConnection objects from LocalConnection.allowDomain specified domains, or from any domain, to execute methods of the receiving LocalConnection object. If you don't declare the sendingDomain parameter, you probably want to accept commands from any domain, and the code in your handler would be simply return true. If you do declare sendingDomain, you probably want to compare the value of sendingDomain with domains from which you want to accept commands.
Page 715
The opposite situation can also occur: You might create a child SWF file that wants to accept LocalConnection calls from its parent but doesn't know the domain of its parent. In this situation, implement this method by checking whether the domain argument matches the domain of _parent._url.
Page 716
+= aString+newline; aLocalConn.allowDomain = function(sendingDomain) { return (sendingDomain == this.domain() || sendingDomain == "www.macromedia.com"); aLocalConn.connect("_mylc"); When published for Flash Player 7 or later, exact domain matching is used. This means that the example will fail if the SWF files are located at www.thatDomain.com but will work if the files are located at thatDomain.com.
LocalConnection object. Example The following example allows connections from the current domain or from www.macromedia.com, or allows insecure connections only from the current domain. this.createTextField("welcome_txt", this.getNextHighestDepth(), 10, 10, 100, 20); var my_lc:LocalConnection = new LocalConnection(); my_lc.allowDomain = function(sendingDomain:String) { domain_txt.text = sendingDomain;...
my_lc.sayHello = function(name:String) { welcome_txt.text = "Hello, "+name; my_lc.connect("lc_name"); If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method used in MovieClip.getNextHighestDepth() this example. See also allowDomain (LocalConnection.allowDomain handler) connect (LocalConnection.connect method) close (LocalConnection.close method) public close() : Void...
method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also connect (LocalConnection.connect method) connect (LocalConnection.connect method) public connect(connectionName:String) : Boolean Prepares a LocalConnection object to receive commands from a LocalConnection.send()
Page 720
If you are implementing communication between SWF files in different domains, specifying a string for that begins with an underscore (_) will make the SWF with the connectionName receiving LocalConnection object more portable between domains. Here are the two possible cases: If the string for does not begin with an underscore (_), Flash Player...
Page 721
Example The following example shows how a SWF file in a particular domain can invoke a method named in a receiving SWF file in the same domain. printOut First, create one SWF file with the following code: this.createTextField("tf", this.getNextHighestDepth(), 10, 10, 300, 100); var aLocalConnection:LocalConnection = new LocalConnection();...
"macromedia.com" In SWF files published for Flash Player 7 or later, the returned string is the exact domain of the current SWF file. For example, if the SWF file is located at www.macromedia.com, this command returns "www.macromedia.com" If the current SWF file is a local file residing on the client computer, this command returns "localhost"...
Page 723
// If either the sending or receiving SWF file is Flash Player 7 or later, // then use the exact domain. In this case, commands from a SWF file posted // at www.macromedia.com will be accepted, but those from one posted at // a different subdomain, e.g. livedocs.macromedia.com, will not.
Page 724
Line numbers are included for reference purposes. The sequence of events is described in the following list: The receiving SWF file prepares to receive commands on a connection named (line "sum" 11). The Flash Player resolves the name of this connection to (see "mydomain.com:sum"...
// determine our domain and see if we need to truncate it 57 var channelDomain:String = lc.domain(); 58 if (getVersion() >= 7 && this.getSWFVersion() >= 7) 59 { // split domain name into elements 60 var domainArray:Array = channelDomain.split("."); // if more than two elements are found, // chop off first element to create superdomain 61 if (domainArray.length >...
// Code in the sending SWF file var sending_lc:LocalConnection = new LocalConnection(); sending_lc.send("lc_name", "methodToExecute", 5, 7); See also connect (LocalConnection.connect method) send (LocalConnection.send method) onStatus (LocalConnection.onStatus handler) onStatus = function(infoObject:Object) {} Invoked after a sending LocalConnection object tries to send a command to a receiving LocalConnection object.
Example The following example displays a status message about whether the SWF file connects to another local connection object called . A TextInput component called lc_name name_ti TextArea instance called and a Button instance called are used to status_ta send_button display content.
Page 728
For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 6...
Returns - A Boolean value: if Flash can carry out the request; otherwise. Boolean true false A return value of true does not necessarily mean that Flash successfully connected to a receiving object; It means only that the command us syntactically LocalConnection correct.
Page 730
—String ID replacement is controlled using "via ActionScript at runtime" ActionScript at runtime. This option gives you control over both the timing and language of string ID replacement. You can use the properties and methods of this class when you want to replace the string IDs "via ActionScript at runtime."...
Page 731
Method summary Modifiers Signature Description Adds the {instance, string ID} pair into the internal static addDelayedInstance(i array for later use. nstance:Object, stringID:String) : Void Adds the {languageCode and languagePath} pair into static addXMLPath(langCode: the internal array for later use. String, path:String) : Void Returns true if the XML file is loaded;...
Parameters - The language code. langCode:String - The XML path to add. path:String Example The following example uses the method to check whether the language XML setInterval() file has successfully loaded. import mx.lang.Locale; Locale.setLoadCallback(localeCallback); Locale.loadLanguageXML("en"); // create interval to check if language XML file is loaded var locale_int:Number = setInterval(checkLocaleStatus, 10);...
Example The following example uses the property to populate the dynamically Locale.autoReplace created text field on the Stage with the contents of the string greeting_txt IDS_GREETING in the English XML file. In the Strings panel, click the Settings button to open the Settings dialog box.
getDefaultLang (Locale.getDefaultLang method) public static getDefaultLang() : String The default language code as set in the Strings panel dialog box or by calling the method. setDefaultLang() Availability: ActionScript 2.0; Flash Player 8 Returns - Returns the default language code. String Example The following example creates a variable called , which is used to hold the initial...
Example This example shows how to use the method to automatically populate the initialize() text field on the Stage with the user's current OS language. Instead of using greeting_txt method directly, use the string replacement method of initialize() "automatically at runtime" import mx.lang.Locale;...
Example The following example loads a language XML file based on the current value of a ComboBox component. You drag a ComboBox component onto the Stage and give it an instance name . Using the Text tool, you create a dynamic text field and give it an instance name lang_cb .
Example The following example uses the method to load the English (en) XML loadLanguageXML() language file. Once the language file loads, the method is called and localeCallback() populates the text field on the Stage with the contents of the greeting_txt IDS_GREETING string in the XML file.
function checkLocaleStatus():Void { if (Locale.checkXMLStatus()) { clearInterval(locale_int); trace("clearing interval @ " + getTimer() + " ms"); // callback function for Locale.setLoadCallback() function localeCallback(success:Boolean):Void { greeting_txt.text = Locale.loadString("IDS_GREETING"); See also loadStringEx (Locale.loadStringEx method) loadStringEx (Locale.loadStringEx method) public static loadStringEx(stringID:String, languageCode:String) : String Returns the string value associated with the given string ID and language code.
See also loadString (Locale.loadString method) setDefaultLang (Locale.setDefaultLang method) public static setDefaultLang(langCode:String) : Void Sets the default language code. Availability: ActionScript 2.0; Flash Player 7 Parameters - A string representing a language code. langCode:String Example The following example creates a variable called , which is used to hold the initial defLang default language for the Flash document.
Parameters - The function to call when the XML language file loads. loadCallback:Function Example The following example uses an interval to check every 10 milliseconds to see if the language file has successfully loaded. Once the XML file has loaded, the text field greeting_txt instance on the Stage is populated with the...
stringIDArray (Locale.stringIDArray property) public static stringIDArray : Array [read-only] An array containing all the string IDs in the FLA file. The string IDs are not sorted alphabetically. Availability: ActionScript 2.0; Flash Player 8 Example The following example traces the property for the currently loaded Locale.stringIDArray language XML file.
Page 743
To calculate a radian value, use the following formula: radians = degrees * Math.PI/180 The following is an example of passing the equation as a parameter to calculate the sine of a 45° angle: is the same as Math.sin(45 * Math.PI/180) Math.sin(.7854) Availability: ActionScript 1.0;...
Page 744
Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description Computes and returns an absolute value for the static abs(x:Number) : number specified by the parameter x. Number Computes and returns the arc cosine of the number static acos(x:Number) :...
Modifiers Signature Description Returns a pseudo-random number n, where 0 <= n < 1. static random() : Number Rounds the value of the parameter x up or down to static round(x:Number) : the nearest integer and returns the value. Number Computes and returns the sine of the specified angle static sin(x:Number) :...
trace(num); // output: -12 trace(numAbsolute); // output: 12 acos (Math.acos method) public static acos(x:Number) : Number Computes and returns the arc cosine of the number specified in the parameter , in radians. Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
Returns - A number between negative pi divided by 2 and positive pi divided by 2. Number Example The following example displays the arc sine for several values. trace(Math.asin(-1)); // output: -1.5707963267949 trace(Math.asin(0)); // output: 0 trace(Math.asin(1)); // output: 1.5707963267949 See also acos (Math.acos method) atan (Math.atan method)
atan2 (Math.atan2 method) public static atan2(y:Number, x:Number) : Number Computes and returns the angle of the point in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle). The return value is between positive pi and negative pi. Availability: ActionScript 1.0;...
Returns - An integer that is both closest to, and greater than or equal to, parameter Number Example The following code returns a value of 13: Math.ceil(12.5); See also floor (Math.floor method) round (Math.round method) cos (Math.cos method) public static cos(x:Number) : Number Computes and returns the cosine of the specified angle in radians.
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.
Parameters - The exponent; a number or expression. x:Number Returns - A number. Number Example The following example displays the logarithm for two number values. trace(Math.exp(1)); // output: 2.71828182845905 trace(Math.exp(2)); // output: 7.38905609893065 See also E (Math.E property) floor (Math.floor method) public static floor(x:Number) : Number Returns the floor of the number or expression specified in the parameter .
LN10 (Math.LN10 property) public static LN10 : Number A mathematical constant for the natural logarithm of 10, expressed as loge10, with an approximate value of 2.302585092994046. Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
Example The following example displays the logarithm for three numerical values. trace(Math.log(0)); // output: -Infinity trace(Math.log(1)); // output: 0 trace(Math.log(2)); // output: 0.693147180559945 trace(Math.log(Math.E)); // output: 1 LOG10E (Math.LOG10E property) public static LOG10E : Number A mathematical constant for the base-10 logarithm of the constant e ( ), expressed as Math.E log10e, with an approximate value of 0.4342944819032518.
max (Math.max method) public static max(x:Number, y:Number) : Number Evaluates and returns the larger value. Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
Returns - A number. Number Example The following example displays , which is the smaller Sat Dec 25 00:00:00 GMT-0700 2004 of the evaluated expressions. var date1:Date = new Date(2004, 11, 25); var date2:Date = new Date(2004, 11, 30); var minDate:Number = Math.min(date1.getTime(), date2.getTime()); trace(new Date(minDate).toString());...
mc.curveTo(r+x, -Math.tan(Math.PI/8)*r+y, r+x, y); pow (Math.pow method) public static pow(x:Number, y:Number) : Number Computes and returns to the power of Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() random (Math.random method) public static random() : Number Returns a pseudo-random number n, where 0 <= n <...
Returns - A number; an integer. Number Example The following example returns a random number between two specified integers. function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.round(Math.random() * (max-min+1) + (min- .5)); return randomNum; for (var i = 0; i<25; i++) { trace(randRange(4, 11));...
tan (Math.tan method) public static tan(x:Number) : Number Computes and returns the tangent of the specified angle. To calculate a radian, use the information outlined in the introduction to the Math class. Availability: ActionScript 1.0; Flash Player 5 - In Flash Player 4, the methods and properties of the Math class are emulated using approximations and might not be as accurate as the non- emulated math functions that Flash Player 5 supports.
Matrix (flash.geom.Matrix) Object +-flash.geom.Matrix public class Matrix extends Object The flash.geom.Matrix class represents a transformation matrix that determines how to map points from one coordinate space to another. By setting the properties of a Matrix object and applying it to a MovieClip or BitmapData object you can perform various graphical transformations on the object.
Page 763
The Matrix class supports the four major types of transformation functions: translation, scaling, rotation, and skewing. There are specialized methods for three of these functions, as described in the following table. Transformation Method Matrix values Display result Description Translation Moves the translate(tx, ty) (displacement) image...
Page 764
Availability: ActionScript 1.0; Flash Player 8 See also transform (MovieClip.transform property) Transform (flash.geom.Transform) draw (BitmapData.draw method) a (Matrix.a property) b (Matrix.b property) (Matrix.c property) d (Matrix.d property) tx (Matrix.tx property) (Matrix.ty property) translate (Matrix.translate method) scale (Matrix.scale method) rotate (Matrix.rotate method) Property summary Modifiers Property...
Page 765
Constructor summary Signature Description Creates a new Matrix object with the specified parameters. Matrix([a:Number], [b:Number], [c:Number], [d:Number], [tx:Number], [ty:Number]) Method summary Modifiers Signature Description Returns a new Matrix object that is a clone of this clone() : Matrix matrix, with an exact copy of the contained object. Concatenates a matrix with the current matrix, concat(m:Matrix) : effectively combining the geometric effects of the two.
Modifiers Signature Description Returns a text value listing the properties of the Matrix toString() : String object. Applies the geometric transformation represented by transformPoint(pt:Po the Matrix object to the specified point. int) : Point Modifies a Matrix object so that the effect of its translate(tx:Number, transformation is to move an object along the x and y ty:Number) : Void...
Availability: ActionScript 1.0; Flash Player 8 Example The following example creates the Matrix object and sets its value. myMatrix import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(); trace(myMatrix.b); // 0 var degrees:Number = 45; var radians:Number = (degrees/180) Math.PI; myMatrix.b = radians; trace(myMatrix.b);...
Example The following example creates the variable from the variable. The clonedMatrix myMatrix Matrix class does not have an method, so the following example uses a custom written equals function to test the equality of two matrixes. import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(2, 0, 0, 2, 0, 0); var clonedMatrix:Matrix = new Matrix();...
Page 769
Example The following example creates three matrixes that define transformations for three rectangle movie clips. The first two matrixes are applied to rotate45Matrix doubleScaleMatrix the two rectangles . Then the third matrix is created rectangleMc_1 rectangleMc_2 using the method on to create concat() rotate45Matrix...
function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; createBox (Matrix.createBox method) public createBox(scaleX:Number, scaleY:Number, [rotation:Number], [tx:Number], [ty:Number]) : Void Includes parameters for scaling, rotation, and translation. When applied to a matrix it sets the matrix's values based on those parameters.
Example The following example sets the scale, rotation, x location, and y location of scaleX scaleY by calling its method. myMatrix createBox() import flash.geom.Matrix; import flash.geom.Transform; var myMatrix:Matrix = new Matrix(); trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) myMatrix.createBox(1, 2, Math.PI/4, 100, 200); trace(myMatrix.toString());...
Example The following example uses as a parameter for the MovieClip object's myMatrix method. beginGradientFill() import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(); trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) myMatrix.createGradientBox(200, 200, 0, 50, 50); trace(myMatrix.toString()); // (a=0.1220703125, b=0, c=0, d=0.1220703125, tx=150, ty=150) var depth:Number = this.getNextHighestDepth();...
deltaTransformPoint (Matrix.deltaTransformPoint method) public deltaTransformPoint(pt:Point) : Point Given a point in the pretransform coordinate space, returns the coordinates of that point after the transformation occurs. Unlike the standard transformation applied using the transformPoint() method, the deltaTransformPoint() method's transformation does not consider the translation parameters Availability: ActionScript 1.0;...
var pointMc_1:MovieClip = createRectangle(10, 10, 0x00FF00); pointMc_1._x = deltaTransformedPoint.x; function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; identity (Matrix.identity method) public identity() : Void Sets each matrix property to a value that cause a transformed movie clip or geometric construct to be identical to the original.
myMatrix.translate(100,200); trace(myMatrix.toString()); // (a=1.6, b=1.2, c=-1.2, d=1.6, tx=100, ty=200) myMatrix.scale(2, 2); trace(myMatrix.toString()); // (a=3.2, b=2.4, c=-2.4, d=3.2, tx=200, ty=400) myMatrix.identity(); trace(myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) invert (Matrix.invert method) public invert() : Void Performs the opposite transformation of the original matrix. You can apply an inverted matrix to an object to undo the transformation performed when applying the original matrix.
In matrix notation the identity matrix looks like this: Availability: ActionScript 1.0; Flash Player 8 Parameters [optional] - The value in the first row and first column of the new Matrix object. a:Number [optional] - The value in the first row and second column of the new Matrix object. b:Number [optional] - The value in the second row and first column of the new Matrix object.
Page 778
method alters the properties of the Matrix object. In matrix notation rotate() this is shown as follows: Availability: ActionScript 1.0; Flash Player 8 Parameters - The rotation angle in radians. angle:Number Example The following example shows how the method rotates 30°...
Page 779
mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; The previous example uses the property of the MovieClip object to position . Generally, when dealing with Matrix object positioning, mixing positioning rectangleMc techniques is considered poor format. The previous example written in correct syntax would concatenate a translation Matrix to to change the horizontal location of myMatrix...
scale (Matrix.scale method) public scale(sx:Number, sy:Number) : Void Modifies a matrix so that its effect, when applied, is to resize an image. In the resized image, the location of each pixel on the x axis is multiplied by ; and on the y axis it is multiplied by method alters the properties of the matrix object.
Example The following example creates and converts its values to a string in the format of myMatrix (a=A, b=B, c=C, d=D, tx=TX, ty=TY). import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(); trace("myMatrix: " + myMatrix.toString()); // (a=1, b=0, c=0, d=1, tx=0, ty=0) transformPoint (Matrix.transformPoint method) public transformPoint(pt:Point) : Point...
Example The following example uses the method to position x:100 and translate() rectangleMc y:50. The method affects the translation properties , but it doesn't translate() affect the , or properties. import flash.geom.Matrix; var myMatrix:Matrix = new Matrix(2, 0, 0, 2, 100, 100); trace(myMatrix.toString());...
trace(myMatrix.ty); // 0 myMatrix.ty = 50; trace(myMatrix.ty); // 50 Microphone Object +-Microphone public class Microphone extends Object The Microphone class lets you capture audio from a microphone attached to the computer that is running Flash Player. The Microphone class is primarily for use with Flash Communication Server but can be used in a limited fashion without the server, for example, to transmit sound from your microphone through the speakers on your local system.
Page 785
Modifiers Property Description [read- A string that specifies the name of the current sound name:String only] capture device, as returned by the sound capture hardware. [read- Retrieves an array of strings reflecting the names of all static names:Array only] available sound capture devices without displaying the Flash Player Privacy Settings panel.
Method summary Modifiers Signature Description Returns a reference to a Microphone object for static get([index:Number]) capturing audio. : Microphone Sets the microphone gain--that is, the amount by setGain(gain:Number) which the microphone should multiply the signal : Void before transmitting it. Sets the rate, in kHz, at which the microphone should setRate(rate:Number) capture sound.
Example The following example displays the activity level of the current microphone in a ProgressBar instance called activityLevel_pb var activityLevel_pb:mx.controls.ProgressBar; activityLevel_pb.mode = "manual"; activityLevel_pb.label = "Activity Level: %3%%"; activityLevel_pb.setStyle("themeColor", "0xFF0000"); this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth()); var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); this.onEnterFrame = function() { activityLevel_pb.setProgress(active_mic.activityLevel, 100);...
gain_pb.label = "Gain: %3"; gain_pb.mode = "manual"; gain_pb.setProgress(active_mic.gain, 100); gain_nstep.value = active_mic.gain; function changeGain() { active_mic.setGain(gain_nstep.value); gain_pb.setProgress(active_mic.gain, 100); gain_nstep.addEventListener("change", changeGain); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method.
Page 789
When the user responds to this dialog box, the event handler returns Microphone.onStatus an information object that indicates the user's response. To determine whether the user has denied or allowed access to the camera without processing this event handler, use Microphone.muted The user can also specify permanent privacy settings for a particular domain by right-clicking (Windows) or Control-clicking (Macintosh) while a SWF file is playing, choosing Settings,...
var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also get (Microphone.get method) index (Microphone.index property) muted...
method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also get (Microphone.get method) names (Microphone.names property) muted (Microphone.muted property) public muted : Boolean [read-only] A Boolean value that specifies whether the user has denied access to the microphone (...
status_ta.text += "You have "+microphone_array.length+" device(s) installed."+newline+newline; for (var i = 0; i<microphone_array.length; i++) { status_ta.text += "["+i+"] "+microphone_array[i]+newline; See also get (Microphone.get method) names (Microphone.names property) names (Microphone.names property) public static names : Array [read-only] Retrieves an array of strings reflecting the names of all available sound capture devices without displaying the Flash Player Privacy Settings panel.
You have 2 device(s) installed. [0] Logitech USB Headset [1] YAMAHA AC-XG WDM Audio See also name (Microphone.name property) get (Microphone.get method) onActivity (Microphone.onActivity handler) onActivity = function(active:Boolean) {} Invoked when the microphone starts or stops detecting sound. If you want to respond to this event handler, you must create a function to process its activity value.
method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also setSilenceLevel (Microphone.setSilenceLevel method) onStatus (Microphone.onStatus handler) onStatus = function(infoObject:Object) {} Invoked when the user allows or denies access to the microphone.
Example The following code lets you use a ComboBox instance, called , to change the rate at rate_cb which your microphone captures sound. The current rate displays in a Label instance called rate_lbl this.createEmptyMovieClip("sound_mc", this.getNextHighestDepth()); var active_mic:Microphone = Microphone.get(); sound_mc.attachAudio(active_mic); var rate_array:Array = new Array(5, 8, 11, 22, 44);...
Parameters - An integer that specifies the amount by which the microphone should boost gain:Number the signal. Valid values are 0 to 100. The default value is 50; however, the user may change this value in the Flash Player Microphone Settings panel. Example The following example uses a ProgressBar instance called to display and a...
Example The following example sets the microphone rate to the user's preference (which you have assigned to the variable) if it is one of the following values: 5, 8, 11, 22, or 44. If it userRate is not, the value is rounded to the nearest acceptable value that the sound capture device supports.
Page 799
To prevent the microphone from detecting sound at all, pass a value of 100 for level is never invoked. Microphone.onActivity To determine the amount of sound the microphone is currently detecting, use Microphone.activityLevel Activity detection is the ability to detect when audio levels suggest that a person is talking. When someone is not talking, bandwidth can be saved because there is no need to send the associated audio stream.
setUseEchoSuppression (Microphone.setUseEchoSuppression method) public setUseEchoSuppression(useEchoSuppression:Boolean) : Void Specifies whether to use the echo suppression feature of the audio codec. The default value is unless the user has selected Reduce Echo in the Flash Player Microphone Settings false panel. Echo suppression is an effort to reduce the effects of audio feedback, which is caused when sound going out the speaker is picked up by the microphone on the same computer.
active_mic.setUseEchoSuppression(evt.target.selected); useEchoSuppression_ch.addEventListener("click", chListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also setUseEchoSuppression (Microphone.setUseEchoSuppression method) useEchoSuppression (Microphone.useEchoSuppression property) silenceLevel (Microphone.silenceLevel property) public silenceLevel : Number [read-only]...
Availability: ActionScript 1.0; Flash Player 6 Example The following example turns on echo suppression if the user selects a CheckBox instance called . The ProgressBar instance called useEchoSuppression_ch activityLevel_pb displays the current activity level of the audio stream. var useEchoSuppression_ch:mx.controls.CheckBox; var activityLevel_pb:mx.controls.ProgressBar;...
Page 806
A Flash application can only monitor mouse events that occur within its focus. A Flash application cannot detect mouse events in another application. Availability: ActionScript 1.0; Flash Player 5 Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property),...
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)
updateAfterEvent(); Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also show (Mouse.show method) _xmouse (MovieClip._xmouse property) _ymouse (MovieClip._ymouse property)
this.target_mc.clear(); this.target_mc.lineStyle(1, 0xFF0000, 100); this.target_mc.moveTo(this.orig_x, this.orig_y); this.target_mc.lineTo(_xmouse, this.orig_y); this.target_mc.lineTo(_xmouse, _ymouse); this.target_mc.lineTo(this.orig_x, _ymouse); this.target_mc.lineTo(this.orig_x, this.orig_y); updateAfterEvent(); mouseListener.onMouseUp = function() { this.isDrawing = false; Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method.
Page 811
var mouseListener:Object = new Object(); mouseListener.onMouseDown = function() { this.isDrawing = true; canvas_mc.lineStyle(2, 0xFF0000, 100); canvas_mc.moveTo(_xmouse, _ymouse); mouseListener.onMouseMove = function() { if (this.isDrawing) { canvas_mc.lineTo(_xmouse, _ymouse); updateAfterEvent(); mouseListener.onMouseUp = function() { this.isDrawing = false; Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later.
onMouseUp (Mouse.onMouseUp event listener) onMouseUp = function() {} Notified when the mouse is released. To use the listener, you must create a listener onMouseUp object. You can then define a function for and use to register the onMouseUp addListener() listener with the Mouse object, as shown in the following code: var someListener:Object = new Object();...
onMouseWheel (Mouse.onMouseWheel event listener) onMouseWheel = function([delta:Number], [scrollTarget:String]) {} Notified when the user rolls the mouse wheel. To use the listener, you must onMouseWheel create a listener object. You can then define a function for and use onMouseWheel to register the listener with the Mouse object. addListener() Note: Mouse wheel event listeners are available only in Windows versions of Flash Player.
mouseListener.onMouseWheel = function(delta:Number) { line_mc._rotation += delta; mouseListener.onMouseDown = function() { trace("Down"); Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method.
Page 815
startDrawing_button.enabled = false; this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth()); var mouseListener:Object = new Object(); mouseListener.onMouseDown = function() { this.isDrawing = true; canvas_mc.lineStyle(2, 0xFF0000, 100); canvas_mc.moveTo(_xmouse, _ymouse); mouseListener.onMouseMove = function() { if (this.isDrawing) { canvas_mc.lineTo(_xmouse, _ymouse); updateAfterEvent(); mouseListener.onMouseUp = function() { this.isDrawing = false; Mouse.addListener(mouseListener); var clearListener:Object = new Object();...
show (Mouse.show method) public static show() : Number Displays the mouse pointer in a SWF file. The pointer is visible by default. Availability: ActionScript 1.0; Flash Player 5 Returns - An integer; either . If the mouse pointer was hidden before the call to Number then the return value is .
MovieClip Object +-MovieClip public dynamic class MovieClip extends Object The methods for the MovieClip class provide the same functionality as actions that target movie clips. Some additional methods do not have equivalent actions in the Actions toolbox in the Actions panel. You do not use a constructor method to create a movie clip.
Page 818
Modifiers Property Description A Boolean value that indicates whether a movie clip enabled:Boolean is enabled. An indexed array containing each filter object filters:Array currently associated with the movie clip. If the value is undefined or false, a movie clip focusEnabled:Boolean cannot receive input focus unless it is a button.
Page 819
Modifiers Property Description The scrollRect property allows you to quickly scrollRect:Object scroll movie clip content and have a window viewing larger content. Specifies the number of seconds a sound prebuffers _soundbuftime:Number before it starts to stream. Determines whether the children of a movie clip are tabChildren:Boolean included in the automatic tab ordering.
Page 820
Modifiers Property Description Sets the y coordinate of a movie clip relative to the _y:Number local coordinates of the parent movie clip. [read- Indicates the y coordinate of the mouse position. _ymouse:Number only] Sets the vertical scale (percentage) of the movie _yscale:Number clip as applied from the registration point of the movie clip.
Page 821
Event Description Invoked when the mouse button is released. onMouseUp function() {} Invoked when the user clicks the mouse while the pointer is over a movie onPress clip. function() {} Invoked when a user releases the mouse button over a movie clip. onRelease function() {} Invoked after a user presses the mouse button inside the movie clip area...
Page 822
Modifiers Signature Description Fills a drawing area with a bitmap image. beginBitmapFill(bmp: BitmapData, [matrix:Matrix], [repeat:Boolean], [smoothing:Boolean]) : Void Indicates the beginning of a new drawing path. beginFill(rgb:Number , [alpha:Number]) : Void Indicates the beginning of a new drawing path. beginGradientFill(fi llType:String, colors:Array, alphas:Array,...
Page 823
Modifiers Signature Description Creates an instance of the specified movie clip while duplicateMovieClip(n the SWF file is playing. ame:String, depth:Number, [initObject:Object]) : MovieClip Applies a fill to the lines and curves that were since the endFill() : Void last call to beginFill() or beginGradientFill(). Returns properties that are the minimum and getBounds(bounds:Obj maximum x and y coordinate values of the movie clip,...
Page 824
Modifiers Signature Description Converts the pt object from Stage (global) globalToLocal(pt:Obj coordinates to the movie clip's (local) coordinates. ect) : Void Starts playing the SWF file at the specified frame. gotoAndPlay(frame:Ob ject) : Void Brings the playhead to the specified frame of the gotoAndStop(frame:Ob movie clip and stops it there.
Page 825
Modifiers Signature Description Converts the pt object from the movie clip's (local) localToGlobal(pt:Obj coordinates to the Stage (global) coordinates. ect) : Void Moves the current drawing position to (x, y). moveTo(x:Number, y:Number) : Void Sends the playhead to the next frame and stops it. nextFrame() : Void Moves the playhead in the timeline of the movie clip.
See also _alpha (Button._alpha property) _alpha (TextField._alpha property) _visible (MovieClip._visible property) attachAudio (MovieClip.attachAudio method) public attachAudio(id:Object) : Void Specifies the audio source to be played. To stop playing the audio source, pass the value false for the You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
audio_sound.setVolume(audio_sound.getVolume()-10); updateVolume(); // Updates the volume. this.createTextField("volume_txt", this.getNextHighestDepth(), 0, 0, 100, 22); updateVolume(); function updateVolume() { volume_txt.text = "Volume: "+audio_sound.getVolume(); The following example specifies a microphone as the audio source for a dynamically created movie clip instance called audio_mc var active_mic:Microphone = Microphone.get(); this.createEmptyMovieClip("audio_mc", this.getNextHighestDepth());...
Pixel snapping forces the position of the bitmap to the nearest whole pixel value instead of positioning to be on a partial pixel. There are three pixel snapping modes: Auto mode does pixel snapping as long as the bitmap is not stretched or rotated. Always mode always does pixel snapping, regardless of stretching and rotation.
Parameters - The linkage name of the movie clip symbol in the library to attach to a movie id:String clip on the Stage. This is the name that you enter in the Identifier field in the Linkage Properties dialog box. - A unique instance name for the movie clip being attached to the movie clip.
Page 831
[optional] - A matrix object (of the flash.geom.Matrix class), matrix:flash.geom.Matrix which you can use to define transformations on the bitmap. For instance, you can use the following matrix to rotate a bitmap by 45 degrees (pi/4 radians): var matrix = new flash.geom.Matrix(); matrix.rotate(Math.PI/4);...
this.createEmptyMovieClip("bmp_fill_mc", this.getNextHighestDepth()); with (bmp_fill_mc) { matrix = new Matrix(); matrix.rotate(Math.PI/8); repeat = true; smoothing = true; beginBitmapFill(bmpd, matrix, repeat, smoothing); moveTo(0, 0); lineTo(0, 60); lineTo(60, 60); lineTo(60, 0); lineTo(0, 0); endFill(); bmp_fill_mc._xscale = 200; bmp_fill_mc._yscale = 200; If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method, which is MovieClip.getNextHighestDepth()
MovieClip.getNextHighestDepth() An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ See also moveTo (MovieClip.moveTo method) endFill (MovieClip.endFill method) beginGradientFill (MovieClip.beginGradientFill method)
Page 834
The flash.geom.Matrix class includes a createGradientBox() method, which lets you conveniently set up the matrix for use with the method of MovieClip class. Macromedia recommends that you beginGradientFill() use this form of matrix for Flash Player 8 and later.
Page 835
3 matrix of the following form: a b c d e f g h i For Flash Player 8 and later, Macromedia recommends that you define the matrix parameter in the form of a object (as described in the first item in flash.geom.Matrix the list).
Page 836
For Flash Player 8 and later, Macromedia recommends that you define the matrix parameter in the form of a object (as described in the first item in flash.geom.Matrix...
Page 838
this.lineTo(0, 0); this.endFill(); This example uses for the spread method, so the gradient fill looks like the following: "pad" If you used for the spread method, the gradient fill would look like the following: "reflect" If you used for the spread method, the gradient fill would look like the following: "repeat"...
Page 839
[optional] - Added in Flash Player 8. A number that controls the focalPointRatio:Number location of the focal point of the gradient. The value 0 means the focal point is in the center. The value 1 means the focal point is at one border of the gradient circle. The value -1 means the focal point is at the other border of the gradient circle.
This draws the following image (the image is scaled by 50%): If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example. See also createGradientBox (Matrix.createGradientBox method) beginFill (MovieClip.beginFill method)
Page 841
The following table describes the settings. To set the property, you can blendMode blendMode use either an integer from 1 to 14 or a string. The illustrations in the table show blendMode values applied to a circular movie clip (2) superimposed on another onscreen object (1). Integer value String value Illustration Description The movie clip appears in front of the...
Page 842
Integer value String value Illustration Description Multiplies the complement (inverse) of the "screen" movie clip color by the complement of the background color, resulting in a bleaching effect. This setting is commonly used for highlights or to remove black areas of the movie clip.
Page 843
Integer value String value Illustration Description Compares the constituent colors of the "difference" movie clip with those of its background, and subtracts the darker of the values of the two constituent colors from the lighter one. This setting is commonly used for more vibrant colors.
Page 844
Integer value String value Illustration Description Applies the alpha value of each pixel of the "alpha" movie clip to the background. This requires the "layer" setting to be applied blendMode to a parent movie clip. For example, in the illustration, the parent movie clip, which is a white background, has blendMode = "layer"...
Page 845
Example The following example sets up two movie clips with gradient fills, and changes the blend mode of the one in the foreground every second. In order to have the blend mode "alpha" show up with an effect, the gradient for the movie clip includes a range of alpha ratios, and the blend mode is applied to the parent movie clip...
cacheAsBitmap (MovieClip.cacheAsBitmap property) public cacheAsBitmap : Boolean If set to , Flash Player caches an internal bitmap representation of the movie clip. This true can increase performance for movie clips that contain complex vector content. All vector data for a movie clip that has a cached bitmap is drawn to the bitmap instead of to the main Stage.
Example The following example applies a drop shadow to a movie clip instance. It then traces the value of the property which is set to when a filter is applied. cacheAsBitmap true import flash.filters.DropShadowFilter; var container:MovieClip = setUpShape(); trace(container.cacheAsBitmap); // false var dropShadow:DropShadowFilter = new DropShadowFilter(6, 45, 0x000000, 50, 5, 5, 1, 2, false, false, false);...
Page 848
An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI folder. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ ActionScript See also lineStyle (MovieClip.lineStyle method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method)
Page 849
You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0; Flash Player 6 Parameters - A string that identifies the instance name of the new movie clip. name:String - An integer that specifies the depth of the new movie clip. depth:Number Returns - A reference to the newly created movie clip.
createTextField (MovieClip.createTextField method) public createTextField(instanceName:String, depth:Number, x:Number, y:Number, width:Number, height:Number) : TextField Creates a new, empty text field as a child of the movie clip on which you call this method. You can use the method to create text fields while a SWF file plays. The createTextField() parameter determines the new text field's depth level (z-order position) in the movie depth...
Page 851
= "This is my first test field object text."; my_txt.setTextFormat(my_fmt); An example is also in the animation.fla file in the Samples\ActionScriptAnimation folder. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ MovieClip...
See also getInstanceAtDepth (MovieClip.getInstanceAtDepth method) getNextHighestDepth (MovieClip.getNextHighestDepth method) TextFormat _currentframe (MovieClip._currentframe property) public _currentframe : Number [read-only] Returns the number of the frame in which the playhead is located in the movie clip's timeline. Availability: ActionScript 1.0; Flash Player 4 Example The following example uses the property to direct the playhead of the...
Page 853
- An integer that specifies the vertical position of the next anchor point anchorY:Number relative to the registration point of the parent movie clip. Example The following example draws a nearly circular curve with a solid blue hairline stroke and a solid red fill: this.createEmptyMovieClip("circle_mc", 1);...
-Math.tan(Math.PI/8)*r+y, r+x, y); An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ See also beginFill (MovieClip.beginFill method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method)
} else { this._x = origX; this._y = origY; See also startDrag (MovieClip.startDrag method) stopDrag (MovieClip.stopDrag method) eval function duplicateMovieClip (MovieClip.duplicateMovieClip method) public duplicateMovieClip(name:String, depth:Number, [initObject:Object]) : MovieClip Creates an instance of the specified movie clip while the SWF file is playing. Duplicated movie clips always start playing at Frame 1, no matter what frame the original movie clip is on when the method is called.
Page 856
[optional] - (Supported for Flash Player 6 and later.) An object that initObject:Object contains properties with which to populate the duplicated movie clip. This parameter allows dynamically created movie clips to receive clip parameters. If is not an object, it initObject is ignored.
enabled (MovieClip.enabled property) public enabled : Boolean A Boolean value that indicates whether a movie clip is enabled. The default value of enabled . If is set to , the movie clip's callback methods and event true enabled false onaction handlers are no longer invoked, and the Over, Down, and Up frames are disabled.
MovieClip.getNextHighestDepth() An example is also in the drawingapi.fla file in the Samples\ActionScript\DrawingAPI. The following list gives typical paths to this folder: Windows: \Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ Macintosh: HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ See also beginFill (MovieClip.beginFill method) beginGradientFill (MovieClip.beginGradientFill method)
Page 859
If the array is empty, you need not use a temporary array. Instead, you can directly filters assign an array literal that contains one or more filter objects that you created. To modify an existing filter object, whether it was created at design-time or at runtime, you must use the technique of modifying a copy of the array: filters...
focusEnabled (MovieClip.focusEnabled property) public focusEnabled : Boolean If the value is , a movie clip cannot receive input focus unless it is a undefined false button. If the property value is , a movie clip can receive input focus even focusEnabled true if it is not a button.
mc3_mc.onRelease = traceOnRelease; function traceOnRelease() { trace(this._name); Test the SWF file in a browser window by selecting File > Publish Preview > HTML. Give the SWF focus by clicking it in the browser window, and press Tab to focus each instance. You cannot execute code for this movie clip in the browser by pressing Enter or the Spacebar when is disabled.
Place your content on or after Frame 3. Then add the following code on Frame 3: stop(); See also MovieClipLoader getBounds (MovieClip.getBounds method) public getBounds(bounds:Object) : Object Returns properties that are the minimum and maximum x and y coordinate values of the movie clip, based on the parameter.
var bounds_obj:Object = square_mc.getBounds(this); for (var i in bounds_obj) { trace(i+" --> "+bounds_obj[i]); The following information appears in the Output panel: yMax --> 110 yMin --> 10 xMax --> 110 xMin --> 10 See also getRect (MovieClip.getRect method) globalToLocal (MovieClip.globalToLocal method) localToGlobal (MovieClip.localToGlobal method) getBytesLoaded (MovieClip.getBytesLoaded...
Add the following code on Frame 2: if (this._framesloaded<this._totalframes) { this.gotoAndPlay(1); } else { this.gotoAndStop(3); Place your content on or after Frame 3, and then add the following code on Frame 3: stop(); See also getBytesTotal (MovieClip.getBytesTotal method) getBytesTotal (MovieClip.getBytesTotal method) public getBytesTotal() : Number Returns the size, in bytes, of the movie clip.
Place your content on or after Frame 3. Then add the following code on Frame 3: stop(); See also getBytesLoaded (MovieClip.getBytesLoaded method) getDepth (MovieClip.getDepth method) public getDepth() : Number Returns the depth of the movie clip instance. Each movie clip, button, and text field has a unique depth associated with it that determines how the object appears in front of or in back of other objects.
getInstanceAtDepth (MovieClip.getInstanceAtDepth method) public getInstanceAtDepth(depth:Number) : MovieClip Determines if a particular depth is already occupied by a movie clip. You can use this method before using , or MovieClip.attachMovie() MovieClip.duplicateMovieClip() to determine if the depth parameter you want to pass MovieClip.createEmptyMovieClip() to any of these methods already contains a movie clip.
Page 867
getNextHighestDepth (MovieClip.getNextHighestDepth method) public getNextHighestDepth() : Number Determines a depth value that you can pass to MovieClip.attachMovie() , or to ensure MovieClip.duplicateMovieClip() MovieClip.createEmptyMovieClip() that Flash renders the movie clip in front of all other objects on the same level and layer in the current movie clip.
mc.label.text = mc.getDepth(); See also getDepth (MovieClip.getDepth method) getInstanceAtDepth (MovieClip.getInstanceAtDepth method) swapDepths (MovieClip.swapDepths method) attachMovie (MovieClip.attachMovie method) duplicateMovieClip (MovieClip.duplicateMovieClip method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method) getRect (MovieClip.getRect method) public getRect(bounds:Object) : Object Returns properties that are the minimum and maximum x and y coordinate values of the movie clip, based on the parameter, excluding any strokes on shapes.
Page 869
Example The following example creates a movie clip and draws inside of it a square with a stroke width of 4 pixels. The example then calls both the MovieClip.getBounds() methods to show the difference between the two. The MovieClip.getRect() getBounds() method returns the minimum and maximum coordinate values of the entire movie clip, including the stroke width of the square.
See also getBounds (MovieClip.getBounds method) globalToLocal (MovieClip.globalToLocal method) localToGlobal (MovieClip.localToGlobal method) getSWFVersion (MovieClip.getSWFVersion method) public getSWFVersion() : Number Returns an integer that indicates the Flash Player version for the movie clip was published. If the movie clip is a JPEG, GIF, or PNG file, or if an error occurs and Flash Player can't determine the SWF version of the movie clip, -1 is returned.
You can't specify a tab index value for static text in Flash. However, other products may do so (for example, Macromedia FlashPaper). The contents of the TextSnapshot object aren't dynamic; that is, if the movie clip moves to a different frame, or is altered in some way (for example, objects in the movie clip are added or removed), the TextSnapshot object might not represent the current text in the movie clip.
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis You can extend the methods and event handlers of the MovieClip class by creating a subclass.
Page 873
POST sends the variables in a separate HTTP header and is used for long strings of variables. Example The following ActionScript creates a movie clip instance and opens the Macromedia website in a new browser window: this.createEmptyMovieClip("loader_mc", this.getNextHighestDepth()); loader_mc.getURL("http://www.macromedia.com", "_blank");...
globalToLocal (MovieClip.globalToLocal method) public globalToLocal(pt:Object) : Void Converts the object from Stage (global) coordinates to the movie clip's (local) coordinates. method allows you to convert any given x and y MovieClip.globalToLocal() coordinates from values that are relative to the top-left corner of the Stage to values that are relative to the top-left corner of a specific movie clip.
Page 875
The movie clip coordinates were expressed using , because those are the MovieClip properties that you use to set the x and y values for MovieClips. However, your generic object uses without the underscore. The following code converts the x and y values to the local coordinates: var myPoint:Object = {x:0, y:0};...
Mouse.addListener(mouseListener); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also getBounds (MovieClip.getBounds method) localToGlobal (MovieClip.localToGlobal method) Object gotoAndPlay (MovieClip.gotoAndPlay method)
See also gotoAndPlay function play function gotoAndStop (MovieClip.gotoAndStop method) public gotoAndStop(frame:Object) : Void Brings the playhead to the specified frame of the movie clip and stops it there. To specify a scene in addition to a frame, use the method. gotoAndStop() You can extend the methods and event handlers of the MovieClip class by creating a subclass.
_height (MovieClip._height property) public _height : Number The height of the movie clip, in pixels. Availability: ActionScript 1.0; Flash Player 4 Example The following code example displays the height and width of a movie clip in the Output panel: this.createEmptyMovieClip("image_mc", this.getNextHighestDepth()); var image_mcl:MovieClipLoader = new MovieClipLoader();...
Example The following ActionScript specifies that best quality anti-aliasing should be applied to the SWF file. my_mc._highquality = 2; See also _quality (MovieClip._quality property) _quality property hitArea (MovieClip.hitArea property) public hitArea : Object Designates another movie clip to serve as the hit area for a movie clip. If the property hitArea does not exist or the value is...
hitTest (MovieClip.hitTest method) public hitTest() : Boolean Evaluates the movie clip to see if it overlaps or intersects with the hit area that the target coordinate parameters identify. Usage 1: Compares the x and y coordinates to the shape or bounding box of the specified instance, according to the setting.
See also getBounds (MovieClip.getBounds method) globalToLocal (MovieClip.globalToLocal method) localToGlobal (MovieClip.localToGlobal method) lineGradientStyle (MovieClip.lineGradientStyle method) public lineGradientStyle(fillType:String, colors:Array, alphas:Array, ratios:Array, matrix:Object, [spreadMethod:String], [interpolationMethod:String], [focalPointRatio:Number]) : Void Specifies a line style that Flash uses for subsequent calls to the lineTo() curveTo() methods until you call the method or the method with lineStyle()
Page 882
For example, for a linear gradient that includes two colors, blue and green, the following figure illustrates the placement of the colors in the gradient based on different values in the array: ratios Gradient ratios [0, 127] [0, 255] [127, 255] The values in the array must increase, sequentially;...
Page 883
This code draws the following image onscreen: matrixType The properties indicate the following: is the string " ", is the horizontal matrixType position relative to the registration point of the parent clip for the upper-left corner of the gradient, is the vertical position relative to the registration point of the parent clip for the upper-left corner of the gradient, is the width of the gradient, is the height of the...
Page 884
[optional] - A Number that controls the location of the focal focalPointRatio:Number point of the gradient. The value 0 means the focal point is in the center. The value 1 means the focal point is at one border of the gradient circle. The value -1 means that the focal point is at the other border of the gradient circle.
This code draws the following image (the image is scaled by 50%): See also beginGradientFill (MovieClip.beginGradientFill method) lineStyle (MovieClip.lineStyle method) lineTo (MovieClip.lineTo method) moveTo (MovieClip.moveTo method) lineStyle (MovieClip.lineStyle method) public lineStyle(thickness:Number, rgb:Number, alpha:Number, pixelHinting:Boolean, noScale:String, capsStyle:String, jointStyle:String, miterLimit:Number) : Void Specifies a line style that Flash uses for subsequent calls to the lineTo() curveTo()
Page 886
- A hexadecimal color value of the line; for example, red is 0xFF0000, blue is rgb:Number 0x0000FF, and so on. If a value isn't indicated, Flash uses 0x000000 (black). - An integer that indicates the alpha value of the line's color; valid values are 0 alpha:Number to 100.
Page 887
Notice that for set to , you can limit the length of the miter point by jointStyle "miter" using the parameter. miterLimit - Added in Flash Player 8. A number that indicates the limit at which a miterLimit:Number miter is cut off. Valid values range from 1 to 255 (and values outside of that range are rounded to 1 or 255).
If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example. See also beginFill (MovieClip.beginFill method) beginGradientFill (MovieClip.beginGradientFill method) clear (MovieClip.clear method) curveTo (MovieClip.curveTo method) lineTo (MovieClip.lineTo method) moveTo (MovieClip.moveTo method)
See also beginFill (MovieClip.beginFill method) createEmptyMovieClip (MovieClip.createEmptyMovieClip method) endFill (MovieClip.endFill method) lineStyle (MovieClip.lineStyle method) moveTo (MovieClip.moveTo method) loadMovie (MovieClip.loadMovie method) public loadMovie(url:String, [method:String]) : Void Loads a SWF, JPEG, GIF, or PNG file into a movie clip in Flash Player while the original SWF file is playing.
Page 890
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis You can extend the methods and event handlers of the MovieClip class by creating a subclass.
Reads data from an external file and sets the values for variables in the movie clip. The external file can be a text file that Macromedia ColdFusion generates, a CGI script, an Active Server Page (ASP), a PHP script, or any other properly formatted text file. The file can contain any number of variables.
Page 892
In SWF files of any version running in Flash Player 7 or later, must be in exactly the same domain as the SWF file that is issuing this call. For example, a SWF file at www.someDomain.com can load data only from sources that are also at www.someDomain.com.
The params.txt file includes the following text: var1="hello"&var2="goodbye"&done="done" method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also loadMovie (MovieClip.loadMovie method)
Page 894
For example, if you create a movie clip that is positioned at the point (_x:100, _y:100), and you pass a local point representing a point near the top-left corner of the movie clip (x:10, y:10) to the method, the method should convert the x and y values to localToGlobal() global coordinates, which in this case is (x:110, y:110).
this.stopDrag(); method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also globalToLocal (MovieClip.globalToLocal method) _lockroot (MovieClip._lockroot property) public _lockroot : Boolean A Boolean value that specifies what refers to when a SWF file is loaded into a movie...
Page 896
Example In the following example, lockroot.fla has applied to the main SWF file. If the _lockroot SWF file is loaded into another FLA document, always refers to the scope of _root lockroot.swf, which helps prevent conflicts. Place the following ActionScript on the main Timeline of lockroot.fla: this._lockroot = true;...
Page 897
which traces the following information: from current SWF file dumpRoot -> [type Function] $version -> WIN 7,0,19,0 nolockroot_mc -> _level0.nolockroot_mc lockroot_mc -> _level0.lockroot_mc from nolockroot.swf myVar -> 1 i -> lockroot_mc dumpRoot -> [type Function] $version -> WIN 7,0,19,0 nolockroot_mc -> _level0.nolockroot_mc lockroot_mc ->...
See also _root property _lockroot (MovieClip._lockroot property) attachMovie (MovieClip.attachMovie method) loadMovie (MovieClip.loadMovie method) onLoadInit (MovieClipLoader.onLoadInit event listener) menu (MovieClip.menu property) public menu : ContextMenu Associates the specified ContextMenu object with the movie clip. The ContextMenu class lets you modify the context menu that appears when the user right-clicks (Windows) or Control- clicks (Macintosh) in Flash Player.
moveTo (MovieClip.moveTo method) public moveTo(x:Number, y:Number) : Void Moves the current drawing position to (x, y). If any of the parameters are missing, this method fails and the current drawing position is not changed. You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
Example The following example lets you right-click (Windows) or Control-click (Macintosh) a movie clip on the Stage and select from the context menu to view information about that Info instance. Add several movie clips with instance names, and then add the following ActionScript to your AS or FLA file: var menu_cm:ContextMenu = new ContextMenu();...
See also nextFrame function prevFrame function prevFrame (MovieClip.prevFrame method) onData (MovieClip.onData handler) onData = function() {} Invoked when a movie clip receives data from a call or a MovieClip.loadVariables() call. You must define a function that executes when the event MovieClip.loadMovie() handler is invoked.
onDragOut (MovieClip.onDragOut handler) onDragOut = function() {} Invoked when the mouse button is pressed and the pointer rolls outside the object. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
onEnterFrame (MovieClip.onEnterFrame handler) onEnterFrame = function() {} Invoked repeatedly at the frame rate of the SWF file. The function that you assign to the event handler is processed before any other ActionScript code that is attached onEnterFrame to the affected frames. You must define a function that executes when the event handler is invoked.
Example The following example defines a function for the method that sends a onKeyDown() trace() action to the Output panel. Create a movie clip called my_mc and add the following ActionScript to your FLA or AS file: my_mc.onKeyDown = function () { trace ("key was pressed");...
Example The following example defines a function for the method that sends a onKeyUp trace() action to the Output panel: my_mc.onKeyUp = function () { trace ("onKey called"); The following example sets input focus: my_mc.focusEnabled = true; Selection.setFocus(my_mc); See also getAscii (Key.getAscii method) getCode (Key.getCode method) onKeyDown...
Tab between the two instances, and information displays in the Output panel. See also onSetFocus (MovieClip.onSetFocus handler) onLoad (MovieClip.onLoad handler) onLoad = function() {} Invoked when the movie clip is instantiated and appears in the timeline. You must define a function that executes when the event handler is invoked.
See also loadMovie (MovieClip.loadMovie method) onClipEvent handler MovieClipLoader onMouseDown (MovieClip.onMouseDown handler) onMouseDown = function() {} Invoked when the mouse button is pressed. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
Availability: ActionScript 1.0; Flash Player 6 Example The following example defines a function for the method that sends a onMouseUp() trace() action to the Output panel: my_mc.onMouseUp = function () { trace ("onMouseUp called"); onPress (MovieClip.onPress handler) onPress = function() {} Invoked when the user clicks the mouse while the pointer is over a movie clip.
onReleaseOutside (MovieClip.onReleaseOutside handler) onReleaseOutside = function() {} Invoked after a user presses the mouse button inside the movie clip area and then releases it outside the movie clip area. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
onRollOver (MovieClip.onRollOver handler) onRollOver = function() {} Invoked when user moves the pointer over a movie clip area. You must define a function that executes when the event handler is invoked. You can define the function on the timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library.
Example The following example displays information about the movie clip that receives keyboard focus, and the instance that previously had focus. Two movie clips, called my_mc are on the Stage. Add the following ActionScript to your AS or FLA document: other_mc my_mc.onRelease = Void;...
You recognize a greater performance benefit with a movie clip that would have many transparent regions if were not set. opaqueBackground Note:The opaque background region is not matched in a method that has the hitTest() parameter set to shapeFlag true Availability: ActionScript 1.0;...
Example The following example traces the reference to a movie clip and its parent timeline. Create a movie clip with the instance name , and add it to the main timeline. Add the following my_mc ActionScript to your FLA or AS file: my_mc.onRelease = function() { trace("You clicked the movie clip: "+this);...
See also play function gotoAndPlay (MovieClip.gotoAndPlay method) gotoAndPlay function prevFrame (MovieClip.prevFrame method) public prevFrame() : Void Sends the playhead to the previous frame and stops it. You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
_quality (MovieClip._quality property) public _quality : String Sets or retrieves the rendering quality used for a SWF file. Device fonts are always aliased and therefore are unaffected by the property. _quality You can set the to the following values: _quality Value Description Graphic anti-...
Page 916
Value Description Graphic anti- Bitmap smoothing aliasing " " High rendering quality. Graphics are anti- Flash Player 8: Bitmaps HIGH This setting is the aliased using a 4 x 4 are smoothed based on the default rendering pixel grid. parameter used smoothing quality setting that Flash uses.
See also _quality property removeMovieClip (MovieClip.removeMovieClip method) public removeMovieClip() : Void Removes a movie clip instance created with duplicateMovieClip() , or MovieClip.duplicateMovieClip() MovieClip.createEmptyMovieClip() MovieClip.attachMovie() This method does not remove a movie clip assigned to a negative depth value. Movie clips created in the authoring tool are assigned negative depth values by default.
Example The following example creates a movie clip instance dynamically. When you run triangle the SWF file, click the movie clip to rotate it. this.createEmptyMovieClip("triangle", this.getNextHighestDepth()); triangle.beginFill(0x0000FF, 100); triangle.moveTo(100, 100); triangle.lineTo(100, 150); triangle.lineTo(150, 100); triangle.lineTo(100, 100); triangle.onMouseUp= function() { this._rotation += 15; method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later.
Page 920
You can think of the eight regions outside of the center (defined by the rectangle) as being like a picture frame that has special rules applied to it when the movie clip is scaled. When the property is set and a movie clip is scaled, all text and child movie clips scale9Grid scale normally, regardless of which regions of the scale9 grid they are located in;...
Page 921
In the Macromedia Flash authoring environment, you can enable guides for 9-slice scaling for a movie clip symbol in a library. This lets you graphically determine the for the scale9grid object.
Page 922
Example The following creates a movie clip that contains a 20-pixel line (which forms a border) and a gradient fill. The movie clip scales based on the mouse position, and because of the set for the movie clip, the thickness of the 20-pixel line does not vary when the scale9Grid movie clip scales (although the gradient in the movie clip does scale): import flash.geom.Rectangle;...
scrollRect (MovieClip.scrollRect property) public scrollRect : Object property allows you to quickly scroll movie clip content and have a window scrollRect viewing larger content. Text fields and complex content scroll much faster, because pixel level copying is used to scroll data instead of regenerating the entire movie clip from vector data. To see the performance gain, use in conjunction with a movie clip that has scrollRect...
content.lineTo(0, 300); content.lineTo(0, 0); content.endFill(); content._rotation = -90; mc.onEnterFrame = function() { this.content._y += 1; return mc; function performs the following steps: setUpContainer() Create a MovieClip named container Create a MovieClip named inside of content container Draw a gradient shape inside of the MovieClip content Return a reference to the...
Parameters - The instance name of a movie clip to be a mask. This can be a String or a mc:Object MovieClip. Example The following code uses the movie clip to mask the movie circleMask_mc theMaskee_mc clip: theMaskee_mc.setMask(circleMask_mc); _soundbuftime (MovieClip._soundbuftime property) public _soundbuftime : Number Specifies the number of seconds a sound prebuffers before it starts to stream.
[optional] - Value relative to the coordinates of the movie clip's parent that top:Number specify a constraint rectangle for the movie clip. [optional] - Value relative to the coordinates of the movie clip's parent that right:Number specify a constraint rectangle for the movie clip. [optional] - Value relative to the coordinates of the movie clip's parent that bottom:Number specify a constraint rectangle for the movie clip.
Example The following example shows how to stop a movie clip named aMovieClip aMovieClip.stop(); See also stop function stopDrag (MovieClip.stopDrag method) public stopDrag() : Void Ends a method. A movie clip that was made draggable with that MovieClip.startDrag() method remains draggable until a method is added, or until another movie clip stopDrag() becomes draggable.
swapDepths (MovieClip.swapDepths method) public swapDepths(target:Object) : Void Swaps the stacking, or depth level (z-order), of this movie clip with the movie clip that is specified by the parameter, or with the movie clip that currently occupies the depth target level that is specified in the parameter.
tabChildren (MovieClip.tabChildren property) public tabChildren : Boolean Determines whether the children of a movie clip are included in the automatic tab ordering. If property is , the children of a movie clip are included in tabChildren undefined true automatic tab ordering. If the value of , the children of a movie clip are tabChildren false...
tabEnabled (MovieClip.tabEnabled property) public tabEnabled : Boolean Specifies whether the movie clip is included in automatic tab ordering. It is undefined default. If the property is , the object is included in automatic tab ordering tabEnabled undefined only if it defines at least one movie clip handler, such as .
property must be a positive integer. The objects are ordered according to their tabIndex properties, in ascending order. An object with a value of precedes an tabIndex tabIndex object with a value of . The custom tab ordering disregards the hierarchical tabIndex relationships of objects in a SWF file.
_totalframes (MovieClip._totalframes property) public _totalframes : Number [read-only] Returns the total number of frames in the movie clip instance specified in the MovieClip parameter. Availability: ActionScript 1.0; Flash Player 4 Example In the following example, two movie clip buttons control the Timeline. The button prev_mc moves the playhead to the previous frame, and the...
Example The following example sets the property for three movie clips on the Stage. trackAsMenu Click a movie clip and release the mouse button on a second movie clip to see which instance receives the event. myMC1_mc.trackAsMenu = true; myMC2_mc.trackAsMenu = true; myMC3_mc.trackAsMenu = false;...
Page 934
myNewDisplayObj.transform = myOldDisplayObj.transform; The new movie clip, , now has the same values for its matrix, color myNewDisplayObj transform, and pixel bounds as the old movie clip, myOldDisplayObj Availability: ActionScript 1.0; Flash Player 8 Example The following example shows how to use a movie clip's property to access and transform modify a movie clip's location by using Matix positioning.
unloadMovie (MovieClip.unloadMovie method) public unloadMovie() : Void Removes the contents of a movie clip instance. The instance properties and clip handlers remain. To remove the instance, including its properties and clip handlers, use MovieClip.removeMovieClip() You can extend the methods and event handlers of the MovieClip class by creating a subclass. Availability: ActionScript 1.0;...
Output panel. this.createEmptyMovieClip("image_mc", 1); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace("_url: "+target_mc._url); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.macromedia.com/images/shared/product_boxes/ 112x112/box_studio_112x112.jpg", image_mc); The following example assigns the ContextMenu object to the movie clip. menu_cm image_mc...
The MovieClipLoader class used in these examples requires Flash Player 7 or later. The method used in these examples requires Flash Player 7 MovieClip.getNextHighestDepth() or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method.
Example The following example sets the property for two movie clips called _visible myMC1_mc . The property is set to for one instance, and for the other. Notice that myMC2_mc true false instance cannot be clicked after the property is set to myMC1_mc _visible false...
_x (MovieClip._x property) public _x : Number An integer that sets the x coordinate of a movie clip relative to the local coordinates of the parent movie clip. If a movie clip is in the main Timeline, its coordinate system refers to the upper-left corner of the Stage as (0, 0).
Example The following example returns the current x and y coordinates of the mouse on the Stage ) and in relation to a movie clip on the Stage called _level0 my_mc this.createTextField("mouse_txt", this.getNextHighestDepth(), 0, 0, 150, 66); mouse_txt.html = true; mouse_txt.multiline = true;...
Example The following example attaches a movie clip with the linkage identifier to a SWF cursor_id file. The movie clip is called , and it is used to replace the default mouse pointer. cursor_mc The following ActionScript sets the current coordinates of the movie clip instance to the position of the mouse pointer: this.attachMovie("cursor_id", "cursor_mc", this.getNextHighestDepth(), {_x:_xmouse, _y:_ymouse});...
mouse_txt.htmlText += "</textformat>"; method used in this example requires Flash Player MovieClip.getNextHighestDepth() 7 or later. If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method. MovieClip.getNextHighestDepth() See also Mouse _xmouse (MovieClip._xmouse property) _yscale (MovieClip._yscale property) public _yscale : Number Sets the vertical scale (...
this._yscale = 200; box_mc.onRollOut = function() { this._xscale = 100; this._yscale = 100; this._x += this._width/2; this._y += this._height/2; See also _height (MovieClip._height property) _x (MovieClip._x property) _xscale (MovieClip._xscale property) _y (MovieClip._y property) MovieClipLoader Object +-MovieClipLoader public class MovieClipLoader extends Object This class lets you implement listener callbacks that provide status information while SWF, JPEG, GIF, and PNG files are being loaded into movie clips.
Page 945
Availability: ActionScript 1.0; Flash Player 7 Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Event summary Event Description Invoked when a file that was loaded with MovieClipLoader.loadClip() onLoadComplete is completely downloaded. function([target _mc:MovieClip], [httpStatus:Numb...
Constructor summary Signature Description Creates a MovieClipLoader object that you can use to implement a MovieClipLoader() number of listeners to respond to events while a SWF, JPEG, GIF, or PNG file is downloading. Method summary Modifiers Signature Description Registers an object to receive notification when a addListener(listener MovieClipLoader event handler is invoked.
Page 947
Parameters - An object that listens for a callback notification from the listener:Object event handlers. MovieClipLoader Returns - A Boolean value. Returns if the listener was established successfully; Boolean true otherwise false Example The following example loads an image into a movie clip called .
getProgress (MovieClipLoader.getProgress method) public getProgress(target:Object) : Object Returns the number of bytes loaded and the total number of bytes of a file that is being loaded by using ; for compressed movies, returns the number of MovieClipLoader.loadClip() compressed bytes. The method lets you explicitly request this information, getProgress instead of (or in addition to) writing a...
var progress:Object = mcLoader.getProgress(image); trace("bytesLoaded: " + progress.bytesLoaded + " bytesTotal: " + progress.bytesTotal); if(progress.bytesLoaded == progress.bytesTotal) { clearInterval(interval.id); If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example.
Page 950
System.security.allowDomain() For more information, see the following: Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis ActionScript classes...
Page 951
Availability: ActionScript 1.0; Flash Player 7 - Support for unanimated GIF files, PNG files, and progressive JPEG files is available as of Flash Player 8. Parameters - The absolute or relative URL of the SWF, JPEG, GIF, or PNG file to be url:String loaded.
MovieClipLoader constructor public MovieClipLoader() Creates a MovieClipLoader object that you can use to implement a number of listeners to respond to events while a SWF, JPEG, GIF, or PNG file is downloading. Availability: ActionScript 1.0; Flash Player 7 Example MovieClipLoader.loadClip() See also addListener (MovieClipLoader.addListener method) loadClip...
Page 953
Availability: ActionScript 1.0; Flash Player 7 - Support for unanimated GIF files, PNG files, and progressive JPEG files is available as of Flash Player 8. Parameters [optional] - A movie clip loaded by the target_mc:MovieClip method. MovieClipLoader.loadClip() [optional] - (Flash Player 8 only) The HTTP status code returned by httpStatus:Number the server.
See also addListener (MovieClipLoader.addListener method) loadClip (MovieClipLoader.loadClip method) onLoadStart (MovieClipLoader.onLoadStart event listener) onLoadError (MovieClipLoader.onLoadError event listener) onLoadInit (MovieClipLoader.onLoadInit event listener) onLoadError (MovieClipLoader.onLoadError event listener) onLoadError = function(target_mc:MovieClip, errorCode:String, [httpStatus:Number]) {} Invoked when a file loaded with has failed to load. This MovieClipLoader.loadClip() listener can be invoked for various reasons;...
Page 955
Parameters - A movie clip loaded by the target_mc:MovieClip MovieClipLoader.loadClip() method. - A string that explains the reason for the failure, either errorCode:String "URLNotFound" "LoadNeverCompleted" [optional] - (Flash Player 8 only) The HTTP status code returned by httpStatus:Number the server. For example, a status code of 404 indicates that the server has not found anything that matches the requested URI.
onLoadInit (MovieClipLoader.onLoadInit event listener) onLoadInit = function([target_mc:MovieClip]) {} Invoked when the actions on the first frame of the loaded clip have been executed. When this listener has been invoked, you can set properties, use methods, and otherwise interact with the loaded movie. Call this listener on a listener object that you add by using MovieClipLoader.addListener() The value for identifies the movie clip for which this call is being made.
Page 957
this.createEmptyMovieClip("tester_mc", 1); var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { trace("movie loaded"); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.yourserver.com/your_movie.swf", tester_mc); If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example.
- The total number of bytes in the file being loaded. totalBytes:Number Example The following example creates a movie clip, a new instance, and an MovieClipLoader anonymous event listener. It periodically outputs the progress of a load and finally provides notification when the load is complete and the asset is available to ActionScript.
Page 959
Parameters [optional] - A movie clip loaded by the target_mc:MovieClip method. MovieClipLoader.loadClip() Example The following example loads an image into a movie clip instance called . The image_mc events are used to determine how long it takes to load the onLoadInit onLoadComplete image.
removeListener (MovieClipLoader.removeListener method) public removeListener(listener:Object) : Boolean Removes the listener that was used to receive notification when a event MovieClipLoader handler was invoked. No further loading messages will be received. Availability: ActionScript 1.0; Flash Player 7 Parameters - A listener object that was added by using listener:Object MovieClipLoader.addListener() Returns...
image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.helpexamples.com/flash/images/ image1.jpg", image_mc); stop_button.clickHandler = function() { trace("Stopping..."); start_button.enabled = true; stop_button.enabled = false; image_mcl.removeListener(mclListener); stop_button.enabled = false; If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example.
target_mc._y = 100; target_mc.onRelease = function() { trace("Unloading clip..."); trace("\t name: "+target_mc._name); trace("\t url: "+target_mc._url); image_mcl.unloadClip(target_mc); var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc); If your SWF file includes a version 2 component, use the version 2 component's DepthManager class instead of the method, which is MovieClip.getNextHighestDepth() used in this example.
Constructor summary Signature Description Creates a NetConnection object that you can use in conjunction with NetConnection() a NetStream object to play back local streaming video (FLV) files. Method summary Modifiers Signature Description Opens a local connection through which you can play connect(targetURI:St back video (FLV) files from an HTTP address or from ring) : Boolean...
Page 964
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 7 - Note: This method is also supported in Flash Player 6 when used with Flash Communication Server.
NetConnection constructor public NetConnection() Creates a NetConnection object that you can use in conjunction with a NetStream object to play back local streaming video (FLV) files. After creating the NetConnection object, use to make the actual connection. NetConnection.connect() Playing external FLV files provides several advantages over embedding video in a Flash document, such as better performance and memory management, and independent video and Flash frame rates.
Page 966
Property summary Modifiers Property Description The number of seconds of data currently in the buffer. bufferLength:Number [read-only] The number of seconds assigned to the buffer by bufferTime:Number [read-only] NetStream.setBufferTime(). The number of bytes of data that have been loaded bytesLoaded:Number [read-only] into the player.
Method summary Modifiers Signature Description Stops playing all data on the stream, sets the close() : Void NetStream.time property to 0, and makes the stream available for another use. Pauses or resumes playback of a stream. pause([flag:Boolean] ) : Void Begins playback of an external video (FLV) file.
See also bytesTotal (NetStream.bytesTotal property) bufferLength (NetStream.bufferLength property) bytesTotal (NetStream.bytesTotal property) public bytesTotal : Number [read-only] The total size in bytes of the file being loaded into the player. Availability: ActionScript 1.0; Flash Player 7 Example The following example creates a progress bar using the Drawing API and the bytesLoaded properties that displays the loading progress of video1.flv into the video bytesTotal...
var loaded_interval:Number = setInterval(checkBytesLoaded, 500, stream_ns); function checkBytesLoaded(my_ns:NetStream) { var pctLoaded:Number = Math.round(my_ns.bytesLoaded/my_ns.bytesTotal 100); loaded_txt.text = Math.round(my_ns.bytesLoaded/1000)+" of "+Math.round(my_ns.bytesTotal/1000)+" KB loaded ("+pctLoaded+"%)"; progressBar_mc.bar_mc._xscale = pctLoaded; if (pctLoaded>=100) { clearInterval(loaded_interval); If your SWF file includes a version 2 component, use the version 2 components DepthManager class instead of the method, which is MovieClip.getNextHighestDepth()
close_btn.onRelease = function(){ stream_ns.close(); See also pause (NetStream.pause method) play (NetStream.play method) currentFps (NetStream.currentFps property) public currentFps : Number [read-only] The number of frames per second being displayed. If you are exporting FLV files to be played back on a number of systems, you can check this value during testing to help you determine how much compression to apply when exporting the file.
NetStream constructor public NetStream(connection:NetConnection) Creates a stream that can be used for playing FLV files through the specified NetConnection object. Availability: ActionScript 1.0; Flash Player 7 - Note: This class is also supported in Flash Player 6 when used with Flash Communication Server. For more information, see the Flash Communication Server documentation.
Page 975
event handler receives an object with these properties: onCuePoint() Property Description name The name given to the cue point when it was embedded in the FLV file. time The time in seconds at which the cue point occurred in the video file during playback.
Page 976
var ns:NetStream = new NetStream(nc); ns.onCuePoint = function(infoObject:Object) trace("onCuePoint:"); for (var propName:String in infoObject) { if (propName != "parameters") trace(propName + " = " + infoObject[propName]); else trace("parameters ="); if (infoObject.parameters != undefined) { for (var paramName:String in infoObject.parameters) trace(" " + paramName + ": " + infoObject.parameters[paramName]);...
time = 16.02 name = point3 --------- The parameter name "lights" is an arbitrary name used by the author of the example video. You can give cue point parameters any name you want. See also onMetaData (NetStream.onMetaData handler) onMetaData (NetStream.onMetaData handler) onMetaData = function(infoObject:Object) {} Invoked when the Flash Player receives descriptive information embedded in the FLV file being played.
ns.play("http://www.helpexamples.com/flash/video/water.flv"); This causes the following information to be displayed: canSeekToEnd = true videocodecid = 4 framerate = 15 videodatarate = 400 height = 215 width = 320 duration = 7.347 The list of properties will vary depending on the software that was used to encode the FLV file.
Page 979
Code property Level property Meaning status Playback has stopped. NetStream.Play.Stop error The FLV passed to the method can't NetStream.Play.Stream play() be found. NotFound error For video downloaded with progressive NetStream.Seek.Invali download, the user has tried to seek or play dTime past the end of the video data that has downloaded thus far, or past the end of the video once the entire file has downloaded.
pause (NetStream.pause method) public pause([flag:Boolean]) : Void Pauses or resumes playback of a stream. The first time you call this method (without sending a parameter), it pauses play; the next time, it resumes play. You might want to attach this method to a button that the user presses to pause or resume playback.
Page 981
Chapter 17, "Understanding Security," in Learning ActionScript 2.0 in Flash The Flash Player 8 Security white paper at http://www.macromedia.com/go/fp8_security The Flash Player 8 Security-Related API white paper at http://www.macromedia.com/go/ fp8_security_apis Availability: ActionScript 1.0; Flash Player 7 - Note: This method is also supported in Flash Player 6 when used with Flash Communication Server.
// Play a file on a server. my_ns.play("http://someServer.someDomain.com/flash/video/orientation.flv"); See also attachAudio (MovieClip.attachAudio method) close (NetStream.close method) onStatus (NetStream.onStatus handler) pause (NetStream.pause method) attachVideo (Video.attachVideo method) seek (NetStream.seek method) public seek(offset:Number) : Void Seeks the keyframe closest to the specified number of seconds from the beginning of the stream.
// Move to a location 30 seconds from the beginning of the stream my_ns.seek(30); // Move backwards three minutes from current location my_ns.seek(my_ns.time - 180); See also time (NetStream.time property) setBufferTime (NetStream.setBufferTime method) public setBufferTime(bufferTime:Number) : Void Specifies how long to buffer messages before starting to display the stream. For example, if you want to make sure that the first 15 seconds of the stream play without interruption, set to 15;...
Page 984
Example The following example displays the current position of the playhead in a dynamically created text field called . Select New Video from the Library options menu to create a video time_txt object instance, and give it an instance name .
Number Object +-Number public class Number extends Object The Number class is a simple wrapper object for the Number data type. You can manipulate primitive numeric values by using the methods and properties associated with the Number class. This class is identical to the JavaScript Number class. The properties of the Number class are static, which means you do not need an object to use them, so you do not need to use the constructor.
Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Constructor summary Signature Description Creates a new Number object. Number(num:Object) Method summary Modifiers Signature Description Returns the string representation of the specified toString(radix:Numbe Number object (myNumber).
This code displays the following values: Number.MIN_VALUE = 4.94065645841247e-324 Number.MAX_VALUE = 1.79769313486232e+308 MIN_VALUE (Number.MIN_VALUE property) public static MIN_VALUE : Number The smallest representable number (double-precision IEEE-754). This number is approximately 5e-324. Availability: ActionScript 1.0; Flash Player 5 Example The following ActionScript displays the largest and smallest representable numbers to the Output panel.
Example This example compares the result of dividing the following values. var posResult:Number = 1/0; if (posResult == Number.POSITIVE_INFINITY) { trace("posResult = "+posResult); // output: posResult = Infinity var negResult:Number = -1/0; if (negResult == Number.NEGATIVE_INFINITY) { trace("negResult = "+negResult); // output: negResult = -Infinity Number constructor public Number(num:Object) Creates a new Number object.
Example This example compares the result of dividing the following values. var posResult:Number = 1/0; if (posResult == Number.POSITIVE_INFINITY) { trace("posResult = "+posResult); // output: posResult = Infinity var negResult:Number = -1/0; if (negResult == Number.NEGATIVE_INFINITY) { trace("negResult = "+negResult); // output: negResult = -Infinity toString (Number.toString method) public toString(radix:Number) : String Returns the string representation of the specified Number object (...
valueOf (Number.valueOf method) public valueOf() : Number Returns the primitive value type of the specified Number object. Availability: ActionScript 1.0; Flash Player 5 Returns - A string. Number Example The following example results in the primative value of the object. numSocks var numSocks = new Number(2);...
Page 991
Constructor summary Signature Description Creates an Object object and stores a reference to the object's Object() constructor method in the object's constructor property. Method summary Modifiers Signature Description Creates a getter/setter property. addProperty(name:Str ing, getter:Function, setter:Function) : Boolean Indicates whether an object has a specified property hasOwnProperty(name: defined.
addProperty (Object.addProperty method) public addProperty(name:String, getter:Function, setter:Function) : Boolean Creates a getter/setter property. When Flash reads a getter/setter property, it invokes the function, and the function's return value becomes the value of . When Flash writes a name getter/setter property, it invokes the function and passes it the new value as a parameter.
Page 993
- The function that is invoked to set the value of the property; this setter:Function parameter is a Function object. If you pass the value for this parameter, the property is null read-only. Returns - A Boolean value: if the property is successfully created; otherwise.
Page 994
The previous example works, but the properties are added to every bookcount bookname instance of the object, which requires having two properties for every instance of the Book object. If there are many properties, such as in a class, they could bookcount bookname, consume a great deal of memory.
The following code can then be placed in a FLA file and will function the same way as it does in the previous examples: var myBook:Book = new Book(); myBook.bookcount = 5; trace("You ordered "+myBook.bookcount+" copies of "+myBook.bookname); See also get statement set statement constructor (Object.constructor property)
hasOwnProperty (Object.hasOwnProperty method) public hasOwnProperty(name:String) : Boolean Indicates whether an object has a specified property defined. This method returns if the true target object has a property that matches the string specified by the parameter, and name otherwise. This method does not check the object's prototype chain and returns false true only if the property exists on the object itself.
var myObj:Object = new Object(); myObj.prop1 = "hello"; trace(myObj.isPropertyEnumerable("prop1")); // Output: true var myArray = new Array(); trace(myArray.isPropertyEnumerable("length")); // Output: false See also for..in statement isPrototypeOf (Object.isPrototypeOf method) public isPrototypeOf(theClass:Object) : Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as an argument.
__proto__ (Object.__proto__ property) public __proto__ : Object Refers to the property of the class (ActionScript 2.0) or constructor function prototype (ActionScript 1.0) used to create the object. The property is automatically __proto__ assigned to all objects when they are created. The ActionScript interpreter uses the __proto__ property to access the property of the object's class or constructor function to find...
prototype (Object.prototype property) public static prototype : Object A reference to the superclass of a class or function object. The property is prototype automatically created and attached to any class or function object you create. This property is static in that it is specific to the class or function you create. For example, if you create a custom class, the value of the property is shared by all instances of the class, and is prototype...
registerClass (Object.registerClass method) public static registerClass(name:String, theClass:Function) : Boolean Associates a movie clip symbol with an ActionScript object class. If a symbol doesn't exist, Flash creates an association between a string identifier and an object class. When an instance of the specified movie clip symbol is placed on the Timeline, it is registered to the class specified by the parameter rather than to the class MovieClip.