Retrieving the Data

Lấy các dữ liệu Bây giờ bạn đã tạo ra một kiến trúc lưu trữ dữ liệu, bạn cần phải phát triển một cách để lấy lại thông tin từ lưu trữ, và có liên quan đến một số cú pháp mới cung cấp một phương tiện để viết một đường dẫn cú pháp dấu chấm động. dấu ngoặc vuông được sử dụng để đánh giá một biểu thức. | Retrieving the Data Now that you ve created a data-storage architecture you need to develop a way to retrieve the information from storage and that involves some new syntax that provides a means of writing a dot syntax path dynamically. Square brackets are used to evaluate an expression. Here s how it works. Assume we have three variables that contain animal sounds var dog String bark var cat String meow var duck String quack We ll create a variable and assign it a text value of dog cat or duck note that these text values have the same names as the variables we just mentioned . We ll start with dog var currentAnimal String dog Using this syntax we can access the value of the variable named dog var animalSound this currentAnimal Here animalSound is assigned a value of bark . The expression to the right of the equals sign looks at currentAnimal and sees that it currently contains a string value of dog . The brackets surrounding currentAnimal tell ActionScript to treat this value as a variable name. Flash sees this line of script like this var animalSound String Because dog has a value of bark that s the value assigned to animalSound. If we were to change the value of currentAnimal to cat animalSound would be assigned a value of meow . Note that you must use this in the expression to include the target path of the variable used to set the dynamic variable name in this case currentAnimal because it relates to the variable to the left of the equals sign in our case animalSound . Using this denotes that these two variables are on the same timeline. If animalSound existed in a movie clip instance s timeline while currentAnimal was on the root main timeline the syntax would look like this var animalSound String _root currentAnimal Here are a couple of other examples var animalSound String _parent currentAnimal var animalSound String myMovieClip currentAnimal This syntax is critical to the way you retrieve information from the objects in this exercise. Remember .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.