I’m trying to figure out how to eliminate the need for an external XML file with my SWF
Right now I have a SWF and an XML containing a few thousand lines, that are being grabbed using this AS
on (release) {
if (_global.my_xml == null)
{
trace("my_xml is null")
_global.my_xml = new XML();
_global.my_xml.ignoreWhite = true;
_global.my_xml.onLoad = function(success){
if (success)
{ trace("successful");
var stocklist = my_xml.firstChild.childNodes;
trace("records found : " + stocklist.length);
var found = false;
for (var i = 0; i < stocklist.length; i++){
var stockitem = stocklist*;
if (act == stockitem.attributes.Customer_Number)
{
amt = stockitem.attributes.Revenue_Target;
nam = stockitem.attributes.Customer_Name;
net = stockitem.attributes.Ranging_Target;
found = true;
}
}
if (found == false)
{
amt = "not found";
nam = "not found";
net = "not found";
}
}
else trace("Error loading XML file"); // no success? trace error (wont be seen on web)
}
// _global.my_xml.load("Customer_Target.xml");
}
else
{
trace("my_xml found")
var stocklist = my_xml.firstChild.childNodes;
var found = false;
for (var i = 0; i < stocklist.length; i++){
var stockitem = stocklist*;
if (act == stockitem.attributes.Customer_Number)
{
amt = stockitem.attributes.Revenue_Target;
nam = stockitem.attributes.Customer_Name;
net = stockitem.attributes.Ranging_Target;
found = true;
}
}
if (found == false)
{
amt = "not found";
nam = "not found";
net = "not found";
}
}
}
I understand one way to do this is to throw all the XML data into actionscript, eg:
var my_xml = new XML("<CustomerDetails><Customer Customer_Number=\"1000\" Customer_Name=\"NAME\" Revenue_Target=\"$500,000.00\" Ranging_Target=\"1\" /></CustomerDetails>");
However there are formatting issues with this as well as it only being able to be read on one line.
I also understand there is a method to place all this data into a dynamic text field, and just call it from there. The problem is I’m not sure how to call data from a text field.
Was hoping someone could give some suggestions?