LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-20-2006, 01:22 PM
SSJ17Vegeta SSJ17Vegeta is offline
Registered User
 
Join Date: Jan 2006
Posts: 1
Rep Power: 0
SSJ17Vegeta is on a distinguished road
SWF Problem with asynchronous XML.sendAndLoad() method

Hi to all of you,

I've been writing an external ActionScript class (named SQL), designed to handle XML-PhP-MySQL flux.
The SQL object contains a property named "result" (an XML object that receives the XML from a sendAndLoad();

I've written a method named getXML() in order to load the XML from an external PhP file :
Code:
public function getXML():Boolean {
		var XMLtemp:XML = new XML(this.queryText); // an XML-formatted query that will be sent by php
		var fileloadedOK:Boolean = true;
		this.result.onLoad = function (success:Boolean) {
			if (success) {
				trace("XML successfully loaded");
								if(this.resultat.status != 0) // Bad XML
									   fileloadedOK = false;
			} else {
				trace("Error while downloading the file");
				fileloadedOK = false;
			}
		};
		XMLtemp.sendAndLoad("http://localhost/myfile.php", this.result); // Sends the query to the server and gets an XML object back
		return fileloadedOK;
	}
This method returns a boolean (true for successful, false for failed) and sets the SQL.result property with an XML object that can be later converted into a

string, or an array, or simply returned as XML through methods such as SQL.asString(), .asXML() or .asArray().

The problem is : the XML.load() method is asynchronous, so that means the program directly goes to the instruction "return fileloadedOK" before the XML is

actually correctly loaded. The methods asString, asXML and asArray must use SQL.result as a base to return a result, so errors occur, as the XML is still not

loaded.
I tried a while(this.result.loaded != true) but all I get is an infinite loop :-/
I've been told to use a listener, but I searched the web and didn't find anything that rang some bells, anyone has an idea how to do ?

Thanx in advance
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XML PRELOAD Problem grafxidg Newbies 3 04-08-2010 01:06 AM
Question|my first post - problem with link in SWF file james341 Flash CS4 0 09-28-2009 08:49 AM
textfield focus problem in external swf mrpoate Newbies 1 07-10-2007 11:34 AM
Link problem 0morgan0 Newbies 3 12-01-2005 07:48 AM
weird problem; what's the initialization sequence in AS2? Sewdn Actionscript 2.0 1 08-20-2004 03:36 PM




All times are GMT. The time now is 12:40 AM.