View Full Version : Newbie ASP to Flash to ASP question
zenassassin
05-29-2005, 05:01 PM
It sounded simple when I first thought of it but now it's turned into some kind of scripting nightmare that I can't even think clearly about anymore. Here's the scenario; I have an ASP page that has a link on it that sends a client to an account modification page. The client's id number, is retrieved via a connection to the database and stored in a variable called "id".
My text link goes as follows:
<a href="client-mod.asp?id=<% =id %>" target="display">[-Modify Info-]</a>
That works fine. My dilema is that I would like to mod my interface and have a Flash navigation instead of text links. How exactly do I pass that VBScript variable "id" to flash so that when the navigation button is pressed it sends that same variable to the next asp page?
I hope I explained myself correctly. I'm so painfully inept in programming I tend to frustrate others. LoL
LoadVars would be a good solution for you. Do a search in the forums and you'll find more than enough examples.
zenassassin
05-31-2005, 05:26 AM
Thanks for the assist, Cota. The base code you posted is pretty much what I was looking for.
Let me know if you have any other questions
zenassassin
05-31-2005, 12:41 PM
Funny you should say that, :) .
I tweaked my asp code and used the formula you posted in this thread (http://www.actionscript.org/forums/showthread.php3?t=67379). My asp page created a flash variable of essentially what I needed. The tail end of my asp code looked like this:
<% Response.Write "&folder="&folder %> 'the asp variable was established earlier in the code and contains a Name & ID concatenated string
My flash code ended up looking like this:
myVars = new LoadVars();
myVars.onLoad = function(success) {
if (success) {
cfolder = this.folder;
}
}
myVars.load("http://localhost/clients/top2.asp");
I tested to see if the information loaded by quickly putting it in a dynamic text field with the var name "cfolder" and it displayed it fine, however when I tried to concatenate that "cfolder" variable with a url, I had no success. The code on my button looked like this:
on (press) {
getURL("http://localhost/clients/accounts/"+cfolder+"/temp.htm", "display");
}
Where exactly did I go astray?
Lets add a trace to see whats actually being output
on (press) {
trace(cfolder);
//getURL("http://localhost/clients/accounts/"+cfolder+"/temp.htm", "display");
}
What is the trace outputting?
zenassassin
06-01-2005, 12:05 PM
Well, through some trial and error I came across some interesting information (at least for me). So I figured I'd do some trial and error tests and see where I was going wrong. Turns out that the asp page that was defining the flash variables was putting out more than I wanted INTO the variable. The asp page isn't just straight VBscript. It has some HTML elements in it. When I defined the flash variables, the tail end of my code looked like this:
<% Response.Write "&id="&id %>
<% Response.Write "&folder="&folder %>
</body>
</html>
The "id" variable was brought in fine, but the "folder" one was bringing in not only what I defined as the folder but "</body></html>" as well. So I placed the response.writes after the closing html tag ...
</body>
</html>
<% Response.Write "&id="&id %>
<% Response.Write "&folder="&folder %>
...and cleaned up my flash syntax a bit ...
on (press) {
getURL("http://localhost/clients/accounts/"+ cfolder +"/temp.htm", "display");
}
... and now all is well and works like it should. Why exactly was it pulling the tail end of that html code in? Did I fail to place some form of "variable closer" on the defined flash variables?
That was kind of weird....I've had similar problems in the past and I completely forget how I solved them. Well at least you got it working.
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.