Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




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



FlashKit > Flash Help > Flash ActionScript
Posted on: 08-31-2004, 07:36 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

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)

Dynamic Addition Of Images In Flash Using Xml
can anybody plz help me how to put the images deynamically into flash-the complete procedure.
can you plz tell me the complete thing i.e what all is to be done in flash n xml n how to connect them properly.
i really need help
thank you

Full Browser Flash Addition - Help Req.
Hello,
I have undertaken the Full Browser Flash tutorial with success, but I am trying to advance further using it.
Rather than just having a static image (movie clip) which is centered, I would like to have this centered box contain an intereactive site... buttons, scrolling images etc.
Would it be possible to create my menu/content/images and group it with an instance name of 'cover'? or how would I do this?
Thanks

Using Flash Media Server- Developer Addition
Ok.. I'm a newbie and I just want to try and understand this real quick.... I'm looking to incorporate within my site a page where people can login and upload content possibly with a thumb nail description of it.... I would use this right... and I would use the free developer addition right ?

humor me... or point me in the direction of a tutorial I could read to comprehend this... my site has been completely done in Flash... www .catch22combines.com looking to incorporate a forum page where the info can be uploaded...


Trey

XML Flash Gallery - Small Addition, And Problems...
I'm using the XML flash gallery from Kirupa's tuturial (waut to go Kirupa!) on Flash CS3 with AS2. I have a minor adjustment: when you start sliding and then drag the mouse out of the mask, keeping the Y axis constraints, the thumbs keep sliding until reaching the end. So I made turned the mask rectangle into a MC, gave it an instance name and added the following code to the ThumbNailScroller() function:

Code:
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
if ((_root._xmouse>=(hit_right._x-40)) && (_root._xmouse<=(thumbs_mask._x+thumbs_mask._width)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=(hit_left._x+40)) && (_root._xmouse>=thumbs_mask._x) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
I hope this helps someone.

Besides that, I need to make some modification that I can't seem to figure out how to do:
I have a cars gallery: there are 15 cars, each have 2-3 photos from several angles. I want to have 15 thumbnails, one each for every car; When you'll click the thumbnail, it's corresponding big image will open in the Picture MC, and the other 2-3 thumbs of the same car will open in a third empty mc on the side of the big image; when you'll click the other thumbs they will each open a big image in Picture MC; when you'll click a thumbnail of the main 15 thumbnails, it will again open its corresponding big image in Picture MC and will load the new car's other 2-3 thumbs on the third empty mc.

Any idea how to do that anyone??

Mouse Wheel Scrolls Browser Page In Addition To Flash
I am working on interactive flash maps, where I let the user utilize the mouse wheel to zoom in or zoom out of the interactive map (in addition to keyboard and button options).

In AS2, using the mousewheel on a flash element that is in focus would not scroll the whole web page that contains the flash. But, in AS3, the mousewheel scrolls the whole page in addition to communicating the mouse events with the flash element. Here's a comparison of the two maps:

AS2 vs AS3 Swfmap

Any ideas on how to keep the web page from moving when the user is mouse wheeling on the flash in AS3?

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?

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

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...

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

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

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

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.

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.

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.

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..

[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)

(Variable Addition) Problem With AS.2
hi evey one...
i have littil problem with flash in the addition using the variables
Every thing is working normaly.
the subtraction and the others are working fine
the only problem is the addition
..
when i teake the variable from Text feald or external source hte flash will add the numbers beside each other . it treat them as strings
chick the attatchment to see what i mean

but when identfy the variable in the action befor the addition works normal
like

PHP Code:



nom1 = 5;nom2 = 6;trace (nom1+nom2); // output = 11 




,,,,,,
any one can help me in this ?

thanks first

Text Effect A La Www.addition.com.au
Hi, does anyone know how to do the text effect where the lines tween together one by one (the spaces reduce), check http://www.addition.com.au/ to see what I mean...

Much appreciated,

jpixels

Math Troubles With Addition
My script is conjoining the two values instead of adding them together.
So instead of 2 + 2 = 4, 2 + 2 = 22

calculate_btn.onPress = function() {
textbox3_txt.text = textbox1_txt.text + textbox2_txt.text
}

textbox1 = input text with instance name of textbox1_txt
textbox2 = dynamic text with instance name of textbox2_txt
textbox3 = dynamic text with instance name of textbox3_txt

The problem is only with addition. Multiplication, division and subraction all work fine.

Code For Addition And Multiplication
hello

Easy question

why when input 3 and 4 and press button, i get 34 which is normal because it is treated as string see code below

code on frame 1
inButton.onRelease = function (){
outText.text = inText1.text + inText2.text;
};

but why when I use multiply for example I get 12,
inButton.onRelease = function (){
outText.text = inText1.text x inText2.text;
};

Is it because flash has no choice, really to be strict i should use
Number(inText1.text) x Number(inText2.text);

thanks

Xav

Help New User .....need Gallery Addition
i am trying to modify the callery with thumbnail, but i don't know how.

i want the scrolling grid to be vertical and i need at least 4 thumbnails from left to right and 6 top to bottom. plz help!!

Scene Addition Causes Dithering With AS?
OK... I have this tire that bounces in, you know the kind.. bounces off walls and what have you...... works great until I add another scene into the mix.

The motion still works and it all runs as its coded, but the quality of the tire is reduced dramtically??? What could be the cause of this?

And YES I know that scenes suck, but gotta use them for this.....


Any help?

Vector Addition - Polygon Method
I had a problem here.Thats is to have an action script to calculate the resultant length.How to do it?

//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.,?????

Copyright © 2005-08 www.BigResource.com, All rights reserved