Flash XML Applications Use AS2 and AS3 to Create Photo Galleries, Menus, and Databases phần 4

tin var Ngoại trừ cho các biến, màộ phim, chúng tôi thực hiện tất cả các biến tư nhân để ngăn chặn họ khỏi bị truy cập từ phim hoặc từ các lớp giờ sau khi kết thúc những gì tôi sẽ gọi phần đầu của lớp một kịch bản, chúng tôi sẽ viết một số | 88 Flash XML Applications one value associated with them and we need to be able to call them from another class. The variable myCity holds the name of the city and myCityXml holds the URL for the XML file. private var partofCity ComboBox public static var myCity String public static var myCityXml String private var cityDefault String The next part is to add data to the combo box. We create a local variable selCity which will hold the child node with id 1 which contains child nodes with local names for the city and node values for the XML files cb North xml_files cb North . You can now see how handy the idMap array is since we can access the whole node in one piece var selCity XMLNode 1 Using a for loop we loop through the child nodes of this node for var count01 0 count01 count01 We set the default value which is the node value of the first node cityDefault 0 . Then we create local variables which hold values for the label and data. We can use the same name as for the static variables because these local variables will exist only within this function. Note To get the name of the city we need to ask for the local name and not the node name which would be cb Davis for example since the XML file contains namespaces. var cityXML String count01 . var myCity String count01 . localName We use the addItem method which is common among many list-type components. As we are used to adding values to an array we now add the label and data values to the combo box label myCity data cityXML We need to use the this word since originally our class extends the MovieClip class and this refers to the MovieClip comboPack where all the combo boxes are located. We then wr ite two functions to add functionality to the combo box 1 when the user selects an item selectCity and 2 to set the default value defaultCity .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
20    99    1    20-06-2024
42    548    21    20-06-2024
Đã 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.