Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








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!




KirupaForum > Flash > ActionScript 3.0
Posted on: 12-03-2007, 12:20 AM


View Complete Forum Thread with Replies

Sponsored Links:

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!!

View Replies !    View Related
Setting The Length Of Decimals (after Decimal Point)
Howdi guys.
Watching big brother Final are we all?

Anyway, I have a simple question here. How do you round a variable number off to a certain amount of points? I already know how to round it off to a whole number.

Thanx a million in advance.

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
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:

View Replies !    View Related
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

View Replies !    View Related
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)

View Replies !    View Related
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

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
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

View Replies !    View Related
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!!

View Replies !    View Related
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!

View Replies !    View Related
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

View Replies !    View Related
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

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
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?

View Replies !    View Related
_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.

View Replies !    View Related
Decimal Point Problem
Iam in the process of building an eshop and have a small prob with my sub_total text box, when you add item to cart at a value of 3.90 my sub_total text box shows it as 3.9 missing the zero, can any one help

Ive enclosed a sample of the coding Iam using.

Tar in advance.......

View Replies !    View Related
AS2.0 Printing Decimal Point
hello,

as in C++ you may find a keyword called fixed and showpoint. i was wondering if anyone knows what this keywords would be in AS2.0?

these two keywords basically allow to you to set a decimal point in numbers when printing or output.

i know AS2.0 has the floatparcer method, but that is not quite what i am looking for,cuz i want it to stop at the .00 place.

thank you
Hector

View Replies !    View Related
Decimal Point Question
I have created an dynamic text box that I want to use to display a number based on a calculation. The number that I want to display must be in dollars and cents (0.00). The calculation that I have created works fine, but it rounds off to the tenths place (0.0). What can I do to extend it to include the hundredths place?

Thanks!

View Replies !    View Related
Decimal Point Issue
Hi, i have a preloader that calculates the % loaded. Simple, but i am getting a % number with multiple decimal points, i would like it to just show full integers or maybe 1 decimal. Can anyone revise my code (below) to do this.
that would be great, thanks alot

mark

function navReleaseFcn () {
this.onEnterFrame = function () {
percentage = top.getBytesLoaded()/top.getBytesTotal() * 100;
preloader.text = percentage + '%';
if (percentage == 100 && this.getBytesLoaded() > 100) {
onEnterFrame = false;
}
}
}

View Replies !    View Related
Decimal Point Madness
Just a small thing.

I'm doing alot of AS sprite movements and the velocity values I get are stretching to 14 decimal points.

Does anyone know whether this has any impact on performance? Looking at the sheer number of characters runing down my output window, I think it might when I have lots of sprites moving around.

Then again, if I run a function reducing the number of decimals, then that will probably have more impact on performance! Or would it?


ActionScript Code:
function reduceDec(num):Number {
    var myNum:Number = Math.round(num*100)/100;
    return myNum;
}

View Replies !    View Related
[AS] Show The Decimal Point
Morning all!

I hoping this can be solved quite simply :

How can the decimal point be made to show within a variable?
ie. 21.456 - the point shows when the variable is traced via output but within the movie the point is removed.

Does anyone know a simple way to show this point??

Thanks in advance,
Mutley

View Replies !    View Related
Decimal Point Display Not Working.. Why Why?
i am using flash5.

why is it that in debug mode or test mode the decimal points are displayed correctly but in the swf file displayed values do not have the decimal values.

what i am trying to do..
flash file has a draggable slider where the _x value is used to calculate a value which is display on screen using

e.g.
if (int(slider._x+0)>100) {
_root[_name+"slider"] = 30.0;
} else {
bmix = (Math.round((slider._x*10)+1000, 4)/10)+30.0;
_root[_name + "slider"] = (Math.round((slider._x*100)+10000, 5)/100)+30.0;
_root["bmi"] = (bmix/(_root["yslider"]*_root["yslider"]))
}

where _name+"slider" is displayed on screen using a variable with this name.

View Replies !    View Related
Eliminating A Zero Behind A Decimal Point (using Function)
I have a dynamic text box that displays the sum of variables formated in currency form ($77,777.777). Script is in a function.

Sometimes I need to show answers that are in the thousandths.
That's why I have three spaces after the decimal point, but some answers don't need the 3rd place behind the decimal point.
ex: $1,540.890 should display as $1,540.89

How would I eliminate this zero while retaining the thousandths spot for answears that need it?

Here's my code:

function FormatAsDollars (amount, isCents) {
if (isNan(amount)) {
return "0";
}

if (isCents != "isCents") {
amount = amount*1000;
amount = Math.round(amount);
}
amount = String(Math.floor(amount));

if (amount.length == 1) {
return ("0.0"+amount);
}

if (amount.length == 2) {
return ("0."+amount);
}

if (amount.length == 3) {
return ("0."+amount);
}

cents = amount.slice(-3);
amount = amount.substring(0, amount.length-3);

dollars = [];
do {
dollars.push(amount.slice(-3));
amount = amount.substring(0, amount.length-3);
} while (amount.length>3);

if (amount.length) {
dollars.push(amount);
}

return (dollars.join()+"."+cents);
}

// Thanks,
// Pooglins

View Replies !    View Related
Adding A Zero After Decimal Point In Totals?
Hi, new here so sorry if this is a very basic question.

I'm making a money-bank game where coins get dragged across to the piggy-bank and the total is displayed throughout.

My problem is that, if say the amount is 10p, it is displayed as 0.1 rather than 0.10, or 1.1 for £1.10 etc. It would be great if I could get something to recognise those situations - adding 0 to make 0.10 - but not, say, to make 11p into 0.110.

I put in some seriously clunky code which checked if the amount was a specific number (such as 0.1, 0.2, 0.3 etc) and told it to add a 0 on, but I'm sure there must be a simpler way of doing this? Specifically to maybe try and get it to only scan the number AFTER the decimal point and if there's only 1 number there, then add a 0 on afterwards to display the correct amount.

I have a vague feeling it might have something to do with charAt(), but I'm not sure - it's not something I've looked at before. So any suggestions/help would be really appreciated.

View Replies !    View Related
Evaluate The Decimal Point Of An Interger
Hey all,

