[F8] Adding Numbers In Flash?
hi.
How do i add numbers together in flash? eg. 2+3=5 (the result should be shown in a text box or something)
thanks
FlashKit > Flash Help > Flash ActionScript
Posted on: 10-12-2006, 10:02 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Adding Two Numbers In Flash 5
I want to have an idea that how can i add two different numbers and get their result in another text field..
Can any one give me an idea about Dynamic Text Fields and how do they Work
=======================
Looking forward for a "Guru's" Reply
D'oh - Adding Numbers - Flash 101
Hi - I can't believe I can't figure this out! I'm trying to add two numbers from two variables into a third.
ie var timeTaken = _root.lastEntry + _root.calculatedTimeTaken;
Obviously a + gives you a string concatination, so I always get 1010 instead of 20 for example. Where am I going wrong?
thanks
frank
Adding Numbers
Hi,
i'm making a game in witch if i click on the target the total point add uon more point...
es...
1(the start point) + 1 (the point to add) = 2 (the total score)
and make too operation sutch as 2 - 1
Bye!
p.s. i don't know some english words... and my sentences are so strange
Add Numbers Without 'adding'
hello
i have a log-in section in my current project. im using a pin number technique so i have four seperate boxes that generate a number everytime it is clicked. the number increases by 1 on each click, when number = 10 the variable resets to 0.
Now, how do I add together the four number variables, called a,b,c,d?
a+b+c+d literally adds the value of each and generates one number.
"a"+"b"+"c"+"d" gives me "abcd". I need a four digit number that gives me 10000 combinations (0000 - 9999).
must be something simple ive overlooked, thanks in advance
Adding Numbers HELP ME
I am making a game and for the scoreing it needs to add two numbers together, numo and numb
when I have it add them and put it in a text box it just slaps them together in a text box named total total.........Example
total=numo+numb;
but it just puts them together: if numo=5 and numb=6
total would equal 56 not 11
Please Help ME
Adding Numbers Together
Hi i wonder if someone can help
Im trying to create a type of application in flash which involves + - * and /
numbers
Say you have two input boxes that a user can type into what would the code be to add the two numbers together and show the result in another box
hope someone can help
[CS3] Adding Numbers
Hi everybody!
I have what I suspect is a really simple problem.
I want to make a Flash game where there are twleve buttons on the screen. Each button has a different value (1,2,3,4,5,6,7,8,9,10,11,12). When one of the buttons is pressed I would like its value to appear at the side of the screen, and the same value to be added to a total. Then when a second button is pressed, I would like the new value to be shown, and it also to be added to the total. The aim of the game is to press the right buttons so the total doesn't go above 20. Can anyone show me how this is done?
Thanks!
Adding Numbers
Lets say i have two check boxes. And both boxes have various numbers associated with them when checked, the numbers are fixed numbers, not variables. Each of the numbers needs to get added together in its own dynamic text field. How would i approach this? let me know if you need more info
Adding Two Numbers?
I know this is basic, but I just don't get it.
this.regnknap.onRelease=function () {
regn = tal1 + tal2;
tal3 = regn;
}
If I input the numbers tal1 = 4 and tal2 = 5, the result (tal3) equals 45. and NOT 9. I tried to use eval() around tal1 and tal2. alas. Gives the result NaN.
Please help me.
Adding Numbers
Hi
I need your help with following problems!!!
How to add numbers??
I have textfield with instance "field1" and two buttons with following script
onRelease = function(){
_root.field.text =1;
}
how do I add the sum when second button clicked and not insert value 1 again?
I tried this way but didn`t work
onRelease = function(){
_root.field.text =add.1;
}
thanks
green
Adding Two Numbers
I can't get this work properly.There are three input text fields on stage with var called entry1, entry2, and total. When user enter the numbers in entry1 and entry2 input box and click the button, it will populate the total. The problem it gives me a NaN instead an actual number. How to fix the script?
function totalNum() {
_root.total = Number(_root.entry1) + Number(_root.entry2);
}
Thanks
Adding Two Input Numbers
Hi,
I'm having a problem getting Flash to add numbers input into text boxes. I have two input text boxes set up, each with assigned variable names. If, for example, I enter 2 in the first box, then 4 in the second box, the result in the output box is 24, not 6, ie it is concatenating the numbers. To do the calculation, I am using the code output=input1+input2.
I have tried using output= eval(input1)+eval(input2) and this doesn't work either.
Can anyone help?
Thanks
Adding Numbers To A String
How do I add a number to a string . Here is what I have
Code:
on (rollOver) {
isOver+="b"+1;
I want it to show in a variable as b1 and when you roll over it again it will show b2 . As is now it just keeps adding it like b1b21b12 or something like that .
Adding Up Random Numbers
I'm making a boardgame (picture monopoly for instance) where you can roll a dice and the pawn moves over the board. Can someone help me out with adding up the seperate rolls of the dice?
This is what i got:
Code:
on (release) {
roll = random(6)+1;
position = +roll;
}
Where 'roll' is the roll of the dice and 'position' should be the position on the board. But obviously this doesent work
Wat I need is the right code for 'position' to add up the rolls. For example 3 rolls: 4+1+6 then position should be 11.
Can someone help me out here?
Thanks!
Adding Numbers To Variables
i have 2 dynamic text box's, one named score and one named time.
for the score i want it to add a number if something happens. and for time... my movie is running at 45fps so i made a movie clip 45 frames long and i put a dynamic text box named time in it. how do i make it so every second it adds 1 to the number? i tried making it say score=+1 at the end of the 45 frames but that doesnt work.
how do you tell it to add a number to the variable?
or does anyone know of another way to display time? maybe have it after 60 seconds turn to 1:01 i want to use the time number into the score too, so like every 10 seconds it adds like 1 point to the score or something.
Please Stop Numbers From Adding Together
line six of this code is adding both my numbers together i want this line to work like the other lines, as in returning two no's. not one.
one = n-1+b;
two = Number(n)-1+b-1;
thre = n+b-1;
fou = Number(n)+1+b;
fiv = n+(Number(b)+1);
six = n-1+Number(b)+1;
if someone can tell me how to keep n as a integra(or whatever) that would probly work.
Adding/Subtracting Numbers
Can anyone direct me to tutorials explaining how to determine numeric values and either add or subtract them using dynamic text boxes and input text boxes?
Thanks in advance! Missmetz
Numbers Adding Backwards?
i am trying to add 2 number from two different dynamic texts ..
the problem is that 15 ends up > 111 .. can anyone tell me why?
Problem With Adding Two Numbers
I am sending two variables from php to Flash via src="flashfile.swf?variable1="X"&variable2="Y"'. X and Y are returned as numbers into Flash with no problem. However, when I try to add X + Y, I get XY instead of Z. I think it is joining them like a string, but both numbers are defined in Flash as "var variable1:Number = _root.variable1". Any suggestions on how to get the numbers to actually add rather than just joining them?
[CS3] Adding Random Numbers
I have a button that, on release, generates a random number in one text box and adds that random number to whatever's in another text box:
Code:
on (release) {
randomnumber.text = Math.ceil (Math.random ()*20)-10;
adding.text = number(adding.text + randomnumber.text)
}
On first press of the button the two text boxes equal each other, but with each subsequent press adding.text displays "NaN."
If I remove the number(), pressing the button just ends in a number string.
How can I make pressing this button add the random number generated to the value already in adding.text?
Thanks!
Adding Numbers Within Variables
Hey guys, I am having some trouble. I have some inputText boxes that im trying to convert from feet to inches, then add the inches to the newly converted inches(from the feet) but instead of adding the numbers, it just puts them next to eachother.
Like 1 inch plus 12 inches is equalling 112.
Any idea why? I set the variables to Number, but still nothing =
Thanks
ActionScript Code:
on(release){
if(width_txt.text!="Width" && height_txt.text!="Height"){
var widthConversion:Number = (width_txt.text*12);
var heightConversion:Number = (height_txt.text*12);
var widthInches2:Number = widthInches_txt.text;
var heightInches2:Number = heightInches_txt.text;
//trace(widthConversion+" + "+heightConversion);
var convW:Number = (widthInches2 + widthConversion);
var convH:Number = (heightInches2 + heightConversion;)
_root.inputWidth = convW;
_root.inputHeight = convH;
trace(_root.inputWidth +" + "+ _root.inputHeight);
_root.products_mc.alphaTo(100,4);
this.play();
}
}
Adding Two Numbers(digits)
Hello. I have to input text fields and third - dynamic. Also I have a button. I want that on button press in the dynamic field would be displayed the sum of two numbers entered in those input fields. First field: var1 Second: var2
and dynamic text: answer.
I wrote scipt but look what happens. For example I input to numbers: 5 and 6 I need to get answer 11 but the sum is shown: 56 . Any help? Thanks.
Adding Two Numbers(digits)
Hello. I have to input text fields and third - dynamic. Also I have a button. I want that on button press in the dynamic field would be displayed the sum of two numbers entered in those input fields. First field: var1 Second: var2
and dynamic text: answer.
I wrote scipt but look what happens. For example I input to numbers: 5 and 6 I need to get answer 11 but the sum is shown: 56 . Any help? Thanks.
Conditionally Adding Numbers
okay this works
this.onEnterFrame = function () {
Number(this.BG=(Number(this.BG10)+Number(this.BG01)+Number(this.BG02)+Number(this.BG03)+Number(this.BG04)+Number(this.BG05)+Number(this.BG06)+Number(this.BG07)+Number(this.BG08)+Number(this.BG09)));
}
however I don't have a clue on how to only add a number if a field meets a criteria?
if (this.BG01 <= 10) {
then add it
} else {
not
}
anyone ever do this before?
jef
Adding Numbers To The Names Of Variables
Hello all
If I wanted to do something like. . .
for(i=1; i<11; i++) {
myvaiable(i) = i
}
and then basically be left with:
myvariable1 = 1
myvariable2 = 2
and so on. . .
How would I create a loop routine that would essentially create new variable names for ever loop instance?
thanks in advance. . .
stevo
Adding Numbers Question/problem
Thanks again for your help.
I am trying to understand this...
I have a sample store, using check boxes. If this check box is visible then place in the items text box 'name' and in the price text box 'cost'.
This all works well.
I also have a total textbox that is suppose to contain the totals added up from the cost text boxes.
I have this on the frame
_root.total = cd1cost + cd2cost + cd3cost + cd4cost; (an expression)
But in the total text box I get this
$25.00$15.00 etc...
the prices of everything and not the total price.
How do I get the total price to show rather then the price of each
individually?
Thanks for the help
Allan
I would also like to add a quantity input text to this as well so that when I say put a 3 in the quantity for cd1 then the toal for the cd1cost will *3 ut I have no idea how to do this.
Adding Numbers To Variable Names?
Hi,
I have 13 variables that I want set equal to 13 other variables. This second set of variables are paths to files.
code:
_root.img0 = imgThumb0
where imgThumb0 = db_pics/IndianRiver.jpg
Ok, simple so far.
Now, I don't want to type out _root.img0 = imgThumb0, _root.img1 = imgThumb1, _root.img2 = imgThumb2, etc...
So, I created an array that increments everytime the loop is run through, like this:
code:
for (a=0; a<13; a++) {
_root.img[a] = imgThumb[a];
}
STOP... it doesn't work, so I try this:
code:
for (a=0; a<13; a++) {
_root.img[a] = ["imgThumb" + a];
}
and this:
code:
for (a=0; a<13; a++) {
_root.img[a] = [imgThumb + a];
}
Still doesn't work...
It's not successfully putting the number on the end of the string and then using that entire string (imgThumb3, for instance) as the variable to grab the path.
What I need, in the end, is for _root.img[a] to be equal to the path of the picture for whatever (imgThumb + a) is....
I'm not sure I've totally made myself clear, but if you could help me out I'd really appreciate it..
Thanks...
Rounding Numbers And Adding Zeros...
Hi
Im kinda in a rush right now and haven't slept a lot in the last days. My brain's off now and I can't find the answer...
I need to put a counter which goes like that:
0.01
0.02
0.03, etc...
I rounding it to the hundreds using that:
rounder = int((number)*100)/100;
The problem is that sometimes, for example, it gives me 0.1 and i want 0.10... How can I easily add zeros automatically so I always have 2 decimal numbers?
Thanks
Adding Numbers Per Button Clicked
Hello,
I'm working on a training lesson regarding automotive repair. Each time the user clicks a button to replace a part I need the parts cost text field to increase by that amount.
I have got some code going that passes the price. Not sure how to add the existing amount to the new amount. Any part can be added in any order.
My code so far.
var partCost:Number = 1.58;
partcost_btn.onRelease = function () {
partcost_mc.partcost_txt.text="$" + partCost;
}
I have tried some math but get no results. Any ideas? I know you already have it figured out.
Thanks in advance
[F8] Adding Numbers Dynamically In A Form
I am working on a form for an online store, which allows the user to select a bunch of options. I need the total to change as the user selects different options with checkboxes. Then I need to export the total to another frame, where the confirmation page is.
It is the first time I do this, so I am a little confused.
What I got so far, (which doesnt work...of course)
Code:
var TotalSuitCost:Number = 425 ;
function getTotalSuitCost() {
if (form_mc.armGrip_cb.selected) {
TotalSuitCost + 10;}
return;
}
confirmation_mc.totalCost_txt.text = "Total: $" + TotalSuitCost ;
I know I am missing some crucial parts here...
if anyone would have any suggestions to help me, I would be the happiest person on earth for the moment...:-)..and maybe get some sleep too...
Thanks
sandra
Help With Simple Adding Variables (numbers)
i am making a game and i havent been able to get anyware because of this stupid problem
// i have a button with this script
on (release) {
var money:Number;
var deposit:Number;
var money = money+deposit;
}
// i also have a text box named deposit so when you click the button it adds whatever number you typed in to the money variable but its not working EG: instead of adding 200 + 200 = 400 / i am getting 200200 i have tryed for days and it is gettin annoying now
Dynamic Fields Not Adding Numbers
Hello everyone,
Thanks in advance for helping or helping to point in the right direction.
I have 5 dynamic text (number) fields on my stage. (amt1_txt, amt2_txt...)
5 variables declared. (var a:Number = 2, var b:Number = 4...)
I have 1 dynamic text (number) field on the stage (total_txt).
I also have 5 buttons that on(release) populate the 5 dynamic text fields with the variables.
I have tried a code for the total_txt field that hopefully adds all the other fields as they are populated (seen on the stage).
total_txt.text = (amt1_txt.text + amt2_txt.text...etc.)
I am getting absolutely nothing in the field. If I take out the .text from the 5 fields I at least get a NaN but of course that doesn't help either.
NEW TO FORUMS... THANKS MUCH.
Adding Commas To Dynamic Numbers
I have this calculator that takes a number from one text box, multiplies it by the value of a 2nd box and outputs into another text box the total value.
When the total value appears, I used the Math.round function to round the final number to the nearest whole number.
My question now is... how do I add commas if the total is greater than 999. Example : 1,000 100,000 1,000,000
The code is pasted below. Any help would be greatly appreciated.
Tom
AverageTotal = (Math.random(Breech))*(Math.random(Average));
Adding Commas To Dynamic Numbers
I have this calculator that takes a number from one text box, multiplies it by the value of a 2nd box and outputs into another text box the total value.
When the total value appears, I used the Math.round function to round the final number to the nearest whole number.
My question now is... how do I add commas if the total is greater than 999. Example : 1,000 100,000 1,000,000
The code is pasted below. Any help would be greatly appreciated.
Tom
AverageTotal = (Math.random(Breech))*(Math.random(Average));
Issue With Adding Numbers To A Textbox
Hi,
I have a flash document,where each time you click a button, a text box adds 1 to the value, from the origonal value of 0, on and on, like so:
0 <button is clicked> 1 <button is clicked> 2 <button is clicked> 3 ...
but instead, it gives me:
0 <button is clicked> 01 <button is clicked> 011 <button is clicked> 0111
How do I convert the text-box object to didgits, instead of text?
This is the actionscript:
Attach Code
the_button.onPress = function (){
text_box.text += 1;
}
//And i tried
the_button.onPress = function (){
text_box.text = text_box.text + 1;
}
Trouble Adding Numbers In Array
As an excercise, I'm trying to create a class that will take the average value of numbers in an array.
I'm stuck on adding the values of the array elements. I keep getting "NaN" for the total. Below is my code.
ActionScript Code:
private function getTotal ():Number
{
var total:Number;
for (var i = 0; i<numArray.length; i++)
{
total += Number(numArray[i]);
}
trace("total= "+total);
return (total);
}
Adding Numbers But Ommitting Empty Fields
if I have three numbers I want added (input fields) and the person doesnt have to fill all of them in,
How do I add them so it doesnt output NaN if one of the fields is left blank.
They dont have to fill in all fields.
if I have parseFloat(a) + parseFloat(b) = parseFloat(c)
the sum will = NaN until they are all filled in.
What is the smplest solution?
Test Equality Of Ip Numbers/ Non Existing Numbers
I'm building a site that recognizes the computer that enters. I've set a variable containing the ip adres, and i wanna ad a name to this.
So... when i say
if ip = 120.155.654.321-->flash tells me this is not a number.
if ip eq 120.155.654.321-->flash tells me this is not a word.
know any solutions???
thanx
sven
Converting Numbers To Numbers With Numerical Separators
So if I return 10000 as a number in flash, how can I convert it to 10,000?
or, 1000 - 1,000
or 1000000 - 1,000,000
These numbers are generated by a complicated math formula, so they can be ANY number...
Is there no way of doing this in Flash???
Get Numbers With Xml And Flash
Hello
I have this problem getting the numbers from a xml to flash because I only getting two-digit and hay need to get like 8 or more digit numbers and I dont know what happen.
Here is the AS 2 code:
var mybook:Number = 0;
var mymagazine:Number = 0;
var mycolor:Color = new Color(mccolor);
function loadXML(loaded) {
if (loaded) {
_root.tienda = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.books = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
_root.magazine = this.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
mybook=_root.books;
mymagazine=_root.magazine;
if(mybook>mymagazine)
{mycolor.setRGB(0x462254);
}
else
{mycolor.setRGB(0x45AF23);
}
book_txt.text = _root.books;
magazine_txt.text = _root.magazine;
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("tienda.xml");
And here is the XML code:
<?xml version="1.0"?>
<Tienda>
<Libros>
<id>Estant1</id>
<Books>58</Books>
<Magazine>334</Magazine>
</Libros>
</Tienda>
You can see that magazine have more than books but the var mymagazine is getting only the first 2 digit (33). How can hay get all the numbers in my var?
Here you can see the example of the file http://csform.com/xmltest/
thanks you!
Get Numbers With Xml And Flash
Hello
I have this problem getting the numbers from a xml to flash because I only getting two-digit and hay need to get like 8 digit numbers and I dont know what happen.
Here is a example of the code:
var mybook:Number = 0;
var mymagazine:Number = 0;
var mycolor:Color = new Color(mccolor);
function loadXML(loaded) {
......
mybook=_root.bookonline;
mymagazine=_root.magazineonline;
if(mybook>mymagazine)
{
mycolor.setRGB(0x462254);
} else
{
mycolor.setRGB(0x45AF23);
}
......
}
How To Divide Two Numbers In Flash...
Hi,
Among other things I have been trying this simple computation. I have 2 input text fields. I have to enter 2 numbers in it and then click submit to show the result of their division in another text box.
Can someone guide me how I shud declare variables for the 2 inout boxes, the output box and the submit button and what the on click code wud be like? I hope this is simple stuff for most of you. It will help me get started.
Thanks in advance.
Rounding Numbers In Flash
Im trying to round numbers that are shown are a speedometer for a racing game i am making im not sure wether to use the math.round feture to rmove all intergers making a whole number would that be the way to go?
Flash Doesn't Add Numbers Right... Help
Hi everybody! Thanks in advance for your help!
Here's my problem:
sometimes when within an onEnterFrame, when I add var1+=var2 flash doesn't do it's Math the right way. It sort of says 2.15+2.45=4.55 I'm using trace() to check on the values and that is exactly what it does.
What's the explanation for this and how can it be fixed?
Thanks!
[Flash Pro 8] Hexadecimal Numbers
I am wondering what might be causing this.
I am running Flash Pro 8 on a 12" Mac PowerBook G4 (OS 10.4.9). When I "draw" in ActionScript the shapes are there no problem but when I include in the code the hexadecimal numbers for my fills no colors get filled in.
Last year I was running a different copy of Pro 8 on a 15" Powerbook G4 (OS 10.4) and had no problems doing this. So I am pretty sure I have an idea how to do it just confused why it is not working on this machine. Could it be the computer? Could it be something with this copy of Pro 8? (Both copies I have had I got directly from Adobe. I no longer have access to the copy from last year otherwise I would have just installed that.) Is there something in my settings I need to change? Any ideas on this would be appreciated. Thank you.
|