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

will this code work 1

Status
Not open for further replies.

antonyx

Technical User
Jan 19, 2005
204
GB
my flash movie has one layer...and 2 keyframes. keyframe1 has 2 input boxes with instance names of 'uname' and 'pword', and a button with instance name of 'go_btn'
keyframe2 has two dynamic text boxes with instance names of name and score

KEYFRAME 1 - Actions
Code:

stop();
function doLogin() {
status_text.text = "Checking Login..";
MyVar = new LoadVars();
MyVar.uname = _root.uname.text;
MyVar.pword = _root.pword.text;
MyVar.onLoad = function(success) {
if (success) { if(MyVar.answer == "ok"){
status_text.text = "Login Successful";
_root.name.Text = this.name
_root.score.Text = this.score
nextFrame();
}else{
status_text.text = "Login Failed"; } } };
MyVar.sendAndLoad(" MyVar, "POST"); } _root.go_btn.onRelease = doLogin;



im having my asp checked at the moment. this code successfully logs in a user if their details match my database and proceeds to the next frame, however, the details do not load in keyframe 2.

are their any errors in this code that i couldnt see??
 
damn, my last 5 posts on this subject have had no replies, does nobody in the world know this, am i completely on the wrong track
would like a bit of advice. using the loadvar() if im gonna be displayin details in keyframe2, would i need some code on that keyframe aswell?

on my knees..
 
Yep, that looks fine - as long as the paths to your various text boxes are okay it should work as you expect.
 
Antony I really don't mean any offense, but your question has been answered several times over. There is only so much help that can be given, you have to put it all together on your own. :) You should refer back to your old questions and review the replies now that you have a little more understanding of what you are doing.

The reason your variables aren't carrying over to the next frame is because you are assigning them to text boxes and not variables.

Following creates a _root level variable for you to access later in the movie.

Code:
stop();
function doLogin() {
status_text.text = "Checking Login..";
MyVar = new LoadVars();
MyVar.uname = _root.uname.text;
MyVar.pword = _root.pword.text;
MyVar.onLoad = function(success) {
if (success) { if(MyVar.answer == "ok"){
status_text.text = "Login Successful";
 [highlight]_root.name = MyVar.name
 _root.score = MyVar.score[/highlight]
nextFrame();
}else{
status_text.text = "Login Failed"; } } };
MyVar.sendAndLoad("[URL unfurl="true"]http://k.1asphost.com/Forum66/login.asp",[/URL] MyVar, "POST"); } _root.go_btn.onRelease = doLogin;

The highlighted assigns a variable that you can then call from any frame in the movie. You could also use _global (which is actually a better choice IMHO).

Let's say that on the next frame you have two text boxes (instance names "theName", and "theScore")on the main timeline (not in a Movieclip) you would place the variables above in those text boxes like this. (actions layer on the next frame):

Code:
theName.text = _root.name;
theScore.text = _root.score;

Hope that helps you clear the hurdle.

Wow JT that almost looked like you knew what you were doing!
 
sorry pix, im a desperate maniac
it is actually workin now, one last bit of trouble im havin is this, im sure ive bin given some code on this before but just need one more solution.

Keyframe1 - movie is stopped

4 input text boxes with variable names of username, password, age and email.
one button with instance name of 'go_btn' and on the button actions have the followin actionscript
Code:

on(release){ getURL(" }



it successfully posts the entered details from flash into my database using the signup.asp file.
i want to replace this code, so instead of using the geturl..and openin the signup.asp file in a new window, it just posts the data..and then plays the movie...as in carries on to keyframe2..
 
You already have an action posted in this thread that will do it.

Create a new function with a new loadVars object in it and add your text fields to it. If you don't need a reply from the ASP use the loadVars.send() instead of loadVars.sendAndLoad().

Then go_btn.onRelease = newFunctionName.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
ok this code adds to the database, but still opens up a new window displayin answer=ok

by the way i have removed the code from my button.

this is my keyframe code
code:

stop();
function doSignup() {
SendVar = new LoadVars();
SendVar.username = _root.username.text;
SendVar.password = _root.password.text;
SendVar.age = _root.age.text;
SendVar.email = _root.email.text;
SendVar.onLoad = function(success) {
if (success) {
if (SendVar.answer == "ok") {
nextFrame();

} else {

}
}
};
SendVar.send(" SendVar, "POST");
}
_root.go_btn.onRelease = doSignup;



and this is my asp code:


<%@language = "VBScript" %>
<%

strUser = Request.Form("username")
strPass = Request.Form("password")
strAge = Request.Form("age")
strEmail = Request.Form("email")

MyPath=Server.MapPath("database.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & MyPath

SQL = "INSERT INTO users (username, password, age, email) VALUES ('"&strUser&"','"&strPass&"','"&strAge&"','"&strEmail&"')"
conn.Execute(SQL)

response.write "answer=ok&"
%>
 
Remove SendVar.onLoad and it's associated function (you are only sending variables, not loading them). In place of the onLoad function put nextFrame().

Also you don't need to get a reply from the ASP so you can do away with the response.write.

Wow JT that almost looked like you knew what you were doing!
 
something like this??



stop();
function doSignup() {
SendVar = new LoadVars();
SendVar.username = _root.username.text;
SendVar.password = _root.password.text;
SendVar.age = _root.age.text;
SendVar.email = _root.email.text;
SendVar.send(" SendVar, "POST");
nextFrame();
}
_root.go_btn.onRelease = doSignup;
 
that code above opens a new window still
 
Sorry, my bad. Send will open a new window. Use sendAndLoad. Code like this:

Code:
stop();
function doSignup() {
    SendVar = new LoadVars();
    SendVar.username = _root.username.text;
    SendVar.password = _root.password.text;
    SendVar.age = _root.age.text;
    SendVar.email = _root.email.text;
    SendVar.sendAndLoad("[URL unfurl="true"]http://k.1asphost.com/Forum66/signup.asp",[/URL] SendVar, "POST");
    nextFrame();
}
_root.go_btn.onRelease = doSignup;

I think that will do it. You don't really need to send the "ok" back though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top