A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How to stop/close a xml load() request?

  1. #1
    Junior Member
    Join Date
    Oct 2004

    How to stop/close a xml load() request?


    I have swf that contains a button and a input textfield. When you press the button it will search in a database for the text you have written in the textfield. Then my php outputs the results in a xml which I load in flash with xml.load()

    If you press multiple times (like 5 times) on the button, flash will request 5 times to the webadress. I want to cancel the first request. If a user search for some string and then regret it and search again with a another string (the first search dident complete the loading). First it will display the first request and the user thinks "ok now its been loaded" but suddenly it will display the other request (the last pressed request). It will confuse the users.

    I tried to use:
    xml = new XML();
    tried with the caching .load("mywebpage.php?" + myString + "&" + random(100000));
    tried to overwrite the .load() with the other myString every time I press the button.

    but nothing works.

    I found in Actionscrip 3.0 theres a class named UILoader. It has a property with the name close() that can close a load connection. Is there similar to Actionscrip 2?

    Im using flash cs3 with actionscript 2

    Thanks !

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    can you not disable the button until the load has completed,
    and re-enable within the onLoad function to prevent multiple clicking ?

  3. #3
    Junior Member
    Join Date
    Oct 2004

    Thanks for answering!! Mmm I thought it would be cool if the user can "cancel" the xml request or get the latest xml request. I figured out a solution to get hold of the last xml request but it wont "cancel" the other proccess´s. This is'nt the best way to do this (I think) but it works. Heres the code for those who whants to know:

    var searchCount:Number = new Number();
    function getNewXml(loadNew:Boolean){
    	_root.ALL_mc["myXmlVar" + searchCount].onData = function(){
    		this = new XML();
    		delete this;
    	//create a new xml variabel
    	_root.ALL_mc["myXmlVar" + searchCount] = new XML();
    	var myXml:XML = _root.ALL_mc["myXmlVar" + searchCount];
    	myXml.ignoreWhite = true;
    	myXml.onLoad = processSearchResult;  //Function to run the correct xml request
    If someone out there finds a better solution please post it here!
    a_modified_dog do you think this is a good "code" or does it fail somewhere?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center