ActionScript 3.0 :: Capturing User Input Restricted To Just Numbers?
Nov 14, 2008
I've written a function that restricts user input to just numbers (0-9,.) and stores the input in the associative array, userInput[]. It works but seems inefficient looping through the entire input text string to scrub out invalid characters. Anyone have suggestions for a more efficient approach? Note that a working solution must correctly process mouse or cursor key movements/edits within the input box.
Also, you can see I'm using the KeyboardEvent.KEY_UP event to trigger the processing. The docs seem to indicate TextEvent.TEXT_INPUT is really the proper event for this purpose. I started with TextEvent.TEXT_INPUT but found the event is triggered before the last key pressed is actually added to the instance. The result is that the function was always one characterbehind. Is there an easy way to get the current text in the input box, including the last key pressed, when processing TextEvent.TEXT_INPUT?
I'm sure it's easy to do, but I just cannot figure it out. I've created a timer but want to let the user set default values to start at so they don't have to modify the start time each time the program starts.I was able to create a text box but it is un-editable in the actual program. It displays '00' nicely but it's useless. I haven't even gotten to the point where the data is pulled and stored.
ActionScript Code: var timerHrs1:TextField = new TextField(); timerHrs1.type = TextFieldType.INPUT;
I would like to restrict user input to numbers only between letters. for example: the user is allowed to input "a2b", but "2ab" or "ab2" isn't allowed.
I am trying to automate the input process so that when a user inputs 3 numbers into the first field, it automatically jumps to the next one. I have the code to do it and it seems as though it should work but, for some reason, when I move focus from one field to the next the data in the previous field is re-arranged so that the last character input becomes the first (610 becomes 061 - for example).Here is my code:
I have a restricted editable textfield in flash like this:
oField.restrict = "0-9";
To capture changes I attach this listener:
oField.onChanged = function(){ trace(1); };
Is there a listener to capture the event when a restricted character is entered (e.g. the event when the key "a" is pressed - the field does not change, so onChanged does not fire).
I've created a drawing app via AS and I'm trying to design a button that when pressed, the user essentially saves his/her drawing as an image file into a certain directory on the web
I an trying to capture keyboard and mouse events for square area on my UI, represented by Sprite. The mouse capture works, the keyboard capture doesn't work at all:
[code]...
I never see reportKeyDown executed, even though Sprite object has a focus.
capturing any of the keyboard combinations below in the Flash Player. I am building this as a stand alone .swf file, so there won't be any conflicts with a internet browser, though my concern is reserved operating system shortcut keys.
I'm new to Flash media server family. I need a server that can capture user recorded video/audio (through a flash recorder) and save it as a flv file on the server. which one of those server family is for me? I'm currently doing it using Red5, but would like to try out Flash media server as well.
I have some text that says go to page with a input textfield box and a go button. This is a flash cs4 file.I want to have the user input the page number and have it go to that frame.I am using actionscript 3.0 and have bought 4 books and researched online and still can't find what I am looking for.I can make the go button go to whatever page I want I just don't know how to get the information the user put in the box.
I using Flash CS5 for the first time, and I'm hitting a snag. I have an input box on Scene 1 for age (variable called old). On scene 3, I have a dynamic test box (variable called display), where I want to display the age (old) + 10.
My Code looks like this: PHP Code: var Real_age = Number(old) + 10; display = Real_age; It's returning NaN.
A trace of the output of Real_age gives: PHP Code: <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"> <FONT FACE="Times New Roman" SIZE="12" COLOR="#009900" LETTERSPACING="0" KERNING="0">2</FONT></P></TEXTFORMAT> <p align="left"></p> <p align="left"></p> NaN <p align="left"></p> <p align="left"></p>
The code works OK in Flash 8, but I figure I must have some some setting that is spitting out the unwanted HTML.
i have been trying to write a multi player bingo game, i have got passed all problems, except 1, the random function, the random function works fine with 1 player but when i play the game with more than one user each user will get different numbers and not the same numbers. how would i do it so all users get the same number is there a way where i can shuffle 90 numbers then load them into a movie clip then all users play the movie clip then all users get the same number is this possible or is there a simple way. I have also tried getting random numbers from php mysql but get the same problem,
I have an input text box and I want the user to be able to enter a number in the text box and hit a button and it will jump to that frame of a movie clip. For some reason I can't get the input text to read the input as a number. I have tried using parseInt or Number, but it gives me this output instead. "<TEXTFORMAT LEADING="2"><P ALIGN="CENTER"><FONT FACE="Myriad Pro Light SemiCond" SIZE="13" COLOR="#000000" LETTERSPACING="0" KERNING="0">2</FONT></P></TEXTFORMAT>" when I just want it to say "2".
Here is the code I have linked to the button:
Code: btn_newPage.onRelease = function (){ pageNum=parseInt(pageString);
[code]...
On the trace of pageString I get the text i put in above and then pageNum comes back as NaN.btn_newPage is the button they would click after they have input a page number in the input text box. pageString is the name of my input text box variable and I was trying to use pageNum to change it to a number. And doc_content is the movie clip I am trying to control.
is there a way to only allow a user to enter numbers in a text feild. setting embed text to numbers only worked for a while, but have to embed all now.
there fellow actionscripters, I am currently studying design and I have a code that was constructed on class:
Code: var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth() ); var image:String = "hxxp://static.vgcats.com/gallery/walk_wallpaper_800.jpg"; var mcl:MovieClipLoader = new MovieClipLoader();
[Code]......
I have to make it, so that a user can input a value (0-255) so they can edit the GBR on the spot.
Like, putting those numbers in an input box and have the picture change according to those numbers.
I'm stumped on this problem and can't seem to figure it out. Any suggestions would be welcomed. Basically I'm building a large calculator that adds over 100 input boxes. I've got it working except for the fact that if a user misses inputing a number into one of the input boxes it does not work anymore. I've tired lots of things to no avail. I just want to add the input boxes and skip those where the user did not enter any information (does not apply to them)
each input box has a variable name assigned to it as indicated above. I've tired setting the variables to 0, tried if statements don't know how to skip one of the above variables when no number is entered.
I am using actionscript 2.0, and I actually have a simple question: the TextInput.text property returns the text string in quotes. However, I am calculating something and don't want it in quotes. How do I get rid of the quotes so I can calculate stuff?
I need to create a text field where the user can only write numbers from 3.0 up to 12.0 with any decimal. With any number he imputs i need another text field to store the number lowered to its nearest .5 number.
for example
input 3.1 result 3.0 input 3.4 result 3.0 input 3.6 result 3.5 input 4.6 result 4.5
I am looking for a way to sort numbers enterred by a user, prefferably in order smallest to largest or vice verser - but at very least to find the smallest & largest numbers of the ones enterred.There are approximately going to be 15 numbers or so.
So for example:
Enterred A = 56 Enterred B = 7
[code]...
when sorted or the other way round (largest to smallest).this could be done with comparrisons but for 15 numbers it would be A LOT of comparisons.
I have two input boxes that I can type numbers into.I'd like a third input box to display the total of the first two.I've set up a key pressed listener on the stage to run a function that adds them together when a key is pressed.Problem is, it just places the strings together - it ddoesn't add them.So how do I tell Flash that box1.text and box2.text are numbers?box3.text = box1.text + box2.text ain't doing it.
I would like the client to be able and type only numbers, and the minus (-) sign into an input textfield. The reason I need them able to type a minus (-) sign is in the case they need the number to be negative. However,
I'm making a sudoko solver, and i have 81 input fields. They're named from i11 to i99. The first number is the column number "x", the second number is the row number "y". I want to transfer those numbers out of the input fields, and into an array.
[Code]...
is something wrong with the way I am naming the grid array? After tracing just about everything, that must be the problem.
I have some input text fields (by the text tool, not the component) in my form that I was wondering if they could be auto-formatted. I was looking specifically for dates & numbers. For example when the user inputs 082606 and then tabs away it would immediately update to 08/26/06, or when the user inputs 50000 it would immediately update to 50,000.