I need to evaluate the decimal point of an interger (bet u wouldn't of guessed that from the title eh?!)

So, im reading in XML for a thumbnail viewer, the viewer displays 5 thumbs per "page" so, i divide the total number of thumbs by 5.

Then i need to evaluate the number if it dosn't have a decimal point (ie, the total divides by 5 exactly) then that is the number of pages i need.

Then if the number does have a decimal 12.2, for instance i need to strip the 2. leaving 12, and then add one so the 2 images left go onto a new page.

Hope you can understand my ramblings.

Cheers in advance. Andy.

View Replies !    View Related
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

View Replies !    View Related
How In Tarnations Do I Get Bytes Loaded With Decimal Point?
I have a preloader with a little byte counter in it.
It works great!
But, how do I also include a decimal point & numbers following?

Here's what I have for the actionscript for the first frame.

total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
ifFrameLoaded ("ftp") {
}

Thanks,
~senior pooglins

View Replies !    View Related
Generate A Random Number, To A Certain Decimal Point
Howdy is there anyway to generate a random number (within a range), to a certain decimal point and then display it in a text box?

I know how to do a full number, but am struggling to find out how you get random numbers with decimals.

Thanks in advance.

View Replies !    View Related
Generate A Random Number, To A Certain Decimal Point
Howdy is there anyway to generate a random number (within a range), to a certain decimal point and then display it in a text box?

I know how to do a full number, but am struggling to find out how you get random numbers with decimals.

Thanks in advance.

View Replies !    View Related
Input Box Comma To Decimal Point Change Help
Ok i got an input box when the user enters a money value i.e. 3.00 or 3,00 i need the comma symbol to be converted into a decimal symbol , how can i write a check for the comma and how can i convert it to a decimal point and put the result back into the text box so its instant as soon as a , is entered.

View Replies !    View Related
Formating A Dynamic Text Box--Decimal Setting To 2
I am trying to format a dynamic text box to 2 decimal places. Can anyone help?

View Replies !    View Related
Setting Reg Point?
I have this code for creating a border around images. (partly from the huge thread on resizeBorder here at Kirupa). The image is loading into a containerMC and that I can align top left, but this code I dont know how to align? Anyone?


Code:
//creating the border:
this.createEmptyMovieClip('border', 3);
with (_root.border) {
lineStyle(0.1, 0x999999);
_x = 100;
_y = 100;
beginFill();
moveTo(-100, -100);
lineTo(100, -100);
lineTo(100, 100);
lineTo(-100, 100);
lineTo(-100, -100);
endFill();
}

View Replies !    View Related
Setting Registration Point On The Fly
How do you set the registration point of a movieclip created using createEmptyMovieClip()? It seems it defaults to the top left hand corner - and I want it in the centre.... Is there a way to do this?


Cheers

View Replies !    View Related
[F8] Setting The Registration Point?
Okay - I want to make a cartoon. I have a few movie clip symbols (running cycle, jumping up and down and waving). I want to swap them at keyframes.

However, one of the clips has a registration point (the little plus icon) WAAAAY far from it... so when I swap it with another symbol, my character jumps far away.

How do you move the registration point? I have not been able to find a solution and it's making me nuts!!!!

View Replies !    View Related
Setting The Registration Point
How do you change the registration point of a TextField or MovieClip?
Suppose you want to Twin a zoom in, I need it to happen from the middle, but I found no methods or properties that let you set it in the center.

thanx
Sil

View Replies !    View Related
Setting An Anchor Point
Is it possible to set an anchor point when animating? I have attached the fla which demonstrated what I am doing. Instead of resizing from the centre, I would like the top line of the box to be fixed in one place (at the top of the screen, because this box will eventually be the outline of a webpage).

I hope this makes sense.

View Replies !    View Related
Setting The Rotation Point
i'm working on a flash game at the moment, and i would like to know if i am able to set the point that the movieclip rotates around using actionscript.

i don't want to do it by simply moving all of the contents of the movieclip closer or nearer. is there any other way of doing it? i couldn't find any simple functions for it. am i just going to have to use some complicated maths?

thanks in advance

[edit] rotation point, aka, registration point.[/edit]

View Replies !    View Related
Setting The Rotation Point
i'm working on a flash game at the moment, and i would like to know if i am able to set the point that the movieclip rotates around using actionscript.

i don't want to do it by simply moving all of the contents of the movieclip closer or nearer. is there any other way of doing it? i couldn't find any simple functions for it. am i just going to have to use some complicated maths?

thanks in advance

[edit] rotation point, aka, registration point.[/edit]

View Replies !    View Related
Setting The Properties Of An Object At A Point?
Is it possible to say in actionscript:

Change the alpha value of the movie clip which resides at point 50, 40?

If so, tell me how.. It would make my life ten times easier.

View Replies !    View Related
Setting The Rotation Point In Actionscript
is there a way to specify the rotation point of a movie clip with actionscript? i tried doing it manually but it didnt work in the published version. if there is i would appreciate someone telling me the code

View Replies !    View Related
Setting An Object Point Of Reference?
Hi,

I am a Flash developer for a while, but there is an annoying thing that ever bugged me, and I would like to know if there is a way to detour that.

How to set the registration point of an object (say a mc) through AS?

Thank you!

View Replies !    View Related
Dynamically Setting Transformation Point
Hi,

I have a blank movieclip and actionscript loads a jpeg into it. Right now, when the jpeg is loaded in, the registration and transformation point is located on the top left corner of the image. This seems to be the default.

I'd like to keep the registration point in the top left corner of the image but I want to move the transformation point to the center of the image. I need to do this using actionscript as everything is dynamically created and set.

Is this possible and how do I go about doing this?

If this isn't possible, how do I go about loading a jpeg into a movieclip and setting both the registration and transformation point to dead center?

Please help.

Thanks.

View Replies !    View Related
Setting Registration Point Using Attachmovie
how do you set the registration point when adding a movie using attachmovie.

i have a small animation that animates round its registration point that is in the centre. however when i add it to my movie useing attachmovie its registration point is top left and spils the effect.

Hambo

View Replies !    View Related
Dynamically Setting Registration Point
hey everyone,

how can i load a jpeg into a dynamically created movie clip and have the registration point be in the center of the enclosing movieclip?


all the best,

miledugo

View Replies !    View Related
Setting Registration Point Dynamically
Hi peeps,

I was wondering if setting the registration point for display objects was possible during run-time. The documentation calls it "..the origin (0, 0 coordinate) of its coordinate space " but other than setting it in the IDE when creating library items I wouldn't know what property to set (or method to call) .

Also noticed something funny...if you assign a value type other than string(sounds logical at first) to a textField.text property the compiler throws an error. Like :

var nNumber:Number = 0;
var tTextField:TextField = new TextField();
//addChild(tTextField);
//setChildIndex(tTextField, numChildren -1);

tTextField.text = nNumber; // This throws error
"1067: Implicit coercion of a value of type Number to an unrelated type String."

tTextField.text = "" + nNumber;
tTextField.text = nNumber + "";
tTextField.text = nNumber.toString(); //These compile just fine

So adding an empty string before or after will compile. It must be I'm missing something or... I just smoke too much these days. I may be high right now...

View Replies !    View Related
Setting Registration Point Of Dynamic Movieclip
Hi All,

I have created one dynamic movie clip. I have loaded one image in it.
I want to rotate that image. it is rotating nicely. But the problem is the center for rotation. So i want to set registration point of that image to center.
But i dont know how to set the registration point of a movie clip dynamically.
I am using AS2.
Any help would be appreciable.
Thanks In Advance...

View Replies !    View Related
Attach Movie.... Setting Center Point..
how do i use attach movie and then set the center points to be the same as the movie i am attaching to??


(i know how to do attachmovie it is the positioning that i dont know how to work)

HELP

thanks

View Replies !    View Related
Setting The Starting Point Of A Sliding Menubar
hi everyone>

i'm building a site with a horizontal sliding menu not unlike the one shown in the "add thumbnails" tutorial. the one that i'm building involves a row of generated movieclips to be placed inside a parent called "displayarea", and "displayarea" needs to line up starting at a point in the middle (for now, it's hard-coded as the negative _x value of a generated movieclip called "menu15" --see below).

my problem is: the way it's displayed using the code below, when the user mouses out of the area that activates the scrolling, the movie clip "displayarea" always snaps back to the original _x position.

how can i set the starting _x position of "displayarea", and tell the code to only use it as a starting point, and the scrolling will take over once the clip has loaded?

i've attached the swf so you can have a look at the problem.

<--this code is attached to the first frame of the timeline that contains "displayarea"-->

alignPoint = getProperty(displayarea.menu15, _x);
reelPos = displayarea._x;
displayarea._x = -alignPoint;

if (_ymouse>-150) {
if (_ymouse<0) {
if (_xmouse<-400) {
if (displayarea.hitTest (hitLeft)) {
reelSpeed = (_xmouse-center)/15;
reelPos = Math.round (reelPos-reelSpeed);
displayarea._x = reelPos;
}
}
else if (_xmouse>400) {
if (displayarea.hitTest (hitRight)) {
reelSpeed = (_xmouse-center)/15;
reelPos = Math.round (reelPos-reelSpeed);
displayarea._x = reelPos;
}
}
}
}

<--end code-->

thanks in advance for your help!

View Replies !    View Related
Setting The Registration Point Of A Movie Clip (with Actionscript)
I am making a photo viewing app that dynamically loads images on the click of a button, and uses the scroll wheel for zooming in an out. However the scrolling isn't working the way I would like because the registration point is not in the center of the image. My question is how do I set the registration point to center of the movie clip whenever I load a new image.

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved