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

Reading Data from an ASP file into Flash on startup

Status
Not open for further replies.

URLJones

Programmer
Jun 14, 2004
42
CA
Hi.

I am currently trying to create a Flash program which displays the status of various systems connected to my main server. The status is kept in a database which I update manually, when required. Now, I have created an ASP file which queries the database for the most recent entry of each system and returns a set of variables in the GET request back to Flash. I know that the ASP file works however, since when I output the data to the resulting HTML, all the information is there and the query was successful. The problem I am having is that the Flash file which uses the following code does not load the variables from the ASP file.

Code:
//recive the variables from the ASP file using the GET method.
this.loadVariables("sCData.asp","", vars=GET);
system1Status = "";
system2Status = "";
// etc...

The above code is placed in the first frame of my "actions" layer. The subsequent layers (where the actual movie is located) are also 1 frame in length. Is this an issue of loading time? In other words, should I place a few more frames in the movie so as to allow more time for the ASP-sent variables to load into Flash? Or, is there a built-in concurrent function in Flash which constantly checks if the variables of a loadVars object is loaded?

Anyways, the status that is gathered from the ASP file is supposed to show up into a dynamic text field in the movie.

In most Flash/ASP tutorials that I have seen, there is usually a button which is clicked which then instantiates the flow of data between the ASP and Flash application. However, what I am trying to do is create a program that would run automatically at startup. Is this also posing a problem with the way the program is functioning?

Any help would be much appreciated.

Thanks,

URL
 
yes. I have tried this as well. I like the loadVars approach a lot better than what I previously used (ie, loadVariables(...)). However, I am still having trouble accepting the input from the ASP. In my ASP I do a response.write and the string of characters is something like:

&system1=system functioning&system2=system functioning& etc...

then, in my Flash, I have these same variables defined:

system1 = "";
system2 = "";
//etc...

I have also used the Server.URLEncode in the ASP as well in order to encode the response to the GET request placed by Flash, and that doesn't seem to work either. Should I still be using this ASP function (Server.URLEncode)?

Thanks,

URL
 
Alright. So, I tried the loadVars method, and it did not work all that great. I went back to using the loadVariablesNum() method (as I used initially, see my first post). Then I went to the Flash MX04 help section and searched for this method to see if there was a way to check if the variables were loaded correctly. Sure enough, they had an example in that description. I modified the chunk of code to suit my program, and it is working great now! Here's roughly what I used:

Code:
loadVariablesNum("data.asp", 0);
	
function checkLoaded() {
  if (systemStatus == undefined) {
        //I have a dynamic textfield named "field" which 
        //accepts a variable named "statusText".
        statusText = "Still loading..."
	trace("still loading.");
  } else {
    statusText = "loading complete.";
    clearInterval(asp_interval);
  }
}
var asp_interval = setInterval(checkLoaded, 100);

So, I hope this helps anyone else who ends up having the same problem.

Regards,

URL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top