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 .
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-25-2002, 10:13 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Numbers To String
This can't be that complicated.
I have two variables that I need to put together in a string so that I can pass them through javascript. The problem is they are acting as number and adding themselves.
var Lat_Array_Num=../:Latitude6.info;
var Long_Array_Num=../:Longitude6.info;
var Array_Num=Lat_Array_Num add Long_Array_Num;
var URL = "javascript: open('http://gisserver/manassas/cfdocs/test.cfm?Lat_Var=" add Array_Num add "','jumpframe')";
getURL (URL, "jumpframe");
If I attempt to put a comma in between the numbers:
var Array_Num=Lat_Array_Num add "," add Long_Array_Num;
I get the error "Expected indentifier".
The receiving variable should be something like "38.5679875,-77.5465848".
Treating Numbers As A String
I have two randomly created numbers, and want them to sit next to each other, so I say:
y = random(8)+random(8)
but it does it mathematically, I just want it to add the number to the end physically, so if the first number was 4 and the second was 3 it would read 43 rather than 7...
Another easy problem
w.
Split() A String Into Numbers?
Hey everyone
Did a search, but couldn't find anything... though it's a stupid question:
I do this:
Code:
var myArray:Array;
myArray[0] = "2,3,4,5,6";
myArray[1] = "3,4,5,6,7";
var splittedMyArray:Array;
splittedMyArray = myArray[0].split(",");
Now theres this in splittedMyArray:
[0] = "2"
[2] = "3" ... and so on
But I have to use the numbers in splittedMyArray as numbers, and not strings as they are now?
How do I do this....?
thanx...
Combining Numbers To A String
hello,
can anybody help me with a problem i have?
i want to make a random six digit number (representing a color), so i have created a loop that makes 6 random single digits, and now i want to have them as a six figure value.
does anybody know what i have to do?
Extract Numbers From A String
Hey guys,
I need a function to extract the numbers from a string. Examples of the strings are '/portfolio/advertising/1/' and '/portfolio/branding/10/'.
I was thinking a solution would be to loop through numbers until it finds an indexOf and then return that number, but I can figure out how to write it.
Any ideas or other suggestions?
Cheers
String Of Numbers To Numeric Value
Hi,
I have 3/4 of my application working, but I can't close the deal. I am building a slot machine in which the user has 3 pulls and the highest resulting combination is kept.
This part is working fine:
_root.sendVar1 = myquote1_actual+""+_root.myquote2+""+myquote3_actu al+""+_root.myquote4;
It produces a single value in a text box, like 3241, for example. I have this duplicated 3 times, resulting in 3 variables: _root.sendVar1, _root.sendVar2, and _root.sendVar3.
Now, I need to compare the 3 variables and make the highest number a new variable.
For example:
result 1 = 0946
result 2 = 1295
result 3 = 0473
I need result 2 to be made into a variable.
Thanks in advance
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
Extracting Just Numbers From A String... Help (should Be Simple?)
Hi - I'm stumped here. I'm trying to extract just numbers from a string. Namely, I'm tracing "this" which returns a path : "level0.instance1.subContainer0.subButton0" What I want to do is extract just the numbers so that I get a value of "0100" (or better yet, "100"). I've looked into substr() but it's only numbers in a sequence. Is there any way to do this???
thnx
t
Random Numbers In Text String
I'm having trouble with the random function . . .
I've got the following actions in a frame:
PHP Code:
stop();
link = "link1";
type = ".jpg";
external = "graphics/";
_root.highlight.gotoAndPlay("fade");
//
pos11 = "knife";
cap_p11 = "This is a dive knife designed for and with Atomic Aquatics. Intended to look very 'Sharkish' and made of titanium, it is truly unique.";
pos12 = "FramelessClear";
cap_p12 = "A frameless dive mask designed by Atomic Aquatics. They needed a compelling image to use in their brochure and convention booth.";
pos13 = "z2_trans";
cap_p13 = "Atomic Aquatics dive regulator. With transparency, cut-aways and decals.";
pos14 = "fin";
cap_p14 = "Split Fin with split cut-away and transparency. Another from Atomic Aquatics";
pos15 = "valve";
cap_p15 = "The low pressure regulator valve assemble cut-away with perspective";
pos16 = "ride";
cap_p16 = "A conceptual amusement park ride.";
pos17 = "z2";
cap_p17 = "Multiple lights and application of perspective together create a dramatic affect.";
pos18 = "SuperTX";
cap_p18 = "Powerski Jetboards Supertorque XT Marine Engine Cut-Away";
pos19 = "DriveSystem";
cap_p19 = "The drive system for the Powerski Jetboard";
detail=pos11
Where "posxx" is the name of a picture and cap_pxx is the caption for that picture. The pictures are loaded elsewhere using loadMovie.
I'd like to randomly choose a picture.
when I use:
detail = pos11
it works (For that matter any number works: pos12. pos13, etc)
if I use:
detail = pos+random(10)
it doesn't
Of course I've tried variations with "" and () to no avail. It seems I'm mixing up text strings and numbers some how . . .
Please help . . . .
AS 2.0 Load Vars From String To Numbers
i am loading two flash vars.
ActionScript Code:
startTime = this["MediaPos"]; and csMediaPlayer.duration = this["VDuration"];
they are both numbers startTime is 1200 and duration is 30. So I need to make a variable called end point that adds them up but when I
ActionScript Code:
var time:Number = csMediaPlayer.startTime;
var time2:Number = csMediaPlayer.duration;
//
trace (time + time2);
It doesnt add it just out puts 120030
Thanks for the help!
Robert
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
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 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.
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/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?
[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
[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
Why Won't Actionscript Join Letters And Numbers Into A String?
Here are some snippets from my air traffic control simulation. These lines are supposed to combine a letter with a number value (eg. H090)
strip.VairspeedStrip = assignedIAS + "K";
//produces the result "300" missing the K
strip.VheadingStrip = "H" + headingAssigned;
//produces the result "090" missing the H
strip.VairspeedStrip = "M." + assignedMACH;
//produces the result "M.78" correctly
Why does it only work on the last of the three? How can I force actionscript to concatenate?
Ken
String To Uint With Out Changing Characters To Numbers
I am having an issue changing the string "0x33ff33" to a uint which will be used to transform the color of an object.
ActionScript Code:
tempTint:String = "0x33ff33";
trace(uint(tempTint).toString()) // Outputs 3407667
I need tint to equal 0x33ff33 like so
ActionScript Code:
tint:uint = 0x33ff33;
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;
}
|