ActionScript 3.0 :: Adding And Subtracting From A Number Within A Text Box?
Jan 27, 2011
I imagine this to be a simple question, but I don't seem to be able to figure it out being knee deep in code !!I have this variable :-var blackCredit = creditBlack.text;When I try to add or subtract 1 from the amount in the text box, like this :-blackCredit += 1;and then update the text box with the new value :-creditBlack.text = blackCredit;It's adding the 1 to the end. i.e. 16 becomes 161, instead of 17..
I have an application performing a simple calculation of adding and subtracting a amout to/from a balance amount.The problem is that every thing works fine except that when i remove the lkast amout from the balance ie: 15.25 -15.25 suppose i get something like -5.32907051820075e-15
I want to change the code a little bit by creating an Input Text. A random number will be typed in that text instead of having a fixed, pre-set number.
i got a input text , how do i set some number if they input the right one?like i want (2,4,6,8,10) to be true if they input the the same number ,i want boolean to be true how i going to do this?
As you can see it equals a number, (This number is subject to change throughout the project.How can I add all of the digits in this number up into a new variable.The number is "1382" so the new number would be all the digits added together... 1+3+8+2, "14"
I have an array, strictly numbers, how could I add... say array[0](value=2)+array[1](value=1) to equal 3? What I come up with is an undefined error, or not a number...
My name is Bryan i am 17 years old and i'm from the Netherlands. As i am trying to become a web design and developer i decided flash was a MUST to know, so i started trying flash and messing about. Now i'm trying to get into Action script 3.0 deeper. Currently i am trying to fix an externaly (XML) loaded image gallery for my self, except i'm a little stuck right now.Up to now all my code has worked. I've got 3 UILoaders set up for 2 jobs: Loading thumbnails (2 of them) and the other is for loading a 'full' version. I got that working. Except if i get huge images like a wallpaper etc. it screws up the size, so i set scaleContent to true.
- Set all the images dynamicly, with that i mean it loops trough all the thumbnails and gets the first 2, it dumps them into the UILoader wich is already the part i am failing at XD
- Check for the width and the height of the image (wich i either will include in the XML document or can i use something like: XMLData.image[ *number here* ].img_thumb.width (as a example)?
- Check if these are less than the UILoader's size and if they are less dissable scale content, if they are more enable it
So as i said im already failing at trying to dump the images in the thumbnails.I've got the following setup:
Root document has a MC: mc_content. Inside mc_content we have: loader_image (full size of the image loader) loader_thumb1 and loader_thumb2.
So what i want:
- Load the XML (works) - Set some limits using variables (works) - Start a for loop (works) - get the thumbnail for the current image number (wich is a variable set and maintained in the for loop) (works) - load the image into the loader_thumb *insert current image number here* (fails)
here is my current XML function:
ActionScript Code: // Function that is called upon loaded complete function xmlLoaded(event:Event):void{ // get the XML Data from the file
Right now it generates a random number from between -1022 and -16 (positions along the x axis).
However, sometimes the skyline movie clip only moves a few pixels and looks boring.
I added 200 pixels to the movement (Math.random() * (-1022 - -16) +200 ) and it looks better. However, sometimes this slides the movie clip past -1022 or -16 and off the stage.
How can I set the value to +200 without passing -1022 or -16?
Having some issues with some variables not adding together to make a new number. Instead they are appending to each other as if adding characters onto a string rather than a number. Here is my code.
ActionScript Code: var dispenserPos:Object = {x1:"41", y1:"180", x2:"283", y2:"180", x3:"530", y3:"180", x4:"775", y4:"180"}; function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min; return randomNum; [Code] .....
It should be tracing out 388 instead of the numbers appended onto one another.
I have addChild(ball); in a for loop creating many balls. I also have addChild(number); I want number to be placed in the ball mc. So ball.addChild(number);. However the whole thing freezes and takes longer than 15 seconds to load. Is there something wrong with adding number, a textfield, in ball?
If I want to add or substract number variables, how can I name them to indicate they are numbers and how can I do basic math with them? If I try adding common variables like
_root.answer = _root.var1+_root.var2; and if var 1 is = 1 and var 2 is = 2
I have a script to upload images to my server. I want to generate a random number to add to the users file name incase they upload an existing name and write over it. I have created a var called file nameAddOn and it gets a random number. When I trace the var nameAddOn I get the number, but when I upload the file it doesent sent the nameAddOn var with the file name. I cant see anything wrong with the code.:[code]....
just learning as3 for flex. i am trying to do this:
var someNumber:String = "10150125903517628"; //this is the actual number i noticed the issue with
var result:String = String(Number(someNumber) + 1);
I've tried different ways of putting the expression together and no matter what i seem to do the result is always equal to 10150125903517628 rather than 10150125903517629.
I am still using flash MX. I'm pulling random text from a textfile (array.txt) into movieclip instance textbox.[code]All is good, but now my question is if I can have a text effect as well. For example having the random quotes typed out as they appear.
The buttons are used to jump to a specific (root-)frame (based on a variable); they're all nested inside a moviclip, each on its own layer, and for every frame there's one button more showing (imagine a staircase). Now, is there a way for a script that works for all buttons without adding the specific frame number every time? I started working with
ActionScript Code: on (release) {_root.gotoAndStop(_root.VAR+3);} where VAR also defines, how many buttons are shown (eg. frame number of the button-MC). +3 is just for the frame number on root. That way, of course, all buttons eventually lead to the same frame, or more precise: only the last button shown will lead to the correct frame.
i am trying to create a timer that when it reaches to the number 10 it changes the text in a dynamic text box, i have got the timer counting but when it gets to 10 it doesnt do anything.here is my code:
Code: stop() cooltimer.text = "0"; var myTimer:Timer=new Timer(1000,0);[code]....
I'm having a problem adding numbers that are loaded to dynamic text boxes. I'm using AS 2 (Flash 8). The numbers are loaded to the textboxes from a text file using a loadVars command. The text boxes have instance names of TELEMATICS and BOOK - I have a third textbox called (instance name) RESULT - the text file is called TEST1.txt. My problem is that after trying (and trying) several solutions in tutorials I am unable to add the values in TELEMATICs and BOOK to get a (sum) total in RESULT. My code to load the numbers is as follows:
i have a text field called Moneytxt and i want it so when u click on a box it somtimes adds 200 and somtimes adds 100 ( also i would like it to add up in numerical value example: if it adds 100 and it has 200 it equals 300 not 200100). I also have penniestxt where sometimes it adds 30 and somtimes it adds 40.
this is the code (box getting added is not included or addeventlistener)
public function boxclick(event:MouseEvent):void { var _box:Box=event.currentTarget as Box; logtxt.appendText(" You collected the box");
I'm having trouble passing a number from an input text box to a dynamic text box after a button is clicked.
In timeline I have two frames labeled: 1) inf, which starts with an input text box and a button, and 2) closing, which receives data from inf section.
INF SECTION has an input text box (age_txt) and a button (inf_bt).
var userAge:Number;age_txt.text; inf_bt.addEventListener(MouseEvent.CLICK, gotoPg1); function gotoPg1 (evt:MouseEvent): void{age_txt.text=String(userAge);// user
I have really no idea how to do this, but i have a textbox and a button.When this button is clicked, i want it to add "<b>" before the currently selected text in the textbox. How would i go by this?
How to add text to a dynamic text field so that a line of text is created, and you can keep on adding to it. I need it to simply add a number to the text line everytime certain buttons are pushed rather than multiplying it like a score in a game and I think I have gone wrong somewhere.
Here's my example: I have multiple buttons on the stage and each button has a different value applied to it (eg: BTN1 has 1, BTN2 has 2, BTN3 has 3 and so on...)
So (as an example) I was wanting to end up with the following in my dynamic text field "1132" if "BTN 1" was clicked 2x and "BTN 3" was clicked 1x and "BTN 2" was clicked 1x......
which equals...... 1132
I'm trying to use the following actionscript but instead of it adding to my line of dynamic text it adds to it like so... 1+1 = 2
BTN1...
on (release) { _root.equationcount+=1; }
I'm now wondering if I should be using "count+" at all? My var for the dynamic text field is "_root.equationcount"
So I'm loading a variable into my .swf from PHP (using loadVars) and adding two loaded variables together. However, when they are added they "add on" to eachother.
Example:
varOne = 1 varTwo = 3 varOne + VarTwo = 13 (????)
I was thinking the variable may think it's a string, but I don't know how to declare the variables sent in from PHP.
Dear Guys I Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It , Is There Any Solution
I have a result screen that shows bonus points and such. I want each text field to increment one after another and also have it increment by a certain amount each frame. Result Screen pops up. First is the player score check the player score, is it more than the score we want to display if the player score is greater than the player display score by 100 increase the player display score by 100 if the player score is greater than the player display score by 10 increase the player display score by 10 else increase the player display score by 1 when finished move to the next score...and so on. I have thought of using timers to move from one score to the next, but not being in an Event.ENTER_FRAME it only does one if then moves to the next one.
Also the if statement for incrementing the score looks ridiculous and I'm thinking there has to be a better way to do it. I was thinking of making it a separate function but then I wouldn't know what to return, or how to return it so it looks like its increasing and not just showing the total number instantly. I'll try to expand on it a little more.
I'm loading a external text file to flash and according to the number present in the text file i'm trying to do a IF - ELSE command. It's not working coz the value I load from the external file is string. How can i get this as intiger.
I Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It,
i am trying to make a banking system, i have a text box which is called totaltxt, the number is currently set to 0, i press a "50" button, and the total should be 50 right?....but im getting 050 instead,heres my code, i am using AS2 btw
PHP Code: var bank:Number; bank.valueOf(totaltxt.text)