Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Actionscript XML Preloader [Code supplied]

Status
Not open for further replies.

QuantumDoja

Programmer
Jun 11, 2004
76
GB
Hi, I have a button, that when pressed, it loads some xml from the server, the problem is, i want to create a pre-loader for it, but i do not know how.

I want to show in a dynamic text field, the percent downloading....but am totally stuck. please help.

Code:
btnLoad.onPress = function():Void {
xCodes = new XML();
		xCodes.load("[URL unfurl="true"]http://www.mysite.co.uk/xmlgateway.asp");[/URL]
		xCodes.onLoad = dosomething;
}

 
xml.getBytesLoaded and xml.getBytesTotal.

Hope it helps.
 
From Flash (MX 2004 Pro) help.
Code:
var doc:XML = new XML();

var checkProgress = function(xmlObj:XML) {
  var bytesLoaded:Number = xmlObj.getBytesLoaded();
  var bytesTotal:Number = xmlObj.getBytesTotal();
  var percentLoaded:Number = Math.floor((bytesLoaded / bytesTotal ) * 100);
  trace ("milliseconds elapsed: " + getTimer());
  trace ("bytesLoaded: " + bytesLoaded);
  trace ("bytesTotal: " + bytesTotal);
  trace ("percent loaded: " + percentLoaded);
  trace ("---------------------------------");
}

doc.onLoad = function(success:Boolean) {
  clearInterval(intervalID);
  trace("intervalID: " + intervalID);
}
doc.load("[place a valid URL pointing to an XML file here]");
var intervalID:Number = setInterval(checkProgress, 100, doc);

That what you are looking for?
 
thats more along the lines of what i was thinking....thanks.....well i wasnt thinking that, but i knew there had to be some sort of loop to check.

many thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top