Ok it is clearer now.
And you are correct there is a delay. That is expected.
When you issue the slideshow.load method, requests go out over the network.
There is no guarantee when the response will arrive and as such the
processing of the onLoad method. So in the meantime the code following
slideshow.load is fully processed and does not waiting for the data to be
received. In general the code will be processed way faster than the network
response.
Do not think of onLoad as a subroutine but as a separate thread processing
on its own sweet time.
When the data is returned the onLoad method is called. Only then you can use
the values you derive from the XML data file.
So what you want to do is in the onLoad add a gotoAndStop(___) or
nextFrame() as the last line in the success if block. On that frame you can
then have access to all the data received. You can also add a gotoAndStop()
for the failure if block.
I put the lines in here but you need to supply the frame numbers.
//Loads function if XML file loaded
function startMovie(success)
{
if (success == true)
{
//trace(slideshow)
//Loads content from nodes from XML
var childItems:Array = mx.xpath.XPathAPI.selectNodeList(this.firstChild,
"rss/channel/item/title");
var descNodes:Array = mx.xpath.XPathAPI.selectNodeList(this.firstChild,
"/rss/channel/item/description");
var urlNodes:Array = mx.xpath.XPathAPI.selectNodeList(this.firstChild,
"/rss/channel/item/link");
//Counts # of Item nodes
count = childItems.length;
trace(count);
//Var z is the _x position of movie
z = 10;
//Create Headline, Description text fields and extract URL
for (var i = 0; i < count; i++)
{
trace(_root.slider_mc.createTextField("headline" + i,
_root.slider_mc.getNextHighestDepth(), z, 10, 50, 100));
trace(_root.slider_mc.createTextField("desc" + i,
_root.slider_mc.getNextHighestDepth(), z + 40, 125, 50, 200));
//Increase _x position for each Item
z += 600;
var headline:String = "headline" + i;
var desc:String = "desc" + i;
var link:String = "link" + i;
var txtFmt:TextFormat = new TextFormat();
var descFmt:TextFormat = new TextFormat();
var linkFmt:TextFormat = new TextFormat();
txtFmt.size = 30;
descFmt.size = 22;
linkFmt.size = 18;
trace(_root.slider_mc[headline].text =
childItems[i].firstChild.nodeValue);
trace(_root.slider_mc[desc].text = descNodes[i].firstChild.nodeValue);
_root.slider_mc[headline].setTextFormat(txtFmt);
_root.slider_mc[headline].wordWrap = true;
_root.slider_mc[headline].multiline = true;
_root.slider_mc[headline]._width = 490;
_root.slider_mc[headline].html = true;
_root.slider_mc[headline].htmlText = "<bold><font size='30'
face='Arial'><ahref='" + urlNodes[i].firstChild.nodeValue + "'
target='_blank'>" + childItems[i].firstChild.nodeValue +
"</a></font></bold>";
_root.slider_mc[desc].setTextFormat(descFmt);
_root.slider_mc[desc].wordWrap = true;
_root.slider_mc[desc].multiline = true;
_root.slider_mc[desc]._width = 450;
}
gotoAndStop(______frame number for success______);
}
else
{
this.createTextField("error", 10, 10, 10, 320, 100);
error.text = "Didn't work";
gotoAndStop(______frame number for failure______);
}
}
var count:Number = 1;
//Loads RSS file from Digg.com
import mx.xpath.XPathAPI;
slideshow = new XML();
slideshow.onLoad = startMovie;
slideshow.load("
http://www.digg.com/rss/index.xml");
slideshow.ignoreWhite = true;
trace("a count" + count);
stop();
--
Lon Hosford
www.lonhosford.com May many happy bits flow your way!