Reading and displaying RSS feeds in Flash MX 2004-03-11 - By Darron J. Schall
Back > The .as file is in the same dir as the FLA. I saved the XML that I got from > the web to a file in the same dir as the FLA for testing purposes. Also, I > added a "var" right in front of the "o =". Is that correct? > > The output window says "undefined". What am I doing wrong?
You have two errors that I can see...
1) You're encountering problems by using the "var" keyword. The var keyword tells Flash to define the variable as a local variable. Because of this, the "o" variable exits in the the mxXML, and not on the timeline where you code is.
2) You're calling the trace before the xml data is actually loaded.
Rewrite your code to look like this:
#include "XMLtoObject.as" myXml = new XML (); mxXml.owner = this; // gives the xml object a refernece to the current timeline myXml.ignoreWhite = 1 myXml.onLoad = function (success){ if (success) { this.owner.o = this.toObject (); } trace(this.owner.o.Section[1].Content[1]);
// clean up some memory by removing the unneed xml object - // note that o will still exist since it exists in the owner delete this; } myXml.load ("index.xml");
That should do it for you..
-d
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Supported by Fig Leaf Software -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Lower Prices for Certified Training! Check out new lower prices for Certified Macromedia Training from Fig Leaf Software. Expand your skill set with courses in ColdFusion, Flash, Rich Internet Applications and .NET in the new year. Fig Leaf Software provides the highest caliber instruction at our training centers in Washington D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location.
Get the details at http://training.figleaf.com/ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) For additional commands, e-mail: flashnewbie-help@(protected)
|
|