music_lp90 Posted August 28, 2008 Share Posted August 28, 2008 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! Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2008 Share Posted August 28, 2008 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. Link to comment Share on other sites More sharing options...
music_lp90 Posted August 28, 2008 Author Share Posted August 28, 2008 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? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2008 Share Posted August 28, 2008 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. Link to comment Share on other sites More sharing options...
music_lp90 Posted August 28, 2008 Author Share Posted August 28, 2008 Thanks! It works now. I thought it was already an int since I could multiply it and then display it in a dynamic textbox correctly, but I guess it wasn't. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 28, 2008 Share Posted August 28, 2008 Yeah, Flash does interesting things with variables that frighten and confuse most people, including myself. I've seen situations in Flash where "1" != "1". Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.