tailieunhanh - Flash: ActionScript Language Reference- P2

Tham khảo tài liệu 'flash: actionscript language reference- p2', công nghệ thông tin, đồ họa - thiết kế - flash phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Availability Flash Player 5. Usage Number Description Property the number of parameters actually passed to a function. Example The following ActionScript includes a function called getArgLength which returns the number of arguments that are passed into the function. Although the method expects three arguments you can pass as many arguments as you want. function getArgLength param_arg1 String param_arg2 String param_arg3 String return trace getArgLength one two three output 3 trace getArgLength one two output 2 trace getArgLength one two three four output 4 In the following example the function called listSum adds the values passed to it and returns the sum. The function uses a for loop to examine each argument passed. If the value is a number the value is added to the sum variable. At the end of the function the value of sum is returned. function listSum Number var sum Number 0 for var i 0 i i if isNaN Number arguments i sum parseFloat arguments i return sum trace listSum 100 200 300 7 output 607 101 Array Availability Flash Player 6. Usage Array Array Array numElements Number Array Array elementO Object elementl element2 .elementN Array Parameters element One or more elements to place in the array. Returns An array. Description Conversion function creates a new empty array or converts specified elements to an array. Using this function is similar to creating an array with the Array constructor see Constructor for the Array class on page 104 . Example Usage 1 The following example adds items to an array by using the array s index and then by using the Array class s push method var myArray Array Array 12 trace myArray traces 12 myArray 4 7 trace myArray traces 12 undefined undefined undefined 7 Usage 2 The following example creates an array of length 4 but with no elements defined var myArray Array Array 4 trace traces 4 trace myArray traces undefined .

TỪ KHÓA LIÊN QUAN