ActionScript 2.
Trademarks 1 Step RoboPDF, ActiveEdit, ActiveTest, Authorware, Blue Sky Software, Blue Sky, Breeze, Breezo, Captivate, Central, ColdFusion, Contribute, Database Explorer, Director, Dreamweaver, Fireworks, Flash, FlashCast, FlashHelp, Flash Lite, FlashPaper, Flash Video Encoder, Flex, Flex Builder, Fontographer, FreeHand, Generator, HomeSite, JRun, MacRecorder, Macromedia, MXML, RoboEngine, RoboHelp, RoboInfo, RoboPDF, Roundtrip, Roundtrip HTML, Shockwave, SoundEdit, Studio MX, UltraDev, and WebHelp are eith
Contents Chapter 1: ActionScript language elements. . . . . . . . . . . . . . . . . . 31 Compiler Directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 #endinitclip directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 #include directive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 #initclip directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadMovieNum function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 loadVariables function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 loadVariablesNum function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 mbchr function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 mblength function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
_focusrect property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 _global property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 _highquality property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 _level property. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 maxscroll property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
<> inequality operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 instanceof operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 < less than operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 lt less than (strings) operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 <= less than or equal to operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
if statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .215 implements statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .216 import statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 interface statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .218 intrinsic statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
toString (Array.toString method). . . . . . . . . . . . . . . . . . . . . . . . . . . . .264 UNIQUESORT (Array.UNIQUESORT property) . . . . . . . . . . . . . . .264 unshift (Array.unshift method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265 AsBroadcaster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265 addListener (AsBroadcaster.addListener method) . . . . . . . . . . . .266 broadcastMessage (AsBroadcaster.broadcastMessage method) . . . . .
noise (BitmapData.noise method) . . . . . . . . . . . . . . . . . . . . . . . . . . . .319 paletteMap (BitmapData.paletteMap method) . . . . . . . . . . . . . . . . 320 perlinNoise (BitmapData.perlinNoise method) . . . . . . . . . . . . . . . . 322 pixelDissolve (BitmapData.pixelDissolve method) . . . . . . . . . . . . 324 rectangle (BitmapData.rectangle property) . . . . . . . . . . . . . . . . . . . 326 scroll (BitmapData.scroll method) . . . . . . . . . . . . . . . . . . . . . . . . . . .
onSetFocus (Button.onSetFocus handler). . . . . . . . . . . . . . . . . . . .366 _parent (Button._parent property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 _quality (Button._quality property). . . . . . . . . . . . . . . . . . . . . . . . . . . .368 _rotation (Button._rotation property) . . . . . . . . . . . . . . . . . . . . . . . . .368 scale9Grid (Button.scale9Grid property) . . . . . . . . . . . . . . . . . . . . .369 _soundbuftime (Button._soundbuftime property) . . . . . . . . . . .
hasEmbeddedVideo (capabilities.hasEmbeddedVideo property) . . . . . . . . . . . . . . . . 409 hasIME (capabilities.hasIME property) . . . . . . . . . . . . . . . . . . . . . . . 409 hasMP3 (capabilities.hasMP3 property) . . . . . . . . . . . . . . . . . . . . . 409 hasPrinting (capabilities.hasPrinting property) . . . . . . . . . . . . . . . . .410 hasScreenBroadcast (capabilities.hasScreenBroadcast property) . . . . . . . . . . . . . . . .410 hasScreenPlayback (capabilities.hasScreenPlayback property) .
redOffset (ColorTransform.redOffset property) . . . . . . . . . . . . . . . 439 rgb (ColorTransform.rgb property) . . . . . . . . . . . . . . . . . . . . . . . . . . 440 toString (ColorTransform.toString method) . . . . . . . . . . . . . . . . . . . 441 ContextMenu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 builtInItems (ContextMenu.builtInItems property) . . . . . . . . . . . . . 444 ContextMenu constructor . . . . . . . . . . . . . . . . . . . . . . .
getTime (Date.getTime method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 getTimezoneOffset (Date.getTimezoneOffset method) . . . . . . . . 487 getUTCDate (Date.getUTCDate method) . . . . . . . . . . . . . . . . . . . . 487 getUTCDay (Date.getUTCDay method). . . . . . . . . . . . . . . . . . . . . . 488 getUTCFullYear (Date.getUTCFullYear method). . . . . . . . . . . . . . 488 getUTCHours (Date.getUTCHours method) . . . . . . . . . . . . . . . . . . 489 getUTCMilliseconds (Date.
angle (DropShadowFilter.angle property). . . . . . . . . . . . . . . . . . . . .532 blurX (DropShadowFilter.blurX property) . . . . . . . . . . . . . . . . . . . . .533 blurY (DropShadowFilter.blurY property) . . . . . . . . . . . . . . . . . . . . .534 clone (DropShadowFilter.clone method) . . . . . . . . . . . . . . . . . . . . .535 color (DropShadowFilter.color property) . . . . . . . . . . . . . . . . . . . . .536 distance (DropShadowFilter.distance property) . . . . . . . . . . . . . . .
browse (FileReferenceList.browse method) . . . . . . . . . . . . . . . . . . 588 fileList (FileReferenceList.fileList property) . . . . . . . . . . . . . . . . . . 590 FileReferenceList constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .591 onCancel (FileReferenceList.onCancel event listener) . . . . . . . . . 592 onSelect (FileReferenceList.onSelect event listener). . . . . . . . . . 592 removeListener (FileReferenceList.removeListener method) . . 593 Function . . . . . . . . . . . .
ratios (GradientGlowFilter.ratios property) . . . . . . . . . . . . . . . . . . . . 647 strength (GradientGlowFilter.strength property) . . . . . . . . . . . . . . 650 type (GradientGlowFilter.type property) . . . . . . . . . . . . . . . . . . . . . . 651 IME (System.IME) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .653 addListener (IME.addListener method). . . . . . . . . . . . . . . . . . . . . . .656 ALPHANUMERIC_FULL (IME.ALPHANUMERIC_FULL property) . . . . . .
onKeyDown (Key.onKeyDown event listener) . . . . . . . . . . . . . . . . 686 onKeyUp (Key.onKeyUp event listener) . . . . . . . . . . . . . . . . . . . . . . 687 PGDN (Key.PGDN property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687 PGUP (Key.PGUP property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688 removeListener (Key.removeListener method) . . . . . . . . . . . . . . . 688 RIGHT (Key.RIGHT property). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
loadStringEx (Locale.loadStringEx method) . . . . . . . . . . . . . . . . . .739 setDefaultLang (Locale.setDefaultLang method). . . . . . . . . . . . . .740 setLoadCallback (Locale.setLoadCallback method) . . . . . . . . . . .740 setString (Locale.setString method) . . . . . . . . . . . . . . . . . . . . . . . . . 741 stringIDArray (Locale.stringIDArray property) . . . . . . . . . . . . . . . . .742 Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
rotate (Matrix.rotate method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .777 scale (Matrix.scale method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 780 toString (Matrix.toString method) . . . . . . . . . . . . . . . . . . . . . . . . . . . 780 transformPoint (Matrix.transformPoint method). . . . . . . . . . . . . . . . 781 translate (Matrix.translate method) . . . . . . . . . . . . . . . . . . . . . . . . . . 782 tx (Matrix.tx property) . . . . . . . . . . . . . . .
cacheAsBitmap (MovieClip.cacheAsBitmap property) . . . . . . . . .846 clear (MovieClip.clear method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847 createEmptyMovieClip (MovieClip.createEmptyMovieClip method) . . . . . . . . . . . . . . . .848 createTextField (MovieClip.createTextField method) . . . . . . . . . 850 _currentframe (MovieClip._currentframe property) . . . . . . . . . . . . .852 curveTo (MovieClip.curveTo method) . . . . . . . . . . . . . . . . . . . . . . . .
onDragOver (MovieClip.onDragOver handler) . . . . . . . . . . . . . . . . 902 onEnterFrame (MovieClip.onEnterFrame handler) . . . . . . . . . . . . 903 onKeyDown (MovieClip.onKeyDown handler) . . . . . . . . . . . . . . . . 903 onKeyUp (MovieClip.onKeyUp handler) . . . . . . . . . . . . . . . . . . . . . 904 onKillFocus (MovieClip.onKillFocus handler) . . . . . . . . . . . . . . . . . 905 onLoad (MovieClip.onLoad handler). . . . . . . . . . . . . . . . . . . . . . . . . 906 onMouseDown (MovieClip.
_y (MovieClip._y property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 941 _ymouse (MovieClip._ymouse property) . . . . . . . . . . . . . . . . . . . . . 942 _yscale (MovieClip._yscale property) . . . . . . . . . . . . . . . . . . . . . . . . 943 MovieClipLoader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 944 addListener (MovieClipLoader.addListener method) . . . . . . . . . 946 getProgress (MovieClipLoader.getProgress method) . . . . . .
valueOf (Number.valueOf method) . . . . . . . . . . . . . . . . . . . . . . . . . . 990 Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 990 addProperty (Object.addProperty method) . . . . . . . . . . . . . . . . . . . 992 constructor (Object.constructor property) . . . . . . . . . . . . . . . . . . . . 995 hasOwnProperty (Object.hasOwnProperty method) . . . . . . . . . . 996 isPropertyEnumerable (Object.isPropertyEnumerable method).
contains (Rectangle.contains method) . . . . . . . . . . . . . . . . . . . . . . 1037 containsPoint (Rectangle.containsPoint method). . . . . . . . . . . . . 1038 containsRectangle (Rectangle.containsRectangle method) . . . 1038 equals (Rectangle.equals method) . . . . . . . . . . . . . . . . . . . . . . . . . .1039 height (Rectangle.height property) . . . . . . . . . . . . . . . . . . . . . . . . . .1040 inflate (Rectangle.inflate method) . . . . . . . . . . . . . . . . . . . . . . . . . . .
onStatus (SharedObject.onStatus handler) . . . . . . . . . . . . . . . . . 1092 Sound . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1094 attachSound (Sound.attachSound method) . . . . . . . . . . . . . . . . . 1096 duration (Sound.duration property) . . . . . . . . . . . . . . . . . . . . . . . . . 1097 getBytesLoaded (Sound.getBytesLoaded method) . . . . . . . . . . 1099 getBytesTotal (Sound.getBytesTotal method). . . . . . . . . . . . . . . .
toUpperCase (String.toUpperCase method) . . . . . . . . . . . . . . . . . 1140 valueOf (String.valueOf method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1141 StyleSheet (TextField.StyleSheet) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1142 clear (StyleSheet.clear method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1145 getStyle (StyleSheet.getStyle method) . . . . . . . . . . . . . . . . . . . . . . 1146 getStyleNames (StyleSheet.getStyleNames method). . . . . . . . .
menu (TextField.menu property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1189 mouseWheelEnabled (TextField.mouseWheelEnabled property) . . . . . . . . . . . . . . . . . 1191 multiline (TextField.multiline property) . . . . . . . . . . . . . . . . . . . . . . . 1192 _name (TextField._name property) . . . . . . . . . . . . . . . . . . . . . . . . . . 1192 onChanged (TextField.onChanged handler) . . . . . . . . . . . . . . . . . . 1193 onKillFocus (TextField.onKillFocus handler). . . . . . . . .
TextFormat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1228 align (TextFormat.align property) . . . . . . . . . . . . . . . . . . . . . . . . . . . 1231 blockIndent (TextFormat.blockIndent property) . . . . . . . . . . . . . . 1232 bold (TextFormat.bold property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1232 bullet (TextFormat.bullet property) . . . . . . . . . . . . . . . . . . . . . . . . . . 1233 color (TextFormat.color property) . . .
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1273 _alpha (Video._alpha property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1276 attachVideo (Video.attachVideo method) . . . . . . . . . . . . . . . . . . . .1276 clear (Video.clear method). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1277 deblocking (Video.deblocking property) . . . . . . . . . . . . . . . . . . . . .1278 _height (Video.
cloneNode (XMLNode.cloneNode method). . . . . . . . . . . . . . . . . . 1318 firstChild (XMLNode.firstChild property) . . . . . . . . . . . . . . . . . . . . . 1320 getNamespaceForPrefix (XMLNode.getNamespaceForPrefix method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1322 getPrefixForNamespace (XMLNode.getPrefixForNamespace method) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1323 hasChildNodes (XMLNode.
CHAPTER 1 1 ActionScript language elements This section provides syntax, usage information, and code samples for global functions and properties (those elements that do not belong to an ActionScript class); compiler directives; and for the constants, operators, statements, and keywords used in ActionScript and defined in the ECMAScript (ECMA-262) edition 4 draft language specification.
#include directive #include "[path]filename.as":String Includes the contents of the specified file, as if the commands in the file are part of the calling script. The #include directive is invoked at compile time. Therefore, if you make any changes to an external file, you must save the file and recompile any FLA files that use it. If you use the Check Syntax button for a script that contains #include statements, the syntax of the included files is also checked.
Parameters [path]filename.as:String - filename.asThe filename and optional path for the script to add to the Actions panel or to the current script; .as is the recommended filename extension.
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 order:Number [optional] - A non-negative integer that specifies the execution order of blocks of #initclip code. This is an optional parameter. You must specify the value by using an integer literal (only decimal 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 false A unique Boolean value that represents the opposite of true. Infinity Specifies the IEEE-754 value representing positive infinity. -Infinity Specifies the IEEE-754 value representing negative infinity. NaN A predefined variable with the IEEE-754 value for NaN (not a number).
// 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. The value of this constant is the same as Number.NEGATIVE_INFINITY.
Example The following example shows how newline displays output from the trace() statement on multiple lines. var myName:String = "Lisa", myAge:Number = 30; trace(myName+myAge); trace("-----"); trace(myName+newline+myAge); // output: Lisa30 ----Lisa 30 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. You can use null to represent values that are missing or that do not have a defined data type.
true constant A unique Boolean value that represents the opposite of false. When automatic data typing converts true to a number, it becomes 1; when it converts true to a string, it becomes "true". Availability: ActionScript 1.0; Flash Player 5 Example The following example shows the use of true in an if statement: var shouldExecute:Boolean; // ...
In files published for Flash Player 6 or earlier, the value of Number(undefined) is 0. In files published for Flash Player 7 or later, the value of Number(undefined) is NaN. The value undefined is similar to the special value null. When null and undefined are compared with the equality (==) operator, they compare as equal. However, when null and undefined are compared with the strict equality (===) operator, they compare as not equal. Availability: ActionScript 1.
Global Functions This section contains a set of built-in functions that are available in any part of a SWF file where ActionScript is used. These global functions cover a wide variety of common programming tasks such as working with data types (Boolean(), int(), and so on), producing debugging information (trace()), and communicating with Flash Player or the browser (fscommand()).
Modifiers Signature Description fscommand(command:St Lets the SWF file communicate with either Flash ring, parameters:String) Player or the program hosting Flash Player, such as a web browser. getProperty(my_mc:St Returns the value of the specified property for the ring, property) movie clip my_mc. getTimer() Returns the number of milliseconds that have elapsed since the SWF file started playing.
Modifiers Signature Description loadMovie(url:String Loads a SWF or JPEG file into Flash Player while the , target:Object, original SWF file plays. [method:String]) loadMovieNum(url:Str Loads a SWF or JPEG file into a level in Flash Player ing, level:Number, while the originally loaded SWF file plays.
Modifiers Signature Description Object([value:Object Creates a new empty object or converts the specified ]) number, string, or Boolean value to an object. on(mouseEvent:Object Specifies the mouse event or keypress that triggers ) an action. onClipEvent(movieEve Triggers actions defined for a specific instance of a nt:Object) movie clip. ord(character:String Deprecated since Flash Player 5. This function was ) deprecated in favor of the methods and properties of the String class.
Modifiers Signature Description setInterval(function Calls a function or a method of an object at periodic Reference:Function, intervals while a SWF file plays. interval:Number, [param:Object], objectReference:Obje ct, methodName:String) setProperty(target:O Changes a property value of a movie clip as the movie bject, clip plays.
Modifiers Signature Description trace(expression:Obj Evaluates the expression and outputs the result. ect) unescape(string:Stri Evaluates the parameter x as a string, decodes the ng) string from URL-encoded format (converting all hexadecimal sequences to ASCII characters), and returns the string. unloadMovie(target:O Removes a movie clip that was loaded by means of bject) loadMovie() from Flash Player.
Parameters numElements:Number [optional] - A positive integer that specifies the number of elements in the array. You can specify either numElements or the list of elements, but not both. [optional] - One or more parameters, element0, element1, ... , the values of which can be of any type. Parameters that can accept more than one data type are listed as type Object. You can specify either numElements or the list of elements, but not both. elementN:Object elementN, Returns Array - An array.
Parameters function:String - An identifier for a function. parameter:String - A string that is passed to the function named in the function parameter. Example In the following example, the playMP3() function is defined. The TextField object list_txt is created and set so HTML text can be rendered. The text Track 1 and Track 2 are links inside the text field. The playMP3() function is called when the user clicks either link and plays the MP3 that is passed as a parameter of the asfunction call.
If expression is a string, the return value is as follows: ■ In files published for Flash Player 6 and earlier, the string is first converted to a number. The value is true if the number is not 0, otherwise the return value is false. ■ In files published for Flash Player 7 and later, the result is true if the string has a length greater than 0; the value is false for an empty string.
This example shows a significant difference between use of the Boolean() function and the Boolean class. The Boolean() function creates a Boolean value, and the Boolean class creates 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 number:Number - An ASCII code number. Returns String - The character value of the specified ASCII code. Example The following example converts the number 65 to the letter A and assigns it to the variable myVar: myVar = chr(65); See also fromCharCode (String.
You must clear the interval when you have finished using the function. Create a button called clearInt_btn and use the following ActionScript to clear setInterval(): clearInt_btn.
Example In the following example, a new movie clip instance is created called img_mc. An image is loaded into the movie clip, and then the img_mc clip is duplicated. The duplicated clip is called newImg_mc, and this new clip is moved on the Stage so it does not overlap the original clip, and the same image is loaded into the second clip. this.createEmptyMovieClip("img_mc", this.getNextHighestDepth()); img_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.
Example The following code produces the result someuser%40somedomain%2Ecom: var email:String = "someuser@somedomain.com"; trace(escape(email)); In this example, the at symbol (@) was replaced with %40 and the dot symbol (.) was replaced with %2E. This is useful if you're trying to pass information to a remote server and the data has special characters in it (for example, & or ?), as shown in the following code: var redirectUrl:String = "http:// www.somedomain.
Parameters expression:Object - The name of a variable, property, object, or movie clip to retrieve. This parameter can be either a String or a direct reference to the object instance (i.e use of quotation marks (" ") is optional.) Returns Object - A value, reference to an object or movie clip, or undefined . Example The following example uses eval() to set properties for dynamically named movie clips.
The fscommand() function lets a SWF file communicate with a script in a web page. However, script access is controlled by the web page's allowScriptAccess setting. (You set this attribute in the HTML code that embeds the SWF file—for example, in the PARAM tag for Internet Explorer or the EMBED tag for Netscape. When allowScriptAccess is set to "never", a SWF file cannot access web page scripts.
Availability: ■ None of the commands described in the table are available in web players. ■ All of the commands are available in stand-alone applications, such as projectors. ■ Only allowscale and exec are available in test-movie players. The exec command can contain only the characters A-Z, a-z, 0-9, period (.), and underscore (_). The exec command runs in the subdirectory fscommand only.
Usage 3: The fscommand() function can send messages to Macromedia Director. These messages are interpreted by Lingo (the Director scripting language) as strings, events, or executable Lingo code. If a message is a string or an event, you must write the Lingo code to receive the message from the fscommand() function and carry out an action in Director. For more information, see the Director Support Center at www.macromedia.com/support/ director.
You must add a function to the web page that contains the SWF file. This function, myDocument_DoFSCommand(), waits for an fscommand() call. When fscommand() is triggered in Flash (for example, when a user clicks the button), the command and parameter strings are passed to the myDocument_DoFSCommand()function. You can use the passed strings in your JavaScript or VBScript code in any way you like.
Returns Object - The value of the specified property. Example The following example creates a new movie clip someClip_mc and shows the alpha value (_alpha) for the movie clip someClip_mc in the Output panel: this.createEmptyMovieClip("someClip_mc", 999); trace("The alpha of "+getProperty(someClip_mc, _name)+" is: "+getProperty(someClip_mc, _alpha)); getTimer function getTimer() : Number Returns the number of milliseconds that have elapsed since the SWF file started playing. Availability: ActionScript 1.
Parameters url:String - The URL from which to obtain the document. window:String [optional] - Specifies the window or HTML frame into which the document should load. You can enter the name of a specific window or select from the following reserved target names: specifies the current frame in the current window. ■ _self ■ _blank ■ _parent ■ _top specifies a new window. specifies the parent of the current frame. specifies the top-level frame in the current window.
You can also use GET or POST for sending variables. The following example uses GET to append variables to a URL: var firstName:String = "Gus"; var lastName:String = "Richardson"; var age:Number = 92; myBtn_btn.onRelease = function() { getURL("http://www.macromedia.com", "_blank", "GET"); }; The following ActionScript uses POST to send variables in the HTTP header.
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. Availability: ActionScript 1.
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 scene parameter only on the root Timeline, not within Timelines for movie clips or other objects in the document. Availability: ActionScript 1.0; Flash Player 2 Parameters scene:String [optional] - A string specifying the name of the scene to which the playhead is sent.
ifFrameLoaded function ifFrameLoaded([scene:String], frame) { statement(s); } Deprecated since Flash Player 5. This function has been deprecated. Macromedia recommends that you use the MovieClip._framesloaded property. Checks whether the contents of a specific frame are available locally. Use ifFrameLoaded to start playing a simple animation while the rest of the SWF file downloads to the local computer.
isFinite function isFinite(expression:Object) : Boolean Evaluates expression and returns true if it is a finite number or false if it is infinity or negative infinity. The presence of infinity or negative infinity indicates a mathematical error condition such as division by 0. Availability: ActionScript 1.0; Flash Player 5 Parameters expression:Object - A Boolean value, variable, or other expression to be evaluated. Returns Boolean - A Boolean value.
Example The following code illustrates return values for the isNaN() function: trace( isNaN("Tree") ); // returns true trace( isNaN(56) ); // returns false trace( isNaN(Number.POSITIVE_INFINITY) ) // returns false The following example shows how you can use isNAN() to check whether a mathematical expression contains an error: var dividend:Number; var divisor:Number; divisor = 1; trace( isNaN(dividend/divisor) ); // output: true // The output is true because the variable dividend is undefined.
Returns Number - The length of the specified string or variable. Example The following example returns the length of the string "Hello": length("Hello"); The 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.
For Flash Player 8: ■ Loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox. ■ Loading is not allowed if the calling SWF file is in a network sandbox and the movie clip to be loaded is local. ■ Network sandbox access from the local-trusted or local-with-networking sandbox requires permission from the website by means of a cross-domain policy file.
Example Usage 1: The following example loads the SWF file circle.swf from the same directory and replaces a movie clip called mySquare that already exists on the Stage: loadMovie("circle.swf", mySquare); // equivalent statement (Usage 1): loadMovie("circle.swf", _level0.mySquare); // equivalent statement (Usage 2): loadMovie("circle.swf", "mySquare"); The following example loads the SWF file circle.
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. If you load an animated GIF, only the first frame is displayed. TIP If you want to monitor the progress of the download, use instead of this function. MovieClipLoader.
For Flash Player 8: ■ Loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox. ■ Loading is not allowed if the calling SWF file is in a network sandbox and the movie clip to be loaded is local. ■ Network sandbox access from the local-trusted or local-with-networking sandbox requires permission from the website by means of a cross-domain policy file.
Example The following example loads the JPEG image tim.jpg into level 2 of Flash Player: loadMovieNum("http://www.helpexamples.com/flash/images/image1.jpg", 2); See also unloadMovieNum function, loadMovie function, loadClip (MovieClipLoader.
Parameters url:String - An absolute or relative URL where the variables are located. If the SWF file issuing this call is running in a web browser, url must be in the same domain as the SWF file; for details, see the Description section. target:Object - The target path to a movie clip that receives the loaded variables. method:String [optional] - Specifies an HTTP method for sending variables. The parameter must be the string GET or POST . If there are no variables to be sent, omit this parameter.
loadVariablesNum function loadVariablesNum(url:String, level:Number, [method:String]) : Void Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, ASP, PHP, or a Perl script, and sets the values for variables in a Flash Player level. You can also use this function to update variables in the active SWF file with new values. The text at the specified URL must be in the standard MIME format application/x-wwwstandard format used by CGI scripts).
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 setInterval() function is used to check the progress of the data being loaded into the SWF. The script checks for a variable in the params.txt file named done. loadVariablesNum("params.txt", 2); function checkParamsLoaded() { if (_level2.
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 string:String - The string to measure. Returns Number - The length of the multibyte character string. See also String, length (String.
mbsubstring function mbsubstring(value:String, index:Number, count:Number) : String Deprecated since Flash Player 5. This function was deprecated in favor of String.substr(). Extracts a new multibyte character string from a multibyte character string. Availability: ActionScript 1.0; Flash Player 4 Parameters value:String - The multibyte string from which to extract a new multibyte string. index:Number - The number of the first character to extract.
Availability: ActionScript 1.0; Flash Player 7 Parameters command:String - Any command that you can use in a Flash JavaScript (JSFL) file. Returns String - A string representation of the result, if any, sent by the JavaScript statement. Example The following command will output the number of items in the library of the current document to the trace window. You must run this example as a Flash panel because Flash files can't call MMExecute if they are run in either test movie or the browser.
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(); if (init == undefined) { this.createEmptyMovieClip("nextscene_mc", this.getNextHighestDepth()); nextscene_mc.createTextField("nextscene_txt", this.getNextHighestDepth(), 200, 0, 100, 22); nextscene_mc.nextscene_txt.autoSize = true; nextscene_mc.nextscene_txt.
■ If expression is a string, the function attempts to parse expression as a decimal number with an optional trailing exponent (that is, 1.57505e-3). ■ If expression is NaN, the return value is NaN. ■ If expression is undefined, the return value is as follows: - In files published for Flash Player 6 or earlier, the result is 0. - In files published for Flash Player 7 or later, the result is NaN. Availability: ActionScript 1.0; Flash Player 4 - Behavior changed in Flash Player 7.
Object function Object([value:Object]) : Object Creates a new empty object or converts the specified number, string, or Boolean value to an object. This command is equivalent to creating an object using the Object constructor (see "Constructor for the Object class"). Availability: ActionScript 1.0; Flash Player 5 Parameters value:Object [optional] - A number, string, or Boolean value. Returns Object - An object.
Parameters mouseEvent:Object - A mouseEvent is a trigger called an event . When the event occurs, the statements following it within curly braces ({ }) execute. Any of the following values can be specified for the mouseEvent parameter: The mouse button is pressed while the pointer is over the button. ■ press ■ release ■ releaseOutside While the pointer is over the button, the mouse button is pressed and then rolls outside the button area just before it is released.
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 movieEvent:Object - The movieEvent is a trigger called an event . When the event occurs, the statements following it within curly braces ({}) are executed.
Example The following example uses onClipEvent() with the keyDown movie event and is designed to be attached to a movie clip or button. The keyDown movie event is usually used with one or more methods and properties of the Key object. The following script uses Key.getCode() to find out which key the user has pressed; if the pressed key matches the Key.RIGHT property, the playhead is sent to the next frame; if the pressed key matches the Key.LEFT property, the playhead is sent to the previous frame.
Returns Number - The ASCII code number of the specified character. 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, parseFloat() returns NaN.
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 NaN. 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. Availability: ActionScript 1.
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 stop_mc and play_mc. The ActionScript stops the SWF file's playback when the stop_mc movie clip instance is clicked. Playback resumes when the play_mc instance is clicked. this.stop_mc.onRelease = function() { stop(); }; this.play_mc.
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 target movie clip according to the boundaries specified in the parameter (bmovie, bmax, or bframe).
Parameters - The instance name of a movie clip to print. By default, all of the frames in the target instance can be printed. If you want to print specific frames in the movie clip, assign a #p frame label to those frames. target:Object - A modifier that sets the print area of the movie clip.
printAsBitmap function printAsBitmap(target:Object, boundingBox:String) : Void Prints the target movie clip as a bitmap according to the boundaries specified in the parameter (bmovie, bmax, or bframe). Use printAsBitmap() to print movie clips that contain frames with objects that use transparency or color effects. The printAsBitmap() action prints at the highest available resolution of the printer in order to maintain as much definition and quality as possible.
Example The following example prints all of the printable frames in holder_mc with a print area 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.
boundingBox:String - A modifier that sets the print area of the movie clip. Enclose this 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 for all of the printable frames in the movie clip. Assign a #b frame label to the frame whose bounding box you want to use as the print area.
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 level:Number - The level in Flash Player to print. By default, all of the frames in the level are printed. If you want to print specific frames in the level, assign a #p frame label to those frames.
Example The following use of random() returns a value of 0, 1, 2, 3, or 4: random(5); See also random (Math.random method) removeMovieClip function removeMovieClip(target:Object) Deletes the specified movie clip. Availability: ActionScript 1.0; Flash Player 4 Parameters - The target path of a movie clip instance created with or the instance name of a movie clip created with MovieClip.attachMovie(), MovieClip.duplicateMovieClip(), or MovieClip.createEmptyMovieClip().
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 use setInterval() to execute any function repetitively over time.
- The time in milliseconds between calls to the functionReference or function passed in. interval:Number methodName If interval is less than the SWF file's frame rate (for example, 10 frames per second [fps] is equal to 100 millisecond intervals), the interval function is called as close in time to the value of interval as possible. Executing long, memory-intensive scripts during an interval causes delays.
Example 2: The following example is similar to the first, except that it calls clearInterval() before setInterval(). This can help prevent unwanted loops and is especially important in event-based systems where the initiating script can be executed multiple times before any particular interval has been cleared.
"powder blue", "mint"); function executeCallback(param:String) { trace("executeCallback intervalId: " + intervalId + " count: " + count + " param: " + param); clearInterval(intervalId); if(count < maxCount) { count++; intervalId = setInterval(this, "executeCallback", duration, colors[count]); } } if(intervalId != null) { clearInterval(intervalId); } intervalId = setInterval(this, "executeCallback", duration, colors[count]); Example 4: The following example shows how to use setInterval() correctly from an A
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; Flash Player 4 Parameters target:Object - The path to the instance name of the movie clip whose property is to be set.
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; Flash Player 8 Parameters enable:Boolean - Specifies whether to enable (true) or disable (false) redraw regions. When set to true, the redraw rectangles are shown.
startDrag function startDrag(target:Object, [lock:Boolean, left:Number, top:Number, right:Number, bottom:Number]) : Void Makes the target movie clip draggable while the movie plays. Only one movie clip can be dragged at a time. After a startDrag() operation is executed, the movie clip remains draggable until it is explicitly stopped by stopDrag() or until a startDrag() action for another movie clip is called. Availability: ActionScript 1.
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. Sounds set to stream will resume playing as the playhead moves over the frames in which they are located.
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 my_mc when the user releases the mouse button: my_mc.onPress = function () { startDrag(this); } my_mc.onRelease = function() { stopDrag(); } See also startDrag function, _droptarget (MovieClip.
String function String(expression:Object) : String Returns a string representation of the specified parameter, as described in the following list: ■ If expression is a number, the return string is a text representation of the number. ■ If expression is a string, the return string is expression. ■ If expression is an object, the return value is a string representation of the object generated by calling the string property for the object, or by calling Object.toString() if no such property exists.
substring function substring(string: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 string:String index:Number - The string from which to extract the new string. - The number of the first character to extract.
Example The following example traces the target path of a movie clip as soon as it loads: this.createEmptyMovieClip("myClip_mc", this.getNextHighestDepth()); trace(targetPath(myClip_mc)); // _level0.myClip_mc See also eval function tellTarget function tellTarget(target:String) { statement(s); } Deprecated since Flash Player 5. Macromedia recommends that you use dot (.) notation and the with statement.
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); _alpha = 15; _xscale = 50; _yscale = 50; } } See also with statement toggleHighQuality function toggleHighQuality() Deprecated since Flash Player 5. This function was deprecated in favor of _quality.
trace function trace(expression:Object) You can use Flash Debug Player to capture output from the trace() function and display the result. Use this statement to record programming notes or to display messages in the Output panel while testing a SWF file. Use the expression parameter to check whether a condition exists, or to display values in the Output panel. The trace() statement is similar to the alert function in JavaScript.
unescape function unescape(string:String) : String Evaluates the parameter x 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 string:String - A string with hexadecimal sequences to escape. Returns String - A string decoded from a URL-encoded parameter.
Example The following example creates a new movie clip called pic_mc and loads an image into that 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())); var listenerObject:Object = new Object(); listenerObject.onLoadInit = function(target_mc) { target_mc.
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 onClipEvent() handler or as part of a function or method that you pass to setInterval(). Flash ignores calls to updateAfterEvent that are not within an onClipEvent() handler or part of a function or method passed to setInterval().
Global Properties summary Modifiers Property Description _accProps Lets you control screen reader accessibility options for SWF files, movie clips, buttons, dynamic text fields, and input text fields at runtime. _focusrect Property (global); specifies whether a yellow rectangle appears around the button or movie clip that has keyboard focus. _global A reference to the global object that holds the core ActionScript classes, such as String, Object, Math, and Array.
_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().
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 _accProps object that represents the entire Flash document, omit the instanceName parameter. The value of _accProps must be an object.
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 (false for Boolean values; empty strings for stringvalues) by deleting the property from the _accProps object, as shownin the following example: my_mc._accProps.silent = true; // set a property // other code here delete my_mc._accProps.silent; // revert to default value The value of _accProps must be an object.
_focusrect property _focusrect = Boolean; Specifies whether a yellow rectangle appears around the button or movie clip that has keyboard focus. If _focusrect is set to its default value of true, then a yellow rectangle appears around the currently focused button or movie clip as the user presses the Tab key to navigate through objects in a SWF file. Specify false if you do not want to show the yellow rectangle. This is a global property that can be overridden for specific instances.
_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.
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 antialiasing; this will smooth bitmaps if the SWF file does not contain animation. Specify 0 (low quality) to prevent anti-aliasing.
Example The following example stops the playhead in the main Timeline of the SWF file sub.swf that is loaded into _level9. The sub.swf file contains animation and is in the same directory as the document that contains the following ActionScript: loadMovieNum("sub.swf", 9); myBtn_btn.onRelease = function() { _level9.stop(); }; You could replace _level9.stop() in the previous example with the following code: _level9.
Example In the following example, there is a movie clip on the Stage with the instance name square_mc. Within that movie clip is another movie clip with an instance name circle_mc. The following ActionScript lets you modify the circle_mc parent instance (which is square_mc) when the circle is clicked. When you are working with relative addressing (using _parent instead of _root), it might be easier to use the Insert Target Path button in the Actions panel at first. this.square_mc.circle_mc.
Value Description Graphic AntiAliasing "HIGH" High rendering quality. Graphics are antialiased using a 4 x 4 This setting is the pixel grid. default rendering quality setting that Flash uses. Bitmap Smoothing Flash Player 8: Bitmaps are smoothed based on the smoothing parameter used in MovieClip.attachBitmap() and MovieClip.beginBitmapFill() calls. Flash Player 6 and 7: Bitmaps are smoothed if the movie clip is static. "BEST" Very high rendering quality.
_root property _root.movieClip _root.action _root.property Specifies or returns a reference to the root movie clip Timeline. If a movie clip has multiple levels, the root movie clip Timeline is on the level containing the currently executing script. For example, if a script in level 1 evaluates _root, _level1 is returned. Specifying _root is the same as using the deprecated slash notation (/) to specify an absolute path within the current level.
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. The scroll property is useful for directing users to a specific paragraph in a long passage or creating scrolling text fields.
Example The following example streams an MP3 file and buffers the sound before it plays for the user. Two text fields are created at runtime to hold a timer and debugging information. The _soundbuftime property is set to buffer the MP3 for 10 seconds. A new Sound object instance is created for the MP3. // create text fields to hold debug information. this.createTextField("counter_txt", this.getNextHighestDepth(), 0, 0, 100, 22); this.createTextField("debug_txt", this.
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(); var abj:ApplyThis = new ApplyThis(); abj.str = "defined in FLA or AS"; trace(obj.addStr.call(abj, null)); //output: defined in FLA or AS trace(obj.addStr.
In the following example, the keyword this references the Circle object: function Circle(radius:Number):Void { this.radius = radius; this.area = Math.PI*Math.pow(radius, 2); } var myCircle = new Circle(4); trace(myCircle.area); In the following statement assigned to a frame inside a movie clip, the keyword this references the current movie clip. // sets the alpha property of the current movie clip to 20 this._alpha = 20; In the following statement inside a MovieClip.
Operator Description & (bitwise AND) Converts expression1 and expression2 to 32-bit unsigned integers, and performs a Boolean AND operation on each bit of the integer parameters. &= (bitwise AND Assigns expression1 the value of expression1& expression2.
Operator Description /*..*/ (block Indicates one or more lines of script comments. comment delimiter) , (comma) Evaluates expression1 , then expression2 , and so on. add (concatenation 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. Concatenates two or more strings.
Operator Description ++ (increment) A pre-increment and post-increment unary operator that adds 1 to expression . != (inequality) Tests for the exact opposite of the equality (== ) operator. <> (inequality) Deprecated since Flash Player 5. This operator has been deprecated. Macromedia recommends that you use the != (inequality) operator. Tests for the exact opposite of the equality (==) operator. instanceof Tests whether object is an instance of classConstructor or a subclass of classConstructor.
Operator Description %= (modulo Assigns expression1 the value of expression1 % expression2. assignment) * (multiplication) Multiplies two numerical expressions. *= (multiplication Assigns expression1 the value of expression1 * expression2. assignment) new Creates a new, initially anonymous, object and calls the function identified by the constructor parameter. ne (not equal Deprecated since Flash Player 5. This operator was deprecated in favor of the != (inequality) operator.
+ addition operator expression1 + expression2 Adds numeric expressions or concatenates (combines) strings. If one expression is a string, all other expressions are converted to strings and concatenated. If both expressions are integers, the sum is an integer; if either or both expressions are floating-point numbers, the sum is a floating-point number. Availability: ActionScript 1.0; Flash Player 4 - In Flash 4, + is only a numeric operator.
Usage 3: Variables associated with dynamic and input text fields have the data type String. In the following example, the variable deposit is an input text field on the Stage. After a user enters a deposit amount, the script attempts to add deposit to oldBalance. However, because deposit is a String data type, the script concatenates (combines to form one string) the variable values rather than summing them. var oldBalance:Number = 1345.23; var currentBalance = deposit_txt.
Example Usage 1: This example uses the+= operator with a string expression and sends "My name is Gilbert" to the Output panel. var x1:String = "My name is "; x1 += "Gilbert"; trace(x1); // output: My name is Gilbert Usage 2: The following example shows a numeric use of the addition assignment (+=) operator: var x:Number = 5; var y:Number = 10; x += y; trace(x); // output: 15 See also + addition operator [] array access operator myArray = [ a0, a1,...
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.
Example The following example shows two ways to create a new empty Array object; the first line uses brackets ([]): var my_array:Array = []; var my_array:Array = new Array(); The following example creates an array called employee_array and uses the trace() statement to send the elements to the Output panel.
= assignment operator expression1 = expression2 Assigns the value of expression2 (the parameter on the right) to the variable, array element, or property in expression1. Assignment can be either by value or by reference. Assignment by value copies the actual value of expression2 and stores it in expression1. Assignment by value is used when a variable is assigned a number or string literal. Assignment by reference stores a reference to expression2 in expression1.
The following example uses assignment by reference to create a new object, and assign a reference to that object to the variable mercury. Assignment by value is then used to assign the value of 3030 to the diameter property of the mercury object: var mercury:Object = new Object(); mercury.diameter = 3030; // in miles trace (mercury.
Operands expression1 : Number - A number. expression2 : Number - A number. Returns Number - The result of the bitwise operation. 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 expression1 : Number - A number. expression2 : Number - A number. Returns Number - The value of expression1 & expression2 .
Operands expression1 : Number - A number or expression to be shifted left. expression2 : Number - A number or expression that converts to an integer from 0 to 31. Returns Number - The result of the bitwise operation. Example In the following example, the integer 1 is shifted 10 bits to the left: x = 1 << 10 The result of this operation is x = 1024. This is because 1 decimal equals 1 binary, 1 binary shifted left by 10 is 10000000000 binary, and 10000000000 binary is 1024 decimal.
Returns Number - The result of the bitwise operation. 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 // shift all x <<= 1; trace(x); // // 4 decimal // 8 decimal = 4; bits one slot to the left.
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.
| bitwise OR operator expression1 | expression2 Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point. The result is a new 32-bit integer.
|= bitwise OR assignment operator expression1 |= expression2 Assigns expression1 the value of expression1 | expression2. For example, the following two statements are equivalent: x |= y; x = x | y; Availability: ActionScript 1.0; Flash Player 5 Operands expression1 : Number - A number or variable. expression2 : Number - A number or variable. Returns Number - The result of the bitwise operation.
>> bitwise right shift operator expression1 >> expression2 Converts expression1 and expression2 to 32-bit integers, and shifts all the bits in expression1 to the right by the number of places specified by the integer that results from the conversion of expression2 . Bits that are shifted off the right end are discarded.
The following example 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.
Example The following commented code uses the bitwise right shift and assignment (>>=) operator.
Returns Number - The result of the bitwise operation. 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 expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression2, but not both, are 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point. The result is a new 32-bit integer.
// 1111 ^ 1001 = 0110 // returns 6 decimal (0110 binary) See also & bitwise AND operator, &= bitwise AND assignment operator, ^= bitwise XOR assignment operator, | bitwise OR operator, |= bitwise OR assignment operator, ~ bitwise NOT operator ^= bitwise XOR assignment operator expression1 ^= expression2 Assigns expression1 the value of expression1 ^ expression2. For example, the following two statements are equivalent: x ^= y; x = x ^ y; Availability: ActionScript 1.
/*..*/ 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. Use the // (comment delimiter) to identify singleline comments. Use the /* comment delimiter to identify comments on multiple successive lines.
, comma operator (expression1 , expression2 [, expressionN... ]) Evaluates expression1, then expression2, and so on. This operator is primarily used with the for loop statement and is often used with the parentheses () operator. Availability: ActionScript 1.0; Flash Player 4 Operands expression1 : Number - An expression to be evaluated. expression2 : Number - An expression to be evaluated. expressionN : Number - Any number of additional expressions to be evaluated.
The following example uses the comma (,) operator without the parentheses () operator and illustrates that the comma operator sequentially evaluates all of the expressions but returns the value of the first expression. The second expression, z++, is evaluated and z is incremented by one.
Returns String - The concatenated string. See also + addition operator ?: conditional operator expression1 ? expression2 : expression3 Instructs Flash to evaluate expression1, and if the value of expression1 is true, it returns the value of expression2; otherwise it returns the value of expression3. Availability: ActionScript 1.0; Flash Player 4 Operands - An expression that evaluates to a Boolean value; usually a comparison expression, such as x < 5.
-- decrement operator --expression expression-- A pre-decrement and post-decrement unary operator that subtracts 1 from the expression . The expression can be a variable, element in an array, or property of an object. The predecrement form of the operator (--expression) subtracts 1 from expression and returns the result. The post-decrement form of the operator (expression--) subtracts 1 from the expression and returns the initial value of expression (the value prior to the subtraction).
Operands expression : Number - A number or a variable that evaluates to a number. Returns Number - The floating-point result of the operation. Example The following statement divides the current width and height of the Stage, and then displays the result in the Output panel. trace(Stage.width/2); trace(Stage.height/2); For a default Stage width and height of 550 x 400, the output is 275 and 150.
See also / division operator . dot operator object.property_or_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. Availability: ActionScript 1.
The following example creates a new movie clip within the _root scope. Then a text field is created inside the movie clip called container_mc. The text field's autoSize property is set to true and then populated with the current date. this.createEmptyMovieClip("container_mc", this.getNextHighestDepth()); this.container_mc.createTextField("date_txt", this.getNextHighestDepth(), 0, 0, 100, 22); this.container_mc.date_txt.autoSize = true; this.container_mc.date_txt.text = new Date(); The dot (.
Example The following example uses the equality (==) operator with an if statement: var a:String = "David", b:String = "David"; if (a == b) { trace("David is David"); } The following examples show the results of operations that compare mixed types: var x:Number = var y:String = trace(x == y); var x:String = var y:String = trace(x == y); var x:String = var y:String = trace(x == y); 5; "5"; // output: true "5"; "66"; // output: false "chris"; "steve"; // output: false The following examples show comparison
Compares two expressions for equality and returns a value of true if the string representation of expression1 is equal to the string representation of expression2, false otherwise. Availability: ActionScript 1.0; Flash Player 4 Operands expression1 : Object - Numbers, strings, or variables. expression2 : Object - Numbers, strings, or variables. Returns Boolean - The result of the comparison.
Example In the following example, the greater than (>) operator is used to determine whether the value of the text field score_txt is greater than 90: if (score_txt.text>90) { trace("Congratulations, you win!"); } else { trace("sorry, try again"); } gt greater than (strings) operator expression1 gt expression2 Deprecated since Flash Player 5. This operator was deprecated in favor of the > (greater than) operator.
Availability: ActionScript 1.0; Flash 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. The following illustrates the conversion of a Flash 4 file containing a numeric quality comparison.
Returns Boolean - The result of the comparison. See also >= greater than or equal to operator ++ increment operator ++expression expression++ A pre-increment and post-increment unary operator that adds 1 to expression . The expression can be a variable, element in an array, or property of an object. The preincrement form of the operator (++expression) adds 1 to expression and returns the result.
Example The following example uses ++ as a post-increment operator to make a while loop run five times: var i:Number = 0; while (i++ < 5) { trace("this is execution " + i); } /* output: this is execution 1 this is execution 2 this is execution 3 this is execution 4 this is execution 5 */ The following example uses ++ as a pre-increment operator: var a:Array = new Array(); var i:Number = 0; while (i < 10) { a.push(++i); } trace(a.
!= inequality operator expression1 != expression2 Tests for the exact opposite of the equality ( ==) operator. If expression1 is equal to expression2 , the result is false. As with the equality (==) operator, the definition of equal depends on the data types being compared, as illustrated in the following list: ■ Numbers, strings, and Boolean values are compared by value. ■ Objects, arrays, and functions are compared by reference.
The following example illustrates comparison by reference with two functions: var a:Function = function() { trace("foo"); }; var b:Function = function() { trace("foo"); }; a(); // foo b(); // foo trace(a != b); // true a = b; a(); // foo b(); // foo trace(a != b); // false // trace statement output: foo foo true foo foo false The following example illustrates comparison by reference with two arrays: var a:Array = [ 1, 2, 3 ]; var b:Array = [ 1, 2, 3 ]; trace(a); // 1, 2, 3 trace(b); // 1, 2, 3 trace(a!=b);
Operands expression1 : Object - A number, string, Boolean value, variable, object, array, or function. expression2 : Object - A number, string, Boolean value, variable, object, array, or function. Returns Boolean - The Boolean result of the comparison. See also != inequality operator instanceof operator object instanceof classConstructor Tests whether object is an instance of classConstructor or a subclass of classConstructor.
< less than operator expression1 < expression2 Compares two expressions and determines whether expression1 is less than expression2; if so, the operator returns true. If expression1 is greater than or equal to expression2, the operator returns false. String expressions are evaluated using alphabetical order; all capital letters come before lowercase letters. Availability: ActionScript 1.0; Flash Player 4 - In Flash 4, < is a numeric operator.
lt less than (strings) operator expression1 lt expression2 Deprecated since Flash Player 5. This operator was deprecated in favor of the < (less than) operator. Compares expression1 to expression2 and returns true if expression1 is less than otherwise. expression2, false Availability: ActionScript 1.0; Flash Player 4 Operands expression1 : Object - Numbers, strings, or variables. expression2 : Object - Numbers, strings, or variables. Returns Boolean - The result of the comparison.
Returns Boolean - The Boolean result of the comparison.
// 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 comment - Any characters.
Operands expression1 : Number - A Boolean value or an expression that converts to a Boolean value. expression2 : Number - A Boolean value or an expression that converts to a Boolean value. Returns Boolean - A Boolean result of the logical operation. Example The following example uses the logical AND (&&) operator to perform a test to determine if a player has won the game. The turns variable and the score variable are updated when a player takes a turn or scores points during the game.
Returns Boolean - A Boolean result of the logical operation. See also && logical AND operator ! logical NOT operator ! expression Inverts the Boolean value of a variable or expression. If expression is a variable with the absolute or converted value true, the value of !expression is false. If the expression x && y evaluates to false, the expression !(x && y) evaluates to true.
not logical NOT operator not expression Deprecated since Flash Player 5. This operator was deprecated in favor of the! (logical NOT) operator. Performs a logical NOT (!) operation in Flash Player 4. Availability: ActionScript 1.0; Flash Player 4 Operands expression : Object - A variable or other expression that converts to a Boolean value. Returns Boolean - The result of the logical operation.
Example The following example uses the logical OR (||) operator in an if statement. The second expression evaluates to true, so the final result is 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"); // output: the logical OR test passed } The message the logical OR test passed appears because one of the conditions in the if statement is true (y>200).
Availability: ActionScript 1.0; Flash Player 4 Operands condition1 : Boolean - An expression that evaluates to true or false. condition2 : Boolean - An expression that evaluates to true or false. Returns Boolean - The result of the logical operation. See also || logical OR operator, | bitwise OR operator % modulo operator expression1 % expression2 Calculates the remainder of expression1 divided by expression2.
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) %= modulo assignment operator expression1 %= expression2 Assigns expression1 the value of expression1 % expression2.
* 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 floatingpoint number. Availability: ActionScript 1.0; Flash Player 4 Operands expression1 : Number - A number or expression that evaluates to a number. expression2 : Number - A number or expression that evaluates to a number. Returns Number - An integer or floating-point number.
Returns - The value of expression1 * expression2 . If an expression cannot be converted to a numeric value, it returns NaN (not a number).
} book1 = new Book("Confederacy of Dunces", 19.95); book2 = new Book("The Floating Opera", 10.95); The following example uses the new operator to create an Array object with 18 elements: 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. This operator was deprecated in favor of the != operator.
This operator is also used to mark blocks of contiguous code associated with flow control statements (for, while, if, else, switch) and functions. Availability: ActionScript 1.0; Flash Player 5 Operands - The object to create. name1,2,...N The names of the properties. value1,2,...N The corresponding values for each name property. object : Object Returns Object - Usage 1: An Object object.
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,...
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 foo(), and then the function bar(), and returns the result of the expression a + b: var a:Number = 1; var b:Number = 2; function foo() { a += b; } function bar() { b *= 10; } trace((foo(), bar(), a + b)); // outputs 23 Usage 3: The following example shows the use of
expression2 : Object - A number, string, Boolean value, variable, object, array, or function. Returns Boolean - The Boolean result of the comparison.
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. The strict inequality operator performs the same as the inequality operator except that data types are not converted. If expression1 is equal to expression2, and their data types are equal, the result is false.
trace(s1 trace(s1 trace(s1 trace(s1 trace(s1 trace(s1 trace(s1 trace(s1 === === === === !== !== !== !== s2); // true s3); // false n); // false b); // false s2); // false s3); // true n); // true b); // true See also ! logical NOT operator, != inequality operator, && logical AND operator, || logical OR operator, == equality operator, === strict equality operator " string delimiter operator "text" When used before and after characters, quotation marks (") indicate that the characters have a literal valu
- 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 expression. Usage 2: When used for subtracting, it performs an arithmetic subtraction on two numerical expressions, subtracting expression2 from expression1. When both expressions are integers, the difference is an integer.
Operands expression1 : Number - A number or expression that evaluates to a number. expression2 : Number - A number or expression that evaluates to a number. Returns Number - The result of the arithmetic operation.
Availability: ActionScript 1.0; Flash Player 6 Operands - An identifier for a variable. type A native data type, class name that you have defined, or interface name. functionName An identifier for a function. parameter An identifier for a function parameter.
Returns - A String representation of the type of expression. The following table shows the results of the typeof operator on each type of expression. String Expression Type Result String string Movie clip movieclip Button object Text field object Number number Boolean boolean Object object Function function See also instanceof operator void operator void expression The void operator evaluates an expression and then discards its value, returning undefined.
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. Statements summary Statement Description break Appears within a loop (for , for..in, do..
Statement Description function Comprises a set of statements that you define to perform a certain task. get Permits implicit getting of properties associated with objects based on classes you have defined in external class files. if Evaluates a condition to determine the next action in a SWF file. implements Specifies that a class must define all the methods declared in the interface (or interfaces) being implemented. import Lets you access classes without specifying their fully qualified names.
break statement break Appears within a loop (for , for..in, do..while or while) or within a block of statements associated with a particular case within a switch statement. When used in a loop, the 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 switch statement. If the expression parameter equals the expression parameter of the switch statement using strict equality (===), then Flash Player will execute statements in the statement(s) parameter until it encounters a break statement or the end of the switch statement. If you use the case statement outside a switch statement, it produces an error and the script doesn't compile.
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. You would then use the new invoice() command to create invoice objects.
Example The following example creates a class called Plant. The Plant constructor takes two parameters. // Filename Plant.as class Plant { // Define property names and types var leafType:String; var bloomSeason:String; // Following line is constructor // because it has the same name as the class function Plant(param_leafType:String, param_bloomSeason:String) { // Assign passed values to properties when new Plant object is created this.leafType = param_leafType; this.
In an external script file or in the Actions panel, use the new operator to create an ImageLoader object. var jakob_mc:MovieClip = this.createEmptyMovieClip("jakob_mc", this.getNextHighestDepth()); var jakob:ImageLoader = new ImageLoader("http://www.helpexamples.com/flash/ images/image1.
In the following do..while loop, continue causes the Flash interpreter to skip the rest of the 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++; continue; } trace(i); i++; } while (i < 10); In a for loop, continue causes the Flash interpreter to skip the rest of the loop body.
default statement default: statements Defines the default case for a switch statement. The statements execute if the expression parameter of the switch statement doesn't equal (using the strict equality [===] operation) any of the expression parameters that follow the case keywords for a given switch statement. A switch is not required to have a default case statement. A default case statement does not have to be last in the list.
delete statement delete reference Destroys the object reference specified by the reference parameter, and returns true if the reference is successfully deleted; false otherwise. This operator is useful for freeing memory used by scripts. You can use the delete operator to remove references to objects. After all 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]; trace(my_array.length); // output: 3 trace(my_array); // output: abc,def,undefined Usage 4: The following example shows the behavior of delete on object references: var ref1:Object = new Object(); ref1.
Availability: ActionScript 1.0; Flash Player 4 Parameters condition:Boolean - The condition to evaluate. The statement(s) within the do block of code are executed as long as the condition parameter evaluates to true . Example The following example uses a do..while loop to evaluate whether a condition is true, and traces myVar until myVar is greater than 5. When myVar is greater than 5, the loop ends.
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(); Availability: ActionScript 2.
If you add an undeclared function, dance , an error is generated, as shown in the following 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'. craig.
Example In the following example, the else condition is used to check whether the age_txt variable is 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 else statement: if (age_txt.
Example The following example uses else if statements to compare score_txt to a specified value: 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; the latter is the superclass.
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 { var numDoors:Number; var color:String; function Vehicle(param_numDoors:Number, param_color:String) { this.numDoors = param_numDoors; this.
The following example instantiates a Car object, calls a method that is defined in the Vehicle class (start()), then calls the method that is overridden by the Car class (stop()), and finally calls a method from the Car class (activateCarAlarm()): var myNewCar:Car = new Car(2, "Red", true); myNewCar.start(); // output: [Vehicle] start myNewCar.stop(); // output: [Car] stop with anti-lock brakes myNewCar.
for statement for(init; condition; next) { statement(s); } Evaluates the init (initialize) expression once and then starts a looping sequence. The looping sequence begins by evaluating the condition expression. If the condition expression evaluates to true, statement is executed and the next expression is evaluated. The looping sequence then begins again with the evaluation of the condition expression.
for..in statement for (variableIterant in object) { statement(s); } Iterates over the properties of an object or elements in an array and executes the statement for each property or element. Methods of an object are not enumerated by the for..in action. Some properties cannot be enumerated by the for..in action. For example, movie clip properties, such as _x and _y, are not enumerated. In external class files, static members are not enumerable, unlike instance members. The for..
The following example uses for..in to iterate over the elements of an array: var myArray:Array = new Array("one", "two", "three"); for (var index in myArray) trace("myArray["+index+"] = " + myArray[index]); // output: myArray[2] = three myArray[1] = two myArray[0] = one The following example uses the typeof operator with for..
You can use this statement to define a function with the specified functionname, parameters, and statement(s). When a script calls a function, the statements in the function's definition are executed. Forward referencing is permitted; within the same script, a function may be declared after it is called. A function definition replaces any previous definition of the same function. You can use this syntax wherever a statement is permitted.
The following function creates a LoadVars object and loads params.txt into the SWF file. When the file successfully loads, variables loaded traces: var myLV:LoadVars = new LoadVars(); myLV.load("params.txt"); myLV.onLoad = function(success:Boolean) { trace("variables loaded"); } get statement function get property () { // your statements here } 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 get method to return the value of the property. See also addProperty (Object.addProperty method) if statement if(condition) { statement(s); } Evaluates a condition to determine the next action in a SWF file.
The following example uses an if statement to evaluate how long it takes a user to click the submit_btninstance in a SWF file. If a user clicks the button more than 10 seconds after the SWF file plays, the condition evaluates to true and the message inside the curly braces ({}) appears in a text field that's created at runtime (using createTextField()). If the user clicks the button less than 10 seconds after the SWF file plays, the condition evaluates to false and a different message appears. this.
import statement import className import packageName.* 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(); // after importing import macr.util.users.
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. ■ Only public members are allowed in an interface definition; instance and class members are not permitted.
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.
The intrinsic keyword was created specifically to enable compile-time type checking for 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 compiletime type checking with previously defined classes, especially if the classes are defined using ActionScript 1.0. This keyword is supported only when used in external script files, not in scripts written in the Actions panel.
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. By default, a variable or function is available to any caller. Use this keyword if you want to restrict access to a variable or function.
As the following code demonstrates, the constructor for the Beta class is able to access the privateProperty property that is inherited from the Alpha class: var myBeta:Beta = new Beta(); // Output: privateProperty is visible only within class and subclasses Attempts to access the privateProperty variable from outside the Alpha class or a class that inherits from the Alpha class result in an error. The following code, which resides outside of any class, causes an error: trace(myBeta.
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 return statement evaluates expressionand returns the result as a value of the function in which it executes. The return statement causes execution to return immediately to the calling function.
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. Implicit get/set methods are syntactic shorthand for the Object.addProperty() method in ActionScript 1.0. Availability: ActionScript 2.
gus.username = "Rupert"; trace(gus.username); // output: Rupert In the following example, the get function executes when the value is traced. The set 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. A variable is a container that holds data. The container is always the same, but the contents can change.
Parameters variableString:String expression - A string that names a variable to hold the value of the parameter. Example In the following example, you assign a value to a variable. You are assigning the value of "Jakob" to the name variable.
Example The following example demonstrates how you can use the static keyword to create a counter that tracks how many instances of the class have been created. Because the numInstances variable is static, it will be created only once for the entire class, not for every single instance. Create a new AS file called Users.
Returns Both forms invoke a function. The function may return any value. Parameters method:Function - The method to invoke in the superclass. - Optional parameters that are passed to the superclass version of the method (syntax 1) or to the constructor function of the superclass (syntax 2). argN switch statement switch (expression){ caseClause: [defaultClause:] } Creates a branching structure for ActionScript statements.
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 catch{} code block. If an exception is not caught by a catch block, the string representation of the thrown value is sent to the Output panel.
try { checkEmail("Joe Smith"); } catch (e) { error_txt.text = e.toString(); } In the following example, a subclass of the Error class is thrown. The checkEmail() function 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.
}] Encloses a block of code in which an error can occur, and then respond to the error. If any code in the try code block throws an error (using the throw statement), control passes to the catch block, if one exists, and then to the finally code block, if one exists. The finally block is always executed, regardless of whether an error was thrown. If code in the try block doesn't throw an error (that is, if the try block completes normally), then the code in the finally block is still executed.
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 finally block is used to delete an ActionScript object, regardless of whether or not an error occurred. Create a new AS file called Account.
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 try code block with multiple, typed catch code blocks. Depending on the type of error that occurred, the try code block throws a different type of object.
Finally, in another AS file or FLA script, the following code invokes the sortRows() method on an instance of the RecordSet class. It defines catch blocks for each type of error that is thrown by sortRows() import RecordSet; var myRecordSet:RecordSet = new RecordSet(); try { myRecordSet.sortRows(); trace("everything is fine"); } catch (e:RecordSetException) { trace(e.toString()); } catch (e:MalformedRecord) { trace(e.toString()); } See also Error var statement var variableName [= value1][...
Parameters variableName:String - An identifier. Example The following ActionScript creates a new array of product names. Array.push adds an element onto the end of the array. If you want to use strict typing, it is essential that you use the var keyword. Without var before product_array, you get errors when you try to use strict typing. var product_array:Array = new Array("MX 2004", "Studio", "Dreamweaver", "Flash", "ColdFusion", "Contribute", "Breeze"); product_array.
Parameters condition:Boolean - An expression that evaluates to true or false. Example In the following example, the while statement is used to test an expression. When the value of i is less than 20, the value of i is traced. When the condition is no longer true, the loop exits. var i:Number = 0; while (i < 20) { trace(i); i += 3; } The following result is displayed in the Output panel.
To find the value of an identifier in the statement(s) parameter, ActionScript starts at the beginning of the scope chain specified by the object and searches for the identifier at each level of the scope chain, in a specific order. The scope chain used by the with statement to resolve identifiers starts with the first item in the following list and continues to the last item: ■ The object specified in the object parameter in the innermost with statement.
The 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); The with statement is useful for accessing multiple items in a scope chain list simultaneously. In the following example, the built-in Math object is placed at the front of the scope chain. Setting Math as a default object resolves the identifiers cos, sin, and PI to Math.cos, Math.sin, and Math.PI, respectively.
2 CHAPTER 2 ActionScript classes Documentation for ActionScript classes includes syntax, usage information, and code samples for methods, properties, and event handlers and listeners that belong to a specific class in ActionScript (as opposed to global functions or properties). The classes are listed alphabetically and include new classes in Flash Player 8 that are found in the flash.* packages. If you are not sure to which class a certain method or property belongs, you can look it up in the Index.
Property summary 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 static isActive() : Boolean Indicates whether an accessibility aid is currently active and the player is communicating with it.
Returns - A Boolean value: true if the Flash Player is communicating with an accessibility aid (usually a screen reader); false otherwise. Boolean 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 updateProperties (Accessibility.updateProperties method), _accProps property, hasAccessibility (capabilities.
See also isActive (Accessibility.isActive method), _accProps property, hasAccessibility (capabilities.hasAccessibility property) arguments Object | +-arguments public class arguments extends Object An arguments object is used to store and access a function's arguments. While inside the function's body it can be accessed with the local arguments variable. The arguments are stored as array elements, the first is accessed as arguments[0], the second as arguments[1], etc. The arguments.
Method summary Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method) callee (arguments.
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. To create an Array object, you use the constructor new Array().
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"; my_array[3] = "April"; Property summary Modifiers Property Description static CASEINSENSITIVE:Numb In the sorting methods, this constant specifies caseer insensitive sorting.
Method summary Modifiers Signature Description concat([value:Object Concatenates the elements specified in the ]) : Array parameters with the elements in an array and creates a new array. join([delimiter:Stri Converts the elements in an array to strings, inserts ng]) : String the specified separator between the elements, concatenates them, and returns the resulting string. pop() : Object Removes the last element from an array and returns the value of that element.
Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.unwatch method), valueOf (Object.valueOf method), watch (Object.watch method) Array constructor public Array([value:Object]) Lets you create an array.
if (my_array[0] == undefined) { // No quotation marks around undefined. trace("undefined is a special value, not a string"); } // Traces: undefined is a special value, not a string. Usage 3: The following example creates the new Array object go_gos_array with an initial length of 5: var go_gos_array:Array = new Array("Belinda", "Gina", "Kathy", "Charlotte", "Jane"); trace(go_gos_array.length); // Returns 5. trace(go_gos_array.join(", ")); // Displays elements.
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 value parameters specify an array, the elements of that array are concatenated, rather than the array itself. The array my_array is left unchanged. Availability: ActionScript 1.0; Flash Player 5 Parameters [optional] - Numbers, elements, or strings to be concatenated in a new array.
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 options parameter in the sort() or sortOn() method. The value of this constant is 2. Availability: ActionScript 1.0; Flash Player 7 See also sort (Array.sort method), sortOn (Array.sortOn method) join (Array.
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 (,). var a_nested_array:Array = new Array(["Europa", "Io", "Callisto"], ["Titan", "Rhea"]); trace(a_nested_array.
// a,b,undefined,undefined,undefined,undefined,undefined,undefined,undefine d,c // 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.
Example The following code creates the array myPets_array array containing four elements, and then 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 method) push (Array.
RETURNINDEXEDARRAY (Array.RETURNINDEXEDARRAY property) public static RETURNINDEXEDARRAY : Number Specifies that a sort returns an indexed array as a result of calling the sort() or sortOn() method. You can use this constant for the options parameter in the sort() or 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. The value of this constant is 8. Availability: ActionScript 1.
Example The following code creates the array myPets_array and then removes the first element from 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); // Displays dog,bird,fish. See also pop (Array.pop method), push (Array.push method), unshift (Array.unshift method) slice (Array.
Example The following example creates an array of five pets and uses slice() to populate a new array 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); // Returns cat,dog. trace(myPets_array); // Returns cat,dog,fish,canary,parrot.
Availability: ActionScript 1.0; Flash Player 5 - Array sorting option added in Flash Player 7. Parameters compareFunction:Object [optional] - A comparison function used to determine the sorting order of elements in an array.
Example Usage 1: The following example shows the use of Array.sort() with and without a value 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. fruits_array.sort(Array.
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. ■ All of the objects have at least one property in common, the values of which can be used to sort the array. Such a property is called a field.
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 fieldName:Object - A string that identifies a field to be used as the sort value, or an array in which the first element represents the primary sort field, the second represents the secondary sort field, and so on.
} // // // // Results: john, omaha john, kansas city bob, omaha rec_array.sortOn(["name", "city"]); for(i=0; i
Performing a case-insensitive, descending sort on the password field produces the following results: my_array.sortOn("password", Array.CASEINSENSITIVE | Array.DESCENDING); // catchy // Bob // barb // abcd Performing a default sort on the age field produces the following results: my_array.sortOn("age"); // 29 // 3 // 35 // 4 Performing a numeric sort on the age field produces the following results: my_array.sortOn("age", Array.NUMERIC); // my_array[0].age = 3 // my_array[1].age = 4 // my_array[2].
Parameters - An integer that specifies the index of the element in the array where the insertion or deletion begins. You can specify a negative integer to specify a position relative to the end of the array (for example, -1 is the last element of the array). startIndex:Number [optional] - An integer that specifies the number of elements to be deleted. This number includes the element specified in the startIndex parameter.
toString (Array.toString method) public toString() : String Returns a string value representing the elements in the specified Array object. Every element in the array, starting with index 0 and ending with the highest index, is converted to a concatenated string and separated by commas. To specify a custom separator, use the Array.join() method. Availability: ActionScript 1.0; Flash Player 5 Returns String - A string. Example The following example creates my_array and converts it to a string.
unshift (Array.unshift method) public unshift(value:Object) : Number Adds one or more elements to the beginning of an array and returns the new length of the array. Availability: ActionScript 1.0; Flash Player 5 Parameters value:Object - One or more numbers, elements, or variables to be inserted at the beginning of the array. Returns Number - An integer representing the new length of the array. Example The following example shows the use of the Array.
Property summary Modifiers Property Description _listeners:Array A list of references to all registered listener objects. [read-only] Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Modifiers Signature Description addListener(listener Registers an object to receive event notification Obj:Object) : messages.
Parameters listenerObj:Object - The name of the listener object that receives event notification. Returns Boolean - Although this method technically returns a Boolean value, in practical terms it returns Void because it always returns the value true. Example The following example is an excerpt from the full example provided in the entry for the AsBroadcaster.initialize() method. someObject.addListener(myListener1); // Register myListener1 as listener. someObject.
Parameters - The name of the event to broadcast. The name of any listener methods 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. eventName:String Example The following example is an excerpt from the first full example provided in the entry for the AsBroadcaster.initialize() method: someObject.broadcastMessage("someEvent"); // Broadcast the "someEvent" message.
Parameters obj:Object - An object to serve as a broadcasting object. Example The following example creates a generic object, someObject, and turns it into an event broadcaster. The output should be the strings shown in the two trace() statements: var someObject:Object = new Object(); // Creates broadcast object. var myListener1:Object = new Object(); // Creates listener object. var myListener2:Object = new Object(); // Creates listener object. myListener1.
_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 addListener() and removelistener() methods. You can call this property only from an object that was initialized by using the AsBroadcaster.initialize() method. Availability: ActionScript 1.
// 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.
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.
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 angle:Number The angle of the bevel. blurX:Number The amount of horizontal blur in pixels. blurY:Number The amount of vertical blur in pixels.
Constructor summary Signature Description BevelFilter([distanc Initializes a new BevelFilter instance with the specified parameters. 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 clone() : Returns a copy of this filter object.
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. If distance is set to 0, the effect is not offset from the object and, therefore, the angle property has no effect. Availability: ActionScript 1.
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 distance:Number [optional] - The offset distance of the bevel, in pixels (floating point).
type:String [optional] - The type of bevel. Valid values are "inner", "outer", and "full". The default value is "inner". knockout:Boolean [optional] - Applies a knockout effect (true), which effectively makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout). Example The following example instantiates a new BevelFilter and applies it to the MovieClip instance (rect): import flash.filters.
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. Availability: ActionScript 1.
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. Values that are a power of 2 (such as 2, 4, 8, 16, and 32) are optimized to render more quickly than other values. Availability: ActionScript 1.
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 flash.filters.BevelFilter - A new BevelFilter instance with all the same properties as the original BevelFilter instance.
// // // // >> >> >> >> highlightAlpha: 0.8 highlightColor: 16776960 angle: 45 distance: 5 } for(var i in clonedFilter) { trace(">> " + i + ": " + clonedFilter[i]); // >> clone: [type Function] // >> type: inner // >> blurY: 20 // >> blurX: 20 // >> knockout: false // >> strength: 1 // >> quality: 3 // >> shadowAlpha: 0.8 // >> shadowColor: 255 // >> highlightAlpha: 0.
distance (BevelFilter.distance property) public distance : Number The offset distance of the bevel. Valid values are in pixels (floating point). The default value is 4. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the distance property on the existing MovieClip instance (rect) when a user clicks it: import flash.filters.BevelFilter; var rect:MovieClip = createBevelRectangle("BevelDistance"); rect.onRelease = function() { var filter:BevelFilter = this.
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; Flash Player 8 Example The following example changes the highlightAlpha property on the existing MovieClip instance (rect) when a user clicks it: import flash.filters.
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 highlightColor property on the existing MovieClip instance (rect) when a user clicks it: import flash.filters.BevelFilter; var rect:MovieClip = createBevelRectangle("BevelHighlightColor"); rect.
knockout (BevelFilter.knockout property) public knockout : Boolean Applies a knockout effect (true), which effectively makes the object's fill transparent and reveals the background color of the document. The default value is false (no knockout). Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the knockout property on the existing MovieClip instance (rect) when a user clicks it: import flash.filters.
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. For most applications, a quality value of 1, 2, or 3 is sufficient. Although you can use additional numeric values up to 15 to achieve different effects, larger values are rendered more slowly.
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; Flash Player 8 Example The following example changes the shadowAlpha property on the existing MovieClip instance (rect) when a user clicks it: import flash.filters.
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 shadowColor property on the existing MovieClip instance (rect) when a user clicks it: import flash.filters.BevelFilter; var rect:MovieClip = createBevelRectangle("BevelShadowColor"); rect.
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. The default value is 1. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the strength property on the existing MovieClip instance (rect) when a user clicks it: import flash.filters.
type (BevelFilter.type property) public type : String The type of bevel. Valid values are "inner", "outer", and "full". Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the type property on the existing MovieClip instance (rect) when a user clicks it: import flash.filters.BevelFilter; var rect:MovieClip = createBevelRectangle("BevelType"); rect.onRelease = function() { var filter:BevelFilter = this.filters[0]; filter.type = "outer"; this.
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.
See also attachBitmap (MovieClip.attachBitmap method), beginBitmapFill (MovieClip.beginBitmapFill method) Property summary Modifiers Property Description height:Number [read- The height of the bitmap image in pixels. only] rectangle:Rectangle [read-only] The rectangle that defines the size and location of the bitmap image. [read-only] Defines whether the bitmap image supports per-pixel transparency. width:Number [read- The width of the bitmap image in pixels.
Method summary Modifiers Signature Description applyFilter(sourceBi Takes a source image and a filter object and tmap:BitmapData, generates the filtered image. sourceRect:Rectangle , destPoint:Point, filter:BitmapFilter) : Number clone() : BitmapData Returns a new BitmapData object that is a clone of the original instance with an exact copy of the contained bitmap. colorTransform(rect: Adjusts the color values in a specified area of a bitmap Rectangle, image by using a ColorTransform object.
Modifiers Signature Description draw(source:Object, Draws a source image or movie clip onto a destination image, using the Flash Player vector renderer. [matrix:Matrix], [colorTransform:Colo rTransform], [blendMode:Object], [clipRect:Rectangle] , [smooth:Boolean]) : Void fillRect(rect:Rectan Fills a rectangular area of pixels with a specified gle, color:Number) : ARGB color.
Modifiers Signature Description merge(sourceBitmap:B Performs per-channel blending from a source image itmapData, to a destination image. sourceRect:Rectangle , destPoint:Point, redMult:Number, greenMult:Number, blueMult:Number, alphaMult:Number) : Void noise(randomSeed:Num Fills an image with pixels representing random noise.
Modifiers Signature Description pixelDissolve(source Performs a pixel dissolve either from a source image Bitmap:BitmapData, to a destination image or by using the same image. sourceRect:Rectangle , destPoint:Point, [randomSeed:Number], [numberOfPixels:Numb er], [fillColor:Number]) : Number scroll(x:Number, Scrolls an image by a certain (x, y) pixel amount. y:Number) : Void setPixel(x:Number, 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.
■ 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. Returns Number - A number that indicates whether the filter was applied successfully. If 0 is returned, the filter was applied successfully.
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 fillColor parameter, every pixel in the bitmap is set to that color. By default, the bitmap is created as opaque, unless you pass the value true for the transparent parameter. Once you create an opaque bitmap, you cannot change it to a transparent bitmap.
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. Availability: ActionScript 1.0; Flash Player 8 Returns flash.display.
// // // // // // // // // // // // // // // // // // // // // >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> paletteMap: [type Function] hitTest: [type Function] colorTransform: [type Function] perlinNoise: [type Function] getColorBoundsRect: [type Function] floodFill: [type Function] setPixel32: [type Function] getPixel32: [type Function] pixelDissolve: [type Function] draw: [type Function] threshold: [type Function] scroll: [type Function] applyFilter: [type Function] copyPixels: [type
// >> height: 80 // >> width: 100 } To further demonstrate the relationships between bitmap_1, bitmap_2, and clonedBitmap the following example modifies the pixel value at (1, 1) of bitmap_1. Modifying pixel value at (1, 1) demonstrates that the clone() method creates an instance based on values of the bitmap_1 instance instead instead of refering to the values. import flash.display.
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.
Parameters sourceBitmap:flash.display.BitmapData - The input bitmap image to use. The source 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 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. sourceRect:flash.geom.Rectangle destPoint:flash.geom.
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()); mc_1.attachBitmap(bitmapData_1, this.getNextHighestDepth()); var mc_2:MovieClip = this.
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.
colorTransform:flash.geom.ColorTransform [optional] - A ColorTransform object that 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 new ColorTransform() constructor, if you must pass this parameter but you do not want to transform the image. blendMode:Object [optional] - A BlendMode object. clipRect:flash.geom.Rectangle [optional] - A Rectangle object.
mc_1.onPress = function() { myBitmapData.draw(mc_2, myMatrix, myColorTransform, blendMode, myRectangle, smooth); } function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.lineTo(0, 0); return mc; } fillRect (BitmapData.
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 floodFill() method is similar to the paint bucket tool in various painting programs. The color is an ARGB color that contains alpha information and color information. Availability: ActionScript 1.
generateFilterRect (BitmapData.generateFilterRect method) public generateFilterRect(sourceRect:Rectangle, filter:BitmapFilter) : Rectangle Determines the destination rectangle that the applyFilter() method call affects, given a 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.
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.
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.
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) public height : Number [read-only] The height of the bitmap image in pixels. Availability: ActionScript 1.
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. Availability: ActionScript 1.0; Flash Player 8 Parameters firstPoint:flash.geom.Point - A point that defines a pixel location in the current BitmapData instance.
currPoint.x = mc_2._x; currPoint.y = mc_2._y; if(myBitmapData.hitTest(destPoint, 255, currPoint)) { trace(">> Collision at x:" + currPoint.x + " and y:" + currPoint.y); } } mc_2.startDrag(true); function createRectangle(width:Number, height:Number, color:Number):MovieClip { var depth:Number = this.getNextHighestDepth(); var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.lineTo(width, height); mc.lineTo(width, 0); mc.
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.
var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth()); mc_2._x = 101; mc_1.onPress = function() { bitmapData_1.merge(bitmapData_2, new Rectangle(0, 0, 50, 40), new Point(25, 20), 128, 0, 0, 0); } noise (BitmapData.noise method) public noise(randomSeed:Number, [low:Number], [high:Number], [channelOptions:Number], [grayScale:Boolean]) : Void Fills an image with pixels representing random noise.
var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc_1.attachBitmap(bitmapData_1, this.getNextHighestDepth()); var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth()); mc_2._x = 101; mc_1.onPress = function() { bitmapData_1.merge(bitmapData_2, new Rectangle(0, 0, 50, 40), new Point(25, 20), 128, 0, 0, 0); } mc_1.onPress = function() { bitmapData_1.noise(128, 0, 255, 1, true); } mc_2.
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; Flash Player 8 Parameters sourceBitmap:flash.display.BitmapData - The input bitmap image to use. The source image can be a different BitmapData object, or it can refer to the current BitmapData object.
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.
- Frequency to use in the y direction. For example, to generate a noise that is sized for a 64 x 128 image, pass 128 for the baseY value. baseY:Number - Number of octaves or individual noise functions to combine to create this noise. Larger numbers of octaves create images with greater detail. Larger numbers of octaves also require more processing time. numOctaves:Number randomSeed:Number - The random seed number to use.
var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth()); mc_2._x = 101; mc_1.onPress = function() { var randomNum:Number = Math.floor(Math.random() * 10); bitmapData_1.perlinNoise(100, 80, 6, randomNum, false, true, 1, true, null); } mc_2.onPress = function() { var randomNum:Number = Math.floor(Math.random() * 10); bitmapData_2.perlinNoise(100, 80, 4, randomNum, false, false, 15, false, null); } pixelDissolve (BitmapData.
randomSeed:Number [optional] - The random seed to use to start the pixel dissolve. The default value is 0. numberOfPixels:Number [optional] - The default is 1/30 of the source area (width x height). fillColor:Number [optional] - An ARGB color value that you use to fill pixels whose source value equals its destination value. The default value is 0. Returns Number - The new random seed value to use for subsequent calls.
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. Availability: ActionScript 1.0; Flash Player 8 Example The following example shows that the rectangle property of the Bitmap instance is readonly by trying to set it and failing: import flash.display.BitmapData; import flash.
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.
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.
sourceRect:flash.geom.Rectangle - A rectangle that defnes the area of the source image to use as input. - The point within the destination image (the current BitmapData instance) that corresponds to upper-left corner of the source rectangle. destPoint:flash.geom.Point - One of the following comparison operators, passed as a String: "<", "<=", ">", ">=", "==", "!=" operation:String threshold:Number - The value that each pixel is tested against to see if it meets or exceeds the threshhold.
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 true for the transparent parameter. After you create a BitmapData object, you can check whether it supports per-pixel transparency by seeing if the value of the transparent property is true. Availability: ActionScript 1.
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.
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 flash.filters.BitmapFilter - A BitmapFilter object. 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.
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; Flash Player 8 See also filters (MovieClip.filters property), cacheAsBitmap (MovieClip.cacheAsBitmap property), filters (Button.filters property), cacheAsBitmap (Button.cacheAsBitmap property), filters (TextField.
Method summary Modifiers Signature Description clone() : BlurFilter Returns a copy of this filter object. Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.toString method), unwatch (Object.
Example The following example instantiates a new BlurFilter constructor and applies it to a flat, 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(); filterArray.push(filter); rect.
filter.blurX = 200; this.filters = new Array(filter); } function createBlurFilterRectangle(name:String):MovieClip { var rect:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); var w:Number = 100; var h:Number = 100; rect.beginFill(0x003366); rect.lineTo(w, 0); rect.lineTo(w, h); rect.lineTo(0, h); rect.lineTo(0, 0); rect._x = 20; rect._y = 20; var filter:BlurFilter = new BlurFilter(30, 30, 2); var filterArray:Array = new Array(); filterArray.push(filter); rect.
var w:Number = 100; var h:Number = 100; rect.beginFill(0x003366); rect.lineTo(w, 0); rect.lineTo(w, h); rect.lineTo(0, h); rect.lineTo(0, 0); rect._x = 20; rect._y = 20; var filter:BlurFilter = new BlurFilter(30, 30, 2); var filterArray:Array = new Array(); filterArray.push(filter); rect.filters = filterArray; return rect; } clone (BlurFilter.clone method) public clone() : BlurFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns flash.filters.
// // // // >> >> >> >> clone: [type Function] quality: 2 blurY: 30 blurX: 30 } for(var i in clonedFilter) { trace(">> " + i + ": " + clonedFilter[i]); // >> clone: [type Function] // >> quality: 2 // >> blurY: 30 // >> blurX: 30 } To further demonstrate the relationships between filter_1, filter_2, and clonedFilter, the following example modifies the quality property of filter_1.
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. For most applications, a quality value of 1, 2, or 3 is sufficient.
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 Boolean() to create a Boolean object before calling its methods. Availability: ActionScript 1.
Method summary Modifiers Signature Description toString() : String Returns the string representation ("true" or "false") of the Boolean object. valueOf() : Boolean Returns true if the primitive value type of the specified Boolean object is true; false otherwise. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.
toString (Boolean.toString method) public toString() : String Returns the string representation ("true" or "false") of the Boolean object. Availability: ActionScript 1.0; Flash Player 5 Returns String - A string; "true" or "false". Example This example creates a variable of type Boolean and uses toString() to convert the value to a string for use in the trace statement: var myBool:Boolean = true; trace("The value of the Boolean myBool is: " + myBool.
Button Object | +-Button public class Button extends Object All button symbols in a SWF file are instances of the Button object. You can give a button an instance name in the Property inspector, and use the methods and properties of the Button class to manipulate buttons with ActionScript. Button instance names are displayed in the Movie Explorer and in the Insert Target Path dialog box in the Actions panel. The Button class inherits from the Object class. Availability: ActionScript 1.
Modifiers Property Description _name:String Instance name of the button specified by my_btn. _parent:MovieClip A reference to the movie clip or object that contains the current movie clip or object. _quality:String Property (global); sets or retrieves the rendering quality used for a SWF file. _rotation:Number The rotation of the button, in degrees, from its original orientation. scale9Grid:Rectangle The rectangular region that defines the nine scaling regions for the button.
Modifiers Property Description _y:Number The y coordinate of the button relative to the local coordinates of the parent movie clip. _ymouse:Number [read- Indicates the y coordinate of the mouse position only] relative to the button. _yscale:Number The vertical scale of the button as applied from the registration point of the button, expressed as a percentage. Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.
Event Description onRollOver = Invoked when the pointer moves over a button area. function() {} Invoked when a button receives keyboard focus. onSetFocus = function(oldFocu s:Object) {} Method summary Modifiers Signature Description getDepth() : Number Returns the depth of the button instance. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.
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 blendMode property on each pixel of the button. Each pixel is composed of three constituent colors (red, green, and blue), and each constituent color has a value between 0x00 and 0xFF.
Integer value String value Illustration Description 3 "multiply" Multiplies the values of the 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 corresponding color of the pixel in the background both have the value 0x88, the multiplied result is 0x4840.
Integer value String value 6 "darken" Selects the darker of the 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 0xDDF800, the resulting RGB value for the displayed pixel is 0xDDCC00 (because 0xFF > 0xDD, 0xCC < 0xF8, and 0x33 > 0x00 = 33).
Integer value String value Illustration Description 8 "add" Adds the values of the 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.
Integer value String value 11 "alpha" Applies the alpha value of each pixel of the button to the background. This requires the "layer" blendMode to be applied to a parent button. For example, in the illustration, the parent button, which is a white background, has blendMode = "layer". 12 "erase" Erases the background based on the alpha value of the button. This requires the "layer" blendMode setting to be applied to a parent button.
If you attempt to set the blendMode property to any other value, Flash Player sets it to "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; trace (my_button.blendMode) // add For a related example, see the description of the blendMode property of the MovieClip class. See also blendMode (MovieClip.
In the following cases a button does not use a bitmap, even if the cacheAsBitmap property is set to true and instead renders from vector data: ■ 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) The cacheAsBitmap property is best used with buttons that have mostly static content and that do not scale and rotate frequently.
//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. The flash.filters package contains several classes that define specific filters that you can use.
To clear the filters for a button, set filters to an empty array ([]). 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. This bitmap is used as a source image for the filter effects.
_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 _focusrect property. By default, the _focusrect property of a button instance is null; meaning, the button instance does not override the global _focusrect property.
Returns Number - The depth of the button instance. Example If you create myBtn1_btn and myBtn2_btn on the Stage, you can trace their depth using the 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, myBtn4_btn, inside that SWF file using another button in the main SWF file: this.createEmptyMovieClip("myClip_mc", 999); myClip_mc.loadMovie("buttonMovie.
_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 antialiasing; this smooths bitmaps if the SWF file does not contain animation and is the default value. Specify 0 (low quality) to prevent anti-aliasing.
Example The following example assigns a ContextMenu object to a button instance named myBtn_btn. The ContextMenu object contains a single menu item (labeled "Save...") with an associated callback handler function named doSave. Add the button instance to the Stage and name it myBtn_btn. var menu_cm:ContextMenu = new ContextMenu(); menu_cm.customItems.push(new ContextMenuItem("Save...", doSave)); function doSave(menu:Object, obj:Object):Void { trace( " You selected the 'Save...' menu item "); } myBtn_btn.
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 onKeyDown event handler is invoked with no parameters. You can use the Key.getAscii() and Key.getCode() methods to determine which key was pressed. You must define a function that executes when the event handler is invoked. Availability: ActionScript 1.
onKeyUp (Button.onKeyUp handler) onKeyUp = function() {} Invoked when a button has input focus and a key is released. The onKeyUp event handler is invoked with no parameters. You can use the Key.getAscii() and Key.getCode() methods to determine which key was pressed. Availability: ActionScript 1.0; Flash Player 6 Example In the following example, a function that sends text to the Output panel is defined for the onKeyDown handler.
onKillFocus (Button.onKillFocus handler) onKillFocus = function(newFocus:Object) {} Invoked when a button loses keyboard focus. The onKillFocus handler receives one parameter, newFocus, which is an object representing the new object receiving the focus. If no object receives the focus, newFocus contains the value null. Availability: ActionScript 1.0; Flash Player 6 Parameters newFocus:Object - The object that is receiving the focus.
Example In the following example, a function that sends a trace() statement to the Output panel is defined for the onPress handler: 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. Availability: ActionScript 1.
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 onRollOut handler: my_btn.onRollOut = function () { trace ("onRollOut called"); }; onRollOver (Button.
Example The following example demonstrates how you can execute statements when the user of a SWF file moves focus from one button to another. Create two buttons, btn1_btn and btn2_btn, and enter the following ActionScript in Frame 1 of the Timeline: Selection.setFocus(btn1_btn); trace(Selection.getFocus()); btn2_btn.onSetFocus = function(oldFocus) { trace(oldFocus._name + "lost focus"); }; Test the SWF file by pressing Control+Enter.
_quality (Button._quality property) public _quality : String Property (global); sets or retrieves the rendering quality used for a SWF file. Device fonts are always aliased and therefore are unaffected by the _quality property. The _quality property can be set to the following values: ■ "LOW" Low rendering quality. Graphics are not anti-aliased, and bitmaps are not smoothed. ■ "MEDIUM" Medium rendering quality. Graphics are anti-aliased using a 2 x 2 pixel grid, but bitmaps are not smoothed.
Example The following example rotates two buttons on the Stage. Create two buttons on the Stage called control_btn and my_btn. Make sure that my_btn is not perfectly round, so you can see it rotating. Then enter the following ActionScript in Frame 1 of the Timeline: var control_btn:Button; var my_btn:Button; control_btn.onRelease = function() { my_btn._rotation += 10; }; Now create another button on the Stage called myOther_btn, making sure it isn't perfectly round (so you can see it rotate).
■ 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 scale9Grid property is set and a button is scaled, all text and gradients are scaled normally; however, for other types of objects the following rules apply: ■ Content in the center region is scaled normally.
tabEnabled (Button.tabEnabled property) public tabEnabled : Boolean Specifies whether my_btn is included in automatic tab ordering. It is undefined by default. If the tabEnabled property is undefined or true, the object is included in automatic tab ordering. If the tabIndex property is also set to a value, the object is included in custom tab ordering as well. If tabEnabled is false, the object is not included in automatic or custom tab ordering, even if the tabIndex property is set.
The tabIndex property may be a non-negative integer. The objects are ordered according to their tabIndex properties, in ascending order. An object with a tabIndex value of 1 precedes an object with a tabIndex value of 2. If two objects have the same tabIndex value, the one that precedes the other in the tab ordering is undefined. The custom tab ordering defined by the tabIndex property is flat. This means that no attention is paid to the hierarchical relationships of objects in the SWF file.
Example Add a button instance to the Stage with an instance name my_btn and add the following code to Frame 1 of the Timeline: trace(my_btn._target); //displays /my_btn Select my_btn and convert it to a movie clip. Give the new movie clip an instance name my_mc. Delete the existing ActionScript in Frame 1 of the Timeline and replace it with: my_mc.my_btn.onRelease = function(){ trace(this.
Example The following example demonstrates how to track two buttons as a menu. Place two button instances on the Stage called one_btn and two_btn. Enter the following ActionScript in the Timeline: var one_btn:Button; var two_btn:Button; one_btn.trackAsMenu = true; two_btn.trackAsMenu = true one_btn.onRelease = function() { trace("clicked one_btn"); }; two_btn.
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 true (the default), indicates whether a pointing hand (hand cursor) displays when the mouse rolls over a button. If this property is set to false, the arrow pointer is used instead.
Example Create two buttons on the Stage with the instance names myBtn1_btn and 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 myBtn2_btn after the alpha is set to 0. See also _visible (MovieClip._visible property), _visible (TextField._visible property) _width (Button.
_x (Button._x property) public _x : Number An integer that sets the x coordinate of a button relative to the local coordinates of the parent movie clip. If a button is on the main Timeline, then its coordinate system refers to the upper left corner of the Stage as (0, 0). If the button is inside a movie clip that has transformations, the button is in the local coordinate system of the enclosing movie clip.
table_str += "Stage\t"+"x:"+_xmouse+"\t"+"y:"+_ymouse+newline; table_str += "Button\t"+"x:"+my_btn._xmouse+"\t"+"y:"+my_btn._ymouse+newline; table_str += ""; 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. Thus, for a movie clip rotated 90 degrees counterclockwise, the enclosed button inherits a coordinate system that is rotated 90 degrees counterclockwise.
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; Flash Player 6 Example The following example scales a button called my_btn. When you click and release the button, it grows 10% on the x and y axis.
Camera Object | +-Camera public class 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 attached to your local system. (Flash provides similar audio capabilities; for more information, see the Microphone class entry.
Modifiers Property Description motionLevel:Number A numeric value that specifies the amount of motion required to invoke Camera.onActivity(true). [read-only] motionTimeOut:Number The number of milliseconds between the time the [read-only] camera stops detecting motion and the time Camera.onActivity (false) is invoked. muted:Boolean [read- A Boolean value that specifies whether the user has denied access to the camera (true) or allowed access (false) in the Flash Player Privacy Settings panel.
Method summary Modifiers Signature Description static get([index:Number]) Returns a reference to a Camera object for capturing video. : Camera setMode([width:Numbe Sets the camera capture mode to the native mode that r], [height:Number], best meets the specified requirements. [fps:Number], [favorArea:Boolean]) : Void setMotionLevel([moti Specifies how much motion is required to invoke onLevel:Number], 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 my_video. Add a ProgressBar component instance to the Stage and give it the instance name activity_pb. Then add the following ActionScript to Frame 1 of the Timeline: // video instance on the Stage. var my_video:Video; var activity_pb:mx.
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 my_video. Add a NumericStepper component instance to the Stage and give it the instance name bandwidth_nstep. Then add the following ActionScript to Frame 1 of the Timeline: var bandwidth_nstep:mx.controls.NumericStepper; var my_video:Video; var my_cam:Camera = Camera.
Example The following example detects the rate in frames per second that the camera captures data, using the currentFps 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 my_video. Add a ProgressBar component instance to the Stage and give it the instance name fps_pb. Then add the following ActionScript to Frame 1 of the Timeline: var my_video:Video; var fps_pb:mx.controls.
Example The following example detects the rate in frames per second that the camera captures data, using the currentFps 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 my_video. Add a ProgressBar component instance to the Stage and give it the instance name fps_pb. Then add the following ActionScript to Frame 1 of the Timeline: var my_video:Video; var fps_pb:mx.controls.
When a SWF file tries to access the camera returned by Camera.get(), Flash Player displays a 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 Camera.onStatus event handler returns an information object that indicates the user's response.
Returns Camera - If index is not specified, this method returns a reference to the default camera or, if it is in use by another application, to the first available camera. (If there is more than one camera installed, the user may specify the default camera in the Flash Player Camera Settings panel.) If no cameras are available or installed, the method returns null. If index is specified, this method returns a reference to the requested camera, or null if it is not available.
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 my_video. Add a Label component instance to the Stage and give it the instance name dimensions_lbl. Then add the following ActionScript to Frame 1 of the Timeline: var my_cam:Camera = Camera.get(); var my_video:Video; my_video.
cameras_txt.html = true; cameras_txt.border = true; cameras_txt.wordWrap = true; cameras_txt.multiline = true; for (var i = 0; i"+Camera.names[i]+"
"; } function changeCamera(index:Number) { my_cam = Camera.get(index); my_video.attachVideo(my_cam); camera_lbl.text = my_cam.index+". "+my_cam.name; } The MovieClip.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.
motionTimeOut (Camera.motionTimeOut property) public motionTimeOut : Number [read-only] The number of milliseconds between the time the camera stops detecting motion and the time Camera.onActivity (false) is invoked. The default value is 2000 (2 seconds). To set this value, use Camera.setMotionLevel(). Availability: ActionScript 1.0; Flash Player 6 Example In the following example, the ProgressBar instance changes its halo theme color when the activity level falls below the motion level.
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 (true) or allowed access (false) in the Flash Player Privacy Settings panel. When this value changes, Camera.onStatus is invoked. For more information, see Camera.get(). Availability: ActionScript 1.
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. Create a new video instance by selecting New Video from the Library options menu.
Calling the Camera.names property requires an extensive examination of the hardware, and it may take several seconds to build the array. In most cases, you can just use the default camera. NO T E The correct syntax is Camera.names. To assign the return value to a variable, use syntax like cam_array = Camera.names. To determine the name of the current camera, use active_cam.name. Availability: ActionScript 1.
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); } See also setMotionLevel (Camera.setMotionLevel method) onStatus (Camera.
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; case 'Camera.Unmuted' : trace("Camera access granted"); break; } } See also get (Camera.get method), muted (Camera.muted property), showSettings (System.
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.
favorArea:Boolean [optional] - A Boolean value that specifies how to manipulate the width, height, and frame rate if the camera does not have a native mode that meets the specified requirements. The default value is true, which means that maintaining capture size is favored; using this parameter selects the mode that most closely matches width and height values, even if doing so adversely affects performance by reducing the frame rate.
setMotionLevel (Camera.setMotionLevel method) public setMotionLevel([motionLevel:Number], [timeOut:Number]) : Void Specifies how much motion is required to invoke Camera.onActivity(true). Optionally sets the number of milliseconds that must elapse without activity before Flash considers motion to have stopped and invokes Camera.onActivity(false). N OT E Video can be displayed regardless of the value of the sensitivity parameter. This parameter determines only when and under waht circumstances Camera.
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(); x = 0; function motion(mode) { trace(x + ": " + mode); x++; } active_cam.onActivity = function(mode) { motion(mode); } active_cam.setMotionLevel(30, 500); myVideoObject.
■ 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. Availability: ActionScript 1.
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 my_video. Add a Label component instance to the Stage and give it the instance name dimensions_lbl. Then add the following ActionScript to Frame 1 of the Timeline: var my_cam:Camera = Camera.get(); var my_video:Video; my_video.
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 System.capabilities object are read-only. Availability: ActionScript 1.0; Flash Player 6 Property summary Modifiers Property static avHardwareDisable:Bo A Boolean value that specifies whether access to the olean [read-only] static static Description user's camera and microphone has been administratively prohibited (true) or allowed (false).
Modifiers static Property hasStreamingAudio:Bo A Boolean value that is true if the player can play olean [read-only] static static ean [read-only] stream. isDebugger:Boolean A Boolean value that indicates whether the player is an officially released version (false) or a special debugging version (true). language:String [read-only] static static streaming video; false otherwise.
Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Method summary Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.
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.
hasEmbeddedVideo (capabilities.hasEmbeddedVideo property) public static hasEmbeddedVideo : Boolean [read-only] A Boolean value that is true if the player is running on a system that supports embedded video; false otherwise. The server string is EV. 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); hasIME (capabilities.
hasPrinting (capabilities.hasPrinting property) public static hasPrinting : Boolean [read-only] A Boolean value that is true if the player is running on a system that supports printing; false otherwise. The server string is PR. 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); hasScreenBroadcast (capabilities.
hasStreamingAudio (capabilities.hasStreamingAudio property) public static hasStreamingAudio : Boolean [read-only] A Boolean value that is true if the player can play streaming audio; false otherwise. The server string is SA. 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); hasStreamingVideo (capabilities.
isDebugger (capabilities.isDebugger property) public static isDebugger : Boolean [read-only] A Boolean value that indicates whether the player is an officially released version (false) or a special debugging version (true). The server string is DEB. Availability: ActionScript 1.0; Flash Player 6 Example The following example traces the value of this read-only property: trace(System.capabilities.isDebugger); language (capabilities.
Language Tag German de Hungarian hu Italian it Japanese ja Korean ko Norwegian no Other/unknown xu Polish pl Portuguese pt Russian ru Simplified Chinese zh-CN Spanish es Swedish sv Traditional Chinese zh-TW Turkish tr 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); localFileReadDisable (capabilities.
Availability: ActionScript 1.0; Flash Player 7 Example 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" (OSName could be "Windows", "Macintosh", "Linux", or "Other OS Name"). The server string is M. Availability: ActionScript 1.
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: ■ "StandAlone" ■ "External" ■ "PlugIn" ■ "ActiveX" for the Flash StandAlone Player for the Flash Player version used by the external player, or test movie mode..
Example The following example traces the value of this read-only property: trace(System.capabilities.screenDPI); screenResolutionX (capabilities.screenResolutionX property) public static screenResolutionX : Number [read-only] An integer that indicates the maximum horizontal resolution of the screen. The server string is R (which returns both the width and height of the screen). Availability: ActionScript 1.
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 The server string is V. 8,0,0,0"). Availability: ActionScript 1.
Property summary Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.prototype property), __resolve (Object.__resolve property) Constructor summary Signature Description Color(target:Object) Class Deprecated. Creates a Color object for the movie clip specified by the target_mc parameter. Method summary Modifiers Signature Description getRGB() : Number Class Deprecated.
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 target_mc parameter. You can then use the methods of that Color object to change the color of the entire target movie clip. Availability: ActionScript 1.0; Flash Player 5 Parameters target:Object - The instance name of a movie clip.
Example The following code retrieves the RGB value for the Color object my_color, converts the value to a hexadecimal string, and assigns it to the myValue variable. To see this code work, add a movie clip instance to the Stage, and give it the instance name my_mc: var my_color:Color = new Color(my_mc); // set the color my_color.setRGB(0xff9933); var myValue:String = my_color.getRGB().toString(16); // trace the color value trace(myValue); // traces ff9933 See also setRGB (Color.
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 Color.setTransform() settings. Availability: ActionScript 1.0; Flash Player 5 Parameters offset:Number - 0xRRGGBB The hexadecimal or RGB color to be set.
■ gb is the offset for the green component (-255 to 255). ■ ba is the percentage for the blue component (-100 to 100). ■ bb is the offset for the blue component (-255 to 255). ■ aa is the percentage for alpha (-100 to 100). ■ ab is the offset for alpha (-255 to 255). You create a colorTransformObject parameter as follows: var myColorTransform:Object = new Object(); myColorTransform.ra = 50; myColorTransform.rb = 244; myColorTransform.ga = 40; myColorTransform.gb = 112; myColorTransform.
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. It allows saturation changes, hue rotation, luminance to alpha and various other effects.
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. The following two optimized modes are available. Alpha only.
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]); // blue matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha var filter:BitmapFilter = new ColorMatrixFilter(matrix); image.filters = new Array(filter); } Mouse.
Method summary Modifiers Signature Description clone() : Returns a copy of this filter object. ColorMatrixFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.
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.
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.
Property summary Modifiers Property Description alphaMultiplier:Numb A decimal value that is multiplied by the alpha er transparency channel value. alphaOffset:Number A number from -255 to 255 that is added to the alpha transparency channel value after it has been multiplied by the alphaMultiplier value. blueMultiplier:Numbe A decimal value that is multiplied by the blue channel r value.
Constructor summary Signature Description ColorTransform([redM Creates a ColorTransform object for a display object with the ultiplier:Number], specified color channel values and alpha values.
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 MovieClip._alpha property, it affects the value of the alphaMultiplier property of that movie clip's ColorTransform object. Availability: ActionScript 1.
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 alphaMultiplier value. Availability: ActionScript 1.0; Flash Player 8 Example The following example creates the ColorTransform object colorTrans and adjusts its alphaOffset value from 0 to -128. import flash.geom.ColorTransform; import flash.geom.
Example The following example creates the ColorTransform object colorTrans and adjusts its blueMultiplier value from 1 to .5. 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); trans.
colorTrans.blueOffset = 255; trace(colorTrans.blueOffset); // 255 var rect:MovieClip = createRectangle(20, 80, 0x000000); var trans:Transform = new Transform(rect); trans.colorTransform = colorTrans; function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip { scope = (scope == undefined) ? this : scope; var depth:Number = scope.getNextHighestDepth(); var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.
greenOffset:Number [optional] - The offset for the green color channel value (-255 to 255). The default value is 0. [optional] - The offset for the blue color channel value (-255 to 255). The default value is 0. blueOffset:Number alphaOffset:Number [optional] - The offset for alpha transparency channel value (-255 to 255). The default value is 0. Example The following example creates a ColorTransform object called greenTransform: var greenTransform:flash.geom.ColorTransform = new flash.geom.
Example The following example concatenates the ColorTransform object colorTrans_2 to colorTrans_1 resulting in a full red offset combined with a .5 alpha multiplier. import flash.geom.ColorTransform; import flash.geom.
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 colorTrans and adjusts its greenMultiplier from 1 to .5. import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans:ColorTransform = new ColorTransform(); trace(colorTrans.greenMultiplier); // 1 colorTrans.greenMultiplier = .
Example The following example creates the ColorTransform object colorTrans and adjusts its greenOffset value from 0 to 255. 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); trans.
colorTrans.redMultiplier = .5; trace(colorTrans.redMultiplier); // .5 var rect:MovieClip = createRectangle(20, 80, 0xFF0000); var trans:Transform = new Transform(rect); trans.colorTransform = colorTrans; function createRectangle(width:Number, height:Number, color:Number, scope:MovieClip):MovieClip { scope = (scope == undefined) ? this : scope; var depth:Number = scope.getNextHighestDepth(); var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth); mc.beginFill(color); mc.lineTo(0, height); mc.
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.
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.
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.
See also ContextMenuItem, menu (Button.menu property), menu (MovieClip.menu property), menu (TextField.menu property) Property summary Modifiers Property Description builtInItems:Object An object that has the following Boolean properties: zoom, quality, play, loop, rewind, forward_back, and print. customItems:Array An array of ContextMenuItem objects. Properties inherited from class Object constructor (Object.constructor property), __proto__ (Object.__proto__ property), prototype (Object.
Method summary Modifiers Signature Description copy() : ContextMenu Creates a copy of the specified ContextMenu object. hideBuiltInItems() : Hides all built-in menu items (except Settings) in the Void specified ContextMenu object. Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.
In the next example, a for..in loop enumerates through all names and values of the built-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 + ": " + propValue); } ContextMenu constructor public ContextMenu([callbackFunction:Function]) Creates a new ContextMenu object.
} } 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.
} 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. To add new menu items, you first create a new ContextMenuItem object, and then add it to the menu_mc.customItems array (for example, using Array.push()).
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; it does not affect items that appear in the edit or error menus.
Parameters item:Object - A reference to the object (movie clip, button, or selectable text field) that was under the mouse pointer when the Flash Player context menu was invoked and whose menu property is set to a valid ContextMenu object. item_menu:Object - A reference to the ContextMenu object assigned to the menu property of object. Example The following example determines over what type of object the context menu was invoked.
Custom menu items appear at the top of the context menu, above any built-in items. A separator bar always divides custom menu items from built-in items. You can add no more than 15 custom items to a context menu. Each item must contain at least one visible character; control characters, newlines, and other white space characters are ignored. No item can be more than 100 characters long.
Constructor summary Signature Description ContextMenuItem(caption:Str Creates a new ContextMenuItem object that can be added to the ContextMenu.customItems array. ing, callbackFunction:Function, [separatorBefore:Boolean], [enabled:Boolean], [visible:Boolean]) Method summary Modifiers Signature Description copy() : Creates and returns a copy of the specified ContextMenuItem object. ContextMenuItem Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.
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 ContextMenu.customItems array. Availability: ActionScript 1.0; Flash Player 7 Parameters caption:String - A string that specifies the text associated with the menu item. callbackFunction:Function - A function that you define, which is called when the menu item is selected.
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 ContextMenuItem - A ContextMenuItem object. Example This example creates a new ContextMenuItem object named original_cmi with the caption Pause and a callback handler set to the function onPause.
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. The Start menu item is re-enabled and the Stop menu item is disabled.
Parameters obj:Object - A reference to the object (movie clip, Timeline, button, or selectable text field) on which the user right or Control clicked. menuItem:Object - A reference to the selected ContextMenuItem object. Example The following example determines over what type of object the context menu was invoked. var my_cmi:ContextMenu = new ContextMenu(); var start_cmi:ContextMenuItem = new ContextMenuItem("Start"); start_cmi.onSelect = function(obj, item) { trace("You chose: "+item.
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 customItems array. Finally, the menu is attached to the current Timeline of the SWF file.
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 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. For a 3 x 3 matrix convolution, the following formula is used for each independent color channel: dst (x, y) = ((src (x-1, y-1) * a0 + src(x, y-1) * a1....
Property summary Modifiers Property Description alpha:Number The alpha transparency value of the substitute color. bias:Number Bias to add to the result of the matrix transformation. clamp:Boolean Indicates whether the image should be clamped. color:Number The hexadecimal color to substitute for pixels that are off the source image. divisor:Number The divisor used during matrix transformation. matrix:Array An array of values used for matrix transformation; returns a copy.
Method summary Modifiers Signature Description clone() : Returns a copy of this filter object. ConvolutionFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.
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; Flash Player 8 Example The following example changes the bias property of filter from its default value of 0 to 50. import flash.filters.
Example The following example changes the clamp property of filter from its default value of true to false. import import import import flash.filters.ConvolutionFilter; flash.display.BitmapData; flash.geom.Rectangle; 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); var myBitmapData:BitmapData = new BitmapData(100, 80, true, 0xCCFF0000); var mc:MovieClip = this.
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.
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; Flash Player 8 Example The following example changes the color property of filter from its default value of 0 to 0xFF0000. import import import import flash.filters.
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). The default value is 0.
The following example creates a ConvolutionFilter object with the four required parameters matrixX, matrixY, matrix, and divisor. import flash.filters.ConvolutionFilter; import flash.display.
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.
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 matrixX property of filter. import flash.filters.ConvolutionFilter; var filter:ConvolutionFilter = new ConvolutionFilter(2, 3, [1, 0, 0, 1, 0, 0], 6); trace(filter.matrixX); // 2 matrixY (ConvolutionFilter.
Example The following example changes the preserveAlpha property of filter from its default value of true to 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); var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth()); mc.
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 static get(name:String) : Reads the contents of the custom action XML definition file named name. String static install(name:String, Installs a new custom action XML definition file data:String) : indicated by the name parameter.
Parameters name:String - The name of the custom action definition to retrieve. Returns String - If the custom action XML definition is located, returns a string; otherwise, returns undefined. Example The following example lists the custom actions in a ComboBox instance, and gets the custom action when a Button instance is clicked. Drag an instance of a ComboBox, Button, and TextArea onto the Stage.
Parameters name:String - The name of the custom action definition to install. data:String - The text of the XML definition to install. Returns - A Boolean value of false if an error occurs during installation; otherwise, a value of true is returned to indicate that the custom action has been successfully installed. Boolean Example The following example installs information into the Actions panel from an XML file. Open a text editor and save a new document called dogclass.xml.
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, list() returns a zero-length array. If an error occurs, list() returns the value undefined. Availability: ActionScript 1.
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; Flash Player 6 Parameters name:String - The name of the custom action definition to uninstall.
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. The Date.UTC() method is an exception; it is a static method.
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 Date([yearOrTimevalu Constructs a new Date object that holds the specified date and time.
Method summary Modifiers Signature Description getDate() : Number Returns the day of the month (an integer from 1 to 31) of the specified Date object according to local time. getDay() : Number Returns the day of the week (0 for Sunday, 1 for Monday, and so on) of the specified Date object according to local time. getFullYear() : Returns the full year (a four-digit number, such as 2000) of the specified Date object, according to local time.
Modifiers Signature Description getUTCMinutes() : Returns the minutes (an integer from 0 to 59) of the specified Date object, according to universal time. Number getUTCMonth() : Number getUTCSeconds() : Number getUTCYear() : Number getYear() : Number Returns the month (0 [January] to 11 [December]) of the specified Date object, according to universal time. Returns the seconds (an integer from 0 to 59) of the specified Date object, according to universal time.
Modifiers Signature Description setUTCFullYear(year: Sets the year for the specified Date object (my_date) Number, [month:Number], in universal time and returns the new time in milliseconds. [date:Number]) : Number setUTCHours(hour:Num Sets the hour for the specified Date object in universal ber, time and returns the new time in milliseconds.
Modifiers Signature Description static UTC(year:Number, Returns the number of milliseconds between midnight on January 1, 1970, universal time, and the time specified in the parameters. month:Number, [date:Number], [hour:Number], [minute:Number], [second:Number], [millisecond:Number] ) : Number valueOf() : Number Returns the number of milliseconds since midnight January 1, 1970, universal time, for this Date. Methods inherited from class Object addProperty (Object.
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.
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. Availability: ActionScript 1.0; Flash Player 5 Returns Number - An integer.
Example The following example creates a new Date object and uses getDay() to determine the current 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); getFullYear (Date.
Example The following example uses the constructor to create a Date object based on the current time and uses the getHours() method to display hour values from that object: var my_date:Date = new Date(); trace(my_date.getHours()); var my_date:Date = new Date(); var hourObj:Object = getHoursAmPm(my_date.getHours()); trace(hourObj.hours); trace(hourObj.ampm); function getHoursAmPm(hour24:Number):Object { var returnObj:Object = new Object(); returnObj.
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 Number - 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. Local time is determined by the operating system on which Flash Player is running. Availability: ActionScript 1.
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 Number - An integer. 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 Number - An integer. Example The following example creates a new Date object and uses Date.getUTCDay() and Date.getDay(). The value returned by Date.getUTCDay() can differ from the value returned by Date.
Example The following example creates a new Date object and uses Date.getUTCFullYear() and Date.getFullYear(). The value returned by Date.getUTCFullYear() may differ from the value returned by Date.getFullYear() if today's date is December 31 or January 1, depending on the relationship between your local time zone and universal time. var today_date:Date = new Date(); trace(today_date.getFullYear()); // display based on local timezone trace(today_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 Number - An integer. Example The following example creates a new Date object and uses getUTCMilliseconds() to return the milliseconds value from the Date object. var today_date:Date = new Date(); trace(today_date.
Returns Number - An integer. Example The following example creates a new Date object and uses Date.getUTCMonth() and Date.getMonth(). The value returned by Date.getUTCMonth() can differ from the value returned by Date.getMonth() if today's date is the first or last day of a month, depending on the relationship between your local time zone and universal time. var today_date:Date = new Date(); trace(today_date.getMonth()); // output based on local timezone trace(today_date.
Returns Number - An integer. Example The following example creates a new Date object and uses Date.getUTCFullYear() and Date.getFullYear(). The value returned by Date.getUTCFullYear() may differ from the value returned by Date.getFullYear() if today's date is December 31 or January 1, depending on the relationship between your local time zone and universal time. var today_date:Date = new Date(); trace(today_date.getFullYear()); // display based on local timezone trace(today_date.
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; Flash Player 5 Parameters date:Number - An integer from 1 to 31. Returns Number - An integer.
[optional] - A number from 1 to 31. If you omit this parameter, the date field of the specified Date object will not be modified. date:Number Returns Number - An integer. Example The following example initially creates a new Date object, setting the date to May 15, 2004, and uses Date.setFullYear() to change the date to May 15, 2002: var my_date:Date = new Date(2004,4,15); trace(my_date.getFullYear()); //output: 2004 my_date.setFullYear(2002); trace(my_date.
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; Flash Player 5 Parameters millisecond:Number - An integer from 0 to 999. Returns Number - An integer.
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 Date.setMinutes() to change the time to 8:30 a.m.: var my_date:Date = new Date(2004,4,15,8,0); trace(my_date.getMinutes()); // output: 0 my_date.setMinutes(30); trace(my_date.getMinutes()); // output: 30 setMonth (Date.
Parameters second:Number - An integer from 0 to 59. Returns Number - An integer. Example The following example initially creates a new Date object, setting the time and date to 8:00:00 a.m. on May 15, 2004, and uses Date.setSeconds() to change the time to 8:00:45 a.m.: var my_date:Date = new Date(2004,4,15,8,0,0); trace(my_date.getSeconds()); // output: 0 my_date.setSeconds(45); trace(my_date.getSeconds()); // output: 45 setTime (Date.
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 Date.getUTCDay() and Date.getDay() can report a new value if the day of the week changes as a result of calling this method. Availability: ActionScript 1.0; Flash Player 5 Parameters date:Number - A number; an integer from 1 to 31.
Parameters year:Number - An integer that represents the year specified as a full four-digit year, such as 2000. [optional] - An integer from 0 (January) to 11 (December). If you omit this parameter, the month field of the specified Date object will not be modified. month:Number [optional] - An integer from 1 to 31. If you omit this parameter, the date field of the specified Date object will not be modified. date:Number Returns Number - An integer.
[optional] - A number; an integer from 0 to 59. If you omit this parameter, the seconds field of the specified Date object will not be modified. second:Number [optional] - A number; an integer from 0 to 999. If you omit this parameter, the milliseconds field of the specified Date object will not be modified. millisecond:Number Returns Number - An integer. Example The following example initially creates a new Date object with today's date, uses Date.setUTCHours() to change the time to 8:30 a.m.
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()); // output: 250 my_date.setUTCMilliseconds(575); trace(my_date.getUTCMilliseconds()); // output: 575 setUTCMinutes (Date.
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 Date.getUTCDay() and Date.getDay() might report a new value if the day of the week changes as a result of specifying a value for the date parameter. Availability: ActionScript 1.
millisecond:Number [optional] - An integer from 0 to 999. If you omit this parameter, the milliseconds field of the specified Date object will not be modified. Returns Number - An integer. Example The following example initially creates a new Date object, setting the time and date to 8:00:00 a.m. on May 15, 2004, and uses Date.setSeconds() to change the time to 8:30:45 a.m.: var my_date:Date = new Date(2004,4,15,8,0,0); trace(my_date.getUTCSeconds()); // output: 0 my_date.
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 String - A string. Example The following example returns the information in the dateOfBirth_date Date object as a string. The output from the trace statements are in local time and vary accordingly.
Returns Number - An integer. Example The following example creates a new maryBirthday_date Date object defined in universal time. This is the universal time variation of the example used for the new Date constructor method. The output is in local time and varies accordingly. For Pacific Daylight Time the output is seven hours earlier than UTC: Sun Aug 11 17:00:00 GMT-0700 1974. var maryBirthday_date:Date = new Date(Date.UTC(1974, 7, 12)); trace(maryBirthday_date); valueOf (Date.
To apply filters to movie clips at runtime, use the filters property. Setting the 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 BitmapData.applyFilter() method. Calling applyFilter() on a BitmapData object modifies that BitmapData object and cannot be undone. You can also apply filter effects to images and video at authoring time. For more information, see your authoring documentation.
Property summary Modifiers Property Description alpha:Number Specifies the alpha transparency value to use for outof-bounds displacements. color:Number Specifies what color to use for out-of-bounds displacements. componentX:Number Describes which color channel to use in the map image to displace the x result. componentY:Number Describes which color channel to use in the map image to displace the y result. mapBitmap:BitmapData A BitmapData object containing the displacement map data.
Method summary Modifiers Signature Description clone() : Returns a copy of this filter object. DisplacementMapFilte r Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.
filter.alpha = .25; this.filters = new Array(filter); } function createDisplacementMapRectangle():MovieClip { var mapBitmap:BitmapData = createGradientBitmap(300, 80, 0xFF000000, "radial"); var filter:DisplacementMapFilter = new DisplacementMapFilter(mapBitmap, new Point(-30, -30), 1, 1, 10, 10, "wrap", 0x000000, 0x000000); var txtBlock:MovieClip = createTextBlock(); txtBlock._x = 30; txtBlock._y = 30; txtBlock.
clone (DisplacementMapFilter.clone method) public clone() : DisplacementMapFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns flash.filters.DisplacementMapFilter - A new DisplacementMapFilter instance with all the same properties as the original one.
} for(var i in clonedFilter) { trace(">> " + i + ": " + clonedFilter[i]); // >> clone: [type Function] // >> alpha: 0 // >> color: 0 // >> mode: wrap // >> scaleY: 10 // >> scaleX: 10 // >> componentY: 1 // >> componentX: 1 // >> mapPoint: (-30, -30) // >> mapBitmap: [object Object] } 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.
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"; trace(filter_1.mode); // ignore trace(filter_2.
Example The following example modifies the out-of-range color property on the existing MovieClip filteredMc to 0x00FF00 when a user clicks it. import import import import import flash.filters.DisplacementMapFilter; flash.display.BitmapData; flash.geom.Point; flash.geom.Matrix; flash.geom.ColorTransform; var filteredMc:MovieClip = createDisplacementMapRectangle(); filteredMc.onPress = function() { var filter:DisplacementMapFilter = this.filters[0]; filter.scaleY = 25; filter.mode = "color"; filter.
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.
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.
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 componentY property on the existing MovieClip when a user clicks it. The value changes from 1 to 4, which changes the color channel from red to blue.
mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.endFill(); (hide == true) ? mc._alpha = 0 : mc._alpha = 100; var bmp:BitmapData = new BitmapData(w, h, true, bgColor); bmp.draw(mc, new Matrix(), new ColorTransform(), "normal", bmp.rectangle, true); mc.attachBitmap(bmp, this.getNextHighestDepth()); return bmp; } function createTextBlock():MovieClip { var txtBlock:MovieClip = this.
componentX:Number - Describes which color channel to use in the map image to displace the x result. Possible values are the following: ■ 1 (red) ■ 2 (green) ■ 4 (blue) ■ 8 (alpha) componentY:Number - Describes which color channel to use in the map image to displace the y result. Possible values are the following: ■ 1 (red) ■ 2 (green) ■ 4 (blue) ■ 8 (alpha) scaleX:Number - The multiplier to use to scale the x displacement result from the map calculation.
import import import import import flash.filters.DisplacementMapFilter; flash.display.BitmapData; flash.geom.Point; flash.geom.Matrix; flash.geom.
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. The mapBitmap property cannot be changed by directly modifying its value.
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"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.
mapPoint (DisplacementMapFilter.mapPoint property) public mapPoint : Point A flash.geom.Point value that contains the offset of the upper-left corner of the target movie clip from the upper-left corner of the map image. The mapPoint property cannot be changed by directly modifying its value. Instead, you must get a reference to mapPoint, make the change to the reference, and then set mapPoint to the reference. Availability: ActionScript 1.
function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1); var matrix:Matrix = new Matrix(); matrix.createGradientBox(w, h, 0, 0, 0); mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.endFill(); (hide == true) ? mc._alpha = 0 : mc.
mode (DisplacementMapFilter.mode property) public mode : String The mode for the filter. Possible values are the following: ■ "wrap" — Wraps the displacement value to the other side of the source image. This is the default value. ■ "clamp" ■ "ignore" ■ — If the displacement value is outside the image, substitutes a pixel value composed of the alpha and color properties of the filter. — Clamps the displacement value to the edge of the source image.
return txtBlock; } function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1); var matrix:Matrix = new Matrix(); matrix.createGradientBox(w, h, 0, 0, 0); mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.endFill(); (hide == true) ? mc._alpha = 0 : mc.
import flash.geom.Point; import flash.geom.Matrix; import flash.geom.ColorTransform; var filteredMc:MovieClip = createDisplacementMapRectangle(); filteredMc.onPress = function() { var filter:DisplacementMapFilter = this.filters[0]; filter.scaleX = 5; this.
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.
function createGradientBitmap(w:Number, h:Number, bgColor:Number, type:String, hide:Boolean):BitmapData { var mc:MovieClip = this.createEmptyMovieClip("mc", 1); var matrix:Matrix = new Matrix(); matrix.createGradientBox(w, h, 0, 0, 0); mc.beginGradientFill(type, [0xFF0000, 0x0000FF], [100, 100], [0x55, 0x99], matrix, "pad"); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc.endFill(); (hide == true) ? mc._alpha = 0 : mc.
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 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 BitmapData.applyFilter() method.
Property summary Modifiers Property Description alpha:Number The alpha transparency value for the shadow color. angle:Number The angle of the shadow. blurX:Number The amount of horizontal blur. blurY:Number The amount of vertical blur. color:Number The color of the shadow. distance:Number The offset distance for the shadow, in pixels. hideObject:Boolean Indicates whether or not the object is hidden. inner:Boolean Indicates whether or not the shadow is an inner shadow.
Method summary Modifiers Signature Description clone() : Returns a copy of this filter object. DropShadowFilter Methods inherited from class BitmapFilter clone (BitmapFilter.clone method) Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.isPropertyEnumerable method), isPrototypeOf (Object.isPrototypeOf method), registerClass (Object.registerClass method), toString (Object.
art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; } angle (DropShadowFilter.angle property) public angle : Number The angle of the shadow. Valid values are 0 to 360° (floating point). The default value is 45.
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. Values that are a power of 2 (such as 2, 4, 8, 16 and 32) are optimized to render more quickly than other values.
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. Availability: ActionScript 1.0; Flash Player 8 Example The following example changes the blurY property on an existing movie clip when a user clicks it. import flash.filters.
clone (DropShadowFilter.clone method) public clone() : DropShadowFilter Returns a copy of this filter object. Availability: ActionScript 1.0; Flash Player 8 Returns flash.filters.DropShadowFilter - A new DropShadowFilter instance with all the properties of the original one.
// // // // // // // // // // // >> >> >> >> >> >> >> >> >> >> >> hideObject: false strength: 1 blurY: 16 blurX: 16 knockout: false inner: false quality: 3 alpha: 0.8 color: 0 angle: 45 distance: 15 } To further demonstrate the relationships between filter_1, filter_2, and clonedFilter, the following example modifies the knockout property of filter_1. Modifying knockout demonstrates that the clone() method creates a new instance based on the values of filter_1 instead of pointing to them in reference.
var mc:MovieClip = createDropShadowRectangle("DropShadowColor"); mc.onRelease = function() { var filter:DropShadowFilter = this.filters[0]; filter.color = 0xFF0000; this.filters = new Array(filter); } function createDropShadowRectangle(name:String):MovieClip { var art:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); var w:Number = 100; var h:Number = 100; art.beginFill(0x003366); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art.
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(); filterArray.push(filter); art.
[optional] - 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. blurY:Number strength:Number [optional] - 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. Valid values are 0 to 255. The default is 1.
blurY, strength, quality, inner, knockout, hideObject); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; function createRectangle(w:Number, h:Number, bgColor:Number, name:String):MovieClip { var mc:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); mc.beginFill(bgColor); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); mc._x = 20; mc._y = 20; return mc; } hideObject (DropShadowFilter.
var h:Number = 100; art.beginFill(0x003366); art.lineTo(w, 0); art.lineTo(w, h); art.lineTo(0, h); art.lineTo(0, 0); art._x = 20; art._y = 20; var filter:DropShadowFilter = new DropShadowFilter(15, 45, 0x000000, .8, 16, 16, 1, 3, false, false, false); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; return art; } inner (DropShadowFilter.inner property) public inner : Boolean Indicates whether or not the shadow is an inner shadow.
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 (true), which effectively makes the object's fill transparent and reveals the background color of the document. The default is false (no knockout).
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. A value of 2 is medium quality, and a value of 3 is high 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. Valid values are from 0 to 255. The default is 1.
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 Error constructor function. Typically, you throw a new Error object from within a try code block that is then caught by a catch or finally code block. You can also create a subclass of the Error class and throw instances of that subclass. Availability: ActionScript 1.
Method summary Modifiers Signature Description toString() : String Returns the string "Error" by default or the value 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 method), unwatch (Object.
message (Error.message property) public message : String Contains the message associated with the Error object. By default, the value of this property is "Error". You can specify a message property when you create an Error object by passing the error string to the Error constructor function. Availability: ActionScript 1.0; Flash Player 7 Example In the following example, a function throws a specified message depending on the parameters entered into theNum.
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"); // output: Strings do not match. } catch (e_err:Error) { trace(e_err.toString()); } See also message (Error.message property), throw statement, try..catch..
ExternalInterface is supported in the following combinations of browser and operating system: Browser Operating System Internet Explorer 5.0 and higher Windows Netscape 8.0 and higher Windows Macintosh Mozilla 1.7.5 and higher Windows Macintosh 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. See http:// www.mozilla.
Method summary Modifiers Signature static addCallback(methodNa Registers an ActionScript method as callable from me:String, Description the container. instance:Object, method:Function) : Boolean static call(methodName:Stri Calls a function exposed by the Flash Player ng, container, passing 0 or more arguments. [parameter1:Object]) : Object Methods inherited from class Object addProperty (Object.addProperty method), hasOwnProperty (Object.hasOwnProperty method), isPropertyEnumerable (Object.
Returns - If the call succeeded, returns true. If it failed because the instance was not available, a security restriction was encountered, there was no such function object, a recursion occurred, or something similar, returns false. Boolean A return value of false may also mean that the containing environment belongs to a security sandbox to which the calling code does not have access.
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 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. Availability: ActionScript 1.0; Flash Player 8 Parameters - The name of the function to call in the container.
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. Unless the HTML page is hosted on a server, your browser may alert you with a security warning.