Jump to content
Sign in to follow this  
music_lp90

Flash input boxes

Recommended Posts

Hi, I am trying to figure out how to get the value that is entered into a flash input box. Using the text tool, I created a text box and set it to Input text. I gave it an instance name of mc_length and a variable name of $length. How can I access the value now with my actionscript once a user clicks on my button named mc_draw?Here's the code where I need the input value:

mc_draw.onPress = function() : Void {	$dynamicName = "a" + $i;	$i++;	/*instanceName, layer, Xwidth, Yheight, Xplacement, Yplacement */  	newRect($dynamicName, $i, INPUT VALUE NEEDS TO GO HERE, 6, $placeObjX, $placeObjY);}

Thanks!

Share this post


Link to post
Share on other sites

Don't use variable names, they are going away in future versions of Flash (I mean a variable name on a text box). Using the instance name, the text in the box is mc_length.text.

Share this post


Link to post
Share on other sites

Hi justsomeguy, thanks for the help. I can get the value now, but for some reason it comes out completly different if I get the value from the input box or if I hard code the value right into the function that needs the value from the input box.Here's the section of code:

mc_draw.onPress = function() : Void {	$dynamicName = "a" + $i;	$i++;	/*instanceName, layer, Xwidth, Yheight, Xplacement, Yplacement, allowDrag */  	newRect($dynamicName, $i, mc_length.text, 6, $placeWallX, $placeWallY, $wallColor, "yes");}

If in the function I hardcode a number like 10 in place of mc_length.text, the rectangle that is drawn is much shorter than if I enter 10 into the input box and use mc_length.text. Why might that be?

Share this post


Link to post
Share on other sites

Try converting it to a number, when you type something into a text box it's a string. Also trace the value out to make sure you're reading it correctly.

Share this post


Link to post
Share on other sites

Yeah, Flash does interesting things with variables that frighten and confuse most people, including myself. I've seen situations in Flash where "1" != "1".

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...