0% found this document useful (0 votes)
90 views65 pages

Action Script

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views65 pages

Action Script

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ActionScript Programming

Introduction to ActionScript............................................................................................................................ 1 Button scripts ................................................................................................................................................. 3 Loops ............................................................................................................................................................. 5 Functions ....................................................................................................................................................... 6 Arrays ............................................................................................................................................................ 7 Edit fields ....................................................................................................................................................... 8 Operators....................................................................................................................................................... 9 Assignment operators.................................................................................................................................. 11 Internal functions ......................................................................................................................................... 13 MovieClip ..................................................................................................................................................... 16 Drawing Sprites ........................................................................................................................................... 21 Array ............................................................................................................................................................ 24 Key............................................................................................................................................................... 28 Mouse .......................................................................................................................................................... 30 Button .......................................................................................................................................................... 31 Math............................................................................................................................................................. 33 Date ............................................................................................................................................................. 35 Variable classes........................................................................................................................................... 37 Sound .......................................................................................................................................................... 41 String ........................................................................................................................................................... 43 Stage ........................................................................................................................................................... 45 System......................................................................................................................................................... 46 TextField ...................................................................................................................................................... 49 CSS ............................................................................................................................................................. 55 XML ............................................................................................................................................................. 57 LoadVars ..................................................................................................................................................... 61 Functions not supported by Alligator Flash Designer.................................................................................. 63

Introduction to ActionScript
ActionScript allows Flash developer to control contents of a Flash document by using commands executed during animation playback. Frame script is executed before the frame appears on the screen. Button script is triggered by events like mouse click or when the mouse cursor enters the area of an object. Frame Script To define the script, choose Frame > ActionScript and enter the script in the dialog box. The simplest ActionScript Launch Alligator Flash Designer, draw an edit field using the Edit field tool. The field will appear as Edit1,Edit2 etc.).

Choose Frame > ActionScript and paste the following code: Edit1 = "hello!!!"; Press F9 to run the animation. The text hello!!! will appear in the edit field. Language Syntax ActionScript consists of a series of commands each ending with a semicolon. To maintain script clarity each command shall be entered on a separate line. Text and Numbers In order to distinguish text from numbers in ActionScript, text is limited with quotes, and numbers are entered without any delimiters. In the following example, number 100 will appear instead of hello!!!: Edit1 = 100; Variables Variables can be divided into text variables and number variables. Text variables store a string of characters and number variables store numbers. A variable stores data during playback of the entire Flash animation. In the following example you can use ActionScript to calculate area of a rectangle. Launch Alligator Flash Designer, draw and edit field with the Edit field tool. The edit field will appear as Edit1, Edit2 etc. Choose Frame > ActionScript and paste the following code: width = 20; height = 30; result = width * height; Edit1 = result;

Press F9 to run the movie. 600 will be displayed in the edit field. You can use numeric variables in various mathematical equations, for example to calculate surface area of a triangle: result = 0.5 * width * height; or more complex operation result = 1.45 + (width * height + 20) * 100; Text variables Text variables can be concatenated with + operator: width = 20; height = 30; result = width * height; text = "Area: " + result + " m2"; Edit1 = text; The result displayed in the edit field is Area: 600 m2". Variable name must start with an alphanumeric character: a to z and can include numbers (not as the first character) and underscore sign _. Variable names must not include any national characters. Correct variables: variable1, my_variable Incorrect variables 1variable (starts with a number) variable (includes diacritics)

Button scripts
ActionScript can be executed in response to mouse events (click, mouse over, mouse out, mouse up). To define button script, select an object and choose Action, then one of the commands: On Click, On Over, On Out, On Up. In the dialog window select ActionScript and enter the script. To define a simple event, open a new Flash project and draw 2 objects: edit field Edit1 and Button2. Select Button2 and choose Action > On Click. Enter the following code and click OK Edit1 = "Button event";

Press F9 to run preview. Click Button2 to execute the code; Button event will be displayed in the edit field. Mouse over and mouse out event. choose Action > On Over and enter the code: Edit1 = "Mouse over"; choose Action > On Out and enter the code: Edit1 = ""; this command will erase the content of Edit1.

Conditionals
The following instruction checks the variable value and executes part of the code if the condition is met Syntax: if (condition) { .. execute code } Example: width = 20; height = 30; result = width * height; if (result > 500) { text = "Area > 500"; } Edit1 = text; If the area is larger than 500, Area > 500 will be displayed in the Edit1 field. Else instruction Else command executes the code, if the condition is not met: width = 20; height = 30; result = width * height; if (result > 500) { text = "What a large area"; } else { text = "What a small area"; } Edit1 = text; If the result is larger than 500, command text = What a large area will be executed, otherwise text = What a small area will be executed.

Loops
Loop will execute the same code several times, each time with increased (or decreased) specific variable, enabling the same calculation for several variable values. For instruction Syntax for( initial value ; continuation condition ; increasing command ) { instructions will be repeated in the loop }

Draw Edit1 text field, choose Frame > ActionScript and enter the following script: text = "Even numbers: "; for( i = 2 ; i < 10 ; i = i + 2 ) { text = text + i + " "; } Edit1 = text; The code will display Even numbers: 2 4 6 8 While instruction While loop is another type of loop:: while( condition ) { instructions will be repeated in the loop } In this case, you have to enter the command for initiating variable and increasing its value so the loop can end. text = "Even numbers: "; i = 2; while( i < 10 ) { text = text + i + " "; i = i + 2; } Edit1 = text;

Functions
Function is a part of code that can be stored in a memory and executed as one of the ActionScript commands. Function can have parameters and return a value calculated inside the function. In the following example, a function calculating rectangle area surface will be defined and executed. function area(width,height) { result = width * height; return result; } Edit1 = area(20,30);

Function definition must be preceded by function word. The name of the function must obey the same rules as variable names, e.g. it can not start with a numerical and it can include letters, numbers and underscore sign. The code of a function is entered between brackets { }. The last command is return returning calculated value.

Arrays
Array is a variable with several values. Array index is specified in brackets [ ]. For example, create an array with female names: names = new Array(); names[0] = "Julia"; names[1] = "Maria"; names[2] = "Sandra"; Edit1 = names[2]; Unlike numeric and text variables, arrays must be created before used. Array can be initialized directly with the command new . names = new Array("Julia","Maria","Sandra"); Edit1 = names[2];

Objects
Objects, also referred to as classes, are similar to variables, although their structure allows you to store variables referred to as object attributes and functions referred to as object methods. For example all Sprite objects are of MovieClip class. They include _x and _y attributes which is the upper and left position of a sprite. A sprite object can be moved during the playback by modifying these attributes. Attributes and methods must be referenced with a dot between the object name and the method or between the object name and the attribute name. Draw Sprite1 object, draw circle inside the Sprite. Exit the sprite, choose "Frame" > "ActionScript" and enter the code: Sprite1._x = 0; Sprite1._y = 0; Press F2 to change the sprite name so it is identical to the name used in the code, in this case it must be Sprite1. Press F9 to execute the code. The sprite will move to the upper left corner of your animation. Use new command to create objects: variable = new ObjectType( parameters );

Edit fields
Edit fields, usually Edit1, Edit2 etc. can be used for displaying variables and entering data. Create a new Flash project and draw 3 edit fields: Edit1, Edit2 and Edit3, and Button4 button. Select each field and press Enter to open preferences. Name the fields accordingly height, width and result, and name the button Calculate:

