Macromedia Flash MX 2004 Killer Tips

[ LiB ] 

I'm Ignoring You Now

Dealing with XML in Flash isn't always the easiest thing to do. There are just so many darn rules. For one, if you're importing an XML file into an XML object and your file was created with tabs, spaces, and return characters in it (as most are), then you can run into some trouble. Flash will treat these characters (known as white space) as if they are nodes themselves, and that can cause big problems. You could just remove all the white space and make the file one long string, but that's hard to read. Instead, just use this code.

myData = new XML(); myData.ignoreWhite = true; myData.load("myfile.xml");

With the ignoreWhite attribute set to true, Flash will simply ignore those pesky characters and treat the entire file as if it were one long string of text. It seems to me that ignoreWhite should be set to true by default, but that's just me.

[ LiB ] 

Категории