Summary of Contents for MACROMEDIA FLASH 8-FLASH LITE 1.X ACTIONSCRIPT LANGUAGE
Page 1
Flash Lite 1.x ActionScript Language Reference...
Page 2
If you access a third-party website mentioned in this guide, then you do so at your own risk. Macromedia provides these links only as a convenience, and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the content on those third-party sites.
Introduction This manual describes the syntax and use of ActionScript elements as you use them to develop applications for Flash Lite 1.0 and Flash Lite 1.1, collectively referred to as Flash Lite 1.x. Flash Lite 1.x ActionScript is based on the version of ActionScript that was used in Flash 4. To use examples in a script, copy the code example from this manual, and paste it into the Script pane or into an external script file.
A set of sample files can be found in the /Samples and Tutorials/Samples/FlashLite/ directory within the Flash 8 installation directory. Typical paths to this folder are as follows: Windows: /Program Files/Macromedia/Flash 8/Samples and Tutorials/Samples/FlashLite/ Macintosh: HD/Applications/Macromedia/Flash 8/Samples and Tutorials/Samples/ FlashLite/ The FlashLite folder contains a set of FLA files that are complete Flash Lite projects that have working ActionScript code.
CHAPTER 1 Flash Lite Global Functions This section describes the syntax and use of the Macromedia Flash Lite 1.1 ActionScript global functions. It includes the following functions: Function Description Executes the script in the called frame without moving the playhead call() to that frame.
Page 10
Function Description Reads data from an external file, such as a text file or text generated loadVariables() by a ColdFusion, CGI ASP, PHP, or Perl script, and sets the values for variables in a Flash Lite level. This function can also update variables in the active SWF file with new values.
Function Description Turns anti-aliasing on and off in Flash Lite. Anti-aliasing smooths the toggleHighQuality() edges of objects but slows down SWF file playback. Evaluates the expression and shows the result in the Output panel in trace() test mode. Removes a movie clip from Flash Lite that was loaded using unloadMovie() , or loadMovie() loadMovieNum()
Example The following examples execute the script in the frame: myScript // to execute functions in frame with label "myScript" thisFrame = "myScript"; trace ("Calling the script in frame: " add thisFrame); // to execute functions in any other frame on the same timeline call("myScript");...
Page 13
Operands The target path of the movie clip to duplicate. target A unique identifier for the duplicated movie clip. newname A unique depth level for the duplicated movie clip. The depth level indicates a depth stacking order for duplicated movie clips. This stacking order is much like the stacking order of layers in the timeline;...
eval () Availability Flash Lite 1.0. Usage eval(expression) Operands A string containing the name of a variable, property, object, or movie clip expression to retrieve. Description Function; accesses variables, properties, objects, or movie clips by name. If is a expression variable or a property, the value of the variable or property is returned.
getProperty() Availability Flash Lite 1.0. Usage getProperty(my_mc, property) Operands The instance name of a movie clip for which the property is being retrieved. my_mc A property of a movie clip. property Description Function; returns the value of the specified property for the movie clip.
Example The following example sets the variable to the number of milliseconds that timeElapsed elapsed since the SWF file started playing: timeElapsed = getTimer(); trace (timeElapsed);// Output: milliseconds of time movie has been playing getURL() Availability Flash Lite 1.0. Usage getURL(url [ , window [, "variables"]]) Operands The URL from which to obtain the document.
Page 17
Even under such getURL() circumstances, only one function is processed per event handler. getURL() Example In the following ActionScript, the Flash Lite player opens mobile.macromedia.com in the default browser: myURL = "http://mobile.macromedia.com"; on(keyPress "1") { getURL(myURL); You can also use for sending variables from the current timeline.
Page 18
Method 2: Define each parameter within the function, as in this example: getURL() on (release, keyPress "#"){ getURL("mailto:somebody@anywhere.com?cc=cc@anywhere.com&bcc=bcc@anywhere. com&subject=I am the email subject&body=I am the email body"); Method 1 results in automatic URL encoding, while Method 2 preserves the spaces in the strings.
gotoAndPlay() Availability Flash Lite 1.0. Usage gotoAndPlay([scene,] frame) Operands An optional string specifying the name of the scene to which the playhead is sent. scene A number representing the frame number, or a string representing the label of the frame frame, to which the playhead is sent.
Description Function; sends the playhead to the specified frame in a scene and stops it. If no scene is specified, the playhead is sent to the frame in the current scene. You can use the parameter only on the root timeline, not within timelines for movie scene clips or other objects in the document.
Example The following example uses the function to check if Frame 10 of the SWF ifFrameLoaded file is loaded. If the frame is loaded, the command prints “frame number 10 is trace() loaded” to the Output panel. The output variable is also defined with a variable of frame loaded: 10 ifFrameLoaded(10) {...
The result is 5. The following example validates an e-mail address by checking that it contains at least six characters: email = "someone@macromedia.com"; if (length(email) > 6) { //trace ("email appears to have enough characters to be valid"); loadMovie() Availability Flash Lite 1.1.
Page 23
Operands A string specifying the absolute or relative URL of the SWF file to load. A relative path must be relative to the SWF file at level 0. Absolute URLs must include the protocol reference, such as http:// or file:///. A reference to a movie clip or a string representing the path to a target movie clip.
loadMovieNum() Availability Flash Lite 1.1. Usage loadMovieNum(url, level [, method]) Operands A string specifying the absolute or relative URL of the SWF file to be loaded. A relative path must be relative to the SWF file at level 0. For use in the stand-alone Flash Lite player or for use in test mode in the Flash authoring application, all SWF files must be stored in the same folder and the filenames cannot include folder or drive specifications.
The text at the specified URL must be in the standard MIME format application/x-www- form-urlencoded (a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables: company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103 loadVariables()
To load variables into a specific level, use the function instead of the loadVariablesNum() function. loadVariables() Example The following examples load variables from a text file and from a server: // load variables from text file on local file system (Symbian Series 60) on(release, keyPress "1") { filePath = "file://c:/documents/flash/myApp/myvariables.txt";...
The text at the specified URL must be in the standard MIME format application/x-www- form-urlencoded (a standard format used by CGI scripts). Any number of variables can be specified. The following example phrase defines several variables: company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103 Normally, Flash Lite displays a single SWF file, and then closes. The loadVariablesNum() function lets you display several SWF files at once and switch among SWF files without loading another HTML document.
Example The following example converts ASCII code numbers to their mulitibyte character equivalents: trace (mbchr(65));// Output: A trace (mbchr(97));// Output: a trace (mbchr(36));// Output: $ myString = mbchr(51) - mbchr(49); trace ("result = " add myString);// Output: result = 2 See also mblength() mbsubstring()
mbord() Availability Flash Lite 1.0. Usage mbord(character) Operands The character to convert to a multibyte number. character Description String function; converts the specified character to a multibyte number. Example The following examples convert the characters in the variable to myString multibyte numbers: myString = "A";...
Operands The multibyte string from which to extract a new multibyte string. value The number of the first character to extract. index The number of characters to include in the extracted string, not including the count index character. Description String function; extracts a new multibyte character string from a multibyte character string. Example The following example extracts a new multibyte character string from the string contained in variable:...
Example In the following example, when the user clicks the button, the playhead moves to the next frame and stops: on (release) { nextFrame(); See also prevFrame() nextScene() Availability Flash Lite 1.0. Usage nextScene() Operands None. Description Function; sends the playhead to Frame 1 of the next scene and stops it. Example In the following example, when a user releases the button, the playhead moves to Frame 1 of the next scene:...
Number() Availability Flash Lite 1.0. Usage Number(expression) Operands An expression to convert to a number. expression Description Function; converts the parameter to a number and returns a value as described in expression the following list: is a number, the return value is expression expression is a Boolean value, the return value is 1 if...
on() Availability Flash Lite 1.0. Usage on(event) { // statement(s) Operands The instructions to execute when occurs. statement(s) event This trigger is called an event. When a user event occurs, the statements following it event within curly braces ( ) execute. Any of the following values can be specified for the parameter: event The button is pressed while the pointer is over the button.
ord() Availability Flash Lite 1.0. Usage ord(character) Operands The character to convert to an ASCII code number. character Description String function; converts characters to ASCII code numbers. Example The following example uses the function to display the ASCII code for the character A: ord() trace ("multibyte number = "...
Example The following example uses an statement to check the value of a name that the user enters. If the user enters , the function is called, and the playhead moves forward in the Steve play() timeline. If the user enters anything other than , the SWF file does not play, and a text Steve field with the variable name...
prevScene() Availability Flash Lite 1.0. Usage prevScene() Operands None. Description Function; sends the playhead to Frame 1 of the previous scene and stops it. Example In this example, when the user clicks a button that has the following handler attached to it, the playhead is sent to the previous scene: on(release) { prevScene();...
Example The following examples generate a number based on an integer specifying the range: //pick random number between 0 and 5 myNumber = random(5); trace (myNumber);// Output: could be 0,1,2,3,4 //pick random number between 5 and 10 myNumber = random(5) + 5; trace (myNumber);// Output: could be 5,6,7,8,9 The following examples generate a number, and then concatenate it onto the end of a string being evaluated as a variable name.
set() Availability Flash Lite 1.0. Usage set(variable, expression) Operands An identifier to hold the value of the parameter. variable expression A value assigned to the variable. expression Description Statement; 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.
setProperty() Availability Flash Lite 1.0. Usage setProperty(target, property, value/expression) Operands The path to the instance name of the movie clip whose property is to be set. target The property to be set. property The new literal value of the property. value An equation that evaluates to the new value of the property.
Description Function; stops the SWF file that is currently playing. The most common use of this function is to control movie clips with buttons. Example The following statement calls the function when the user clicks the button associated stop() with this event handler: on(release) { stop();...
String() Availability Flash Lite 1.0. Usage String(expression) Operands An expression to convert to a string. expression Description Function; returns a string representation of the specified parameter as described in the following list: is a number, the return string is a text representation of the number. expression is a string, the return string is expression...
Operands The string from which to extract the new string. string The number of the first character to extract. index The number of characters to include in the extracted string, not including the count index character. Description Function; extracts part of a string. This function is one-based, whereas the String class methods are zero-based.
Example In the following example, controls the movie clip instance on the main tellTarget() ball timeline. Frame 1 of the instance is blank and has a function so that it isn’t ball stop() visible on the Stage. When the user presses the 5 key, tells the playhead in tellTarget() to go to Frame 2 where the animation starts.
trace() Availability Flash Lite 1.0. Usage trace(expression) Operands An expression to evaluate. When a SWF file opens in the Flash authoring expression tool (by means of the Test Movie command), the value of the parameter appears expression in the Output panel. Description Function;...
Description Function; removes a movie clip from Flash Lite that was loaded by means of loadMovie() “duplicateMovieClip()”. loadMovieNum(), or Example When the user presses the 3 key, the following code responds by unloading the draggable_mc movie clip on the main timeline and loading movie.swf into level 4 of the document stack: on (keypress "3") { unloadMovie ("/draggable_mc");...
CHAPTER 2 Flash Lite Properties This section describes the properties that Macromedia Flash Lite 1.x recognizes. The entries are listed alphabetically, ignoring any leading underscores. The properties are summarized in the following table: Property Description Specifies or returns a reference to the main movie timeline.
Property Description Returns the target path of the movie clip instance. _target Returns the total number of frames in a movie clip. _totalframes Indicates whether a movie clip is visible. _visible Returns the width of the movie clip, in pixels. _width Contains an integer that sets the x coordinate of a movie clip.
Example 3: The variable in the movie clip instance mc2 nested in the movie clip instance mc1 that resides on the main Timeline: /mc1/mc2/:car Example 4: The variable in the movie clip instance mc2 that resides on the current Timeline: mc2/:car _alpha Availability...
Example The following example uses the property and the function _currentframe gotoAndStop() to direct the playhead of the movie clip to advance five frames ahead of its current my_mc location: tellTarget("my_mc") { gotoAndStop(_currentframe + 5); See also gotoAndStop() _focusrect Availability Flash Lite 1.0.
_framesloaded Availability Flash Lite 1.0. Usage my_mc:_framesloaded Description Property (read-only); the number of frames that have been loaded from a dynamically loaded SWF file. This property is useful for determining whether the contents of a specific frame, and all the frames before it, have loaded and are available locally in the browser. It is also useful as a monitor while large SWF files download.
_height Availability Flash Lite 1.0. Usage my_mc:_height Description Property (read-only); the height of the movie clip, in pixels. Example The following example of event handler code sets the height of a movie clip when the user clicks the mouse button: on(release) { tellTarget("my_mc") { _height = 200;...
_level Availability Flash Lite 1.0. Usage _levelN Description Identifier; a reference to the root timeline of . You must use the _levelN loadMovieNum() function to load SWF files into the Flash Lite player before you use the property to _level target them.
maxscroll Availability Flash Lite 1.1 Usage variable_name:maxscroll Description Property (read-only); indicates the line number of the first visible line of text in a scrollable text field when the last line in the field is also visible. The property works with the maxscroll property to control how information appears in a text field.
Description Property; the instance name of the movie clip that specifies. It applies only to movie my_mc clips and not to the main timeline. Example The following example displays the name of the movie clip in the Output panel as bigRose a string: trace(bigRose:_name);...
scroll Availability Flash Lite 1.1. Usage textFieldVariableName:scroll Description Property; controls the display of information in a text field associated with a variable. The property defines where the text field begins displaying content; after you set it, Flash scroll Lite updates it as the user scrolls through the text field. You can use the property to scroll create a scrolling text field or to direct a user to a specific paragraph in a long passage.
_totalframes Availability Flash Lite 1.0. Usage my_mc:_totalframes Description Property (read-only); returns the total number of frames in the movie clip. my_mc Example The following code loads mySWF.swf into Level 1, and then 25 frames later, checks to see whether it is loaded: loadMovieNum("mySWF.swf", 1);...
Example The following code disables the movie clip when the user presses the 3 key, and enables my_mc it when the user presses the 4 key: on(keyPress "3") { my_mc:_visible = 0; on(keyPress "4") { my_mc:_visible = 1; _width Availability Flash Lite 1.0.
Description Property; an integer that sets the x coordinate of a movie clip (represented here by my_mc relative to the local coordinates of the parent movie clip. If a movie clip is in the main timeline, its coordinate system refers to the upper-left corner of the Stage as (0, 0). If the movie clip is inside another movie clip that has transformations, the movie clip is in the local coordinate system of the enclosing movie clip.
Page 60
Example The following example changes the horizontal scale of the movie clip when the user my_mc presses the 7 key: on(keyPress "7") { my_mc:_xscale = 10; See also _yscale Availability Flash Lite 1.0. Usage my_mc:_y Description Property; an integer that sets the y coordinate of a movie clip (represented here by my_mc relative to the local coordinates of the parent movie clip.
_yscale Availability Flash Lite 1.0. Usage my_mc:_yscale Description Property; sets the vertical scale ( ) of the movie clip, as applied from the percentage registration point of the movie clip. The default registration point is (0, 0). Scaling the local coordinate system affects the property settings, which are defined in pixels.
CHAPTER 3 Flash Lite Statements This section describes the syntax and use of the Macromedia Flash Lite 1.x ActionScript statements, which are language elements that perform or specify an action. The statements are summarized in the following table: Statement Description...
Statement Description switch Similar to the statement, the statement tests a condition switch and executes statements if the condition evaluates to true while Tests an expression and runs a statement or series of statements repeatedly in a loop as long as the expression is true.
case Availability Flash Lite 1.0. Usage case expression: statements Parameters Any expression. expression Any statements. statements Description Statement; defines a condition for the statement. The statements in the switch statements parameter execute if the parameter that follows the keyword equals the expression case parameter of the...
In the following example, no break occurs in the first case group, so if the number is 1, both appear in the Output panel: switch (myNum) { case 1: trace ("A"); case 2: trace ("B"); break; default: trace ("D") See also switch continue Availability...
Page 67
Example In the following loop, causes Flash Lite to skip the rest of the loop body and while continue jump to the top of the loop, where the condition is tested: i = 0; while (i < 10) { if (i % 3 == 0) { i++;...
do..while Availability Flash Lite 1.0. Usage do { statement(s) } while (condition) Parameters The statement(s) to execute as long as the parameter evaluates statement(s) condition true The condition to evaluate. condition Description Statement; executes the statements, and then evaluates the condition in a loop for as long as the condition is true Example...
else Availability Flash Lite 1.0. Usage if (condition){ t-statement(s); } else { f-statement(s); Parameters An expression that evaluates to condition true false The instructions to execute if the condition evaluates to t-statement(s) true An alternative series of instructions to execute if the condition evaluates f-statement(s) false Description...
else if Availability Flash Lite 1.0. Usage if (condition){ statement(s); } else if (condition){ statement(s); Parameters An expression that evaluates to condition true false A series of statements to run if the condition specified in the statement statement(s) false Description Statement;...
Availability Flash Lite 1.0. Usage for (init; condition; next) { statement(s); Parameters An expression to evaluate before beginning the looping sequence, typically an init assignment expression. An expression that evaluates to . The condition is evaluated condition true false before each loop iteration; the loop exits when the condition evaluates to false An expression to evaluate after each loop iteration;...
Page 72
Availability Flash Lite 1.0. Usage if (condition) { statement(s); Parameters An expression that evaluates to condition true false The instructions to execute if the condition evaluates to statement(s) true Description Statement; evaluates a condition to determine the next action in a SWF file. If the condition , Flash Lite runs the statements that follow the condition inside curly braces ( ).
switch Availability Flash Lite 1.0. Usage switch (expression){ caseClause: [defaultClause:] Parameters Any numeric expression. expression keyword followed by an expression, a colon, and a group of statements caseClause case to execute if the expression matches the switch parameter. expression An optional keyword followed by statements to execute if none of defaultClause default...
Example In the following example, if the parameter evaluates to 1, the statement that myNum trace() follows executes; if the parameter evaluates to 2, the statement that case 1 myNum trace() follows executes; and so on. If no expression matches the parameter, the case 2 case...
Page 75
Parameters The expression that is evaluated each time the statement executes. condition while The instructions to execute when the condition evaluates to statement(s) true Description Statement; tests an expression and runs a statement or series of statements repeatedly in a loop as long as the expression is true Before the statement block is run, the condition is tested;...
CHAPTER 4 Flash Lite Operators This section describes the syntax and use of the Macromedia Flash Lite 1.x ActionScript operators. All entries are listed alphabetically. However, some operators are symbols and are alphabetized by their text descriptions. The operators in this section are summarized in the following table:...
Page 78
Operator Description Subtracts 1 from . The pre-decrement form of the operator –– (decrement) expression ) subtracts 1 from and returns the result as a ––expression expression number. The post-decrement form of the operator ( expression–– subtracts 1 from and returns the initial value of expression expression (the value before the subtraction).
Page 79
Operator Description Tests for equality; if is equal to , the result == (numeric expression1 expression2 equality) true Compares two expressions and determines whether > (numeric greater expression1 than) greater than ; if it is, the operator returns . If expression2 true is less than or equal to...
Operator Description Compares the string representation of to the string lt (string less expression1 than) representation of and returns a value if expression2 true expression1 is less than ; otherwise, it returns expression2 false Compares the string representation of to the string le (string less than expression1 or equal to)
+= (addition assignment) Availability Flash Lite 1.0. Usage expression1 += expression2 Operands Numbers or strings. expression1, expression2 Description Operator (arithmetic compound assignment); assigns the value of expression1 . For example, the following two statements have the expression1 + expression2 same result: x += y;...
Description Operator; performs a logical AND operation. Example The following example uses the operator to test whether a player has won the game. The variable and the variable are updated when a player takes a turn or scores points turns score during the game.
Example The following example uses the assignment (=) operator to assign a numeric value to the variable weight weight = 5; The following example uses the assignment (=) operator to assign a string value to the variable greeting greeting = "Hello, " and personName; /* (block comment) Availability Flash Lite 1.0...
, (comma) Availability Flash Lite 1.0. Usage expression1, expression2 Operands Numbers or expressions that evaluate to numbers. expression1, expression2 Description Operator; evaluates , then , and returns the value of expression1 expression2 expression2 Example The following example uses the comma (,) operator without the parentheses operator and illustrates that the comma operator returns only the value of the first expression without the parentheses...
The following example is identical to the previous example except for the addition of the parentheses operator and illustrates once again that when used with the parentheses operator, the comma ( ) operator returns the value of the last expression in the series: v = 0;...
?: (conditional) Availability Flash Lite 1.0. Usage expression1 ? expression2 : expression3 Operands An expression that evaluates to a Boolean value, usually a comparison expression1 expression, such as x < 5 Values of any type. expression2 expression3 Description Operator; instructs Flash Lite to evaluate , and if the value of expression1 expression1...
Description Operator (arithmetic); a pre-decrement and post-decrement unary operator that subtracts 1 from . The pre-decrement form of the operator ( ) subtracts 1 from expression ––expression and returns the result as a number. The post-decrement form of the operator expression ) subtracts 1 from and returns the initial value of...
/= (division assignment) Availability Flash Lite 1.0. Usage expression1 /= expression2 Operands Numbers or expressions that evaluate to numbers. expression1, expression2 Description Operator (arithmetic compound assignment); assigns the value of expression1 . For example, the following two statements are equivalent: expression1 / expression2 x /= y x = x / y...
Description Operator; used to navigate movie clip hierarchies to access nested (child) movie clips, variables, or properties. Example The following example identifies the current value of the variable in the hairColor movie clip person_mc person_mc.hairColor This is equivalent to the following slash notation syntax: /person_mc:hairColor See also / (Forward slash)
Example The following example uses ++ as a post-increment operator to make a loop run five while times: i = 0; while (i++ < 5){ trace("this is execution " + i); The following example uses ++ as a pre-increment operator: a = "";...
Page 91
Description Operator (logical); performs a Boolean operation on the values of one or both of the expressions. The operator evaluates (the expression on the left side of the expression1 operator) and returns if the expression evaluates to . If evaluates to false false expression1...
! (logical NOT) Availability Flash Lite 1.0. Usage !expression Operands None. Description Operator (logical); inverts the Boolean value of a variable or expression. If is a expression variable with the absolute or converted value of , the value of . If true !expression false...
Description Operator (logical); evaluates . The result is if either or expression1 expression2 true both expressions evaluate to ; the result is only if both expressions evaluate to true false . You can use the logical OR operator with any number of operands; if any operand false evaluates to , the result is...
Example The following code shows a numeric example that uses the modulo ( ) operator: trace (12 % 5);// output: 2 trace (4.3 % 2.1);// output: 0.0999... %= (modulo assignment) Availability Flash Lite 1.0. Usage expression1 %= expression2 Operands Numbers or expressions that evaluate to numbers. expression1, expression2 Description Operator (arithmetic compound assignment);...
Operands Numbers or expressions that evaluate to numbers. expression1, expression2 Description Operator (arithmetic compound assignment); assigns the value of expression1 expression1 * expression2 For example, the following two expressions are the same: x *= y x = x * y Example Usage 1: The following example assigns the value 50 to the variable x = 5;...
Example Usage 1: The following statement multiplies the integers 2 and 3: 2 * 3 The result is 6, which is an integer. Usage 2: The following statement multiplies the floating-point numbers 2.0 and 3.1416: 2.0 * 3.1416 The result is 6.2832, which is a floating-point number. + (numeric add) Availability Flash Lite 1.0.
== (numeric equality) Availability Flash Lite 1.0. Usage expression1 == expression2 Operands Numbers, Boolean values, or variables. expression1, expression2 Description Operator (comparison); tests for equality; the exact opposite of the operator. If <> is equal to , the result is .
> (numeric greater than) Availability Flash Lite 1.0. Usage expression1 > expression2 Operands Numbers or expressions that evaluate to numbers. expression1, expression2 Operator (comparison); compares two expressions and determines whether expression1 greater than ; if it is, the operator returns .
Example The following examples show results: true false trace(3.14 >= 2);// output: 1(true) trace(3.14 >= 4);// output: 0(false) See also ge (string greater than or equal to) <> (numeric inequality) Availability Flash Lite 1.0. Usage expression1 <> expression2 Operands Numbers, Boolean values, or variables. expression1, expression2 Description Operator (comparison);...
< (numeric less than) Availability Flash Lite 1.0. Usage expression1 < expression2 Operands Numbers. expression1, expression2 Description Operator (comparison); compares two expressions and determines whether expression1 less than ; if so, the operator returns . If is greater than or expression2 true expression1...
Example The following examples show results for numeric comparisons: true false trace(5 <= 10);// output: 1(true) trace(2 <= 2);// output: 1(true) trace (10 <= 3);// output: 0 (false) See also le (string less than or equal to) () (parentheses) Availability Flash Lite 1.0.
Example Usage 1: The following statements show the use of parentheses to control the order in which expressions are executed (the value of each expression appears in the Output panel): trace((2 + 3) * (4 + 5)); // displays 45 trace(2 + (3 * (4 + 5)));...
eq (string equality) Availability Flash Lite 1.0. Usage expression1 eq expression2 Operands Numbers, strings, or variables. expression1, expression2 Description Comparison operator; compares two expressions for equality and returns if the string true representation of is equal to the string representation of expression1 expression2 otherwise, the operation returns...
Description Operator (comparison); compares the string representation of to the string expression1 representation of and returns a value if is greater than expression2 true expression1 ; otherwise, it returns a value. Strings are compared using alphabetical expression2 false order; digits precede all letters, and all capital letters precede lowercase letters. Example The following examples show results:...
Example The following examples show results: true false animals = "cats"; breeds = 7; trace ("cats" ge "cattle");// output: 0(false) trace (animals ge "cats");// output: 1(true) trace ("persons" ge "people");// output: 1(true) trace (animals ge "Cats");// output: 1(true) trace (breeds ge "5");// output: 1(true) trace (breeds ge 7);// output: 1(true) See also >= (numeric greater than or equal to)
lt (string less than) Availability Flash Lite 1.0. Usage expression1 lt expression2 Operands Numbers, strings, or variables. expression1 expression2 Description Operator (comparison); compares the string representation of to the string expression1 representation of and returns a value if is less than expression2 true expression1...
Operands Numbers, strings, or variables. expression1, expression2 Description Operator (comparison); compares the string representation of to the string expression1 representation of and returns a value if is less than or equal expression2 true expression1 ; otherwise, it returns a value. Strings are compared using alphabetical expression2 false order;...
Description Operator (arithmetic); used for negating or subtracting. Usage 1: When used for negating, it reverses the sign of the numeric expression. Usage 2: When used for subtracting, it performs an arithmetic subtraction on two numeric expressions, subtracting from . When both expressions are expression2 expression1 integers, the difference is an integer.
Page 109
Description Operator (arithmetic compound assignment); assigns the value of expression1 . No value is returned. expression1 - expression2 For example, the following two statements are the same: x -= y; x = x - y; String expressions must be converted to numbers; otherwise, -1 is returned. Example Usage 1: The following example uses the operator to subtract 10 from 5 and assign the...
CHAPTER 5 Flash Lite Specific Language Elements This section describes both the platform capabilities and variables that Macromedia Flash Lite 1.1 recognizes, and the Flash Lite commands you can execute using the fscommand() functions. The functionality described in this section is specific to Flash Lite.
Page 112
Language element Description Indicates whether Flash Lite executes ActionScript expressions _cap4WayKeyAS attached to key event handlers associated with the Right, Left, Up, and Down Arrow keys. Contains the version number of Flash Lite. $version A function used to execute the command (see next entry).
Page 113
Language element Description Returns the maximum battery level of the device. GetMaxBatteryLevel Returns the maximum signal strength level. GetMaxSignalLevel Returns the maximum volume level of the device as a GetMaxVolumeLevel numeric value. Returns a value that indicates the current network GetNetworkConnectStatus connection status.
Decodes an arbitrary string that was encoded to be safe for Unescape network transfer into its normal, unencoded form. Capabilities This section describes the platform capabilities and variables that Macromedia Flash Lite 1.1 recognizes. The entries are listed alphabetially, ignoring any leading underscores. _capCompoundSound Availability Flash Lite 1.1.
Page 115
_capEmail Availability Flash Lite 1.1. Usage _capEmail Description Numeric variable; indicates whether the Flash Lite client can send e-mail messages by using ActionScript command. If so, this variable is defined and has a value of 1; if GetURL() not, this variable is undefined. Example If the host application can send e-mail messages by using the ActionScript...
Page 116
Example If the host application can perform dynamic loading of movies and variables, the following example sets to 1: iCanLoad canLoad = _capLoadData; if (canLoad == 1) { loadVariables("http://www.somewhere.com/myVars.php", GET); } else { trace ("client does not support loading dynamic data"); _capMFi Availability Flash Lite 1.1.
Page 117
_capMIDI Availability Flash Lite 1.1. Usage _capMIDI Description Numeric variable; indicates whether the device can play sound data in the Musical Instrument Digital Interface (MIDI) audio format. If so, this variable is defined and has a value of 1; if not, this variable is undefined.
Page 118
Example The following example sets to 1 in Flash Lite 1.1, but leaves it undefined in Flash Lite canMMS 1.0 (however, not all Flash Lite 1.1 phones can send MMS messages, so this code is still dependent on the phone): on(release) { canMMS = _capMMS;...
Page 119
_capSMAF Availability Flash Lite 1.1. Usage _capSMAF Description Numeric variable; indicates whether the device can play multimedia files in the Synthetic music Mobile Application Format (SMAF). If so, this variable is defined and has a value of 1; if not, this variable is undefined. Example The following example sets to 1 in Flash Lite 1.1, but leaves it undefined in Flash...
Page 120
Example The following example sets to 1 in Flash Lite 1.1, but leaves it undefined in Flash Lite canSMS 1.0 Flash Lite 1.0 (however, not all Flash Lite 1.1 phones can send SMS messages, so this code is still dependent on the phone): on(release) { canSMS = _capSMS;...
Page 121
_cap4WayKeyAS Availability Flash Lite 1.1. Usage _cap4WayKeyAS Description Numeric variable; indicates whether Flash Lite executes ActionScript expressions attached to key event handlers associated with the Right, Left, Up, and Down Arrow keys. This variable is defined and has a value of 1 only when the host application uses four-way key navigation mode to move between Flash controls (buttons and input text fields).
$version Availability Flash Lite 1.1. Usage $version Description String variable; contains the version number of Flash Lite. It contains a major number, minor number, build number, and an internal build number, which is generally 0 in all released versions. The major number reported for all Flash Lite 1.x products is 5. Flash Lite 1.0 has a minor number of 1;...
Page 123
Launch Availability Flash Lite 1.1. Usage status = fscommand("Launch", "application-path, arg1, arg2,..., argn") Parameters The command specifier. In Flash Lite, you use the function only to "Launch" fscommand() execute the command. Launch The name of the application being started "application-path, arg1, arg2,..., argn" and the parameters to it, separated by commas.
fscommand2() Availability Flash Lite 1.1. Usage returnValue = fscommand2(command [, expression1 ... expressionN]) Parameters A string passed to the host application for any use or a command passed to command Flash Lite. A comma-delimited list of strings passed as parameters to the parameter1...parameterN command specified by command...
Page 125
Example Examples are provided with the specific commands that you execute using the fscommand2() function, which are described in the rest of this section. See also fscommand() Escape Availability Flash Lite 1.1. Description Encodes an arbitrary string into a format that is safe for network transfer. Replaces each nonalphanumeric character with a hexadecimal escape sequence ( , or in the case of...
Page 126
FullScreen Availability Flash Lite 1.1. Description Sets the size of the display area to be used for rendering. The size can be full screen or less- than full screen. This command is supported only when Flash Lite is running in stand-alone mode. It is not supported when the player is running in the context of another application (for example, as a plug-in to a browser).
Page 127
Example The following example sets the variable to the current level of the battery: battLevel battLevel = fscommand2("GetBatteryLevel"); See also GetMaxBatteryLevel GetDateDay Availability Flash Lite 1.1. Description Returns the day of the current date. It is a numeric value (without a leading 0). Valid days are 1 through 31.
Page 128
GetDateMonth Availability Flash Lite 1.1. Description Returns the month of the current date as a numeric value (without a leading 0). Command Parameters Value returned None. -1: Not supported. "GetDateMonth" 1 to 12: The number of the current month. Example The following example collects the date information and constructs a complete date string: today = fscommand2("GetDateDay");...
Page 129
GetDateWeekday Availability Flash Lite 1.1. Description Returns a numeric value that is the name of the day of the current date, represented as a numeric value. Command Parameters Value returned None. -1: Not supported. "GetDateWeekday" 0: Sunday. 1: Monday. 2: Tuesday. 3: Wednesday.
Page 130
GetDateYear Returns a four-digit numeric value that is the year of the current date. Command Parameters Value returned None. -1: Not supported. "GetDateYear" 0 to 9999: The current year. Availability Flash Lite 1.1. Example The following example collects the date information and constructs a complete date string: today = fscommand2("GetDateDay");...
Page 131
Example The following code example assigns the device identifier to the variable, and statusdevice then updates a text field with the generic device name. These are some sample results and the devices they signify: A Mitsubishi 506i phone. D506i A Mitsubishi FOMA1 phone. DFOMA1 A Fujitsu 506i phone.
Page 132
case "P506i": /:myText += "device: Panasonic 506i" add newline; break; case "PFOMA1": /:myText += "device: Panasonic FOMA1" add newline; break; case "SH506i": /:myText += "device: Sharp 506i" add newline; break; case "SHFOMA1": /:myText += "device: Sharp FOMA1" add newline; break; case "SO506i": /:myText += "device: Sony 506i"...
Page 133
GetFreePlayerMemory Returns the amount of heap memory, in kilobytes, currently available to Flash Lite. Command Parameters Value returned None. -1: Not supported. "GetFreePlayerMemory" 0 or positive value: Available kilobytes of heap memory. Availability Flash Lite 1.1. Example The following example sets status equal to the amount of free memory: status = fscommand2("GetFreePlayerMemory");...
Page 134
Sets a parameter that identifies the language currently used by the device. The language is returned as a string in a variable that is passed in by name. Command Parameters Value returned "GetLanguage" String to receive the language code. It can -1: Not language be either the name of a variable or a string value that...
Page 135
Example The following example assigns the language code to the variable, and then updates language a text field with the language recognized by the Flash Lite player: statuslanguage = fscommand2("GetLanguage", "language"); switch(language) { case "cs": /:myText += "language is Czech" add newline; break;...
Page 136
case "pl": /:myText += "language is Polish" add newline; break; case "pt": /:myText += "language is Portuguese" add newline; break; case "ru": /:myText += "language is Russian" add newline; break; case "sv": /:myText += "language is Swedish" add newline; break; case "tr": /:myText += "language is Turkish"...
Page 137
Example The following example attempts to return the long form of the current date in the longDate variable. It also sets the value of to report whether it was able to do so. status status = fscommand2("GetLocaleLongDate", "longdate"); trace (longdate); // output: Tuesday, June 14, 2005 See also GetLocaleShortDate...
Page 138
GetLocaleTime Availability Flash Lite 1.1. Description Sets a parameter to a string representing the current time, formatted according to the currently defined locale. Command Parameters Value returned String variable to receive the value of the -1: Not "GetLocaleTime" time current time, such as supported.
Page 139
Example The following example sets the variable to the maximum battery level: maxBatt maxBatt = fscommand2("GetMaxBatteryLevel"); GetMaxSignalLevel Availability Flash Lite 1.1. Description Returns the maximum signal strength level. It is a numeric value greater than 0. Command Parameters Value returned None.
Page 140
Example The following example sets the variable to the maximum volume level of maxvolume the device: maxvolume = fscommand2("GetMaxVolumeLevel"); trace (maxvolume); // output: 80 See also GetVolumeLevel GetNetworkConnectStatus Availability Flash Lite 1.1. Description Returns a value that indicates the current network connection status. Command Parameters Value returned None.
Page 141
Example The following example assigns the network connection status to the variable, connectstatus and then uses a statement to update a text field with the status of the connection: switch connectstatus = fscommand2("GetNetworkConnectStatus"); switch (connectstatus) { case -1 : /:myText += "connectstatus not supported" add newline; break;...
Page 142
Example The following example assigns the name of the current network to the variable myNetName and a status value to the variable: netNameStatus netNameStatus = fscommand2("GetNetworkName", myNetName); GetNetworkRequestStatus Availability Flash Lite 1.1. Description Returns a value indicating the status of the most recent HTTP request. Command Parameters Value returned None.
Page 143
Example The following example assigns the status of the most recent HTTP request to the variable, and then uses a statement to update a text field with requesttatus switch the status: requeststatus = fscommand2("GetNetworkRequestStatus"); switch (requeststatus) { case -1: /:myText += "requeststatus not supported" add newline; break;...
Page 144
GetNetworkStatus Availability Flash Lite 1.1. Description Returns a value indicating the network status of the phone (that is, whether there is a network registered and whether the phone is currently roaming). Command Parameters Value returned None. -1: The command is not supported. "GetNetworkStatus"...
Page 145
GetPlatform Availability Flash Lite 1.1. Description Sets a parameter that identifies the current platform, which broadly describes the class of device. For devices with open operating systems, this identifier is typically the name and version of the operating system. Command Parameters Value returned String to receive the...
Page 146
GetPowerSource Availability Flash Lite 1.1. Description Returns a value that indicates whether the power source is currently supplied from a battery or from an external power source. Command Parameters Value returned None. -1: Not supported. "GetPowerSource" 0: Device is operating on battery power. 1: Device is operating on an external power source.
Page 147
GetTimeHours Availability Flash Lite 1.1. Description Returns the hour of the current time of day, based on a 24-hour clock. It is a numeric value (without a leading 0). Command Parameters Value returned None. -1: Not supported. "GetTimeHours" 0 to 23: The current hour. Example The following example sets the variable to the hour portion of the current time of day,...
Page 148
Example The following example sets the variable to the minute portion of the current time of minutes day, or to -1: minutes = fscommand2("GetTimeMinutes"); trace (minutes); // output: 38 See also GetTimeHours GetTimeSeconds GetTimeZoneOffset GetTimeSeconds Availability Flash Lite 1.1. Description Returns the second of the current time of day.
Page 149
GetTimeZoneOffset Availability Flash Lite 1.1. Description Sets a parameter to the number of minutes between the local time zone and universal time (UTC). Command Parameters Value returned Number of minutes between -1: Not supported. "GetTimeZoneOffset" timezoneOffset the local time zone and UTC. It can be either the 0: Supported.
Page 150
Example The following example sets the variable to the total amount of heap memory: status status = fscommand2("GetTotalPlayerMemory"); See also GetFreePlayerMemory GetVolumeLevel Availability Flash Lite 1.1. Description Returns the current volume level of the device as a numeric value. Command Parameters Value returned None.
Page 151
Quit Availability Flash Lite 1.1. Description Causes the Flash Lite player to stop playback and exit. This command is supported only when Flash Lite is running in stand-alone mode. It is not supported when the player is running in the context of another application (for example, as a plug-in to a browser).
Page 152
Example The following statement resets the soft keys to their original settings: status = fscommand2("ResetSoftKeys"); See also SetSoftKeys SetInputTextType Availability Flash Lite 1.1. Description Specifies the mode in which the input text field should be opened: Command Parameters Value returned Name of the input text field.
Page 153
The following table shows what effect each mode has, and what modes are substituted: Mode Sets the FEP to one of these mutually If not supported on specified exclusive modes current device, opens the FEP in this mode Numeric Numbers only (0 to 9) Alphanumeric Alpha Alphabetic characters only (A to Z, a to z)
Page 154
SetSoftKeys Availability Flash Lite 1.1. Description Remaps the Left and Right soft keys of the device, provided that they can be accessed and remapped. After this command is executed, pressing the left key generates a keypress event, and PageUp pressing the right key generates a keypress event.
Page 155
StartVibrate Availability Flash Lite 1.1. Description Starts the phone’s vibration feature. If a vibration is already occurring, Flash Lite stops that vibration before starting the new one. Vibrations also stop when playback of the Flash application is stopped or paused, and when Flash Lite player quits. Command Parameters Value returned...
Page 156
Example The following example calls and saves the result (not supported or vibration StopVibrate stopped) in the variable: status status = fscommand2("StopVibrate"); See also StartVibrate Unescape Availability Flash Lite 1.1. Description Decodes an arbitrary string that was encoded to be safe for network transfer into its normal, unencoded form.
Page 159
gotoAndPlay() function 19 gotoAndStop() function 19 _name property 54 greater than operator 98 ne (string not equal) operator 105 greater than or equal to operator 98 nextFrame() function 30 gt (string greater than) operator 103 nextScene() function 31 NOT operator 92 Number() function 32 numeric addition 96 _height property 52...
Page 160
if 72 logical NOT 92 play() function 34 switch 73 prevFrame() function 35 while 74 prevScene() function 36 stop() function 39 properties stopAllSounds() functions 40 _alpha 49 string delimiter operator 102 _currentframe 49 string equal operator 103 _focusrect 50 string greater than operator 103 _framesloaded 51 string greater than or equal to 104 _height 52...
Need help?
Do you have a question about the FLASH 8-FLASH LITE 1.X ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers