ActionScript 3.0 :: Round Off Decimals Easily?
Aug 14, 2007As the title, is there a class method in Flash to limit and round of a number's decimals ?Like :roundToTwoDecimals(1.2362 ) = 1.24
View 8 RepliesAs the title, is there a class method in Flash to limit and round of a number's decimals ?Like :roundToTwoDecimals(1.2362 ) = 1.24
View 8 RepliesI've this problem with rounding up. My problem is more complex than i describe here but I'm sure i can figure out the rest myself once I got this working. I want flash to round up with two decimals at all time.
[Code]....
This one seems though, as there isn't even a regular "round-to-specific-decimal" function.. (I know the work around for that though)[code]...
View 2 RepliesI'm making a canadian tax calculator - and it all works BUT I need it to check the fields and if they're blank, make it process it as zero. ALSO, I've now discovered I need to make the fields display as money would. Is it possible to make the fields only show two decimal points, put a comma in (like --> 2,546.00) and have it everytime show two zeros (sometimes it displays as this --> 26.0 instead of 26.00. At the *least* I need it to show 26.0 >> like this ...26.00
View 1 Replieshow do you round a number to 4 digits... so 3.45356345345 is 3.456 and 1 is 1.000
View 5 RepliesI have a text field that displays a number from a variable. How can I make it so this number is always formatted to 2 decimal places?
For example, 1 would be changed to 1.00 and 1.5 would be 1.50, etc.
I know how to remove all decimals with:
ActionScript Code:
Math.round (xTwo*0.39);
But, how do I keep 1 or 2 decimals?
Can I use a decimal in a variable name in AS2? I need to create a variable named SCC.Q2.
View 4 RepliesRecently I share some videos in my blog: keyfun.wordpress, clarify how to convert ppt to flash easily with effect samples. Or you can visit [URL].
View 2 RepliesI have made a class for handling colors with decimals.It's not really impressive i think, but i made it because i needed something like this in my game: in the normal interpolateColor function of Color if you do: color1: 0xFFFFFE color2 0xFFFFFF and progress = 0.8, then the tint will be 0xFFFFFF, whereas with my class it will be 0xFFFFFE, and store a value of 0.8 for blue, so that the next time it is interpolated, that 0.8 will be taken into account.it then only needs a 0.2 to jump to 0xFFFFFF.Look especially at the last function, thats what the class is about.[code]....
View 2 RepliesIn AS3, from a division I get a number like this one: 0.9130406010219044.Is there any way to reduce the number of decimals (aside from multiplying that number for one million)? Is there a way to reduce the numbers BEFORE the division is performed?
View 5 RepliesOne more thing that I need for my calculator:
how do I turn the decimals into whole numbers if the number is:
10.56 I want my number to be 11
10.49 I want my number to be 10
these numbers are inside an input field.
I'm trying to do a pretty simple modulo equation but i'm getting a weird return.0.03 % 0.01I was expecting there to be no remainder, so the answer would be 0. However the return flash gives me is: 0.009999999999999998If I bump everything up to whole Numbers it works just fine: 3 % 1 = 0However I know eventually I'll be doing something like 3.4 % 1 and I'm concerned that at that point I'll run into this same issue.
View 4 RepliesI really want to attempt in making my own game kind of like Farmville. I know most of the actionscript, but I do not understand how they make the artwork. I try to make those isometric art in photoshop and stuff, but it's almost impossible for me. I use a tablet.So I'm wondering how do so many people make that art work so easily?
View 1 Repliesi have a basic xml file which im able to load externally easily using :
Code:
private function loadXMLFile():void
{
[code]........
I'm working on some banners in various sizes and I noticed that I can only enter a font size in full pixels but not in decimals. I can type them in but noting happens to the size.
View 1 Replieswhy it is not simple! i just want to restrict input text to allow only number with 2
[Code]...
how can i make it with actionscript 2.0 ?
I wonder if there's a more straightforward way to achieve this.[code]...
View 3 RepliesI have a issue.. I want to display the score as a whole number without decimals, anyone know how this can be done?
the relevant code:
ActionScript Code:
public static const SCORE_PER_APPLE:Number = 1;
public static const SCORE_MULTIPLIER:Number = 1;
private var score:Number;
[Code].....
So yeah.. it displays every decimal. Is there a way to round up the numbers, or not displaying anything less than a whole number?
Is there a good tool can asily download SWF files from internet?
View 2 RepliesI am using FlashDevelop and Flex SDK, I use this to embed things on the swf:[code]Now, I would like to embed more than 100 files (or maybe more!), and doing this one bye one will take long and will be very exhausting Is there any easy way to that easily?
View 1 RepliesI faced a strange problem today while adding some decimal number in AS3. I have simply adding trace(1.025 + 0.025); statment. It didn't returned proper output i.e. 1.05., instead it has given as 1.0499999999999998.
know the reason behind this. Actually we are calculating some angle and leng in geometric function.And we are getting some diffrence in calculation.
Two questions concerning the numericStepper component and I think they both have to do with how to access the textfield part of the component.
1. How do you change the color of the textfield border in the numericStepper component.
2. I'm using the numericStepper to step up/down by increments of .25 (25 cents) and would like it to always show 2 decimals. But when it reaches a whole number (like 25) it will not show the 2 decimals. Do I treat this like a textfield to force the text to have 2 decimals? And if so, how do I access the .text?
An onLoadProgress listener object is returning a variable I am using to tell the user what percentage of the movie has been loaded. I am happy with the results of
Code:
myListener.onLoadProgress = function(empty10MC:MovieClip, loaded:Number, total:Number):Void{
//setText();
var percent:Number = loaded/total*100;
loadingTxt.text = beginTxt + percent + endTxt;
however the number returned is like 15 digits long! Is there any way I can limit the variable to display only 1 or 2 decimal places?
so I'd like to get some input on how exactly to go about coding this thing in the most efficient manner..i have 4 portfolio galleries im trying to display (web design branding motion)and the thumbnails for each of my projects are going to be displayed on a grid of 50x50px squares.id like to dynamically populate these 50x50 squares with thumbnails pulled from a folder and then populated into the grid sequentially then when an individual square is clicked have a full size version of the image (also pulled from the folder) populated in the same manner.
View 1 RepliesJust about all the screens require the text to be set to dynamic text and have character embedding set to basic latin(95 glyph) The problem is that because the project is so big and has so many dynamic text boxs the publishing time is really starting to slow down.
I dont mind if it doesnt embed that fonts while im publishing for debugging. I just need it to publish with the glyphs when im showing it to the client.
Can embedding be set by code?
If it is i could just take some time out to set my dynamic text boxs to look at a specific class or somthing?
Or Am i missing a propertys overright button somewhere that will switch embeding off through out the project when I need to?
Lets say I have an array which has n dimensions. Now in order to access a slot you typically use: array [1][0]What if the number of dimensions are not known at compile-time, is there an easy access like:
slot = "1,0"
array [slot] // accessing 1,0
Which means I can also easily navigate back and forth
[code]....
Let me first say that the project I am working with was my first foray into AS3 as well as OOP. I wanted to be a grown up so I wanted to use classes and not rely on individual swfs.Unfortunately, I didnt quite understand the spirit of OOP, or at least I dont think I did, and I made each section of the site into a separate class. I then integrated the classes and their library materials into one large project. The thing works great - but unfortunately the file has gotten too big.What is the most straightforward way to now break this project back up? Do I need to load in external swfs
View 0 RepliesI have a massive json object that I return from my php script. The object holds strings as well as variables that are of type php associative array. When i trace my json object it's totally not formatted and not readable by human. However If I use a free online json formatter, it looks good. My question is if there is an easy way to trace out all properties and their contents in an easily readable way using as3?
View 2 RepliesI'm currently working on side scroller that has an isometric-type perspective (think Double Dragon) and the only thing I could think of to use to easily manage the depths of the MCs was a bubbleSorting algorithm. (It seemed to lend itself well to the swapChildren command).
[Code]...