How Can I Set A Variable To Have 2 Numbers After The Decimal Maximum?
Hi there! I've been trying to learn how to delete/eliminate numbers after the decimal in an input text field. This is the script that I'm using, altough it rounds the number up.
newresult = Math.round(totalimpostos*Math.pow(10, 2))/Math.pow(10, 2);
I need only two numbers after the decimal, the rest of the numbers must be deleted/eliminated...ignored!! I need a script that DOESN'T round the result number up!! Can anybody help?? Tks a lot!!
FlashKit > Flash Help > Flash General Help
Posted on: 01-17-2003, 07:56 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How Can I Set A Variable To Have 2 Numbers After The Decimal
In a movieclip I have a variable named 'totaalalles' who is set by multiplying 2 other different variables. But i want to set the variable (totaalalles) to 2 numbers after the decimal.
I've searched the helpforum and I found something that I can't get to work.
http://www.flashkit.com/board/showth...=round+decimal
(i'm using MX)
What do I do wrong? Please help!
(Excuse my Englisch, I'm Dutch)
Decimal Numbers
Hello,
I have a problem with an equation....
I divide a X number by 30.
This number X can be anything between 1 and 10 (ie 1,1.2,...)
I would like the result of this division to be formatted like this: xx.xx
Does anybody know how to do that ??
Thx
qali
Displaying Decimal Numbers? (HELP)
I'd be surprised if there wasn't a way to do this, but I haven't been able to figure it out yet:
I need to be able to diplay the price of something in a dynamic textbox, which should include both dollars and cents. Depending on what you select for "quantity" the price changes dynamically.
The problem is, if the value of the "price" variable is a number and not a string and there are zeros to the right of the decimal, they are simply and understandably dropped (example: 8.50 is displayed as 8.5). Because the value of price is always the product of the BasePrice times the Quantity, it is a number by default, not a string.
Is there an actionscript method that allows you to define the number of places to the right of the decimal there should be for a given variable?
Any suggestions would be appreciate!
Thanks,
Shane:confused:
Displaying Decimal Numbers W/AS2.0
does anyone know what the code would look like if i wanted to display two decimal places?
if i type in a number 3 i would like for the display to show 3.00
or
if i type in a number 3.4 i would like for the display to show 3.40
any ideas?
Hector
Read Decimal Numbers?
Hey all,
I think i have a very simple question, but i cant figure it out. When i have a number like 1.25, 1.50 or 1.75 (They always end on: *nothing*, 25, 50, 75)
How can i get the value behind the .?
ThijsD
[EDIT]
Im using AS2
Edited: 01/24/2009 at 05:42:08 AM by ThijsD
Rounding Numbers To 2 Decimal Places?
Hi all,
cam anyone remember how to calculate to 2 decimal places
ie
542.8688
to 2 decimal places would be
542.87
i can cut off the no required places but cant seem to round up or down accurately
any help greatfully appreciated
thanks in advance gilesb
Restrict Textbox To Numbers And ONE Decimal
What would be the best way of restricting a text box to only allow numbers (easy) and only ONE decimal? It's easy enough to restrict it to numbers and decimals, but users can input multiple decimals.
Suggestions?
Whole Numbers Get Decimal Bits Tagged On - Why?
i've had a look at the other posts and not seen one that tackles this, so here goes:
sometimes when you enter a whole number in the height and width properties of an instance they get a decimal bit tagged on (ie 250 becomes 250.3) - why is this? Is it to do with positioning or preferences or something?
thanks
Need To Remove Numbers Two Spots After Decimal?
Hi guys I am making a program thing and what it does is figures out the price plus taxes and prints it off. When it figures out what the PST is (provincial Sales Tax) it comes up with a number like...
0.3152
I need it to be
0.31
How can I do this or where should I look to figure it out. I have seen some math.round and codes like that but they all seem to do different things than what I need. any help would be awsome. Thanks!
Rounding Numbers Up Or Down On Decimal Integrer
Hi,
I have a challenging issue because Math.ceil and Math.floor rounds numbers to a whole number.
I am creating a dosage calculator and unfortunately I need to follow and produce existing values present on a printed sheet where the rounding does not happened in a straightforward manner. So I need to be able to round the numbers up or down in order to match existing values on the printed data sheet.
In one case, I have 6.251 as a result and I need to round it up to 6.3
In another case, I have 52.508 as a result and I need to round it down to 52.5
How can I accomplish this?
Thank you in advance.
Attila
Setting Length On Decimal Numbers
i am trying to use something like this
Code:
float_variable = parseFloat(string_var)
to represent dollar amounts... is there anyway to set the length of a float variable to do this? or is there any kind of dollar datatype in AS? (im using studio mx 2004)
thanks!!
Setting Numbers Before The Decimal Point To 0
Hello all,
I am wonder how one could set the numbers before the decimal point to 0.
For example, if i have 23842348.000389384, then i would get 0.000389384.
As another example, if i have 15264.985653, then i would get 0.985653.
I have tried converting the number to a string, splitting it into an array by the decimal point.
But in that case, if the decimal has got zeroes in front, they get truncated.
Any ideas appreciated
cheers!
Random Numbers With 2 Decimal Places
hi,
i want to use actionscript to generate random numbers that resemble a stock ticker.... so they would need to have two decimal places & a '+' or '-' sign before. i've been playing with random() & math.random() but neither will accomplish the task.
any hints would be appricated
ciao
jr
Displaying Decimal Places When Calculating Numbers..?
is it possible to show decimal places when calculating numbers...?
i want the output to display 20.00 instead of 20 when calculating whole numbers.
heres my button script;
on (release) {
ordertotal = Number ( ordervalue )+Number ( shrewdelivery);
where ordervalue and shrewdelivery are whole numbers, any ideas anyone?
_alpha Fade In And Out Giving Decimal Numbers
I'm trying to do a simple alpaha fade using actionscript. I have the following code in a goto previous frame loop.
loadText._alpha += 5;
trace(loadText._alpha);
When I run the swf the _alpha value is never 5,10,15 etc...
It is always a decimal number (4.83813, 9.983, 14.2324 etc...). Am I missing something? I have tried int() and Math.Round(). None of them kept the _alpha value even when doing +=.
Thanks for the help.
Help Conveting Decimal Numbers To Years-months-weeks-days
Hello guys
Well Im developing one interactive form could let you know in what period of time you could recover your money
For example you need to recover your money = 1,000 days
but now I want to calculate the same amount of days but converting in years, months,weeks and days
example :
1,000 days are:
2 years____=720
9 months___=270
1 week_____= 7
3 days _____=3
The month model I use is a flat 30 days, then the year is 360 days.
hope someone could give some help Im unable to find useful articles over the net
here is one aproach of waht is the closest result I could get, but the results stay as decimal numbers
example:
1000 days = 142.8571429 weeks
http://www.onlineconversion.com/time.htm
Maximum Number Of Variable Values
Does flash have a maximum number of variable values which it can store ??
Actually i am using the listbox component to load dynamic data, when i use trace on the variable names i get the data in the trace output window, however, they do not appear in the listbox ?? Help !!
I have currently over 200 records per listbox and around 4-5 listboxes.
Maximum Length Of Variable Content
Is there any limit to the length of content stored in a variable that is loaded with LoadVariables?
I did look around in the forums but could not find a post that answered it. Thanks.
Rounding A Variable To 2 Decimal Places
Hey all,
I am currently making a flash application where the user can purchase items and add them to a basket. I have all the code in place but when Flash adds up variables and stores it in a total, it never rounds it to a decimal place!!!!!
eg. 1.25 + 1.75 = 3 (not 3.00!!!!!!)
(Obviously the 2 decimal places symoblise the pennies)
I am hoping that this is easy to sort out as at the moment it could make the user confused.
Please please help a student in his final year at uni asap......deadline looming
Cheers
Griff
Numbers In A Variable
hi!
I have a textfile with a string containing some words seperated by a dot. a flashmovie loads this file and the variable. I then concatenate it depending on the dots. Now the thing is that I want also to know how may words there are. I've tried addin a variable in the file like this...
&numberofwords=10
..but It doesn't seem to work....the variable get the right value but I can't use it as a number in my scripts. Anybody got any sugestions? or know a way of how to check how many parts the concatenationprocess makes?
~ Variable Numbers
hi, i"ve got some calculations in my program. the numerical solution is then set as a variable and displayed. however, the number can be something like: 16.78412613. is there a way of displaying that number as 16.8 ?
Thanks
Variable Must Accept Only Certain Numbers
Is there any way that I can set an input text box to accept only numbers in this condition:
- If the user types anything different than xx.00 or xx.50 is shows an ERROR message (note that the user can type any number, but is must be followed by .00 or .50).
Is that possible without using a button???
If I have to use a button, that it's ok...I can live with that, but PLEASE, help me to get this settings working for the variable named weight
Stripping Numbers From A Variable
Does anyone know how I could strip numbers from a variable? For example:
var[0] = "apple1"
var[1] = "banana13"
var[2] = "apple53"
with hopes of outputting
var[0] = "apple"
var[1] = "banana"
var[2] = "apple"
Any ideas?
Variable With Text And Numbers
I have a variable called money and I am using this code
money = "&" add 0;
I want it so when i click the button it goes from $0 to $10.
My buttons script is
on (release) {
money += 10;
}
When i click the button it goes from $0 to $010 to $01010.
Can someone tell me what i am doing wrong
It works fine without the $ sign
Rounding Numbers In A Variable Field?
I have a calculator like tool I am trying to create but would like to be able to round to certain decimal point.I have been given a function that is suppose to work but upon insertion to the file it prevents my calculator from working?????
here is the original scripts on the button
on (release) {
rev_c11 = 60/as_a7;
rev_c12 = 50/as_a7;
rev_c13 = 1.2/as_a7;
}
This works fine. I then put the script below on the first frame of the scene where the button resides...
trim(thenumber,place){
if (place>=0){
var temp= Math.pow(10,place);
return Math.round(thenumber*temp)/temp;
}
}
and reference the script like this off of the button...
on (release) {
rev_c11 = trim((60/as_a7),2);
rev_c12 = trim((50/as_a7),2);
rev_c13 = trim((1.2/as_a7),2);
My only problem is I can not get it to work, Anyone out there have another solution or see what I have done wrong???
please help, Thanks
nauhs
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...
Avoiding Repeated Variable Numbers
Hello all. The following is some code to have movie clips randomly loaded into the main movie. How would I go about making it so that once a certain number out of the range was selected, it would not be repeated. That is to say, if the movie clip mcExercise2 has been loaded, it will never happen again, it will select a different number because "2" has already been used.
Any input is most appreciated..
Attach Code
var nExerciseCount:Number = 0;
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
}
for (var i = 0; i<100; i++) {
}
function displayExercise():Void {
mcExercise.removeMovieClip();
this.attachMovie("mcC1Exercise"+randRange(1, 3), "mcExercise", this.getNextHighestDepth());
mcExercise._x = 410;
mcExercise._y = 270;
for(i=0; i<5; i++) { }
if(nExerciseCount <= 3) {
nExerciseCount++;
trace(nExerciseCount);
}
else {
mcExercise.removeMovieClip();
gotoAndPlay("C1A_End");
}
};
Variable Isn't Holding The Value (strings, Numbers.. Anything)
Hi Thanks in advance for taking a look, I've been trying to display a value from a variable, in this case just text. Here is what i'm doing;
made a text box on the stage called it messageBox_txt (set it to dynamic)
in the code on other layer, i wrote;
var Message:String = "This is a test message";
messageBox_txt.text = Message;
when i run this it is blank and these instructions are from the Flash 8 textbook so they can't be wrong. is there a chance i need to change some setting? but it didn't work on the machine to me either. i'm in a computer lab.
Any help from one of you gurus would be a get assist, unless i'm just jinxed let me know
Numbers Imported As A Variable... Transfered To An Array?
ok this may get a little tricky... I am importing information from a domino server to my flash... here is a list of numbers similar to what will be imported....
0, 0, 1, 1, 2, 2, 5, 3, 4, 4, 0, 5, 4, 0, 0, 1, 4, 2, 2, 3, 0, 4, 0, 5, 5, 0, 1, 1, 5, 2, 0, 3, 2, 4, 4, 5, 1, 0, 1, 1, 0, 2, 1, 3, 4, 4, 5, 5, 2, 0, 0, 1, 0, 2, 1, 3, 2, 4, 2, 5, 0, 0, 1, 1, 2, 2, 1, 3, 1, 4, 0, 5
is there any way to import that into an array???
It gets trasfered right now as varialble such as
imported_numbers = 0, 0, 1, 1, 2, 2, 5, 3, 4, 4, 0, 5, 4, 0, 0, 1, 4, 2, 2, 3, 0, 4, 0, 5, 5, 0, 1, 1, 5, 2, 0, 3, 2, 4, 4, 5, 1, 0, 1, 1, 0, 2, 1, 3, 4, 4, 5, 5, 2, 0, 0, 1, 0, 2, 1, 3, 2, 4, 2, 5, 0, 0, 1, 1, 2, 2, 1, 3, 1, 4, 0, 5
but i want to make that work like an array... and
TestingAttempt = new Array(imported_numbers);
does not seem to work... any suggestions
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???
What Is The Maximum _x Value , I Can Use?
Have a sliding MC that holds 15 images that are 780 px wide each.
Comes upto 11700 px when all adds up. Now I know that i can not possibly import and image and give a value more than 2500 to its _value through the PROPERTIES window.
But could I do it by Action Scripting?
Load External JPEG and set the _x value to 11700 ?
Any help is much appreciated.
Thank you
Attachmovieclip Maximum?
Hi guys
It seems to me that there is a maxium of attachmovieclips that Flash is performing.
i've got a movieclip which at a certain frame attaches the same movie to it,parent. when flash reaches to 256 it stops ?? i canot find any documentation on this ??
does any body know something about this??
Find Maximum Value...s
I have 8 input texts (r1,r2...r8) and 3 dynamic texts (max1, max2 and max3). Input can accept only 1 number each and max dynamic boxes should display the maximum values (max1>max2>max3). I have, unsuccessfully, tried "Math.max".
The most logical solution seems to be the development of a set for r-values and when calculating max1 exclude the r-value behind max1 while calculating max2 etc. But how? Any other ideas?
...At the end, what if all values are equall??
Maximum Size
Hello,
i have a flash web site including a main flash movie which calls other small flash movies while the visitor clicks on menu items.
1. What should be the maximum size of the main flash movie?
2. What should be the maximum size of the loaded flash movies?
3. What should be the maximum size of all the movies loaded at same time in the flash player?
4. I am using flash mx and 24fps. Is 24 fps to much?
Thanks,
Miguel
Is There A Maximum Depth?
Howdy freinds.
wondering if there is a maximum depth I can use (ie: for swapDepth(amount)). Because at the moment my game has depths that run like this:
swapDepth((1000*_y) + _x)
that arranges objects so items closer to the bottom are in front and then subdivided by its _x position. so that uses max 6 digits. I wanted to introduce a 7th digit to represent master height (to distinguish between things like doormats and the people standing on them) enough backstory...
soooo when I added a 7th digit (making the depth maximum 9million) and it works fine, with one exception... i cant remove any objects any more where they used to with the 6 digit system.
So-- is depth allowed to go into the millions?
thanks all
Maximum Filesize
Hi guys,
I remember back in the days of flash 4-5 there was a maximum file size that plash would export and the flash player would handle ... is this still the case?
thanks,
nitchy
MC Maximum Size
What are the limits to a MC's size?
I have a scrolling MC with a text field inside. the height is approx 1800px. When I get to the last 300 px or so the content is empty. Even if I manually position the MC on the stage just to see if I can view the end of the text, its blank for the last 300px.
Maximum Browser Help
Hi,
Is there a way when someone opens my MC that it will open my MC to maximum?
Maximum Scaling? Help
Hi there, I wondered if I could get some help regarding formatting of my Flash website. Basically, my website doesn't have a white background, but also has a couple of colours in the background - So inotherwords, if placed on a single colour background (via html colour code) it still looks like a strange block, just like it does when naturally formatted (white background).
I know you can stretch it to fill the entire space, but I don't want to stretch the design, it looks ridiculous. So I want the site to display as large as possible - So, either fully sizes horizontally or vertically depending on the size of the viewer's monitor and web browser, and I'll have a black background - This will leave EITHER two black horizontal bars or two black vertical bars, depending on the monitor settings.
Here is a couple of images of what I mean:
Maximum Frames
hi Friends,
i would like to know how many frames support the Flash cs3
like 10,000 key frames.and how much load we publish swf file?.
anybody knows
i am waiting for the reply
Thanks and Regards
Karthick Raj.S
Textfield Maximum ?
I have a static textfield in Flash that is used in a scrolling effect.
I have noticed that Flash has a maximum of character that it displays. After that certain amount of characters, flash just dosen't display the rest of the text. If you divide the text into different textfield, it's fine.
Of course, the solution would be to use dynamic text. No problem, no limitation of character, but I just wanted to know :
is that a known problem in Flash ? If so, does anyone know what is the maximum amount of characters for a static textfield ?
Maximum Size?
What should be the maximum size of a flash webpage?
Maximum MC Size
Hi everybody,
Just a basic question Does anybody know if the width of a Movie clip can be large, like a long string of text? Im trying a simple horizontal text scrolling from one side of the stage to another, using a simple code. This movie clip is really long (like 3000 px) and any _X value doesnt seem right. Pleeease help
Thanks
Mcs Maximum Width
I have an mc of about 6000px width (it's a row of pictures) and flash display the animation with that mc in an ackward way. With a shorter version the swf works fine.
So can anyone tell me what are the limitations of size (max width and max height) of a mc so flash can handle it correctly?
Thx in advance.
Maximum Limit For XML
Hi Guys,
What is the maximum data limit in KBs we can load from an xml file? Any link would be helpful 2.
Thanks and Regards,
MS
Maximum X/y Coordinate
Is there any limit for x/y coordinate of MovieClip (real question is what is maximum x/y coordinate that MovieClip can have) ?
Thanks,
Zaharije Pasalic
|