NAVIGATION:

 

SUPPORTERS:

FlashComponents
  Flash Templates
  Flash Gallery
  Flash Slideshow
  Flash Menu
  Flash Design
  Flash Video
  User Interface

 

FOLLOW:

RSS it down! Twitter it up! Facebook it like a fiend!

 

 

Using XML in Flash CS3/AS3 - Page 7
       by kirupa  |  17 July 2007

In the previous page, you learned how to filter your data based on conditions that you set. In all of the previous filtering examples, though, you only filtered your values based on one condition. You can actually have as many conditions as you want, so you can create sophisticated filters for precisely find the data you need.

For example, try the following code:

function ParseBooks(bookInput:XML):void {
trace("XML Output");
trace("------------------------");
 
var bookList:XMLList = bookInput.Book.(author == "Stephen E. Ambrose" && title != "Nothing Like It In the World").title;
trace(bookList);
}

When you test your application with the above code, Undaunted Courage will be the only returned result. Notice that we are filtering our data by both author and title. The author must be Stephen E. Ambrose, but the title cannot be Nothing Like It In the World.

Conclusion
Hopefully the previous six pages provided you with enough tools to tackle even the most demanding XML-related tasks. The introduction of E4X in AS3 is quite significant and makes dealing with XML data easier. With the ease, though, comes a relatively different (sometimes complicated) syntax for accessing the data, and this tutorial only covered a sub-set of all that is possible under E4X.

Throughout this tutorial, you used a sample XML file that contained four of my favorite books. Below, I have provided the cover image and an Amazon link where you can learn more or even buy them:

Sherlock Holmes : The Complete Novels and Stories (Bantam Classic) Volume I
by Sir Arthur Conan Doyle

The Great Gatsby
by F. Scott Fitzgerald

Undaunted Courage: Meriwether Lewis, Thomas Jefferson, and the Opening of the American West
by Stephen E. Ambrose
Nothing Like It In the World : The Men Who Built the Transcontinental Railroad 1863-1869
by Stephen E. Ambrose

I hope the information helped. If you have any questions or comments, please don't hesitate to post them on the kirupa.com Forums. Just post your question and I, or our friendly forum helpers, will help answer it.

The following is a list of related tutorial and help resources that you may find useful:

How to use the Forums
New, Upcoming, and In-Progress Tutorials
How to Help out kirupa.com
Writing Tutorials
 

Cheers!

Kirupa Chinnathambi
facebook | twitter

 

1 | 2 | 3 | 4 | 5 | 6 | 7

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components Flash effects. Art without coding.
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Citrus Engine: Flash platformer and sidescrolling game engine
Learn how to advertise on kirupa.com

cdn
content delivery network (cdn)