Whittler
03-12-2011, 01:54 AM
Hello to everyone in this forum. I'm a newb. Sorry if my post is not formatted correctly.
Can't seem to find any info on how to do this. I just want to read and parse my xml file into variables so I can display them and format them. I'm getting an error that reads:
TypeError: Error #1034: Type Coercion failed: cannot convert "m_products.xml" to flash.net.URLRequest.
This is my code snippet:
//create variables used later for getting/displaying xML info
var myXML:XML;
var itemNumber:uint = 0;
var myLoader:Loader = new Loader();
var totalItems:int = 0;
//create variables to hold the information retrieved from the XML file
var prodName:String;
var prodDescription:String;
//create object to get the XML information
var xmlLoader:URLLoader = new URLLoader();
//object now gets the XML file
xmlLoader.load(URLRequest("m_products.xml"));
//once the object has a hold of the data begin displaying it
xmlLoader.addEventListener(Event.COMPLETE, setupXMLData);
function setupXMLData(e:Event):void
{
myXML = new XML(xmlLoader.data);
totalItems = myXML.children().length() - 1;
}
function displayProduct():void
{
prodName = myXML.prodpage[itemNumber].prodname;
prodDescription = myXML.prodpage[itemNumber].proddescription;
}
trace(prodName);
Any help would be greatly appreciated.
Thanks
Can't seem to find any info on how to do this. I just want to read and parse my xml file into variables so I can display them and format them. I'm getting an error that reads:
TypeError: Error #1034: Type Coercion failed: cannot convert "m_products.xml" to flash.net.URLRequest.
This is my code snippet:
//create variables used later for getting/displaying xML info
var myXML:XML;
var itemNumber:uint = 0;
var myLoader:Loader = new Loader();
var totalItems:int = 0;
//create variables to hold the information retrieved from the XML file
var prodName:String;
var prodDescription:String;
//create object to get the XML information
var xmlLoader:URLLoader = new URLLoader();
//object now gets the XML file
xmlLoader.load(URLRequest("m_products.xml"));
//once the object has a hold of the data begin displaying it
xmlLoader.addEventListener(Event.COMPLETE, setupXMLData);
function setupXMLData(e:Event):void
{
myXML = new XML(xmlLoader.data);
totalItems = myXML.children().length() - 1;
}
function displayProduct():void
{
prodName = myXML.prodpage[itemNumber].prodname;
prodDescription = myXML.prodpage[itemNumber].proddescription;
}
trace(prodName);
Any help would be greatly appreciated.
Thanks