Log in

View Full Version : input?



bluewalrus
07-16-2008, 06:43 PM
Can't get this to work. Don't know why I think i have to declare something I forgot about. I have a text field type input text with an instance name inputData. I have a submit button called submit. This is the action script associated with is:


var test:String='Your Name is' + inputData.text + 'Right?';
if (all.selected==true) {
submit.onRelease=function() {
trace(test);
}
}

The trace brings back a result of Your Name isRight?. Completely ignoring any input put in. It does the same thing if nothing is put in and the submit is hit. Any help you have is appreciated. Thanks.

Medyman
07-17-2008, 06:13 PM
Your code is right, but your logic is a little off. I'm assuming your logic, so please forgive me if I'm wrong. But, from the code I can glean that you're thinking that when you click the submit button, Flash will dynamically generate the value of test. In fact, that's not how it works.

When you declare var test:String='Your Name is' + inputData.text + 'Right?'; at the onset of your Flash application, that variable is being set at that moment. Since, when you trace() out the value, it's blank...I'm assuming that the input field is black at the point of this call. Thus, your results.

To fix this, you can declare the variable inside of the submit onRelease function.


if (all.selected == true) {
submit.onRelease=function() {
var test:String = "Your Name is" + inputData.text + "Right?";
trace(test);
}
}