Join Todd Perkins for an in-depth discussion in this video Working with comments and processing instructions, part of ActionScript 3.0: Working with XML.
Now there may come a time when you want to access comment or processing instructions in your XML data. In this movie we will talk about how to do that. If you are following along I am working in 02_Comments_Processing.fla in the Chapter 3 folder. You can also just use the same file from the last exercise. Let's go to the first keyframe in the Actions Layer and open up the Actions panel. Now when Flash parses XML data, if you have not already told Flash not to ignore comments and processing instructions then comments and processing instructions will be ignored and you can't access them later on.
What we have to do is tell Flash not to ignore comments or processing instructions. The properties that handle whether you ignore comments and processing instructions are held as static properties of the XML class. So let's go all the way to the top of our code. I am going to type XML.ignore comments. This has a default value of True so if we just set that equal to False then we get our comments. And if we go to the next line and we type XML.ignore processing instructions and we set that equal to False as well and we test the movie, our XML string will display both our processing instructions and our comments.
Now let's say we wanted to access processing instructions or comments. One thing we can do is we are can refer to our XML object and we can type .Comment and comment is a method of the XML class that returns all the comments in our XML data. So I test the movie at this point and then you will see our comment. And if you want to see processing instructions it's essentially the same process. So test the movie and then we have our processing instructions there.
Now if you have multiple comments or multiple processing instructions you can access them similar to an array. The type of data that's returned when you run the processing instructions or comments method from the XML class is called an XMLList which is similar to an array of XML data. We are going to be talking about XMLList more as we go on throughout this chapter but there is a look at how to access comments and processing instructions if you ever need to.
- Understanding XML data
- Creating XML in ActionScript 3.0
- Working with external XML data
- Building a reusable RSS reader class
- Using PHP with XML
- Working with blogs
- Working with Flickr images using the Flickr API
- Working with podcasts
Skill Level Intermediate
1. Understanding XML Data
2. Creating XML in ActionScript 3.0
3. Working with External XML Data
4. Building a Reusable RSS Reader Class
5. Using PHP with XML Data
6. Working with Blogs
7. Working with the Flickr API
8. Working with Podcasts
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.