Đang chuẩn bị liên kết để tải về tài liệu:
Foundation Flash CS4 for Designers- P20
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Foundation Flash CS4 for Designers- P20: I can remember the day as clear as if it were just yesterday. I was walking by my boss’s office late one winter afternoon at the college where I teach, and he called me into his office. Sitting on his desk was a thin, white box with some sort of weird swirl on it. He slid the box across to me and asked, “You know anything about Flash?” | XML DYNAMIC DATA In this situation another XMLList method can help you out. To make each title appear on its own line append toXMLString to the existing expression trace xmlDoc.film.i title.toXMLString Swap title for the releaseDate attribute as follows trace xmlDoc.film.i releaseDate.toXMLString As shown in Figure 13-2 you ll see release dates instead of titles in the Output panel. Figure 13-2. Any element s attributes can be retrieved. What about looking at a list of the cast members Viewing individual cast members is just as easy. Update the trace function to look like this trace xmlDoc.tilm o .cast.character l This trace function instructs Flash to look at the first tilm element s cast element and then pull out that node s second character element which happens to be Olive Oyl. For fun and to see how easy E4X makes things for you contrast the preceding intuitive reference with its ActionScript 2.0 equivalent xmlDoc.firstChild.firstChild.tirstChild.childNodes l . Which would you rather use Moving back to the kinder gentler world of ActionScript 3.0 update the trace function as follows to see the whole cast of the third film trace xmlDoc.tilm 2 .cast.character This time you get elements again complete with their tag markup as shown in Figure 13-3. This is just like tracing xmlDoc.tilm earlier where the Output panel showed tilm elements and their descendants. Figure 13-3. Accessing elements selects the elements themselves as well as their children. 565 CHAPTER 13 Node types In the previous section when you used the array access operator xmlDoc.tilm o .cast. character l Flash gave you the immediate descendant of the character tag you specified which was a text node that is just a string . Here you re looking at a list of element nodes and their text node descendants. If you want just the text nodes you can use another XMLList method descen-dants to retrieve what you re after. You ll see an example in just a bit. First make sure you grasp the idea that when you see