(*)Simple Number Addition Problem
Hi, Please take a look at this here file. http://www.geocities.com/bassemonline/ABmath.fla Why won't the A+B work? what should I use instead of "+"?
Thanks.
FlashKit > Flash Help > Flash ActionScript
Posted on: 03-15-2002, 05:23 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Simple Addition
im trying to have a mousedown action +1 to my varialbe by selecting the correct answer in a quiz , i dont reacall the string to do addition...help plz...
thanks
Simple Addition
i have a button wich i want to ad a value of 20 to my target everytime i click it, i can get it to add 20 one time but not every time i click it, help...
Simple Addition
I have collect totals in text boxes vars are:
var 1stTotal
var 2ndTotal
var 3rdTotal
I need to total these textboxes answers into a totalScore.
I have the following, but it puts the 1st total and undefined for the others
ie 100%undefinedundefined
How do I get this to add up the numbers?
totalScore = 1stTotal + 2ndTotal + 3rdTotal;
also how do I get percent to round off to 2place, like 33.33333% to 33%
Thanks
Simple Addition
i am stuck here, i got bored and decided to make a simple calculator. I can get the muplication and all the other simple stuff to work, but the addition has me swamped. heres the code im using.
the multiplication works...
on (release){
sum = integer1*integer2;
}
the addition one doesnt work right...
on (release){
sum = integer1 + integer 2:
}
when I type in the two integers(for example: 2+2) instead of getting 4 I get 22 becausing instead of adding it combines it. what do I use for it to perform addition.
Simple Addition Issue
I haven't been getting enough sleep....I CAN'T believe this has me stumped - thanks in advance for the lack of sarcasm in your help ; )
So, I have two text fields (var names myNum & myNum2 respectively) both with the number 0 in them. I then insert the simple AS "++myNum" and "++myNum2" in frame 2 and all is as it should be. The simple text fields count up forever.
Now, I want to make the addition happen from an AS in a frame of a MC - one for each of the text fields and I cannot get it to work to save my life. I can't believe it's not working....what am I missing here?
FLA File
Howtodo:simple Addition
Hello friends,
I am trying to add values of 5 inputfields.
1st value1
2nd value2
3rd value3
4th value4
5th value5
6th totalval
when i enter number in value 1 and press tab the totalval field should show up the value of 1st then in after entering number in value2 and tab, totalval should show up addition of 1and2 and like this so on..
not getting how to get this done.. can someone guide me.
thanks..
//simple.addition W/ Textfields PleaseHelp
.Ok I have 4 input text fields accepting numbers only.
.textfield#1's variable = in1
.textfield#2's variable = in2
.textfield#3's variable = in3
.textfield#4's variable = total
.One button w/ the script
on (release) {
total = in1+in2+1n3;
}
textfield #4 should display the total of all numbers put in text fields 1-3 but instead of the actual total, i get them all place next to each other so if
field#1 = 20
field#2 = 20
field#3 = 20
I would get total = 202020
..not what i want? what am i doing wrong! I need the numbers added together.,?????
Simple Addition , But Why Doesnt Work?
19 variables loaded external
on one dynamic text I want to write the sum of these 19 variables and also do scaling using this number in a percentage equation.
lets say loaded variables are dspIzmir,dehapIzmir and mhpIzmir
totalIzmir = dspIzmir+dehapIzmir+mhpIzmir//or shall I use set property for this one
totaltext=totalIzmir//totaltext is the variable name of dynamic text field
it does not work, I tried different settings expression or not for the variables but no way... I need help.
Simple Addition Problem W/input Text
I have a little app that takes a number from an input text box in one frame and generates several other numbers in dynamic text boxes using simple math in the next frame. The variable attached to the input text is "temperature"
The problem is that instead of adding to the value of the inputted number, it is adding the second number to the end of the first number!
I'm ready to pull my hair out! It should be so simple!
Here's the code:
Frame 1:
input text box with variable "temperature" and button that takes us to frame 2:
on (release) {
gotoAndStop("frame2_name");
}
Frame 2:
dynamic text fields named "temp_plus1" and "temp_plus2"...
temp_plus1.text = temperature + 1;
temp_plus2.text = temperature + 2;
If you put 68 in the input box in frame one and click the button, the results are 681 and 682, instead of 69 and 70! I've tried putting the equation in brackets and deleting all the spaces and even defining the variable as a number in frame 1 (using var temperature:Number).
Please help!
Simple Number Escalation (MX)
Can somebody give me the actionscript to make 0 escalate up to 2003. This is very similar to how a preloader escalates, except it isn't a preloader and it goes up to 2003. I know nothing about actionscript, so if you could, please tell me where to change the speed and the X & Y location of the numbers.
Simple, Convert String To Number
alright simple question, converting string to number whats wrong with the code?
boxNumber = "01";
boxNumberObject = new Object(boxNumber);
answer = boxNumberObject.valueOf();
i just want the value of a string that the user gives me? any answers? thanks people.
Simple: Number Of Nodes In An XML File?
I'm migrating to using AS3 for my XML and am missing something basic. How do I find the length of my XML document, the number of total nodes? Clearly I need some sleep.
For example...
PHP Code:
var myXML:XML = new XML();
var XML_URL:String = "http://www.example.com/Sample3.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(event:Event):void
{
myXML = XML(myLoader.data);
trace("Data loaded.");
//How do I find the length of myXML?
}
Need Simple Script To Create Unique Random Number
Hello
I just need a simple script that will make a new random number, that is unique to an array of numbers.
So I have for example:
usedNumbers[0] = 5;
usedNumbers[1] = 3;
usedNumbers[2] = 9;
Then I need to create a new random number that does NOT match any of the numbers in the above array.
Can anyone help me here?
Thanks
Ben
Simple Rookie Question: Adding Variables To Number
hi,
this might seem to simple for anyone to ask but i just dont know it:
i have to gather a few numbers from several input-textfields and add them together to get the total number.
but if one or more input-fields are not filled out, the value of that field turns to 'undefined' and i cant add them values anymore.
how can i add only the number together and leave the undefined fields out of this equation?
ActionScript Code:
var minQuantity:Number = Number(sizeXS + sizeS + sizeM +sizeL + sizeXL + size2XL + size3X);
trace(minQuantity);
please help me out
Would Something Like This Even Be Possible... Using Addition?
Here is my dilemma.
I have a page that has a map of the USA. You click on a button for the city which displays the city name and a number total. Currently I just have the city name/number total as a MC that is hidden and the visibility of it is turn on once the button is clicked. When you click on a new city it turns the visibility of the active MC off and shows the new city name/number total.
Now I want to know is this is possible. I know I would have to change how I am doing things now but could I have it where when you click the city it still shows the city name/number total but say if you wanted to click another city maybe a keypress of CTRL and click that it would display the city name/number total under the one already visable and add the number totals together?
For example: Click New York and it says New York 9,999,999 then you click Boston and under it Boston 999,999 and adds the two numbers together.
So would something like this be possible and any clue as to how to even begin going about it?
Thanks
Addition
now it only lets me go to the second scene
Addition
I have 5 dynamic text boxes with variables as follows.....box 1 = line1,box 2 = line2 and so on
and I need the sum of the numbers that are in those boxes to be added up and put into another dynamic box.....
what I need is....
code:
additup.onRelease=function(){
boxfortotal=(line1+line2+line3+line4+line5)
}
Do I need to use instance name in stead of variables?
HELP! !!
Addition
I have a simple problem I think!
I have numerical values read in from a database and assigned to a variable.
Like value = gFetchValue.Number;
What I want to do is add a certain amount to value after it has been retrieved from database.
i tried value = value + 0.5;
But all I would get is the 0.5 added to the end of the value like it was a string.
So if value was 50 i would get 500.5
How do I add an amount so it would become 50.5. Incrementing the value.
Thanks!!
If Then Addition?
In kirupa's example of how to set up a password I was wondering how to extend to include more paswords. I know its simple but dont know the syntax????? helpppppp ;-)
password = inputName
if (password == "kirupa"){
answer = "Access granted!" ;
} else {
answer = "Access denied!" ;
}
Addition?
has anyone had any problems with addition? I'm trying to get two numbers to add and instead it is concatenating them together as a string, however when I multiply, divide, or even subtract them it works fine.
If Then Addition?
In kirupa's example of how to set up a password I was wondering how to extend to include more paswords. I know its simple but dont know the syntax????? helpppppp ;-)
password = inputName
if (password == "kirupa"){
answer = "Access granted!" ;
} else {
answer = "Access denied!" ;
}
Addition?
has anyone had any problems with addition? I'm trying to get two numbers to add and instead it is concatenating them together as a string, however when I multiply, divide, or even subtract them it works fine.
Addition
i have a dynamic text field "total"
and everytime a user hits a button i want the total to add the current number and the number value of the button. there is like 10 buttons with different number values.
i have total = x + 0 because the game starts at 0 and then having each button be an x value but, it doesnt seem to be showing up.
any help?
Flash Addition BUG
I've just finished compiling a simple actionscript to put a .swf counter in my homepage that works with a PERL script.
It just loads a variable ("Count=") from a text file, adds 1, and saves the new text file. (I made the function work in flash because I don't know how to write perl scripts).
THE PROBLEM:
I don't know why, but (unlike with internal variables), trying to add a number to the loaded variable has been difficult, because:
Count = Count++
doesn't work (if Count is 100, result is 100)
Count = Count + 1
doesn't work (if Count is 100, result is 1001)
because subtraction workes perfectly I just inverted the thing....
Count = -(-(Count)-1)
)))))))))) in these cases I get so angry with the program that when I make it I just feel like I fooled it....
you can see the counter working on the bottom of my homepage
p.s.
I did the same thing with an internal variable:
Number = 1
Number = Number +1
(result Number = 2 and not 11)
Addition Of Variables
Hi you all!
I've got some strange problem here:
I made two inputtext fields, assigned the variable names av and av2.
Now i've got a dynamic text field which should show the addition of those two variables, but it doesn't. Instead i get
e.g:
av=1
av2=1
sum=11
??
what did i do wrong? Any help is appreciated
thanks,
-------------Vincenzo
Addition Within If Statement
I am using an if statement to determine whether a user has selected too many objects on the screen...
I have a series of buttons, each with a variable assigned to them (var1, var2, var3, var4). When the user selects the button, the value of each var is changed from zero to 1. I want to say "If user has selected more than two buttons at a time, give them ERROR message". I tried to do this with the following code, but it doesn't seem to be working. Any suggestions?
Thanks!
--------------------------------------------------------
function alert()
{
if ((_root.var1) + (_root.var2) + (_root.var3) + (_root.var4)) >= 3
{
alertsMC.gotoAndStop("ERROR");
}
}
Addition Of 2 Variables?
Hi all,
I'm getting nuts here...I know it's pretty easy to achieve but still i haven't found a clue so far...
Here we go:
I have two variables
var1 = _level2.count1
var2 = _level2.count2
Let's say var1 is 10 and var2 is 5. Now I want to add them
varAll = var1 + var2;
What i'd like to get for varAll is 15 but what i'm getting is 105 (in a txt box which displays varAll).
Any help would be greatly appreciated!!
Natsurfer
In Addition (Pausing)
In addition to my earlier question re: buttons, It may help me to find the solution to my problem if i could add a short pause into the action code for a mc.
any suggestions
Addition In Flash?
hey folks, I've got a total txt field called 'score'
now I've got 5 buttons. I would like depending on what button is clicked to add a set amount to the score.
e.g If I clicked 5, then 5 , then 5 again the score would show 15.
I really hope you can help
Array Addition
i'm missing here, and hopefully one of you can point it out to me.
what I am doing is this:
I have a global variable used throughout several timelines of a movie called _global.location
in a function I am trying to simply add the contents of a single location in two arrays and I am storing the result in a variable like so:
my var:Number = array1[_global.location] + array2[_global.location];
now say the value in array 1 is 3 and the value in array 2 is 1. The result I am recieving is "31" vs "4". It seems to be treating my values as a string or something and simply appending the character. Do I have to declare the array in a certain way?
the values are entered in to the arrays through XML, could this be part of the problem?
Gradual Addition
Hi everybody,
is here anybody who could help me with gradual addition for variable? It would help me very much! This code trace No. 6 after every buttonPress.
Code:
for (i=1; i<5; i++) {
my_mc.onPress = function() {
n = i+1;
trace(n);
};
}
How could I achieve to get no. 1 after first press, no. 2 after second and so on? I'll appreciate every attempt.
Thanks
[F8] Need Addition And Subtraction Help
I am trying to create a swf that will add a value up to a certain value then stop adding the value. However I am having an issue with what is displayed when it stops. In the example I posted I have a text box that starts out with a value of 0. Value of the text box should only range from +14 to -14. The subtract button will continually subtract by 1 and then stop at -14. However when the add button is used it will continually add by 1 but stop on ++14. I am not sure why it is doing it. I know it has something to do with the addition of the “+” sign because when I remove the code for the “+” sign it stops at 14 just fine. Does anyone have any idea as to what I need to do to fix this?
Math Addition
Hi,
I have 3 variables each in its own movie clip. Each of these variables contains a different amount:
var 1 = 24
var 2 = 70
var 3 = 125
Each of these variables has a submit button which places a figure in a 4th variable in a fourth movie clip: for exampl
The submit btn for var1 in movie has the following code . . .
on (release) {
_root.movie4_mc.var4 = 24;
}
That works fine adding one figure only. But if I select a second figure it just replaces the first. I need to be able to add the figures together - so the result in var 4 could be 94,149 or 219 if all 3 amounts are selected for example.
Thanks in advance for any ideas on this.
Jo
Addition Problems
I have the code...
_parent.firstscore += 50;
and firstscore is a dynamic text field. When it adds 50 it LITERALLY adds fifty.... the result is 50, 5050, 505050, 50505050 etc... then I tried it like this....
_parent.firstscore+50;
now it doesn't work, period. Can somebody tell me what I'm doing wrong??
Float Addition Bug In AS3
Try this:
Make a new AS3 project and in the actions in frame 1 write: trace(10.3+0.3)
Now run it and get the result: 10.600000000000001
Trying the same with a AS2 project gives 10.6 as expected.
Please let me know if others can replicate this?
Edited: 11/30/2007 at 02:04:23 AM by stroyer
Button To Do Addition
I hope someone can help. I am making a weakest link screen to use with pupils when doing a quiz. So far i have an 11 frame movie clip which shows the amount of prize money. I have a correct button which moves the movie clip to show £100, £200 etc. I have a wrong button which when pressed takes the moviclip back to frame 1,which shows £0.
What i want to do is work on the 'bank' clip. When i press this i want it to add whatever sum they have reached and display it in a dynamic text box. e.g. if they have reached the frame in the money movieclip which has £400 highlighted, then 400 will appear in the text box.
I also want it to do addition, so that when the button is pressed the money movie clip might be in the frame which has £200 highlighted and then the total score box will show £600.
I think i want something along the lines
when the button is pressed,
if movie clip is in frame 1 then show 0 in text ( total score)
if movie lcip is in frame 3 then add 300 to total score
if moviclip is in frame 5 then add 500 to total score
But i have no idea about adding - i am rubbish at maths and avoid this section of flash.
Could anyone point me in the right direction. stockdill
Button To Do Addition
I hope someone can help. I am making a weakest link screen to use with pupils when doing a quiz. So far i have an 11 frame movie clip which shows the amount of prize money. I have a correct button which moves the movie clip to show £100, £200 etc. I have a wrong button which when pressed takes the moviclip back to frame 1,which shows £0.
What i want to do is work on the 'bank' clip. When i press this i want it to add whatever sum they have reached and display it in a dynamic text box. e.g. if they have reached the frame in the money movieclip which has £400 highlighted, then 400 will appear in the text box.
I also want it to do addition, so that when the button is pressed the money movie clip might be in the frame which has £200 highlighted and then the total score box will show £600.
I think i want something along the lines
when the button is pressed,
if movie clip is in frame 1 then show 0 in text ( total score)
if movie lcip is in frame 3 then add 300 to total score
if moviclip is in frame 5 then add 500 to total score
But i have no idea about adding - i am rubbish at maths and avoid this section of flash.
Could anyone point me in the right direction. stockdill
Hexadecimal Addition
guys,
I have been trying to do this for an hour now. Is there a way (in actionscript) to add 2 hexadecimal numbers (e.g. 00ee11+00ff10) without converting it to decimal first?
Please help!
thanks in advance
biggie
The Man of Tomorrow is forged by his battles today.
Variable Addition Problem
Hi,
I have a weird problem which is driving me crazy, hopefully someone can spot my problem.
I have the following attached to a button:
on (press) {
if (title1=="Moonlit Thirst") {
text1 = (quantity1+1)
call("quantityupdate1") }
quantity1 is a dynamic text box which already has 1 as its value.
quanityupdate1 is a function which updates quanity1 with whatever the value of text1 is.
The weird thing is that on the first press of the button, the 1 in quantity1 becomes 11. After that, on each subsequent press, 1 is added to quanity1.
So first press becomes 11, second 12, etc.
Why is 10 added on the first click?
Thanks in advance.
nick
Radio Button Addition
ok the stage has 20+ radio buttons and 2 diffrent kinds of radio buttons
For one of radio buttons True = D=+1
For the other radi button True = D=+2
false = 0
Anyhting 2 or greater would move on to the next frame in the movie and anything less than 2 would go to the sry frame(frm 32).
so if they picked two radio buttons that both had +1 wich would be 1+1 wich equals 2 they would go to the next frame. Where as if some one picked only one radio button that has a D=+1 property it would not equal 2 and they would be directed to the sry frame.
(button)if d=2 nextFrame
I have tried a few times but I am not sure of how to structure it.
first thoght was to make d=0
make a few MOVIE/button two frames. clicked-unclicked. Clicked frame had FrameAction d=+1 (or 2 depending on radeo button) but then I didn't know how to do the actions script on the button too see if d=2 or greater
I genrally jus look threw movies or tutorials for help but I could not find anything that applied oddly enough. Always find what I need here =)
Any Help appreaciateed tks...
Ego-Trip
Using Flash MX
Addition Script (in Progress)
Not even sure if this is possible but I'll give it a try:
Basically I have a number (346) and i want to add another number (10).
Here's the tricky part - Instead of the script adding it instantly and displaying the added total (356) the second you get to the frame, I'd like to actually see the addition in progress (i.e. 346, 347, 348, 349....etc etc.) quickly adding up until the final total.
Thanks in advance to any suggestions!!!
Targeting With Variables And Addition
This code is being used in a for loop, where "i" is being set to a number:
my_color = new Color(_root.fly0.eval("pod" + i).background);
I'm trying to set a color on:
_root.fly0.pod0.background
_root.fly0.pod1.background
_root.fly0.pod2.background
etc.
Thanks.
Addition Is Supposed To Be Easy...
Problem: When I add two dynamic numbers they are joined rather than added (1+3 = 13). See below for more detail.
As an experiment I've been writing some code to construct musical scales based on a template. The template is an array of numbers. The following function is intended to construct the scale using a starting note in numerical form(rN) and the template(scale). A third index array (chromatic) is used to return the actual notes:
code:
function buildScale(rN, scale){
outputScale=[];
outputScale.push(chromatic[rN]);
for(i in scale){
rN+= scale[i];
outputScale.push(chromatic[rN]);
}
}
What seems to happen is when i add to rN (in order to find the next note in the scale) the two numbers are joined so 3+1 becomes 31 and i eventualy end up with an 8 digit number.
I guess this is something to do with extracting the numbers dynamically, but i'm stumped for a solution.
[CS3] Input Field Addition
I'm making a form where the user puts in three prices, one for phone, one for internet, and then one for video. Then they click a button, and it adds these numbers together. This is the code I have thus far:
total_button.onRelease = function () {
total.text = Number(video.text)+Number(internet.text)+Number(ph one.text);
total2.text = Number(video.text)+Number(internet.text)+Number(ph one.text);
};
The problem I am running into, is that I want to treat these numbers as currency, so that it displays them with dollars and cents. As it currently stands though, if a number is to the far left of the decimal and is a 0, it drops it. For instance, if 10.00 and 5.00 are added together, the result is 15, or if I add 10.50 and 1.00, the result is 10.5
When I searched the forum, I in one page they listed this link
http://www.macromedia.com/support/fl...mal_places.htm
But I am not sure how I would work this in with what I have thus far. I'm not very knowledgeble in regards to action script.
Creating Addition Tests
I am creating a test to see whether peple can do simple addition (IT coursework :[) The only way I can think of doing it is having 2 movie clips and have 50 frames and each frame sets the variable to the number that's shown. Then there is an input text box and then a button that checks to see whether the two variables added together equals the number in the input box.
Is this the best way to do it, and how do I make Flash go to a random frame in the two movie clips?
I'm also doing a subtraction and multiplication one, but the code would be similar, wouldn't it? (Something like If (Input== Number1 + Number 2){ Goto frame "correct" else goto frame "Wrong} (Not correct sytax or whatever, but something along those lines, I haven't used if statements for a while)
|