Decimal Problems:
I’m having a strange problem with Flash5 actionscript…
All I am trying to do is run some simple math to solve for a percent change, but every time the code runs, it gives me a number with no decimals! Instead of .20668 it gives me 20668 and its pissing me off. Here is the code:
changeinsize = _root.screen._width/(_root.end_x-_root.start_x);
changeinypos = (_root.start_y-_root.screen._y)/_root.screen._height;
changeinxpos = (_root.screen._width/2)/(_root.start_x-_root.screen._x+((_root.end_x-_root.start_x)/2));
And ideas on how to get to output a multiple would be great!
Thanks again,
Dave
FlashKit > Flash Help > Flash ActionScript
Posted on: 11-07-2001, 04:15 AM
View Complete Forum Thread with Replies
Sponsored Links:
Hex To Decimal
is there a function or anything in AS to convert decimal numbers(0-255) to Hexadecimal Numbers(0-FF)?
take a 3 randoms numbers to set the RBG of a MC.
Thanks alot!!!!!!!!!
View Replies !
View Related
Sin, Cos, Tan (in Decimal?)
using my calculator in decimal mode it returns 0.36 if i type tan 20
in flash when i do
Code:
trace(Math.tan(20))
i get 2.23716094422474
ive heard that flash operates in radons or something......... how do i get it to work in decimal????
View Replies !
View Related
Decimal To Hex
SO I'm trying to create a bunch of little blocks that are colored. The colors of the these blocks will increase like a gradient. Odd, but beleive me it's nessecary. Flash likes to use hex color codes. Ok great but how do I increment a hex code? Or even better how do I take a number like 200 for r (r being red) and convert it to hex? Then I could just convert all the 0-255 of each color and paste them together to make the hex code. This is all to be done in code. All automated. That's my issue.
Thanks,
Travis
View Replies !
View Related
2 Decimal Places?
im doing a mathematical calc with variables and i want the answer displayed as £s. How can i ensure that there are two decimal places in the answer so that i dont get an answer of £9.5 etc
cheers
View Replies !
View Related
Decimal To Hex Function?
I need to use the hex code of characters.
I did not find a function like hex(character) or similar in flash 4. Now there is that very clumsy workaround:
1. set up a var table in a var inits frame:
hexDigit0 = "0"
hexDigit1 = "1"
hexDigit2 = "2"
...
hexDigit16 = "F"
2. convert char like this:
n = Ord(char)
h1 = Int(n / 16)
h2 = n - (h1 * 16)
hexChar = Eval("hexDigit" & h1) & Eval("hexDigit" & h2)
It seems to work fine, but i wonder if there is a undocumented function built in with vs 4?
sunday
View Replies !
View Related
Multiply Decimal Only
Hey, here is one for you math guys.
I doing this:
z = _root._currentframe; (let's say I'm on frame 420)
z = z/32
That gives me: 13.125
Now take ONLY the decimal (.125) and multiply by a number (let's say 4)
.125*4 = 0.5
Leaving you with a display number of 13.5
Remember I want to keep the orignal whole number and show it with my new decimal
????
Mike
View Replies !
View Related
Decimal Case
Hi,
I need a problem with dynamic text filds to display decimal cases.
My function is:
function decimal (result) {
final = int(result*100)/100;
var dec = (final-(parseInt(final)));
if (dec == 0) {
final = (String(parseInt(final))+".00");
}
if ((length(dec))<4) {
final = (String(parseInt(final))+"."+(dec*10)+"0");
}
return (final);
}
I have looped objects that re-display the values to text filds, but always when the second case after the "." is zero , the second case is not displayed in the result.
Should someone help me?
thanks
View Replies !
View Related
Decimal Limiter
okey....
How can I limit numberstring to two decimals and show two decimal eaven when their value is 0. And if posible round last desimal to nearest five.
exsample:
123.456 -> 123.45
123.452 -> 123.40
123 -> 123.00
=/
View Replies !
View Related
Decimal Nightmare
I have an input text field where the user needs to enter 3 numbers. As the user enters the numbers I need to have the numbers display as starting from the tenths place and working up. To make this clearer lets say they were to enter "989" when the type the first 9 it needs to appear as .9; then when they type the "8" it needs to be 9.8 and lastly when they type the second 9 it needs to show up as 98.9.
Can anyone help me out, I don't have alot of actionscript experience so you may have to walk me through the code or just provide code that works. THANKS!
View Replies !
View Related
Converting A Hex Value To A Decimal
This is my code. Unfortunately it goes into an infinite loop or something. I dunno. I don't seem to see any problem. Hope someone can help. And thanks in advance.
function hexToDec(temp) {
var output = 0;
var count = 0;
while(temp != 0 || temp != NULL) {
digit = temp.charAt(temp.length - 1);
switch(digit) {
case "A":
digit = 10;
break;
case "B":
digit = 11;
break;
case "C":
digit = 12;
break;
case "D":
digit = 13;
break;
case "E":
digit = 14;
break;
case "F":
digit = 15;
break;
}
temp.slice(0, temp.length - 1);
output += digit * Math.pow(16, count);
}
return output;
}
[Edited by Puppy Chow on 09-06-2002 at 07:55 AM]
View Replies !
View Related
Help Me Set Decimal Precision
I have this file which I am attempting to set decimal precision. Take a look at the ActionSctipt here and tell me why this isn't working. View the URL of the .swf and the .fla
http://web.csuchico.edu/~rp15/CDES270B
//code form a button where yellow and x are dynamic textfields.
//When subtotal reaches 29.5, it should display $29.50, instead it
//renders $29.5.
on (release) {
yellow += 2.95;
subtotal += 2.95;
// test variables initialized
var test = 0;
var test_num = 0;
test_num = subtotal%1;
if (test_num == 0) {
// whole number, append two zeros
subtotal.toString();
x = "$"+subtotal+".00";
} else {
// not a whole number so append one zero
test = (subtotal*100)%2;
if (test == 0) {
subtotal.toString();
x = "$"+subtotal+"0";
} else {
subtotal.toString();
x = "$"+subtotal;
}
}
}
View Replies !
View Related
Decimal Points
i have a dynamic chart that displays values from mathmatical equations from other entered variables. The resulting values are price figures, so i need them to stop at 2 digits to the right of the decimal. how do i do this?
View Replies !
View Related
Decimal Places
Can anybody tell me how to limit the decimal places to 2 in the dyanamic text field? I have given a dynamic field a variable name. and I created a button to change its value by 0.1. But when I click the button the text box shows me many number of decimal places after a point. I want to limit it to 2 places
Thanks
View Replies !
View Related
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
View Replies !
View Related
Decimal Places
im kinda new to flash. Not really but theres a few things i dont know yet.
i dunno if its possible... i know it is in programming languages that are similar to actionscript so i thought it'd give it a shot. Anyway,
im doing some equations and stuff in the action script... like... to figure out the precentage of somehting. the 'thing' is out of 136. So theres 136 possibly points you can get...
Since its such a number, the equation will turn out with a bunch of decimal places
so im asking how i can make it so only one decimal point appears... like 55.3%
???
Please help
Thanks
View Replies !
View Related
Decimal Places
Hello!
I have a dynamic text which displays a number to however many decimal places it can fit in the text box. I'd like to make it show 2 decimal places, can anybody help?
Thanks you
View Replies !
View Related
2 Decimal Places, How?
I want to have a timer, in a game I'm creating.
I want the timer to be in seconds, with 2 decimals all the time! I.e. 41.10 sec. (not 41.1), or 7.00 (not 7). <-- was that an AND/OR error?
Well, how do I tell the "time-variable" to contain 2 decimals in every value?!
View Replies !
View Related
Decimal Places
hey how can i limit the number of decimal places displayed in an output of an equation? my code is for a preloader to show the percentage loaded but i don't want any decimal places...
onClipEvent (load) {
preload = " ";
}
onClipEvent (enterFrame) {
preload = _root.getBytesLoaded() / _root.getBytesTotal()*100 + "%";
if (_root.getBytesTotal() == _root.getBytesLoaded() ) {
preload = "done";
}
}
thanks guys
View Replies !
View Related
Round Off Decimal
I have a variable and a dynamic text box that shows that variable. the only problem is sometimes the variable has a decimal how do i have it os when the variable is say 3.3 it rounds it off giving it the variable of 3?
View Replies !
View Related
Getting Rid Of Decimal Point?
I created a simple calculator here http://www.alamofitness.com/macrocalc.html
I would like to know how to make each result in the 3 bottom fields,
show up as whole numbers instead of decimals. For example, if i enter
3200 calories,60 carb,10 protein, and 30 fat, the amount of fat shows
up as 106.6666667. I would like it to round up to 107
thanks
View Replies !
View Related
Decimal Problem
Hi, I have a movement script which works fine, the only problem is sometimes it results in a decimal which I think slows everything down and causes pixel fonts to look blurry. Is there any code I can add to make it allways end on a full number? My actionscrpiting is a little dusty but I would preseume something like:
if x < 1 and > -1 x = target
Any help would be greatly appreciated.
Code:
onClipEvent (load) {
_root.targIMAGE = 0;
}
onClipEvent (enterFrame) {
cIMAGE = this._x;
difIMAGE = cIMAGE-_root.targIMAGE;
setProperty(this, _x, cIMAGE-(difIMAGE/5));
}
View Replies !
View Related
Decimal Question
I have a variable text field with a number like 123456
and I want flash to be able to display that number as
12:34:56. How do I write actionscript that says for every 2 number slots divide by ":".
Any idea's?
View Replies !
View Related
Animating A Decimal
I have a number that I want to animate from 0 up to a total number.
The number changes everytime the flash file is loaded.
for example it could be something like:
var num:Number=0.45; or
var num:Number=2.12;
Ans so on
The problem is if I do something like
Code:
var num:Number=2.45;
var counter:Number=0.01;
var interval:Number;
interval=setInterval(animateNum,200);
function animateNum():Void{
var newCount=Number(counter=counter+0.01);
trace("newCount = "+newCount);
}
when it reaches 0.10 it shows as 0.1 then when it reaches 0.80 it traces as
newCount = 0.800000000000001.
Also when it reaches 1.00 it shows newCount = 1
How can I get it to always show a count up of 3 numbers or four if it reached
10.34
Thanks,
View Replies !
View Related
Decimal To Binary...?
Hi...
this might be a really dumb question, but isn't there some built-in method in AS3 to convert a decimal number to binary and vice-versa? I can't find it...seems ridiculous to write a method when there must be some C-level code to tap into that would do this much, much faster...
Thanks for any help!
Josh
View Replies !
View Related
Decimal Places...
hello!
i've been given the task of creating an insurance/tax calculator for work despite the fact that i am not a programmer or have the slightest idea how to write code. anyways, after 2 long weeks i've managed to get it working but i'm stuck when i try to display decimal places. basically, i want the numbers to display 2 decimal places and a comma once it reaches the thousands, ex. 1,234.56. i've been searching these forums for some time now and the related threads i have found, i can't seem to make it work with the code i already have. please put me out of my misery by helping me out!!! any help is appreciated.
attached is my flash file.
View Replies !
View Related
How To Return A Decimal Value
the following code:
Code:
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.round(Math.random()*(max-min+1)+(min-.5));
return randomNum;
}
..returns a random integer in between the range specified when triggering the action. now i need to make this number a decimal, i.e.: my return number should be something like '0.7' instead of '7'. how can i accomplish this?
thanks in advance,
- w
View Replies !
View Related
Decimal In Flash
I am trying to create a math presentation. I need to show a limit as it approaches 1. Unfortunately, in my dynamic text box that has the equation to figure the limit, it shows numbers like 2.133984399400 - e^4. I need it to show all the zeroes in the beginning to make the point.
Is there a setting or actionscript that would force it to show all of the decimal places? I have found a ton of tutorials and ideas on how to limit the decimal places, but I need just the opposite. It seems Flash only wants to go up to 10 places.
Thanks for any help you can give.
Natasha
View Replies !
View Related
Cut Decimal Places
Hi,
a perhaps basic question. I am getting some values of variables like 3.1, 3.7, 3.9 etc. Now I want to cut the decimal places to get 3 in this case. Or 2 for 2.0 to 2.9. How can I do this?
Thanks in advance
View Replies !
View Related
Decimal Problem...
value= int((20/7)*10)/10;
1) 2.8
value= int((20/7)*100)/100;
2) 2.85
the value was show correctly...
but
14/7....
it will return 2
how can I make the return value is 2.00
with 2 decima points?
View Replies !
View Related
Fraction To Decimal
Does any Math genius out there know the formula of decimal to fraction conversion including how to apply the fundamental rule of fractions (the fraction should be written in its lowest terms?)
Thanks
P
View Replies !
View Related
To 4 Decimal Points
Ok i'm lost, even though I've asked this before.
I've got my file here http://home.exetel.com.au/twistedpancreas/images/test1.fla , calculating an equation.
But once again I need the answer to be to 4 decimal points (ie like an answer of 0.0393), but for the life of me I can't get it to work.
I tried *100 / 100 but i'm just confusing myself.
Sorry for my lack of knowledge, but i appreciate the help.
View Replies !
View Related
Alpha Decimal Bug AS 2.0?
Hello! I'm working on a photo gallery slideshow loading pictures externally. I have a setInterval to count up/down the "alpha" and up/down the "_x". The "_x" is working fine but the "alpha" only works when set to 25 or 50. I've been running traces on it when set to 5, 10 and 20 and it adds up a decimal value instead of a whole number. Been trying to get it right with Math.round but it wont count correct. Anyone have any idea of what this problem is about? I'll post an example for anyone to please have a look at...
trace returns: 9.765625
Anyone with ideas?
Attach Code
function myFunction(){
this._alpha = 10;
trace(this._alpha);
}
myFunction();
View Replies !
View Related
Decimal Part
if I have this number (or a var) but I only want to keep what is left after the period for example:
1.28 want to keep only .28
23.43 =>.43
45.00=>.00
how do I do that?
Thanks
View Replies !
View Related
Decimal Places
hi,
This might sound stupid..
Does anybody kknow how to restrict the decimal places values in a number?
for example.... if iam doing something like:
var n;
n=100/3;
input.text=n;
In the input textfield i want only 33.33 to appear rather than 33.3333...is there any way to do this, rather than restricting the size of the textfield??
pls help!!!
View Replies !
View Related
Decimal Places
I have asked this before but I think Im a bit slow cos I still dont understand how it works?
on (release){
extras = ((options.abQty*25)+(options.dustQty*9.50) + (options.truckQty * 25) + (options.lightQty*15));
extras.text=extras;
dayVal = day.value;
DayVal = day.value;
rate = Math.ceil(DayVal/7);
costa = rate*storesize.selectedItem.data;
total.text=costa + extras + packingSO.selectedItem.data ;
}
I want total.text to contain a number with 2 decimal places this is a lot harder than I thought it would be? I thought there would just be an option or something like that?
View Replies !
View Related
Integer Or Decimal
How can you tell rfom a variable if the number it is holding is a whole number or its holding a decimal number
ActionScript Code:
var num=55.234;
How can I check to see if variable num is 55.234 or if it is 55
View Replies !
View Related
AS3 Decimal Precision
Well I'm having a little problem with decimal in as3. Here's what I'm trying to do :
ActionScript Code:
var p:Number = 0;addEventListener(Event.ENTER_FRAME, mainLoop);function mainLoop(evt:Event){p+= 0.1;trace(p);}
And I get those weird results :
0.1
0.2
0.30000000000000004
0.4
0.5
0.6
0.7
0.7999999999999999
0.8999999999999999
0.9999999999999999
1.0999999999999999
In AS2, no problem, I get the right incrementation. Also, doing this in AS3 works well too:
ActionScript Code:
var p:Number = 0;addEventListener(Event.ENTER_FRAME, mainLoop);function mainLoop(evt:Event){p+= 1;trace(p/100);}
Any idea why this is happening?
View Replies !
View Related
_x & _yscale To Decimal?
Title says it all. Is there a known way to have _xscale and or _yscale show as if it was say 25% have it show .25, and if it's a 100% it's shows 1??
I leave this dastardly mined defining Epiphany to you my fellow kirupaian
View Replies !
View Related
How To Represent Decimal No.
As we all know in flash,
Number('077') = 63 coz it treats it as octal if you start your no. with one zero.
Number('0011') = 9, binary for the numbers starting with 2 zeroes.
Number('0XFF') = 255, hex for the numbers starting with 0x.
Is there any way to specifically tell flash to consider the number to be decimal only?
View Replies !
View Related
How To Represent Decimal No.
As we all know in flash,
Number('077') = 63 coz it treats it as octal if you start your no. with one zero.
Number('0011') = 9, binary for the numbers starting with 2 zeroes.
Number('0XFF') = 255, hex for the numbers starting with 0x.
Is there any way to specifically tell flash to consider the number to be decimal only?
View Replies !
View Related
Decimal Places
hi,
This might sound stupid..
Does anybody kknow how to restrict the decimal places values in a number?
for example.... if iam doing something like:
var n;
n=100/3;
input.text=n;
In the input textfield i want only 33.33 to appear rather than 33.3333...is there any way to do this, rather than restricting the size of the textfield??
pls help!!!
View Replies !
View Related
|