PDA

View Full Version : Input Textbox Variable


holtzy
02-13-2003, 03:54 AM
This is a simple syntax question. What is the syntax to store the value of an input textbox with the variable name of "txtUserID" to an object? i.e.//Store the user input into the object
phpScript.txtUserID = _root.txtUserID;I think my syntax after the equal sign is wrong. Does anyone know? Thanks in advance.

CyanBlue
02-13-2003, 05:00 AM
Howdy...

Try this...phpScript.txtUserID = _root.txtUserID.text;I think this is what you are asking...

holtzy
02-14-2003, 01:19 AM
It's still not working. It works when I change the line to phpScript.txtUserID = "mholtz"; but it's not taking my input text field value. The text box has an instance name of txtUserID & a variable name of txtUserID. What am I doing wrong? It has to be something simple. Thanks!

CyanBlue
02-14-2003, 01:51 AM
Well... For the starter, you can get rid of the variable name on that input text field... I am not sure, but you are confusing Flash with two different things of txtUserID... Just make the variable name empty and try it... Let me know if it solves problem...

holtzy
02-14-2003, 02:26 AM
Nope. Still doesn't work.

CyanBlue
02-14-2003, 02:41 AM
Um... Okay... Don't know why it doesn't work on your end, but I got it working with no problem... Check it out for yourself... :)

holtzy
02-14-2003, 02:55 AM
You don't even want to know what it was. After looking at your code, I realized I was storing the value upon the startup of the movie. When I moved the code under the onrelease it works like a charm. Thanks so much, and sorry, I should have seen that earlier. My bad.

CyanBlue
02-14-2003, 03:22 AM
Nah... Don't worry about it... That kind of mistake happens all the time... :) The more you make mistake, you faster you learn, of course the deeper you get depressed and frustrated too... But then, there is no royal road in learning, right??? :)

holtzy
02-14-2003, 03:48 AM
You got that right. It seems like one problem after another. Here's another one, probably some simple syntax or another something overlooked as before...

function parseResults(success) {
if(!success) {
Status.text = "No Success";
}
else {
if (this.Status == "Success Login Complete") {
gotoAndPlay("success");
}
else {
Status.text = this.Status
}
}
}
Ok, this makes no sense to me. The text field called "Status" shows the text "Success Login Complete". If this.Status == "Success Login Complete" shouldn't it have gone and played the frame labeled "success"?

CyanBlue
02-14-2003, 04:00 AM
Well... I am not sure...
if (this.Status == "Success Login Complete") {
may be replaced with
if (Status.text == "Success Login Complete") {

That is not the least of my concern... You will be using that fucntion called parseResults with an argument... If you are passing a variable that says 'DO NOT RUN THIS FUNCTION' why do you need to call that function in the beginning??? Know what I mean???

parseResults(true) will check the condition with the value of the text field and do the gotoAndPlay() to the given frame label... But if you call the function parseResults(false), it will just say no success and get out of the function execution... Why do you need that??? That's what I don't understand...

holtzy
02-14-2003, 01:51 PM
The function is successful if the data was loaded correctly without trouble, if the function is not successful the data had trouble loading. So the function is actually just to make sure the data loaded, then after I know the data loaded I need to check and see if the variable (Status) came back as the string I'm checking for. I tried it both ways, this.Status & Status.text and neither one worked.

holtzy
02-15-2003, 04:56 PM
I am so sick of this. I'm used to programming in VB and using if/then statements all the time. But I can't even get a simple if statement to work in actionscript. I've done everything I know to do, so I'm attaching the fla if anyone is kind enough to look it's probably a syntax or stupid error. I would be most greatful for help. Thanks a million.

CyanBlue
02-15-2003, 04:58 PM
Okay... It sounds like you have that function inside the onLoad handler of the LoadVars() object... If it is, try yourLoadVarsObjectName.Status instead of this.Status... If that doesn' help, show me the whole code...
If you say this.Status within the function, this means the function itself...

CyanBlue
02-15-2003, 05:06 PM
Hehe... You just made one more post while I was replying to your older one... :D

I just did look at the code... Without looking at your PHP code, I am just assuming that 'Status' is the string that you get back from the PHP script, then I am sticking to my previous answer...

phpScript.Status will do the job, I believe...

And, if you don't use that parseResults function again and again, why not just attach it to the onLoad handler??? Just a suggestion and actually it might create some variable scope problem, not in this case, I think...

Let me know... :)

holtzy
02-15-2003, 05:41 PM
Nope, still nothing. And yes Status is the string I'm sending back from PHP. Here is that line from the PHP, and I know the PHP is working because it is displaying this variable in the text field at the bottom of my movie. Print "&Status=Success Login Complete";I just totally don't understand. Like I said before, I know the variable is sending back the text "Success Login Complete" because it is showing it in the text box at the bottom. So why doesn't this if statement execute?trace(phpScript.Status) //this shows: Success Login Complete
if(phpScript.Status == "Success Login Complete") {
gotoAndPlay("Success");
}

--so frustrated...

CyanBlue
02-15-2003, 07:54 PM
Okay... I think a several days gap on the thread made me dull too... :(

So, basically your question goes... How to display "Success Login Complete" on the text field when button is pressed and get the right feedback from the PHP script, right???

The problem was that you have a KEY FRAME in the timeline for the text filed, Status...

To resolve this...

Select the Layer 1's frame 1... Delete the text field Status...
Select the Layer 1's frame 2... Cut the text field Status...
Create a new Layer and name it 'Status'... Plast the text field there...

Run it again and see if that's what you are looking for... :D

holtzy
02-15-2003, 08:28 PM
Nope, that didn't do it. I'm not having problems displaying the variable from PHP in the textbox. That works fine. My problem is this if statement...if(phpScript.Status == "Success Login Complete") {
gotoAndPlay("Success");
}It's not going to and playing the frame labeled "Success"(which is frame two). It stays on frame one. Thanks for sticking with me...

CyanBlue
02-15-2003, 08:44 PM
Um... That part is working too... Check out the file... (Change the location of the PHP file within the LoadVars() object's sendAndLoad() function...)

Let me know... :)

holtzy
02-15-2003, 10:21 PM
The output window shows this phpScript : Status=Success Login Complete
&onLoad=[type Function]&txtPassword=password&txtUserID=mholtz
phpScript.Status : Success Login Complete

_root.Status.text = Success Login Completebut it still always says frame 1 at the bottom. It never moves past frame one. What could possibly make it work on yours and not mine? I made sure I had the flash 6 player downloaded, anything else it could be?

CyanBlue
02-16-2003, 04:03 AM
So... Basically you don't get to see the play head moving to frame 2??? You don't get to see the Login Successful animation & the 'Success Login Complete' in the box & the letter that says FRAME 2 at all??? Yet, you are able to see the trace statement when you have pressed the button??? I am not getting it at all... How come it works just fine on my computer and it doesn't on yours??? I see that you have downloaded the new plugin, but make sure that you have 6.0.65.0 or above... and try this and see if this make any difference... Go to the Windows Explorer, and double click on the SWF file so that it will be loaded into the Flash player and test it, and publish the HTML file and open that up into the different web browsers... Let me know... Hm...

holtzy
02-16-2003, 04:35 AM
I tried it in the flash player (locally) and it still doesn't move from frame one. I don't have any other browsers to check it with (no I don't even have opera believe it or not). Is there another way to sayif(phpScript.Status == "Success Login Complete") {
gotoAndPlay("Success");
}Should I maybe pass another variable to check it with? I think I'll try that because this is driving me crazy. I'll let you know. Thanks!

CyanBlue
02-16-2003, 04:47 AM
Well... I don't really see any other thing except that frame label is set to 'success', not 'Success'... You could also do gotoAndPlay(2)... You could also send '1/0' or 'true/false' for the Status variable from the PHP script and check it inside of the if statement... Rather than that, I have no clue... :(

holtzy
02-16-2003, 04:57 AM
What in the world...check this out. trace(phpScript.Auth)
if(phpScript.Auth=1) {
trace(phpScript.Auth)
gotoAndPlay("success");
}the first trace is outputting 0 and the second trace is outputting 1. I'm totally lost for words...

CyanBlue
02-16-2003, 05:51 AM
Use == instead of =...
You are getting 1 at the second trace because you have assigned it to be 1 within the if statement... :D

holtzy
02-16-2003, 03:10 PM
that solved that problem, but it still is not moving to the next frame. In fact, it's skipping the first part of the if statement and going to the else.

Can you give me an simple example of an if statement? something like...if (b==1) {
gotoAndPlay(2)
}
else {
//do nothing
}
I was reading in help that the if statement returns the value of true or false. Do I need to put true or false in there somehow? p.s. I tried another if statement later in the movie and can't get it to work either. Are you sure that my if statement syntax is o.k?

holtzy
02-16-2003, 03:19 PM
Thank the Lord I got it to work, but it doesn't make much sense...if(phpScript.Auth >= "1") {
trace(phpScript.Auth);
gotoAndPlay(2);
}
else {
//do nothing
}Using "==" it doesn't work, but using ">=" it works. Thanks for sticking with me. I still would like to be able to compare strings if you have any idea why it wasn't working. the traces were only showing 0 or 1. Thanks again.

CyanBlue
02-16-2003, 05:18 PM
Well...

if(phpScript.Auth >= "1") {

I don't know about that... Actually I have no idea why the one that I have sent you didn't work... You might want to send me your computer so that I can check it??? :D

You could try this too...

if(Number(phpScript.Auth) == 1) {

will check if parsed phpScript.Auth is a number '1' or not...

if(Number(phpScript.Auth) {

same thing here... Just checking to see if the value is true or false by checking 1 or 0...

Not a clue why string wasn't working to you... :(