Flash TextInput component question

  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

I am trying to get take the text within a Flash textInput component, and store into a variable for form processing (via LoadVars). My first approach was to do the following:

var Name = UIComponent.text (no good) so I added:
var Name = _root.UIComponent.text(no good). These are all tested by using the on (release) of my submit button. I have a trace function setup for this and the similar fields after the submit form button is clicked. The value is undefined. I searched through live docs and the code I am using should be working, however it is not. I would rather use the text input components for aesthetic purposes, over the plain input fields (which work fine by the way).

Does anyone have any suggestions. It seems like all the easiest things become brick walls in my projects. This form ghas been in the works for 5-6 months now I believe. :oops:

I assigned the variables on the main timeline in the first frame like so:


Main timeline frame 1:
var Name = username_ti.text;
var Email = email_ti.text;
var Message = comments_ti.text;
var Track = track_cb.selectedItem;


Submit button:
on (release){
trace(Name)
trace(Email)
trace(Message)
trace(Track)
}
this is the output panel:

undefinedx4

I even tried using a function, which was very similar to the above, is there something different when using text components that I am unaware of?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

If you use the input text, then make sure it has an instance name (i.e.: email_txt)
then jus use:
btnSubmit.onRelease = function()
{
trace(email_txt.text);
}
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

I am not worried about that, I am worried about getting the text names stored into variable. Let me further specify. It is "supposed" to be set up to trace back to me the input text from the components, then store them into the loadVars object, and then I trace the loadvars object to make sure that the variables I am sending to Bluehost are as specified. Here is the actionscript:

stop();

//----------------<LoadVars>------------------\\

var myLoadVars:LoadVars = new LoadVars();

//----------------</LoadVars>------------------\\



//----------------<Bluehost>------------------\\

var sendtoemail:String = "myemail@somewhere.com";
var redirect:String = "http://www.mysite.com";
var subject:String = "Music Critique";

//----------------</Bluehost>------------------\\

this.invisible_Btn.onRelease = function () {
gotoAndPlay(main);
}

//----------------<Submit Button>------------------\\

this.contactForm.submit_btn.onRelease = function () {
trace("Button is working");
if (this.contactForm.name_txt.text == "" || this.contactForm.email_txt == "") {
gotoAndPlay(error);//----this little bit isn't working either---\\
}
myLoadVars.Name = this.contactForm.name_txt.text;
myLoadVars.Email = this.contactForm.email_txt.text;
myLoadVars.Comments = this.contactForm.comments_txt.text;
myLoadVars.Address = this.contactForm.track_cb.selectedData;
trace(myLoadVars);
gotoAndPlay(sent);

}
This is the output panel:
Button is working
Address=undefined&Comments=undefined&Email=undefined&Name=undefined

I can see the button was clicked, and that the loadVars is displaying it's UNDEFINED! #$%$# variables
:tempertandrum:

They should not be undefined....This is not making any sense to me.
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

to further this I simplified all the above code into this, to show how it does not even show the text of the components. Is this something about components that I am unaware of:

this.contactForm.submit_btn.onRelease = function() {
trace(this.contactForm.name_txt.text);
trace(this.contactForm.email_txt.text);
trace(this.contactForm.comments_txt.text);
trace(this.contactForm.track_cb.selectedItem);

all the above variables are shown in the output panel as undefined.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

mostly sure is a path problem, plus in this case you don't know what "this" stands for.
this.contactForm.submit_btn.onRelease ->
inside the function "this" represents the "_root.contactForm.submit_btn"
so skip it from trace, use only
trace(name_txt.text);

"this" is a notation for the current movie clip you are inside.
In main timeline, "this" represents _root
If you are in _root.mc1 and u use this.var1 = 5; ->"this" represents _root.mc1.
  • Travis Coats
  • Graduate
  • Graduate
  • Travis Coats
  • Posts: 107

Post 3+ Months Ago

Thanks, yeah that was it. I got it working the other day. I thought I tried it both ways and remembered it not working. Anyways, it is good to go now.

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 14 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.