Select the Calculate button, choose "Action" > "On Click", enter the following code: result = height * width; Press F9 and try some calculations by entering input data and clicking Calculate button. Multiline fields Text fields are a single line as a default. Select the field and press Enter to modify the field parameters. Check Multiline to accept return key in the edit field. New line mark Use "\n" string inside the string variable to break the text into lines. Create the text field and extend it vertically to contain several lines, check the Multiline option. Enter the following frame code: Edit1 = "Line 1\nNew line\nAnother line";

Operators
Operators are mathematical or logical operation commands for variables and numbers. + add values subtract values / divide values * multiply values % modulo, remainder of the division e.g. Edit1 = 10 % 3; the result is 1 Comparison operators Operators used for conditional commands, returning true or false value. < less, returns true, if the first parameter is less than the second parameter > greater, returns true, if the first parameter is greater than the second parameter <= less or equal to, returns true, if the first parameter is less or equal to the second parameter >= greater or equal to, returns true, if the first parameter is greater or equal to the second parameter == equality, returns true, if the parameters are identical, and false if they differ === exact equality, returns true if the parameters are identical and of the same type, and false if they differ != inequality, returns true if the parameters differ, false if they are identical ! logical negation, converts true to false or false to true

Logical operators Operators used in conditional commands to combine true of false values. && logical sum, returns true if both conditions are met, otherwise returns false || returns true if one of the conditions is met, returns false if both conditions are not met Bit operators Operators for binary numbers Example: decimal and binary numbers 1 2 3 4 8 16 32 = = = = = = = 00000001 00000010 00000011 00000100 00001000 00010000 00100000

& bitwise AND operator, if for both parameters in a specific location the bit has a value of 1, the result is also 1. example 1 & 2 = 0 1 & 3 = 1 | if both bits on specific location have a value of 1, the resulting bit is also 1 example 1 & 2 = 3 ^ Xor, if bits in a specific location are equal, the result is a bit 0, if they differ, the result is 1 example 1 ^ 3 = 2 ~ Bit negation, inverse the bit value for each position

10

Assignment operators
Assignment operator calculates value on the right-hand side of the equal sign and stores it in the variable on the left-hand side of the equal sign. Edit1 = x + 1; Also the following operators are available:

+=
adds value on the right-hand side of the equal sign to the variable x += 4; is equivalent to x = x + 4; or Edit1 += "additional text"; is equivalent to Edit1 = Edit1 + "additional text";

-=
subtracts value on the right-hand side of the equal sign from the variable x -= a + 2; is equivalent to x = x (a + 2);

*=
multiplies value on the right-hand side by the variable x *= a + 2; is equivalent to x = x * (a + 2);

/=
divides a variable by the value on the right-hand side of the equal sign x /= a + 2;

11

is equivalent to x = x / (a + 2);

%=
calculates variable modulo and assigns a result

&=
adds bit value to the current variable and assigns a result

|=
executes OR operation of the value and the current variable and assigns a result

^=
executes XOR operation of the value and the current variable and assigns a result

>>=
moves variable bits to the right-hand side and assigns a result

<<=
moves variable bits to the left-hand side and assigns a result

12

