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

Flash and database 1

Status
Not open for further replies.

Greenleaf

Programmer
Feb 14, 2002
93
IT
Hello,
I would like to know what is the best way to create dinamic pages with Flash and what are the things to consider to male the choice. Is xml the best option?
 
Thanks Kenneth;
at the moment I have to use Access and I'm struggling with Flash because I cannot visualize images whose path is provided by an ASP page.
I do like this:
Code:
 loadVariablesNum('test_news.asp', 0);
 loadMovie(immagine1, "_root.clip");

where immagine1 stores the path of the image (I verified this and it actually stores the correct string) but the image is not shown.
i cannot figure out where the problem is.
 
[tt]loadVariablesNum[/tt] is Flash 4 and you shouldn't be using those ancient code!

Anyway, the variable "immagine1" becomes available only after your ASP returns the string back, therefore you cannot use it immediately after [tt]loadVariablesNum()[/tt] - it's not there yet. You have to wait until the data is received fully.

Have a look at LoadVars Class, which was invented to make this data loading process easier. If you want to keep [tt]loadVariablesNum[/tt] then let me know, I'll show you how to wait for the data (or read the doc!)

Kenneth Kawamoto
 
OPS! is really that ancient? :)
But I pass other values as well and they appear fine, I pass 4 record fields and this is the only one that doesn't load properly. And I made a text box with the var value "immagine1" just to see when it is available, and the value appears quickly in it. And I use a check function just to see how long the params take to be available.
I tried with LoadVars..but it seems more complicated, I mean, there is more code to write. loadVariablesNum does everything (well...not exactly everything :)) in one codeline...so bad.
 
I made a text box with the var value "immagine1" just to see when it is available, and the value appears quickly in it.
You may think it's quick but it's not quick enough. Try this:
Code:
loadVariablesNum('test_news.asp', 0);
[b]trace("immagine1: " + immagine1);[/b]
loadMovie(immagine1, "_root.clip");
What do you get?

Kenneth Kawamoto
 
But I don't test things locally, I upload files on a remote server, that's why I use a textfield to see when the value is available and I cannot see it with trace, right?
 
What is Flash IDE?? Things are getting complicated...
I have not configured OS to act as a server locally so how can ASP work if I don't upload to a remote server?
 
Sorry IDE means Flash software. Just do "Test Movie" from Flash.

ASP obviously needs to be in the server but Flash movie does not have to be in the server at all when you testing using Flash IDE. If I have to upload the SWF everytime I change something while developing, I'll go insane!

Kenneth Kawamoto
 
If I just do Test Movie how can I get the variables from the asp page? I don't get anything at all. I cannot understand...:-(
Yes you're right, it's rather insane, I think I'll configure XP to act as a server soon; but back to my problem. With my remote test, I don't have the variables passed immediately, I can see them after half a second or so, even that damn variable with the image path, the only missing thing is the image.
 
Kenneth you're right, my minuscule brain prevented me from thinking to write the entire url in flash; anyway you're right: with trace I get immagine1:undefined...but I try to call the trace every second and the first call gives me undefined the second call gives me the correct string, so in about 2 seconds I obtain the information I need. Is that right?
 
You get the data from ASP in 2 seconds, but I may get in 5 seconds and someone else may get in 1 second. It all depends on the connection, server workload, etc, and you cannot assume the time it takes is always 2 seconds.

The only way to check if the data from [tt]loadVariablesNum[/tt] is loaded, is to check it again and again until you know it's loaded:
Code:
loadVariablesNum('test_news.asp', 0);

var intervalID = setInterval(this, "checkIfDataIsLoaded", 100);

function checkIfDataIsLoaded() {
	if (immagine1) {
		clearInterval(intervalID);
		trace("Data loaded. immagine1: "+immagine1);
		loadMovie(immagine1, "_root.clip");
	}
}
Do you still think that "loadVariablesNum does everything in one codeline" ??? :)


Kenneth Kawamoto
 
Hello Ken,
I already had a function similar to that in my code but I didn't have the line
Code:
loadMovie(immagine1, "_root.clip");

I added it and that did the trick!
You're wonderful!
Thanks a lot!
 
As I suppose the problem is similar I don't open a new thread.
Now my trouble is with sendAndLoad, although I try to follow Flash guide, I miss something, as usual.
Now I simply pass username and password from Flash to ASP and I would like to load the response sent from ASP. The ASP code seems fine, cause I checked the variables:

Code:
<% 
Dim user, pass , accesso

user= Request("username")
pass= Request("password")

Response.Write(user)
Response.Write("<BR>" & pass)
accesso = "attendo"
if (((StrComp(user, "jack") = 0 ) AND (StrComp(pass, "jack") = 0 ))) then
  accesso = "yes"
  else
  accesso = "no"
  end if

Response.Write("<BR>" & accesso)
%>

the Flash is

Code:
var login_lv:LoadVars = new LoadVars();
	var result_lv:LoadVars = new LoadVars();
	//recupero i valori dai campi TextInput
	login_lv.username = username_ti.text;
	login_lv.password = password_ti.text;
	// e lo invio allo script asp
	login_lv.sendAndLoad("[URL unfurl="true"]http://../login.asp",[/URL] result_lv, "POST");
	result_lv.onLoad = function(success:Boolean) {
		if (success) {
			debug.text = "ok "+this.accesso;
			if (result_lv.accesso == "yes") {
				_root.semaforo.gotoAndStop(10);
			} else {
				_root.semaforo.stop();
			}
		} else {
			debug.text = "no";
		}
	};

I constantly get "undefined" for accesso. What's wrong?
 
This is what I get:

hp = 1';w = window.open(popupURL, 'nuova', 'alwaysRaised,left=5000,top=0,resizable=no,location=0,directories=0,status=0,menubar=0,scrollbar=0');}</script><!-- 7host_fine -->
jack<BR>jackyes

what is this?
 
> what is this?

Don't ask me!

I don't do ASP but at least you've got "jack<BR>jackyes", which is the user and pass submitted from Flash, isn't it?

But why do you get JavaScript text in your response?

Kenneth Kawamoto
 
Ok, now I have slightly changed the syntax in the ASP and now the value "accesso" is

no

<!-- 7host_ini --><p align=right><A HREF=" size="1">7host ASP Hosting</font></A></p><script>if ((self==top) || (self==top.frames[0])){popupURL = '
the webhost send me this crap, it is a banner window but what does it have to do with my variable??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top