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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Download Complete Not working? 1

Status
Not open for further replies.

ronaldo7

Programmer
Jun 24, 2004
3
GB
The problem is as follows;

In order for Flash to load variables / data into a movie from an external source i.e. a text file, web page, web service etc. you use the .load method - eg. xml.load, loadVars.load. However, because we don't know how long it is going to take the data to download / upload we have to execute such requests asynchronously, that is, subsequent code continues to execute whilst waiting for the data to complete loading.

When the data has loaded, flash uses a callback function to execute code in a function that you specify, enabling you to work with the data you have downloaded but protecting you from accessing data that is only partly downloaded.

This works fine; an example might be this....

myVars = new loadVars(); // create a new instance of the loadVars object
myVars.onLoad = DownloadComplete; // specify the function you want flash to call when download is complete
myVars.load(" // request the data from the web source and return it to myVars

< other code goes here and is executed immediately after last statement>


function DownloadComplete()
{
<code to do something with the downloaded data>
}

HOWEVER, when this approach is used within the Rap_lite.swf the call-back function (DownloadComplete in our example) is not called. In fact, the target web-page is never contacted to get the data!!! I have no idea why.

My workaround is to load the data from a blank movie at _level0 then use this new movie to launch Rap_lite.swf at some other level. However, this has the undesirable effect of offsetting the presentation away from the top right of the screen and looks quite wrong! additionally, depending on which level it is launched at, the cursor movie does not work either! I am attempting to pursue a solution to this but so far without success. Hopefully you flash boys can help.
 
Try this slightly different syntax:

Code:
myVars = new LoadVars();
myVars.onLoad = function(success){
	if(success){
		//code to do something with the downloaded data.  Reference variables as myVars.variableName (or call DownloadComplete function and pass the variables)
	}
	else{
		trace("An error has occured");
	}
}
myVars.load("[URL unfurl="true"]http://myWebPage.asp?data=getdata");[/URL]

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Thanks but it didnt solve my problem this time
 
Happy to continue to help you. You will either need to post your code or maybe a link to your .fla.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top