tailieunhanh - Thiết kế flash với flash cs5 part 61

Kiểm soát dữ liệu Có một số cách quan trọng để kiểm soát dữ liệu trong ActionScript . Chúng bao gồm các mảng, chia sẻ đối tượng và XML. Array An là phương pháp đầu tiên bạn có khả năng sử dụng trong mã ActionScript của bạn. | Controlling Data There are several key ways to control data in ActionScript . They include Arrays Shared Objects and XML. An Array is the first method you are likely to use in your ActionScript code. The role of an Array is to create a list of data types in your code. For example you may want to list the colors red green blue and orange. To do this you need to define a new variable with the data type of Array var colorArray Array new Array red green blue orange You can see in this script that a set of four items have been inserted into the Array. You can access the data in the Array with the following trace statement trace colorArray The push property will allow you to add a new item into your array purple To remove the last item of an Array you can use the Pop property. What you will find is that Arrays are great for manage simple lists. Additional properties allow you to remove specific values to count the number of values you have and to sort your lists. For more complex data you will want to leverage the Local Data Storage or XML. When you are counting the number of values in an Array you have to remember that Arrays always start with 0. For instance if you have five items in an array and tell the array to pull item 1 it will pull the second item. This is because the first item has the registered value of 0. If you are developing an AIR solution you can take advantage of the SQL database built right into AIR. The SQL database comes with support for the creation of tables stored procedures and SQL statements. Using Flash Cookies The Flash Player can also store data locally in very much the same way that a cookie can be stored in a Web browser. Flash does not call this cookies but Shared Objects. An example of Share Object ActionScript is var mySO SharedObject myFlashCookie new Date .time trace The Share Object is declared and given a name where it will be stored on the local