Internal functions
escape(expression:String) : String Changes a string to a form that can be transmitted as HTTP call arguments, i.e. all non-alphanumeric characters are changed to % code unescape(x:String) : String Changes string from the HTTP call arguments to normal text getTimer() : Number Returns milliseconds from the time when the movie clip has started getURL(url:String) Opens an internet link getURL(url:String, window:String) Opens an internet link with target parameter Example getURL("[Link] opens [Link] address in a new window Link parameters can be specified after ? sign getURL("[Link] gotoAndPlay(scene:String) jumps to the frame with specified name gotoAndPlay("Frame 2"); [Link]("Frame 2"); _root.gotoAndPlay("Frame 2"); gotoAndPlay(frame:Number) jumps to the frame by physical frame index, number of frames depends on movie clip frequency, usually 20 frames per second. gotoAndStop(scene:String) jumps to the frame with specified name and stops gotoAndStop("Frame 2"); [Link]("Frame 2"); _root.gotoAndStop("Frame 2");

gotoAndStop(frame:Number) jumps to the frame with frame index and stops isNaN(expression:Object) : Boolean Returns true if value is non-numerical, false if it is numerical

13

Number(text: String) Converts string value to numeric Example Edit3 = Number(Edit1) + Number(Edit2); parseFloat(string:String) : Number Changes string to number Example Edit1 = parseFloat("3.5e6"); 3500000 is obtained parseInt(expression:String [, base:Number]) : Number Changes an integer in the specific base system: binary or hexadecimal Examples Edit1 = parseInt("101",2); setInterval(functionName:Function, interval:Number) : Number Call specific function in specified time interval in milliseconds Example: draw Edit1 field and paste the frame code Edit1 = 0; function myInterval() { Edit1 = Edit1 + 1; } setInterval(myInterval,100); this Variable used inside the function refers to the current owner of the function function Constructor() { this.attribute1 = "some text"; } o = new Constructor(); Edit1 = o.attribute1;

14

typeof(expression) : String Return variable type String: string Sprite: movieclip Button: object Text field: object Number: number Boolean: boolean Object: object Function: function Null value: null Undefined value: undefined Examples: s = "12345"; Edit1 = typeof(s); or s = 12345; Edit1 = typeof(s); or Edit1 = typeof(_root); or Draw Sprite1 with a circle inside and Edit1 text field, paste the frame code: [Link] = function () { Edit1 = "press"; } Edit1 = typeof([Link]); undefined Not a number if (someUndefinedVariable == undefined) { Edit1 = "variable does not exist"; }

15

MovieClip
MovieClip it is the most commonly used class. All Group or Sprite type objects exist as MovieClips. The main Flash movie is defined as a _root object. MovieClip._alpha : Number Object transparency from 0 to 100 % MovieClip._currentframe : Number Number of current physical frame during playback. MovieClip._droptarget : String Name of other Sprite, the current Sprite is dragged and dropped into [Link] : Boolean True if the Sprite can receive mouse events, otherwise the Sprite is blocked [Link] : Boolean True value if the Sprite can receive key events, otherwise Sprite is blocked MovieClip._focusrect : Boolean If true, Sprite is enclosed with a rectangle, which means that it accepts keyboard events MovieClip._framesloaded : Number Number of Sprite frames currently downloaded from the internet, if the Sprite is loaded from an external file MovieClip._height : Number Sprite height in pixels [Link] : MovieClip Indicator of a different Sprite, if the Sprite has a different object acting as an active button field MovieClip._lockroot : Boolean If the subclip is loaded from an external file _lockroot = true, references from the subclip to the _root object are related to the subclip object not the main clip that loads a subclip. [Link] : ContextMenu Context menu objects (right mouse button) assigned to a specific Sprite. File must be exported to Flash Player 8 or higher. In this example, menu item for the main clip is added function goOnTheWeb() { getURL("[Link] "_blank"); } mymenu = new ContextMenu(); [Link](new ContextMenuItem("[Link]",goOnTheWeb)); _root.menu = mymenu;

16

MovieClip._name : String Sprite instance name Edit1 = Sprite1._name; MovieClip._parent : MovieClip Indicator for parent Sprite including this sprite MovieClip._quality : String Movie quality: "LOW" Low quality, fast playback "MEDIUM" Medium quality, bitmaps and text are not optimized "HIGH" Default quality "BEST" High quality, bitmaps are optimized MovieClip._rotation : Number Sprite angle of rotation MovieClip._soundbuftime : Number Delay in seconds, before buffered sound is played [Link] : Boolean True if the Sprite belongs to the chain of Tab switching [Link] : Boolean True if the Sprite children will be included in the Tab switching cycle [Link] : Number Entry number for Tab switching MovieClip._target : String Absolute sprite path Edit1 = Sprite1._target; MovieClip._totalframes : Number Total number of sprite frames

17

[Link] : Boolean If true, specific Sprite accepts all events of mouse up, even outside the sprite area MovieClip._url : String Internet address from which the Sprite is loaded [Link] : Boolean If false and when mouse action is defined, the Sprite will have an arrow cursor instead of a link cursor [Link] = false; MovieClip._visible : Boolean Defines if Sprite is visible or not

Show sprite: Sprite1._visible = true; Hide sprite: Sprite1._visible = false;

MovieClip._width : Number MovieClip._height : Number Sprite width and height in pixels MovieClip._x : Number MovieClip._y : Number Sprite location inside the parent MovieClip._xmouse : Number MovieClip._ymouse : Number Cursor location function readmouse() { Edit1 = _root._xmouse + ", " + _root._ymouse; } setInterval(readmouse,10); MovieClip._xscale : Number MovieClip._yscale : Number Sprite x and y scale in percents, default 100

[Link](instanceName:String, depth:Number) : MovieClip Creates new and empty Sprite object with instanceName and specific depth, higher depth hides the object under other objects

[Link](instanceName:String, depth:Number, x:Number, y:Number, width:Number, height:Number) Creates empty text field with instanceName, specific depth and dimensions.

18

Dimensions are specified in pixels. _root.CreateTextField("EditField1",10,20,20,500,40); [Link] = "My text field"; [Link](newname:String, depth:Number) : MovieClip Duplicates Sprite and places it on specific depth [Link]("Sprite2",100); Sprite2._x = Sprite1._x + 10; Sprite2._y = Sprite1._y + 10; [Link](targetCoordinateSpace:Sprite) : Object Returns rectangle with items visible inside the Sprite in relation to targetCoordinateSpace object or in relation to each other, if the parameter is not specified rect = [Link](); Edit1 = [Link] + ", " + [Link] + ", " + [Link] + ", " + [Link]; [Link]() : Number Returns loaded bytes if the file is downloaded from the internet [Link](): Number Returns total Sprite bytes [Link](): Number Returns sprite depth [Link](depth:Number) : MovieClip Returns pointer to the sprite on specific depth [Link]() : Number Returns any depth on which the new Sprite can be located Each depth may include a single object. [Link](): Number Returns version number for which the specific sprite is intended, if loaded from an external file [Link]() : String Creates a string from the content of text fields within the Sprite [Link](URL:String [,window:String, method:String]) Open link URL: internet address e.g. [Link] window: _blank opens new browser window, _self opens link in the current window method: string POST or GET, if link has parameters after the ?, default value is GET [Link](point:Object) Changes global point coordinates (x and y) to the coordinates within the Sprite

[Link](framename:String) Jumps to the specific frame (e.g. Frame2) and starts playback [Link](framename:String) Jumps to specific frame (e.g. Frame2) and stops playback

19

[Link](target:Object) Returns true, if the Sprite overlaps (contacts) the Sprite specified as a target parameter [Link](x:Number, y:Number, shapeFlag:Boolean) Returns true, if point (x and y) touches the Sprite, shapeFlag parameter defines, if the visible sprite components or the whole rectangle is taken for the calculations [Link](url:String) Loads SWF, FLV or JPG file [Link](url:String) Loads variable from the text file, text file must contain variable in the same form as the URL addresses .txt file example var1="hello"&var2="goodbye" [Link](point:Object) Changes point coordinates (x and y) inside the Sprite to global coordinates [Link]() Jumps to the next frame [Link]() Starts movie playback [Link]() Jumps to the previous frame [Link]() Removes Sprite created using [Link]() command [Link](target:Sprite) Sets Sprite as a mask for other Sprite [Link]() Starts dragging a Sprite with a mouse [Link]([lock:Boolean, [left:Number, top:Number, right:Number, bottom:Number]]) Starts dragging a Sprite with a mouse limiting available area with left, top, right and bottom values Lock parameter makes the Sprite center correspond to a mouse cursor [Link]() Stops Sprite playback [Link]() Stops dragging a Sprite with a mouse

[Link](depth:Number) [Link](target:String) Swaps 2 Sprite depths at the specific depth or with a specific name [Link]() Removes the sprite, dynamically loaded from an external file, from memory

20

Drawing Sprites
[Link](rgb:Number) [Link](rgb:Number, alpha:Number) Specifies fill Color using hexadecimal code and alpha opacity [Link](fillType:String, Colors:Array, alphas:Array, ratios:Array, matrix:Object) Specifies gradient fill between different Colors fillType: "linear" or "radial" Colors: Color array, max. 8 items alphas: opacity array (from 0 transparent to 255 full opacity), max. 8 items ratios: gradient fill Color position array, values from 0 to 255, max. 8 items [Link]() Clears the drawing made with drawing commands [Link](cx:Number, cx:Number, x:Number, y:Number) Draws Bezier curve from point x,y and control point cx and cy [Link]() Closes started lines and fills the curve with Color specified with [Link]() or [Link]() commands. [Link](thickness:Number, rgb:Number, alpha:Number) Sets new line style with specific thickness rgb Color and alpha opacity [Link](x:Number, y:Number) Draws straight line to the x, y point [Link]() Sets new drawing start position

Sprite event support


The below events can be assigned to the defined functions [Link] : Function Called while downloading data [Link] : Function Called when mouse button is pressed within the sprite and moved outside its area [Link] : Function Called when the mouse button is pressed outside the sprite and moved into its area [Link] : Function Called before displaying each physical frame [Link] : Function

21

Called after pressing [Link]() and [Link]() in order to obtain a key code [Link] : Function Called when the key is released [Link] : Function Called when the Sprite cannot accept keyboard events [Link] : Function Called before the Sprite appears in the clip for the first time [Link] : Function Called when left mouse button is used [Link] : Function Called by mouse movement [Link] : Function Called when the mouse button is released [Link] : Function Called when left mouse button is used [Link] : Function Called when the mouse button is released [Link] : Function Called when mouse button is pressed within the sprite, moved outside and released [Link] : Function Called when mouse cursor is moved outside the sprite area [Link] : Function Called when mouse cursor is moved into the sprite area [Link] : Function Called when sprite sets focus [Link] : Function Called when sprite is unloaded from the clip

22

Example: Draw Edit1 field and Sprite2, draw circle inside the sprite:

paste the following code in the ActionScript frame: [Link] = function () { Edit1 = "onPress"; } [Link] = function () { Edit1 = "onRelease"; } [Link] = function () { Edit1 = "onRollOut"; } [Link] = function () { Edit1 = "onRollOver"; }

23

Array
This class represents array type, arranged variables that can be referred to using index in brackets [ ]. [Link]( array1, array2, ... ) Joins arrays arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; arr2 = new Array(); arr2[0] = "Sandra"; arr2[1] = "Pamela"; arr3 = [Link](arr2); Edit1 = arr3[3]; [Link]( separator ) Joins array items as a string arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; arr1[2] = "Pamela"; Edit1 = [Link](", "); [Link]() Removes last array item and returns its value arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; arr1[2] = "Pamela"; Edit1 = [Link](); [Link]() Adds item at the end of an array and returns new number of items arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; [Link]("Pamela"); [Link]() Reverses the order of array items arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; arr1[2] = "Pamela"; [Link](); Edit1 = [Link](", ");

24

[Link]() Removes the first array item and returns its value arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; arr1[2] = "Pamela"; Edit1 = [Link]();

[Link]( start, end ) Slices part of an array from the start item to the end item (not included) and returns a new array arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; arr1[2] = "Sandra"; arr1[3] = "Pamela"; arr2 = [Link](1,3); Edit1 = [Link](", ");

[Link]() Sorts array items arr1 = new Array(); arr1[0] = "Maria"; arr1[1] = "Sandra"; arr1[2] = "Pamela"; arr1[3] = "Julia"; [Link](); Edit1 = [Link](", ");

[Link]( option ) Available option parameter values 1 or [Link], case insensitive 2 or [Link], reversed order (descending) 4 or [Link], sorting error, identical values 8 or [Link], returns indexed arrays without sorting original array 16 or [Link], numerical values in array, otherwise algorithm will sort 100 before 99, since 1 is before 9

25

Sorting function syntax function sort(a, b) { ... compare a and b return 1 , 0 or -1 }

[Link]( compareFunction ) Sort compareFunction must return 0, when items are identical, -1 when item a is lesser than item b, 1 when item b is lesser than item a. arr1 = new Array(); arr1[0] = 30; arr1[1] = 4; arr1[2] = 1; arr1[3] = 16; function sort(a,b) { if(a<b) return -1; if(a>b) return 1; return 0 } [Link](sort); Edit1 = [Link](", ");

[Link]( fieldName) Sorts items in relation to the array field. Array fields can be used as a sorting value: arr1 = new Array(); arr1[0] = new Object(); arr1[1] = new Object(); arr1[2] = new Object(); arr1[3] = new Object(); [Link]("age"); Edit1 = arr1[0].name + ", " + arr1[1].name + ", " + arr1[2].name + ", " + arr1[3].name ;

arr1[0].name arr1[1].name arr1[2].name arr1[3].name

= = = =

"Maria"; "Sandra"; "Pamela"; "Julia";

arr1[0].age arr1[1].age arr1[2].age arr1[3].age

= = = =

24; 15; 31; 22;

26

[Link]( start, count) Removes array items arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; arr1[2] = "Sandra"; arr1[3] = "Pamela"; [Link](1,2); Edit1 = [Link](", ");

[Link]() Converts array to a string. arr1 = new Array(); arr1[0] = 1; arr1[1] = 10; arr1[2] = 100; arr1[3] = 1000; Edit1 = [Link]();

[Link]() Adds new items at the beginning. arr1 = new Array(); arr1[0] = "Julia"; arr1[1] = "Maria"; [Link]("Sandra", "Pamela" ); Edit1 = [Link](", ");

[Link] Returns number of items in the table names = new Array(); names[0] = "Julia"; names[1] = "Maria"; names[2] = "Sandra"; Edit1 = [Link];

27

Key
This Class is responsible for keyboard support. Before keyboard actions are supported by the clip, it must be activated in the browser by clicking a mouse button in the movie clip area. [Link](newListener:Object) Adds listener for support of pressing and releasing buttons Example myListener = new Object(); [Link] = function () { Edit1 = "Key pressed"; } [Link] = function () { Edit1 = "Key released."; } [Link](myListener);

[Link]() : Number Returns ASCII of the last pressed button [Link]() : Number Returns code of the last pressed button [Link](keycode:Number) : Boolean Returns true if specific key is pressed [Link](keycode:Number) : Boolean Returns true if Num Lock or Caps Lock is pressed. [Link](listener:Object) : Boolean Removes listener

28

Key codes To simplify, Key class includes attributes corresponding to the codes of the most common keys [Link] = 8 [Link] = 20 [Link] = 17 [Link] = 46 [Link] = 40 [Link] = 35 [Link] = 13 [Link] = 27 [Link] = 36 [Link] = 45 [Link] = 37 [Link] = 33 [Link] = 34 Example: moving the sprite with keys. Draw Sprite1, place a circle inside, exit the sprite and enter the frame code: myListener = new Object(); [Link] = function () { if([Link]([Link])) Sprite1._x = Sprite1._x - 5; if([Link]([Link])) Sprite1._x = Sprite1._x + 5; if([Link]([Link])) Sprite1._y = Sprite1._y - 5; if([Link]([Link])) Sprite1._y = Sprite1._y + 5; } [Link](myListener);

29

Mouse
[Link](newListener:Object) Adds listener for mouse events support [Link]() : Number Hides mouse cursor, returns true if cursor is visible [Link]((listener:Object) : Boolean Removes listener added by addListener(). [Link]() : Number Shows cursor, returns if cursor is visible before function call [Link] : Function Function called when pressing mouse button [Link] : Function Function called when mouse is moved [Link] : Function Function called when mouse button is released [Link] : Function Function called when mouse scroll is rotated Example display of mouse position in Edit1 field myListener = new Object(); [Link] = function () { Edit1 = _root._xmouse + ", " + _root._ymouse; } [Link](myListener);

30

Button
Button class corresponds to buttons created with Button tool By default buttons are named: ButtonObject1, ButtonObject2 etc. Select the button and press F2 to display button name. In order to define button for ActionScript press F2 and check ActionScript object option. Button._alpha : Number Button opacity: 0 to 100 percent [Link] : Boolean Specifies if the button accepts mouse and keyboard events Example: blocking button before clicking, draw Button1 and paste the frame code: ButtonObject1._alpha = 20; [Link] = false; Button._height : Number Button._width : Number Define button dimensions Button._name : String Button object name Button._rotation : Number Button rotation in relation to upper left corner [Link] : Boolean True if the button is within the chain of Tab switching [Link] : Number Entry number for Tab switching Button._target : String Absolute button path Edit1 = ButtonObject1._target; [Link] : Boolean If true, specific button accepts all mouse release events, even outside the sprite area [Link] : Boolean If false, button will have an arrow cursor instead of a link cursor, if the mouse action is defined for the specific button [Link] = false;

Button._x : Number Button._y : Number Shifting button in relation to the current position, default 0,0

31

Button._xmouse : Number Button._ymouse : Number Mouse cursor position on a button Button._visible : Boolean Specifies if the button is visible [Link] : Function Called when the mouse button is pressed within the button and the cursor is dragged outside the area [Link] : Function Called when the mouse button is pressed outside the button and the cursor is dragged over the area [Link] : Function Called after pressing [Link]() and [Link]() in order to obtain a key code [Link] : Function Called when the key is released [Link] : Function Called when the button cannot accept keyboard events [Link] : Function Called when pressing left mouse button on the button [Link] : Function Called when the mouse button is released [Link] : Function Called when the mouse button is pressed within the button, and the cursor is dragged outside the area and the mouse button is released [Link] : Function Called when the mouse cursor rolls out of the button [Link] : Function Called when the mouse pointer rolls over the button [Link] : Function Called when the button accepts keyboard events

32

Math
Math class provides mathematical functions and fixed values. [Link](x:Number) : Number Absolute number value Edit1 = [Link](-1.45); [Link](x:Number) : Number Calculates acosine. [Link](x:Number): Number Calculates asine [Link](x:Number) : Number Calculates atangent. Math.atan2(y:Number, x:Number) : Number Calculates angle from x,y point to the x axis in radians (from -pi to pi) [Link](x:Number) : Number Rounds up a number to the next integer [Link](x:Number) : Number Calculates cosine [Link](x:Number) : Number exp function [Link](x:Number) : Number Rounds down a number to the next integer [Link](x:Number) : Number Calculates natural logarithm [Link](x1:Number, x2:Number) : Number Returns greater of 2 numbers [Link](x1:Number, x2:Number) : Number Returns lesser of 2 numbers [Link](x:Number, y:Number) : Number Returns number raised to the y power [Link]() : Number Returns random number from 0.0 to 1.0. [Link](x:Number) : Number Rounds up to the next integer [Link](x:Number) : Number Calculates sine

33

[Link](x:Number) : Number Calculates square root [Link](x:Number) : Number Calculate tangent Mathematical variables Incorporated variables that can be used in calculations Math.E : Number Base for the natural logarithm (approx. 2.718). Math.LN2 : Number Natural logarithm of 2 (approx. 0.693). Math.LOG2E : Number approx. 1.442. Math.LN10 : Number Natural logarithm of 10 (approx. 2.302). Math.LOG10E : Number approx. 0.434 [Link] : Number PI (approx. 3.14159). Math.SQRT1_2 : Number Square root of 1/2 (approx. 0.707). Math.SQRT2 : Number Square root of 2 (approx. 1.414). Example: Edit1 = "Area of the circle with the radius of 5 is " + [Link] * [Link](5,2);

34

Date
Date class represents an object with the current time or any time specified by the user. UTC is a coordinated universal time, independent on seasons or time zone. Local time is a standard time accounting daylight savings time and time zone.

new Date() creates a new Data class object with current time to display of a current year use the code d = new Date(); Edit1 = [Link](); new Date(year:Number, month:Number [, date:Number [, hour:Number [, minute:Number [, second:Number [, millisecond:Number ]]]]]) Creates a new data object with specified time year: year month: month number from 0 to 11 date: day from 1 to 31 hour: hour from 0 to 23 minute: minute from 0 to 59 second: second from 0 to 59 millisecond: 1/1000 seconds from 0 to 999 Example: date 12 February 1990 mydate = new Date(1990, 1 ,12); Example: calculation of the number of days between 2 dates: 1 January 1980 and 14 march 2009 date1 = new Date(1980, 0 ,1); date2 = new Date(2009, 2 ,14); days = ( [Link]() - [Link]() ) / (1000 * 60 * 60 * 24); Edit1 = days;

new Date(timeValue:Number) Creates Data class object with time specified in milliseconds, from 1 January 1970, UTC Example: creating 3 seconds after 1 January 1970, UTC d = new Date(3000); Edit1 = d;

[Link]() : Number Returns day of the month [Link]() : Number Returns day of the week

35

[Link]() : Number Returns 4 digit year [Link]() : Number Returns hour [Link]() : Number Returns milliseconds [Link]() : Number Returns minutes [Link]() : Number Returns month [Link]() : Number Returns seconds [Link]() : Number Returns milliseconds from midnight 1 January 1970, UTC [Link]() : Number Returns time difference in seconds, UTC [Link]() : Number Returns year [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number Identical functions, although they return time converted to the UTC [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number [Link]() : Number Functions, which modify time in Date object [Link]() : String Returns time as a string [Link]() : Number Number of milliseconds between 1 January 1970, UTC and the time stored in the object

36

Variable classes
Arguments
Object representing list of function parameters [Link] : Function Pointer to the function called by the specific function [Link] : Function Pointer to the function being called [Link] : Number Number of parameters Example: function getArgCount(param_arg1, param_arg2, param_arg3) { return ([Link]); } Edit1 = getArgCount("par1","par2","par3");

Boolean
Class represents Boolean type variable, i.e. true or false [Link]() : String Returns text representation of a variable ("true" or "false") [Link]() : Boolean Returns object value ("true" or "false")

Hexadecimal system
System used for specifying color values. RGB colors are stored as hexadecimal numbers (6 characters). In hexadecimal notation,every digit instead of 10 values takes on a values between 0 to 15, numerals above the value of 9 are denoted with a,b,c,d,e,f or A,B,C,D,E,F. To differentiate hexadecimal numbers from decimal numbers, they are preceded with 0x, otherwise hexadecimal numbers without any value above 9 might be confused with decimal number. Examples of hexadecimal numbers and equivalent decimal values 0x2 = 0x9 = 0xF = 0x10 2 9 15 = 16

37

0x18 = 32 0xFF = 255 Color in computer graphics is defined using 3 values, corresponding to the intensity of red, green and blue. All Colors can be obtained by mixing primary Colors with correct ratio. Intensity of all Colors can have a value of 0 (no Color) to 255 (maximum brightness of a component Color). Maximum brightness of all Colors gives white, and no brightness gives black. To code a single component Color, also referred to as a channel it is required to use 2 hexadecimal numbers. Maximum value is 255, i.e. 0xFF. Color code is created by specifying hexadecimal number with 6 digits: 0xRRGGBB where RR means intensity of red, GG - green and BB - blue. example of Colors denoted in hexadecimal numbers: 0x000000 0xFFFFFF 0xFF0000 0x00FF00 0x0000FF 0x808080 black white red green blue grey 50%

Color
Color class modifies Sprite color matrix. Sprite matrix allows to change Colors or transparency. Color gain is a percentage gain of specific channel of all graphic items within a Sprite, Color phase means adding all items to the current channel. E.g. by shifting red to 255 and other Colors to -255, all sprite items will be red, irrespective of their previous Color. new Color( target:Sprite ) Creates new Color type object related to a specific Sprite [Link]() : Object Downloads a current sprite Color matrix. It is an object incorporating the following attributes: ra red gain percentage (-100 to 100). rb red value shift (-255 to 255). ga green gain percentage (-100 to 100). gb green value shift (-255 to 255). ba blue gain percentage (-100 to 100). bb blue value shift (-255 to 255). aa opacity gain percentage (-100 to 100). ab opacity value shift (-255 to 255). Default matrix include 100 gain an 0 shift for each channel. [Link](matrix:Object) Creates new sprite Color matrix [Link]() : Number Returns numerical value corresponding to a Color code, incorporating rb, gb and bb values

38

[Link](0xRRGGBB:Number) Sets Color phase in current matrix to the specific numerical value (stores in rb, gb and bb fields) Example: draw Sprite and a grey circle inside. Exit the sprite and enter the frame code: c = new Color(Sprite1); [Link](0xFF0000); Sprite will change Color to red:

Change to 50% opacity c = new Color(Sprite1); m = [Link](); [Link] = 50; [Link](m);

Number
Class represents numerical object [Link]() Returns string [Link]() Returns numerical value of an object

Number.MAX_VALUE The highest possible numerical value, approx. 1.79E+308. Number.MIN_VALUE The lowest possible numerical value, approx. 5e-324. [Link]

39

Expression value for comparing, if an object is a number, Not a Number (NaN). Number.NEGATIVE_INFINITY Positive infinity value Number.POSITIVE_INFINITY Negative infinity value

40

Sound
Class provides sound control new Sound([target:Sprite]) Creates new Sound type object When Sprite parameter is specified, object controls sounds within the Sprite [Link]("idName":String) Attaches sound with a specific ID to the object As a default it is a file name of the sound. Name can be changed in Movie > Sounds [Link]() If the sound is loaded from the file, returns downloaded bytes [Link]() Returns total size of a sound file [Link]() Returns balance value -100 (left channel) to 100 (right channel) [Link]() Returns object with the following attributes ll: intensity of a left track in left speaker lr: intensity of a left track in right speaker rl: intensity of a right track in left speaker rr: intensity of a right track in right speaker values 0 to 100 [Link]() Returns sound intensity 0 to 100 [Link](url:String) Downloads MP3 sound from the internet address [Link](balance:Number) Set balance from -100 to 100 [Link](mixer:Object) Define channel mixing mixer is an object with ll, lr, rl and rr attributes see also getTransform() [Link](volume:Number) Sets sound intensity 0 to 100 [Link]() Starts sound playback from the beginning start(secondOffset:Number) Starts sound playback from the specific second

41

start(secondOffset:Number, loop:Number) Starts sound playback from the specific second and with specific number of repetitions [Link]() Stop sound [Link] Sound duration in milliseconds Sound.id3 Pointer to the ID3 object of a MP3 file, if present Incorporates the following attributes [Link] [Link] [Link] [Link] [Link] [Link] [Link] Comments Album Genre Song name Artist Track number Release year

Attributes with names defined for ID3 specification are also available: COMM TALB TBPM TCOM TCOP TDAT TEXT Comment Album title Pace (per minute) Composer Copyrights Data Text author

[Link] Position of a current sound playback in milliseconds Sound.onID3 Function called when ID3 is available [Link] Function called when sound is read from the file [Link] Function called when sound playback is finished

42

String
Class represents string of alphanumeric characters. Characters in the string are indexed from 0 (first character of a string from the number smaller by 1 from the string length) Letters in Pamela string will have the following indices: 0P 1a 2m 3e 4l 5a

[Link] : Number Number specifying the current number of characters in the string [Link](x:Number) : String Returns character in position x (from 0) [Link](x:Number) : Number Returns ASCII of the character as a number in position x (from 0) [Link](val1:String, ... valN:String) : String Creates and returns combination of a string with specified parameters. stringA = "Hello"; stringB = "World"; Edit1 = [Link](" ", stringB); Hello World is displayed [Link](c1:Number,c2,...cN) : String Returns string consisting of characters in ASCII Edit1 = "dog"+[Link](64)+"[Link]"; dog@[Link] is displayed [Link](substring:String) : Number Returns index of a first instance of a substring from 0 at the beginning, or -1 if the substring is not found [Link](substring:String, startIndex:Number) : Number Returns index of a substring instance, beginning from the startIndex [Link](substring:String) : Number Returns index of a last instance of a substring or -1 if the substring is not found [Link](substring:String, startIndex:Number) : Number Returns index of a last instance of a substring, beginning search from the startIndex [Link](start:Number) : String Returns substring from the start character to the end character

43

[Link](start:Number, end:Number) : String Returns substring consisting of a start character and end character [Link]("delimiter":String) : Array Divides the string into substrings using delimiter and returns string array s = "Maria:Pamela:Sandra"; a = [Link](":"); Edit1 = a[1]; [Link](start:Number) : String Returns substring from the start position to the end position, if start is a negative number, returns substring counted from the end [Link](start:Number, n:Number) : String Returns n character substring from the start position [Link](start:Number, end:Number) : String Returns substring from the start character to the end character, not including end character [Link]() : String Returns string of characters in lowercase without changing the original object [Link]() : String Returns string of characters in uppercase without changing the original object

44

Stage
Stage class correspond to the Flash movie clip located in the browser window [Link] : String Alignment of a Flash object in the browser window "T" top center "B" bottom center "L" center left "R" center right "TL" top left "TR" top right "BL" bottom left "BR" bottom right [Link] : Number [Link] : Number Width and height of a movie clip in pixels [Link] : String Movie clip scale in the browser, available values: "exactFit", "showAll", "noBorder" and "noScale" [Link] : Boolean True if the whole context menu is available, false if the menu is limited [Link](myListener:Object) Adds listener checking if the movie clip is scaled in the browser [Link](myListener:Object) : Boolean Removes listener added by the addlistener command [Link] : Function Pointer to the function with notification about the movie clip scale in the browser. scaleMode parameter must be set to noScale.

45

System
System
[Link](string:String) : Boolean Copies string to the clipboard [Link]() Displays setting panel of a Flash player [Link](n:Number) Displays setting panel in the n tab: 0 Privacy 1 Local Storage 2 Microphone 3 Camera [Link] : Boolean True if the access settings apply to the specific domain, false if they apply to domains and subdomains in a specific domain. [Link] : Boolean If false, Flash treats external text files as a Unicode, true if the files are stored in a code page. It applies to the files loaded by the LoadVars class. [Link] : Function(genericError:Object) Called in the case of a Flash plugin error

[Link]
Object includes information on access permissions for SWF files run in the specific domain. [Link]("domain1":String, "domain2", ... "domainN") Allows SWF files from specified domains to use this SWF file [Link]("domain":String) Allows files from the domain to use this SWF file, if it is provided by the HTTPS [Link](url: String) Download XML permission file from the specific internet address File example: <cross-domain-policy> <allow-access-from domain="*" to-ports="507" /> <allow-access-from domain="*.[Link]" to-ports="507,516" /> <allow-access-from domain="*.[Link]" to-ports="516-523" /> <allow-access-from domain="[Link]" to-ports="507,516-523" /> <allow-access-from domain="[Link]" to-ports="*" /> </cross-domain-policy>

46

[Link]
Object contains information about capabilities of the system, where Flash file is executed [Link] : Boolean Is camera and microphone available [Link] : Boolean Is system equipped with accessibility features [Link] : Boolean Does system play sound [Link] : Boolean Does system store sound [Link] : Boolean Does system play video [Link].hasMP3 : Boolean Does system play MP3 files [Link] : Boolean Is printing available [Link] : Boolean [Link] : Boolean Does system use Flash Communication Server [Link] : Boolean Does system play stream audio [Link] : Boolean Does system play stream video [Link] : Boolean Does system store video in a file (e.g. from a camera) [Link] : Boolean Is plugin version featured with a debugging function [Link] : String System language as a two-letter code, e.g. en English [Link] : Boolean Is access to system files blocked on a disk [Link] : String Flash plugin author [Link] : String Operating system

[Link] : Number

47

Ratio of physical pixels to logical pixels of a display, usually 1 [Link] : String Plugin type, available values: "StandAlone", "External", "PlugIn" or "ActiveX". [Link] : String Screen Color, available values: "Color", "gray", "bw". [Link] : Number Screen resolution in pixels per inch, usually 72 [Link] : Number Horizontal screen resolution [Link] : Number Vertical screen resolution [Link] : String Variable string coded as an URL call [Link] : String Plugin version

48

TextField
Class corresponds to text fields. For text fields, variable name must be differentiated from the field object name. Text fields as objects are referred to by name, not by variable name. Select the field and press F2 to check the field name. Field name is usually EditField1, EditField2 etc. Also check ActionScript object option (after pressing F2) [Link] : Boolean If true, field will automatically extend to include the whole text. [Link] : Boolean Field has a uniform background, otherwise it is transparent [Link] : Number Background Color [Link] : Boolean Field has borders [Link] : Number Frame Color [Link] : Number Index of a last visible line of text TextField..condenseWhite : Boolean If true, in the HTML field all marks of a new line and additional spaces are ignored [Link] : Boolean If true, font from a Flash file is used, if false system font is used TextField._height : Number Total field height in pixels [Link] : Number Position in pixels of a vertically scrolled text [Link] : Boolean If true, fields interpret HTML tags [Link] : String Field HTML code may include the following tags: <br> new line <b>, <i>, <u> bold, italic, underline end with: </b>, </i>, </u> <li> list <font face="times new roman"> font face, end with: </font> <font Color="#FF0000"> font Color, end with: </font> <font size="16"> font size, end with: </font>

49

[Link] : Number Number of characters [Link] : Number maximum allowable number of characters in the field, null = no limits [Link] : Number Maximum possible value of horizontal scroll [Link] : Number Maximum possible value of vertical scroll [Link] : ContextMenu pointer to the field context menu [Link] If true, field supports mouse scroll actions [Link] : Boolean if true, field can be multiline TextField._name : String Field object name TextField._parent : MovieClip Pointer to the sprite containing the field [Link] : Boolean Password type field, characters are masked [Link] : String Set of characters that can be entered in the field. Examples: Allow numerals only [Link] = "0123456789"; Same as above [Link] = "0-9"; Numerals and uppercase only [Link] = "A-Z 0-9"; ^ character forbids entering the specific character * cannot be entered [Link] = "^*"; Numerals cannot be entered [Link] = "^0-9"; If you want to use ^ or - or \ it must be preceded with \ TextField._rotation : Number

50

Rotates text field by a specific angle [Link] : Number Vertical field scrolling, index of a first visible line [Link] : Boolean If true, allows selecting text in the field [Link] : Boolean If true, field is included in the chain of tab switching [Link] : Number Index of an item in the chain of tab switching TextField._target : String Absolute object path [Link] : String Text in field [Link] : Number Font Color [Link] : Number [Link] : Number Text size inside the field [Link] : String "input" text may be input "dynamic" text may not be input TextField._url : String Internet address of a file that created the field [Link] : String Variable name related to the field, usually Edit1 for the EditField1 TextField._visible : Boolean True if the field is visible TextField._width : Number Total width in pixels [Link] : Boolean if true, line are broken if longer than the field TextField._x : Number TextField._y : Number Field x and y position TextField._xmouse : Number TextField._ymouse : Number Cursor location TextField._xscale : Number TextField._yscale : Number

51

Vertical and horizontal scale in percents [Link]() Adds listener to the events of text change within field [Link]() : Array Returns list of fonts available in the system as an array Method must be called for a global TextField class, not for a single field a = [Link](); Edit1 = [Link](); [Link]() Return object depth

[Link]() : Boolean Removes listener [Link]() Removes field created with [Link]() [Link](text:String) Changes the text selected in the field to a new text [Link](beginIndex:Number, endIndex:Number, text:String) Changes the text in a field from beginIndex to endIndex with a new text Function available in a Flash Player 8 plugin or higher

Text field event support


[Link] : Function Function called when the field is modified Example: draw text fields Edit1 and Edit2, paste the frame code: [Link] = function () { Edit2 = Edit1; } text entered in the Edit1 field will be copied to the Edit2 field [Link] : Function Function called when field cannot accept input characters [Link] : Function Function called when field is scrolled [Link] : Function Function called when field accepts input characters

Example: draw text fields Edit1 and Edit2, paste the frame code:

52

[Link] = function() { Edit2 = "modified text"; } [Link] = function() { Edit2 = "finished entering"; } [Link] = function() { Edit2 = "start typing"; }

Text formatting
[Link]() Creates and returns text formatting object, which will be applied to the new text [Link]() Returns default text formatting object [Link](index:Number) Returns text formatting objects from the index character [Link](start:Number, end:Number) Returns text formatting object from the start character to the end character [Link](tf:TextFormat) Sets default text formatting [Link](index:Number, tf:TextFormat) Sets text formatting from the index character [Link](start:Number, end:Number, tf:TextFormat) Sets text formatting from the start character to the end character

TextFormat class
[Link] : String Text adjustment to the left, to the right or centered Values "left", "right" or "center" [Link] : Number Paragraph indent in points, applies to all text lines [Link] : Boolean Bold text [Link] : Boolean Bullets

53

[Link] : Number Font Color [Link] : String Font face [Link] : Number Indent of the first text line [Link] : Boolean Text in italic [Link] : Number Horizontal distance between text lines [Link] : Number Left text margin [Link] : Number Right text margin [Link] : Number Font size in points [Link] : Array[Number] Array of a tabulator position in pixels [Link] : Boolean Underlined text [Link] : String [Link] : String Internet link and link target e.g. _self, _blank etc. Example: Draw Edit1 field, double-click, check HTML and click OK. Paste the following frame code: Edit1 = "[Link] - Click"; tf = new TextFormat(); [Link] = "Tahoma"; [Link] = 0x0000ff; [Link] = true; [Link] = "[Link] [Link](0,15,tf);

54

CSS
[Link]
Class allows text field formatting using CSS code and cascade styles. Style example: .heading { font-family: Arial, Helvetica, sans-serif; font-size: 24px; font-weight: bold; } .mainBody { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; } [Link]() Removes formatting with styles [Link](styleName:String) : Object Returns style object with styleName and attributes e.g. fontWeight = bold FontSize = 24px, fontFamily = Arial, Helvetica, sans-serif itd Example css = new [Link](); [Link](".header { font-size:24pt; Color:#0000FF; font-family:times;}"); headerObject = [Link](".header"); Edit1 = [Link];

[Link]() : Array Returns style name array, e.g. heading, mainBody [Link](url:String) Downloads styles from internet address [Link]. parseCSS(cssText:String) : Boolean Creates style from the string, returns false in the case of an error [Link](name:String, style:Object) Adds style to the collection my_styleSheet:[Link] = new [Link](); styleObj = new Object(); [Link] = "#000000"; [Link] = "bold"; my_styleSheet.setStyle("emphasized", styleObj); [Link](style:Object) : TextFormat Changes styleSheet type object to TextFormat [Link] : Function(success:Boolean) Function called when style loaded from file, success is true, if the operation is finished successfully.

55

Example: creating style and adding it to the edit field. Draw Edit1 field and paste the frame code css = new [Link](); [Link](".header { font-size:24pt; Color:#0000FF; font-family:times;}"); [Link] = css; [Link] = true; [Link] = true; Edit1 = "<p class=\"header\">The Dog</p><p>The dog is brown</p>";

56

XML
Class allows to load and use XML files XML file consists of tags: XML file example <globe name="World"> <continent code="na">North America</continent> <continent code="sa">South America</continent> <continent code="eu">Europe</continent> <continent code="af">Africa</continent> <continent code="as">Asia</continent> <continent code="au">Australia</continent> </globe> File contains main node (globe) and 6 child nodes (continents), each with a code attribute [Link] : Array Object with the attributes of a current node [Link] : Array Child node array [Link] : XMLNode Pointer to the first child node [Link] : Boolean If true, empty nodes are ignored [Link] : XMLNode Pointer to the last child node [Link] : Boolean Specifies if the file is loaded [Link] : XMLNode Pointer to the next node on the same level [Link] : String Node name in the brackets < > [Link] : Number Node type, 1 node < >, 3 text node between < > a </ > [Link] : String Node value in the case of a text node (nodeType == 3) [Link] : XMLNode Parent indicator [Link] : XMLNode Pointer to the previous node on the same level

57

[Link] : Number XML file processing state 0 No error -2 CDATA section without closing -3 XML declaration without closing -4 DOCTYPE declaration without closing -5 Comment without closing -6 Incorrect element -7 No memory -8 Attribute without closing -9 No proper closing tag -10 No proper opening tag [Link] : String XML file declaration, if exists [Link](headerName:String, headerValue:String) In case the file is downloaded from the internet, you can add additional headings and call parameters [Link](childNode:XMLNode) Adds child node to the end of the list [Link](deep:Boolean) : XMLNode Clones and returns node with child nodes to the specific depth [Link](name:String) : XMLNode Creates and returns new tree element with a specific name [Link](text:String) : XMLNode Creates text node [Link]() : Number Returns bytes downloaded when loading file [Link]() : Number Return XML file size [Link]() : Boolean Returns true, if the current node has child nodes [Link](childNode:XMLNode, beforeNode:XMLNode) Add note through other node [Link](url:String) Load XML file from the internet [Link](source:String) Process XML data from the string [Link]() Removes node [Link](send(url:String, [target:String])) Sends XML data to the file on www

58

[Link](url:String, targetXMLobject:XML) Sends XML file to the www address and downloads the server reply in XML format to the other XML object [Link]() : String Returns XML data in text format [Link]: String XML file !DOCTYPE declaration [Link] : function () Function called when XML file download is completed [Link] : function (success:Boolean) Function called during XML file download Example 1 draw Edit1 field and paste the frame code str = "<root><node/></root>"; xml = new XML(str); rootNode = [Link]; Edit1 = [Link];

59

Example: XML tree traversal draw Edit1 field and paste the following frame code: str = "<globe name=\"World\">Continents<continent code=\"na\">North America</continent><continent code=\"sa\">South America</continent><continent code=\"eu\">Europe</continent><continent code=\"af\">Africa</continent><continent code=\"as\">Asia</continent><continent code=\"au\">Australia</continent></globe>"; xml = new XML(str); globeNode = [Link]; Edit1 = "Status: " + [Link] + " ";

Edit1 = Edit1 + [Link] + ", " + [Link] + ": "; continentNode = [Link]; while(continentNode!=null) { if([Link]==1) { Edit1 = Edit1 + [Link]; Edit1 = Edit1 + " [" + [Link] + "] "; continentText = [Link]; Edit1 = Edit1 + [Link] + ", } continentNode = [Link]; } Code creates the following result: Status: 0 globe, World: continent [na] North America, continent [sa] South America, continent [eu] Europe, continent [af] Africa, continent [as] Asia, continent [au] Australia,

";

60

LoadVars
Class allows to import parameters from the text file to SWF file Parameters in the text file: param1=value1&param2=value2 .. etc. Loaded variables can be referred to through an object attribute name LoadVars e.g. LoadVars.param1 new LoadVars() Creates new object [Link](headerName:String, headerValue:String) Adds additional headings to the file call through the internet [Link](params:String) Loads and processes string into variables as param1=value1&param2=value2 [Link]() : Number Bytes loaded by [Link]() or [Link]() function [Link]() : Number Total file size with variables [Link](url:String) : Boolean Loads variable data from the specific address, variable must have a text form: param1=value1&param2=value2 .. etc. [Link](url:String) : Boolean Sends variables to the specific internet address as a string url?param1=value1&param2=value2 [Link](url:String) : Boolean Sends query to the specific www address and loads the server reply [Link]() : String Returns parameters as param1=value1&param2=value2 [Link] : String MIME data type [Link] : Boolean Returns true, if data download is completed [Link] : function Function called when data download is completed [Link] : function Function called during data download

61

Example: lv = new LoadVars(); [Link]("name=Pamela&age=25"); Edit1 = [Link] + " is " + [Link] + " old.";

62

Functions not supported by Alligator Flash Designer


trace() Trace function is not supported by the standard Flash plugin in the browser. Instead of trace(variable) use: Edit1 = variable; break, continue Causes the loop to finish or start over, but are ignored case Use if function set class Custom classes cannot be defined for in Object attributes cannot be enumerated ?: Conditional statement is not supported {} Object attribute initiator Instead of object = { attr1 : "value1", attr2 : "value2" } Use object = new Object(); object.attr1 = "value1"; object.attr2 = "value2";

63

Common questions

Powered by AI

The MovieClip.hitTest(target:Object) checks for collisions by determining if the sprite overlaps with the target sprite object, which is useful for checking whole object interactions . Conversely, using MovieClip.hitTest(x:Number, y:Number, shapeFlag:Boolean) allows for spatial collision detection by specific coordinates, where shapeFlag determines if only visible parts of the sprites are considered. This latter method requires careful consideration of coordinate accuracy and the sprite’s dimensions to ensure precise collision detection .

The _lockroot property in a MovieClip is crucial when managing loaded subclips because it affects how the _root variable is referenced. When _lockroot is set to true, any reference to _root within the loaded clip pertains to the clip's parent, rather than the main movie that loads the clip. This is essential to maintain consistent scope management when subclips are involved, thereby avoiding unintended interference or modifications to the global _root context .

In ActionScript, the parseFloat() function is used to change a string value into a numeric format. For instance, when the string "3.5e6" is passed to parseFloat(), it converts it into the numeric value 3500000 .

In Flash, the TextField.StyleSheet class interacts with CSS to allow comprehensive text styling by separating presentation from content. Using external CSS to manage styles provides consistency across multiple text fields and facilitates easy updates . This separation is beneficial over inline styling as it simplifies maintenance and improves scalability, allowing broad style changes without modifying the Flash content directly, essential for dynamic and stylistically rich applications.

When using System.capabilities.screenResolutionX and System.capabilities.screenResolutionY to tailor Flash applications for varying devices, consider the target audience's most common devices and screen resolutions to optimize layout and functionality . Also, anticipate potential differences in aspect ratios and screen sizes that may affect user experience. Ensuring adaptive or responsive design is crucial to deliver consistent performance and accessibility across different platforms.

In MovieClips, duplicating an instance with duplicateMovieClip(newname:String, depth:Number) supports better layer management by creating a new instance at a specified depth level, which determines the drawing order among sprites . Specifying a higher depth value places the new instance above others on the same layer, while a lower value may cause the instance to be obscured, thereby influencing the visual hierarchy and interactive behavior of elements in complex animations.

MovieClip.gotoAndStop can be used to jump to a specific frame within an animation and halt playback, providing greater control over movie clips. When navigating by frame index, you specify the physical frame number, effectively moving to the desired point in the animation timeline . Conversely, using a frame name allows you to navigate to named frames without needing to know their physical positions. This method is typically used for more dynamic control and readability, especially in larger projects.

The setInterval(functionName, interval:Number) function in ActionScript calls a specified function repeatedly at fixed time intervals, specified in milliseconds. For example, if you have a function myInterval defined to update a variable repeatedly, using setInterval(myInterval, 100) will execute the function every 100 milliseconds . This could be used in animations to update or animate properties over time by repeatedly invoking a function that alters object states based on the elapsed time.

In Flash, TextField.onChanged can be utilized to trigger functions whenever a user modifies the text field’s content, enabling real-time feedback. This interactivity can significantly enhance user experiences by dynamically updating other UI elements or providing instant validation messages as the user types . For instance, implementing onChanged to update a corresponding label or validate form inputs can make applications more intuitive and responsive to user actions.

The TextField.autoSize property automatically extends the text field to fit the content, which prevents text clipping and maintains readability when the content is dynamic or unknown in advance . This is crucial in scenarios where UI elements need to adapt to varying text lengths, such as in internationalization where different languages vary significantly in character count or when displaying user-generated content that changes unpredictably.

You might also like