THE FLASH 4 BIBLE (IDG BOOKS)  back to
FLASH 4 ACTIONSCRIPT FUNCTIONS  

flash 4 actionscript built-in functions

Function Name

Syntax

Example

Definition

Eval

eval(variable or expression)

eval(“product” & count)

Performs the operations in parentheses, then returns the resulting value.

True

True

Set Property ("/ball", Visibility)=True

Long-hand version of boolean “on” state. Equivalent to “1”.

False

False

Set Property ("/ball", Visibility)=False

Long-hand version of boolean “off” state. Equivalent to “0”.

Newline

Newline

Set Variable: "name"="Andy" & Newline & "Harris"

Adds a line break to a string value.

GetTimer

GetTimer

Set Variable: "time"=Int (GetTimer / 1000)

Returns, in milliseconds, the time elapsed since the movie started.

Int

Int(number)

Set Variable: "foo"=Int (5/2)

Returns just the integer of a variable, number, or expression. (eg. the Int of both 2.3 and 2.9 is 2)

Random

Random(number)

Set Variable: "dice"=Int (Random (6)) + 1

Returns a random number between 0 and number, -1. Number may be a variable, number, or expression.

Substring

Substring (string, index, count)

Set Variable: "second_char"=Substring (name, 2, 1)

Returns a portion of a string or variable value. The returned portion has a length of “count”, starting at the character number “index”.

Length

Length (string)

Set Variable: "num_chars"=Length (name)

Returns the number of characters in a string.

Chr

Chr (asciiCode)

Set Variable: "character"=Chr (65)

Returns the character representation of the given ascii value.

Ord

Ord (character)

Set Variable: “ascii_num”=Ord (“A”)

Returns the ascii value of the first letter in the supplied string or variable value.

MBSubstring

MBSubstring (string, index, count)

Set Variable: "second_char"=MBSubstring (name, 2, 1)

Same as Substring, but for multibyte characters.

MBLength

MBLength (string)

Set Variable: "num_chars"=MBLength (name)

Same as Length, but for multibyte characters.

MBChr

MBChr (asciiCode)

Set Variable: "character"=MBChr (65)

Same as Chr, but for multibyte characters.

MBOrd

MBOrd (character)

Set Variable: “ascii_num”=MBOrd (“A”)

Same as Ord, but for multibyte characters.


about this info
this documentation is a short excerpt from colin moock's section of the 600 page book "the flash 4 bible", (idg books). to order, or for general information about the book, visit colin's flash 4 bible page.

revision history
november 30, 1999: created.
december 1, 1999: posted.
december 3, 1999: fixed the definition of eval. it was wrong cause i was using an older version of the chapter when i converted the table to html.
december 20, 1999: fixed the examples for the mb functions. the "mb" had been left out in the syntax example. thanks to jon pryne for noticing.