ActionScript 3.0 :: Get Decimal Part As Whole Number?
Jun 27, 2011
I want to get decimal part of the number in this case 67 (number = 67 ) First problem is internal calculations
ActionScript Code:
var number:Number = 987123456.67;
var intNum:Number = Math.floor(number);
var decimal = parseFloat(String(number - intNum));
trace(decimal); //outputs 0.6699999570846558, instead of 0.67
I wonder is there a any way to doit besides using toString?
View 9 Replies
Similar Posts:
Jan 20, 2006
there is any method to check if a number is a decimal number or not? i searched in the help-panel, but didn't found something.
View 6 Replies
Oct 14, 2009
I've a regex that matches comma separated numbers with an optional two digit decimal part in a given multiline text.
/(?<=s|^)d{1,3}(,d{3})*(.d{2})?(?=s|$)/m
It matches strings like 1, 12, 12.34, 12,345.67 etc successfully. How can I modify it to match a number with only the decimal part like .23?
EDIT: Just to clarify - I would like to modify the regex so that it matches 12, 12.34 and .34
And I am looking for 'stand alone' valid numbers. i.e., number-strings whose boundaries are either white space or start/end of line/string.
View 3 Replies
Mar 28, 2011
If I take a swf, and run it through swfdump
swfdump.exe -abc file.swf > ABC.txt
One the first run I may get some output in ABC.txt like this
ObjectConfig.as$60
And on a subsequent run of the same SWF get a different output
ObjectConfig.as$61
What is the meaning of the number after the $ ?
View 1 Replies
Nov 16, 2009
i have value of have long number after decimal. Now, I want to control in 3 digit after decimal. How could i do.
View 1 Replies
Nov 16, 2009
here i have value of have long number after decimal. Now, I want to control in 3 digit after decimal. How could i do
Ex:
Problem = 9.982540214587
Want = 9.982
View 3 Replies
Mar 22, 2012
I'm making a game where you level up, and then the amount of EXP you need to level up, gets higher. The problem is, if I have it so the amount of EXP needed to get to the next level just multiply by 2, it just gets to an absurdly high number, and I don't want that. I would rather have it multiply by 1.3 or 1.5, but the problem with that is that the right side of the decimal gets all ugly to something like "60.54902380".
how would I be able to round it so there's no decimal point, or at best just one number to the right?
View 2 Replies
Aug 27, 2005
how do you set a number to 2 decimal places??
View 7 Replies
Sep 12, 2006
How can I round off a decimal number upto say three decimal places? The number comes as an output value like 0.98765e^7 for the statement outputvalue = 0.8678/InputValue. How can I make the output value rounded off as 0.988e^7?
View 7 Replies
Feb 22, 2010
I want to get rounded number
Example:
I want to get full number I write
Code:
cas=15.02
int(cas)
and I get 15
But when I write these
Code:
cas=15.02
lol=cas - int(cas)
trace(lol)
I get 0.0199999999999996 instead of 0.02. I need to get only decimals so that i will be able to write 15.02 like 15:02 or 1.2 like 01:20. I need to write numbers like in digital clock.
View 8 Replies
Sep 13, 2008
I am totally confused about this one. I am trying to display a number as x.xx, but I'm having problems! The number has 0, 1 or 2 decimal places, so I have an if else to add '0' or '.00' on the end if there are 1 or 0 decimal places respectively.[code]...
View 3 Replies
Feb 13, 2012
why does this not work for counting the number of decimals?
Code:
var num:Number = 4.321;
counter=0
while (num%1!=0) {
[Code]....
View 0 Replies
Jan 12, 2004
what actionscript do i need to round off a number to 2 decimal points? i have this script which brings me the number but consisting of 8 digits!
digital = _root.val[0].substr(0,_root.val[0].indexOf("<br>"));
digital = Math.abs(digital);
trace(digital);
[Code].....
View 1 Replies
Sep 12, 2004
how I can format numbers in Flash so that it will show two decimal places regardless of the number itself?
View 4 Replies
Aug 30, 2005
I'm trying to calculate loan payments using actionscript.
i'd like to have my variable's value like this:
843.34
instead of:
843.3454 (how it's displaying now)
since I'm ultimately going to display $dollar amounts.
I know how to use Math.round() but I'd like to go to two decimal places!
View 1 Replies
Jan 3, 2004
What is the Math.???? for making a number always have 2 decimal places?
View 5 Replies
Nov 22, 2010
I have tried and tried but i cannot get a number to force show 2 decimal places.I have lots of different buttons and selection boxes that output a different value for 'sizePrice' and 'effectPrize'. An example can be seen below:
Code:
if (sizeSelectionBox.value=="size1") {
sizePrice=67.20;
calcTotalPrice();
[code]...
I need totalCost to always show 2 decimal places so if it is 60 it needs to say 60.00, if it is 67.2 it needs to say 67.20
View 4 Replies
Mar 2, 2011
I looked everywhere on the internet and couldnt find how to generate a random number that had one decimal place.I am trying to generate numbers between 12.0 and 13.0 randomly.Below is my code... I know its wrong because of Math.round and Math.random, but i cant seem to find anything that deals with a decimal place.
addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_1);
function fl_EnterFrameHandler_1(event:Event):void{volt.text = Math.round(Math.random()*(1)+12).toString();}
[code].....
View 3 Replies
Jan 16, 2012
I have the following NumericStepper:
<s:NumericStepper id="estimertTidCell" value="{isNaN(hostComponent.estimertTid)?0:hostComponent.estimertTid}" stepSize="0.5" maximum="5" change="hostComponent.estimertTid=estimertTidCell.value"/>
When i set the value to e.g. 1.5 through the NumericStepper and store the value, the alert in the following code correctly displays 1.5:
private var _estimertTid:Number;
[Bindable]
public function get estimertTid():Number {
[code]....
Problem: My problem is that once the NumericStepper refreshes, or reloads the variable, it displays 2 instead of 1.5, or 4 instead of 3.5 etc. Anyone got any ideas of what is causing this behavior? I would think that by setting the stepSize=0.5 it would correctly display those decimal numbers.Additional information: When i display the same variable in a spark Label, the value is correctly displayed as a decimal number.
View 1 Replies
Jul 3, 2009
I am rather new to actionscript and having some trouble. My goal is to make a app where the user enters a decimal number and the number of decimal places and the output is displayed in a dynamic text box. Here's what I have so far:
ActionScript Code:
go_btn.addEventListener(MouseEvent.CLICK,Display);
function round(num:Number, dp:int):Number {
var decimal:Number = Math.pow(10, dp);
trace(Math.round(decimals * num) / decimal)
[Code]...
View 1 Replies
Jul 21, 2010
I've got a calculator that i created in as2 that converts different units of measurement. However, right now it always converts the numbers into a decimal number like 0.33333333 or 450.72. How in the world would i convert these decimal numbers to scientific notation? For example, say i have a number: 12,700. Expressed in scientific notation, this would be 1.27x10^4.I hope there is an easy way to make flash convert to such a number system? I know its easy to round numbers in decimal, but have never worked with scientific notation before.
View 9 Replies
Nov 22, 2010
I have tried and tried but i cannot get a number to force show 2 decimal places.
I have lots of different buttons and selection boxes that output a different value for 'sizePrice' and 'effectPrize'. An example can be seen below:
Code:
if (sizeSelectionBox.value=="size1") {
sizePrice=67.20;
calcTotalPrice();
[Code]....
I need totalCost to always show 2 decimal places so if it is 60 it needs to say 60.00, if it is 67.2 it needs to say 67.20
I thought the *100/100 should do it but its no
View 2 Replies
Jan 14, 2010
making my number value to 2 decimal places...
I have 2 string that contain a number in dynamic text (pricing_txt /pricing_txt2) that i have turned into numbers (myNumber/myNumber2). I then have a calculation that adds these two together and i need the result to be 2 decimal places long.
I have used the code
Code:
("number"*100)/100
which from looking on mny sites should solve the problem but it is still not working. My code is below...
Code:
var myString:String = pricing_txt.text;
var myString2:String = pricing2_txt.text;
var myNumber:Number = Number(myString);
[Code].....
View 1 Replies
Jan 14, 2010
I am having some problems making my number value to 2 decimal places...
I have 2 string that contain a number in dynamic text (pricing_txt /pricing_txt2) that i have turned into numbers (myNumber/myNumber2). I then have a calculation that adds these two together and i need the result to be 2 decimal places long.
I have used the code
Code:
("number"*100)/100
which from looking on mny sites should solve the problem but it is still not working. My code is below...
Code:
var myString:String = pricing_txt.text;
var myString2:String = pricing2_txt.text;
var myNumber:Number = Number(myString);
[Code].....
View 1 Replies
Mar 7, 2007
I have a Number type variable that is outputting as 3.46666666 I want it to round it up to 1 decimal place i.e., 3.6 so I can display it in a text field what do I do any ideas?
View 2 Replies
Dec 31, 2011
I am converting a number to string
var myResult : Number = 12.6789345
var myString : String ;
myString = String (myResult);
I am trying to search . (decimal point)
if ( myString.search("."){
}
But I am unable to get Result or unable to find " DOT ".
View 3 Replies
Jan 9, 2010
I am making a flash game for a school project, and I decided to make a stick fighting game.once the enemy attacks the player their health just drains. The only way I can fix it is if I have a decimal instead of a whole number, but I have the variable of the health in a text box to display the players current health and it doesn't look to good with a decimal number.So, I am wondering if there is a way to make the health decrease by a decimal, but show a whole number in the textbox.[code]
View 2 Replies
Nov 1, 2011
I have colour values from a Flash application that are ARGB format(A being the alpha/transparency value). I have to convert that long decimal number to a RGB/Hexadecimal number in Javascript. Do you know how I can extract the individual R, G, B & A values from a long(8 digit) number? Here's my function which converts a number to hexadecimal BUT its not good enough because it needs to convert the values individually(R,G,B,A):
[Code]....
View 2 Replies
Feb 18, 2009
How can I get only the integer part of a Number ?
3,14125 -> 3
View 1 Replies
Mar 9, 2011
Ok perhaps ive bitten off too much here...I know you are not supposed to parse xml/html to regex but the thing is there just arent many other options.Im using AS3.im parsing the source of textflowlayout text to a different format.
string to parse :
< fontFamily=Verdana encoding=unicode fontWeight="bold"> some text < fontFamily=Verdana encoding=unicode > some text < fontFamily=Arial encoding=unicode fontStyle="italic"> some text < fontFamily=Arial encoding=unicode fontWeight="bold" fontStyle="italic"> some text
what i really need is:
< fontname=Verdanabold encoding=unicode> some text < fontname=Verdana encoding=unicode > some text < fontname=Arialitalic encoding=unicode > some text < fontname=Arialbolditalic encoding=unicode > some text
logically i think of it as taking apart the string into substrings
checking if there are fontWeight or fontStyle in the substring
if there is then appending the font name with the weight or style so so that the font name becomes font NameWeightStyle.then rebuilding the string.The font could be any font with variouse styles or weights..so far:
pattern = /<(.*?)>/gixsm;
var matches:Object = pattern.exec(str);
var finalstring:String = "";[code]...........
View 1 Replies