ActionScript 2.0 :: Adding The Multiple Numbers?
Sep 8, 2010
I'm building a calculator of sorts and have about 7 input text boxes (input text chosen) that users can enter numbers. At the bottom I have a calculate button that adds all of the numbers users have input into the boxes. The answer goes into a dynamic text box. It all works fine expect if a user does not enter in a number in one or more of the boxes. In other words, users would have to input a number in each box for it to work, I don't want that.Here is the code on the calculate button:
TransportationTotal = Number(Limo) + Number(SUV) + Number(HorseCarriage) + Number(Boat) + Number(Helicopter) + Number(LuxuryCoach) + Number(LuxuryCar) + Number(TransportationGuests);
}
whereas the names in brackets are the var assigned names. Do I need to declare the var's beforehand? Tired this and did not work.
View 2 Replies
Similar Posts:
Mar 7, 2012
I have been using Actionscript 3.0 in Adobe Flash Builder for a few weeks,and I really like it! Bare with me because I'm not really good at it, yet. Anyway, I was wondering how would I go by adding up odd numbers from an array of numbers? I know how to make all of the numbers add up, but adding only the odd numbers I'm not so sure how to do it.
View 5 Replies
Feb 18, 2005
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 .
View 6 Replies
Oct 28, 2009
I am trying to add two numbers (num1 and num2) in Flash Pro 8. Every time that I try to add them I get a result of NaN in my answer box (ans instance, sum var)
The code in the Layer's Background is as follows
Code:
stop();
var num1;
var num2;
var sum;
[Code]......
View 1 Replies
Nov 29, 2010
I have a game I'm trying to create over a number of key frames.I want to be able to contiuously add a users score.Each question is worth different points from 100 - 500 and ther is about 5 different categories.Is there a simple way to add numbers in flash?
View 3 Replies
Feb 24, 2011
I using Flash CS5 for the first time, and I'm hitting a snag. I have an input box on Scene 1 for age (variable called old). On scene 3, I have a dynamic test box (variable called display), where I want to display the age (old) + 10.
My Code looks like this:
PHP Code:
var Real_age = Number(old) + 10;
display = Real_age;
It's returning NaN.
A trace of the output of Real_age gives:
PHP Code:
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT">
<FONT FACE="Times New Roman" SIZE="12" COLOR="#009900" LETTERSPACING="0" KERNING="0">2</FONT></P></TEXTFORMAT>
<p align="left"></p>
<p align="left"></p>
NaN
<p align="left"></p>
<p align="left"></p>
The code works OK in Flash 8, but I figure I must have some some setting that is spitting out the unwanted HTML.
View 5 Replies
Jan 30, 2011
Code:
var result:Number = int(driven.text) / int(mpg.text);
result1.text = String(result);
var result:Number = int(driven.text) / int(mpg.text + 3);
[Code].....
for some reason it doesnt work properly...the correct equation should work like this:
12000 (milesdriven) / 20(mpg) = 600
12000 (milesdriven) / 23(mpg + 3) = 521
600 - 521 = 79(gal.)
79 x $2.75 = $217.25
what im having problems with and what i need to function is that the MPG input has a +3 to any number inputted (i.e. 20 becomes 23)
View 3 Replies
Aug 10, 2011
i want to create a calculater that can add scores from a scale of 1 to 10.for example, if the player gets between 0-3, he gets a point
-between 4-7, he gets 2 points
-between 8-12, he gets 3 points
when this is complete, the points are added up, depending on what the player gets, for example he scores between 4-7 and between 8-12, he gets gets 5 pionts. i can get them to add the points, but not when its between a certain value
View 1 Replies
Mar 4, 2009
Say I have 4 values (level_reached1, level_reached2, level_reached3, level_reached4) I want to add up to a total, and another 4 values (goal1, goal2, goal3, goal4) I want to add up to a total. How do I add these up and compare them to each other, and if the "level_reached" is equal to OR greater than "goal" I want a movie to gotoAndStop(2);
Here is what I have, which does not work, I probably have things really mixed up:
Code:
leveltotal = level1 + level2 + level3 + level4;
goaltotal = goal1 + goal2 + goal3 + goal4;
if (leveltotal >= goaltotal) {
[Code]....
View 2 Replies
Apr 18, 2012
I have an xml file that I loaded and parsed and end up with xmlist like this:
<goals>20</goals>
<goals>23</goals>
<goals>19</goals>
I want to variable that adds the goals together to get 62. How do I go about doing this?
View 1 Replies
Feb 18, 2009
Basically, I have an input box on a widget that sends information via PHP.
One of the input boxes is phone number. Everyone inputs number as normal, but without the country code.
Is there a way of me taking their normal number from the input box, removing the '0' and adding the country code before sending it (i.e. within a calculation/function/formula).
View 1 Replies
Nov 9, 2010
let's say you had a dynamic text field with a number (for example '30'). Everytime you click on a certain button / movie clip, that triggers an animation (so far no problem) AND adds '20' to the number in that textfield.
==> first click, the number displays 50 (30+20), second click 70 (50+20) ...
When you enter a certain keyframe and that number is higher than let's say 290, the movie jumps to frame x. If that number equals 290 or is lower than 290, the movie jumps to frame y.
View 4 Replies
Jan 5, 2009
just trying to add 2 numbers but doesn't seems to work.
error:1067: Implicit coercion of a value of type Number to an unrelated type String.
************************code**********************************
var imput:Number;
var imput2:Number;
var total:Number;
convert_btn.addEventListener(
[Code].....
View 1 Replies
Jan 23, 2011
I dont know why, but I am having the hardest time! All I want is for there to be a movieclip, and when I click it my textfield adds a number! I swear I have looked everywhere but nothing.
View 7 Replies
Oct 31, 2011
Adding 2 numbers having 3 textfields and a button, I can do. The first textfield for input one, the second one for input two and the third one for output (result). The button triggering the operation. [URL]. How can I add 2 numbers only with one textfield( result) and 4 buttons. One button for number 1, another one for number 2, another one for the operator +, and finally another one for the sign =.
I have the code, how to put everything to work:
import flash.events.Event;
var txt_inp:TextField = new TextField();
txt_inp.type = "input";
txt_inp.x = 168.95;
txt_inp.y = 51.10;
[Code] .....
View 10 Replies
Jan 28, 2011
I'm stumped on this problem and can't seem to figure it out. Any suggestions would be welcomed. Basically I'm building a large calculator that adds over 100 input boxes. I've got it working except for the fact that if a user misses inputing a number into one of the input boxes it does not work anymore. I've tired lots of things to no avail. I just want to add the input boxes and skip those where the user did not enter any information (does not apply to them)
Here is my code.
on (press){
ReceptionTotal = Number(LocationFee) + Number(Caterer) + Number(ToastingGlasses) + Number(SecurityFee) + Number(BarPackage) + Number(WeddingCake) + Number(FoodHors) + Number(Baker) + Number(BartentingFee) + Number(CakeKnife) + Number(Servers) + Number(Flatware) + Number(Dinnerwear) + Number(Flatware) + Number(TableLinens) + Number(ChairsCovers) + Number(Glasswear) + Number(Tent) + Number(Napkins) + Number(Childcare) + Number(DanceFloor) + Number(ServingStaff) + Number(Lanterns) + Number(Heaters) + Number(Restrooms);
}
each input box has a variable name assigned to it as indicated above. I've tired setting the variables to 0, tried if statements don't know how to skip one of the above variables when no number is entered.
View 8 Replies
May 22, 2009
I'm sure this is something really basic, but I've searched and nothing quite fits what I'm looking for..I have a timer counting down using this code
Code:
count = 30;
countdown = function(){
[code]....
View 2 Replies
Sep 29, 2009
So I have a project where the user puts in a number, that number is * by a certain number and then spits that number back out to another dynamic textField. All of that is working out great so far. Now I need to figure out a way to add commas to those numbers that I am displaying.
Here is the code I have thus far:
var num1:Number;
var inputFont:Gotham = new Gotham();
var tf:TextFormat = new TextFormat();
[Code].....
View 1 Replies
Oct 28, 2009
I am trying to create a quote estimator on my website. I want to create forms in flash that can take inputs (numbers) from the user and then automatically calculate the values by mutliping certain forms and and then totaling them up.
The total value does not need to be saved. No database is required.
I am assuming I need to use dynamic texts?
View 2 Replies
Sep 23, 2011
var myNumber:Number = 1.8;
trace(myNumber);
The above gives "1.7999999999999998"
conversion of String(myNumber) also gives "1.7999999999999998"
This only happens with certain numbers. If (myNumber == 1.4) it doesn't give me this problem.
I've checked with the debugger and the values are correct both before and after the trace or String conversion. However, the string itself is incorrect.
View 1 Replies
Jan 21, 2009
Is it possible to add kerning (letterspacing) in-between the numbers in a date counter? For example lets say I have a date counter that counts the dates of a month (1,2,3,etc...) and I have two circles sitting side by side not overlapping. How would i go about adding a space in-between the numbers to have the number on the left in the left circle and the number on the right in the right circle? Someone mentioned using strings but how would I go about doing that? Here is the current code that I am using:
[Code]....
View 1 Replies
Mar 10, 2010
how to make a variable that calls upon multiple numbers to condense some code down.
example:
ActionScript Code:
someFunction = function()
{
if(myVar == 2)
[Code].....
Like how would I say if myVar was equal to 2 or 3 or 6 in one line?
View 9 Replies
Apr 11, 2011
that how can i duplicate a movieclip to as much numbers i want through out the stage using actionscript2. i have searched lots of posts in sites but i can't get it
View 6 Replies
Sep 11, 2010
Im trying to display 16 random numbers in the dynamic text field, but Im only one number is being displayed.
ActionScript Code:
for(var i:uint = 0; i < 16; i++){
var randomNumber:Number = Math.floor(Math.random() * 9);
trace(randomNumber);
}
output_txt.text = String(randomNumber);
View 2 Replies
Jun 16, 2009
I've got a long list of similar movieclips I'm adding to the stage. There's 9 in total and the code looks like this...
stage.addChild(zone0_mc);
zone0_mc.x=267.6;
zone0_mc.y=120.5;
[code].....
View 3 Replies
Sep 30, 2009
I have 60 pictures- set sequencially in frame by frame animation.I would like to enter them (imported or from the library- whatever works) into the timeline one picture per frame (or keyframe) so when I can hit play and see the animation.
View 1 Replies
Jun 3, 2010
I have entered the following code and both items do import, but i cant control the label of the second library item called "Cool"After doing some digging, i think i found out the class name of the second object was called "Cool" and the base class was "import flash.display.SimpleButton;" so it looked like i had to import that class at the top like i did! But still not working. and still no joy!I think i need to add in "public class Cool extends SimpleButton" so it inherits the SimpleButton class after the first public class and then create a new function called "public function Cool() " and then add the function body but when i go to do that it all goes wrong. Am i on the right track or am i missing a trick!!
package
{
import flash.display.Sprite;
[code].....
View 3 Replies
Jan 25, 2012
I just started recently using more of AS3.All of our previous banners were in AS2 (before my time here) so I just continued to work within that.I am on a Mac and using Flash 5.5.However, I am now creating some new banners in AS3 from scratch.There are 6 total clickTags on the banner that we track.There is an invisible button over the entire banner that stays on there to a specific keyframe and has a clickTag.Then, at the very end there are 5 text buttons each with a clickTag.
When I test it in Flash 5.5 it plays fine but gives me the following warning under the Output tab:WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.I have done some research and keep seeing that I need to place the actions on separate keyframes.What code do I use and does each clickTag need to be on it's own keyframe?Below is the general clickTag code we have been using but the banners are in AS2.
on (release) {
getURL(_level0.clickTag2, '_blank');
}
View 4 Replies
Aug 20, 2009
what I want is for the text area box to be added the same amount of times as there are nodes in my xml file (currently 5)So, I'm trying to add 5 textboxes to the stage.Whenever my loop fires this
Code:
//make titles
var songTitle:TextField = new TextField;
[code].....
View 5 Replies
May 23, 2010
Adding frames across multiple layers...that's what I want to do. I do not want to add frames one layer at a time if I can help it as I have a good 20 layers going and I'm bound to miss one or something. Now if I am in a tween layer adding frames I know what that does...but it will add more frames of what ever is going on at that point in that layer...right? (Ex. empty space...you will be adding more empty space...next layer has a tween...you are adding more tween...right?)
View 1 Replies