Goodmorning, i am trying to make a formula that makes for example 30.60 of
30.6. So I need it to add a 0.
This is the formula I am using now.
total = Number(Number(600) / 100 * Number(5.1))
I have tried all sorts of additions to the formula to try to get it to make
30.60 of 30.6. But no luck
Hi Jim,
In the Number class there is are a couple of functions to help you.
You want a function called toFixed().
so if you do Number(total).toFixed(2); You get the result you want :)
This is pure AS3 though,
Hope this helps,
Sid
On Jan 27, 2009, at 9:45 AM, jimmi wrote:
Goodmorning, i a
That would be:
num.toFixed(2));
HTH
Cor
-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of jimmi
Sent: dinsdag 27 januari 2009 9:45
To: Flash Coders List
Subject: [Flashcoders] [AS in general] Question corce
Ah snap, i need it for AS2, is there any alternative for that?
Best regards,
Jim
On Tue, Jan 27, 2009 at 9:53 AM, Sidney de Koning
wrote:
> Hi Jim,
>
> In the Number class there is are a couple of functions to help you. You want
> a function called toFixed().
>
> so if you do Number(total).toFix
you need to add it to a string and work out if the extra 0 is needed (maybe
with the modulo (%) comparison operator), in as2, and then manually add the
zero to the string when you output to your textfield
do a search for as2 timers / digital clocks and you'll come across the
technique
a
On Tue,
Hi Jimmi,
Look at this then,
To truncate Numbers in Actionscript:
Three decimals:
var yourNumber:Number = 23.263636453737383838383838;
yourNumber = Math.round(yourNumber *1000)/1000;
// Outputs 23.263
Two decimals:
var yourNumber:Number = 23.263636453737383838383838;
yourNumber = Math.round(yo
Or, split the string on the last '.', look at the length of the string
after the dot, add 0s until it has a length of 2...
Ian
On Tue, Jan 27, 2009 at 10:12 AM, allandt bik-elliott
(thefieldcomic.com) wrote:
> you need to add it to a string and work out if the extra 0 is needed (maybe
> with the
would that work for the number 2:20 tho?
doesn't flash remove zeros at the end of decimal values?
a
On Tue, Jan 27, 2009 at 10:20 AM, Sidney de Koning
wrote:
> Hi Jimmi,
>
> Look at this then,
>
> To truncate Numbers in Actionscript:
> Three decimals:
> var yourNumber:Number = 23.26363645373738
This also works for AS3 but then you have to data type the
precision:Number to precision:int in the function signature.
Sid
On Jan 27, 2009, at 11:20 AM, Sidney de Koning wrote:
function round(number:Number, precision:Number):Number
{
var decimalPlaces:Number = Math.pow(10, precision
Hi allandt,
2:20 is not a number :) its a string. i think what flash tries to do
is convert it to a number but fails and convert it to a string
what you could do is strip out any : or , and replace it with a .
(dot) and then pass it to the round function.
You can use this class for it, its
cheers fella
a
On Tue, Jan 27, 2009 at 10:39 AM, Sidney de Koning
wrote:
> Hi allandt,
>
> 2:20 is not a number :) its a string. i think what flash tries to do is
> convert it to a number but fails and convert it to a string
> what you could do is strip out any : or , and replace it with a . (do
Oh Allandt i misread, sorry.
Yes flash does remove the zero at the end of decimal values.
But then you only want to use this function to display (in a textfield
or something) and not to calcualte with it,
because calculating with double zeroes is the same calucalting with a
zero :) ie 4 * 2.0
Thanks guys, i now have some more insight into this matter.
Best regards,
Jim
On Tue, Jan 27, 2009 at 12:01 PM, allandt bik-elliott
(thefieldcomic.com) wrote:
> cheers fella
>
> a
>
> On Tue, Jan 27, 2009 at 10:39 AM, Sidney de Koning
> wrote:
>
>> Hi allandt,
>>
>> 2:20 is not a number :) its a
I now have this :
total= String(Number(600) / 100 * Number(5.1));
cash = newArray;
cash = total.split(".");
if (cash.length == 1)
{
total+= ".00";
}
else if (cash[cash.length - 1].length == 1)
{
total+= "0";
}
It's doing the job.
On Tue, Jan 27, 2009 at 12:14 PM, Sidney de Koning
wrote:
>
If it works, it works :)
Try converting it to a function so you can reuse it later.
Happy coding :)
Sid
On Jan 27, 2009, at 12:29 PM, jimmi wrote:
I now have this :
total= String(Number(600) / 100 * Number(5.1));
cash = newArray;
cash = total.split(".");
if (cash.length == 1)
{
total+= ".0
Thnx for the links... tried some, but still with no success... I now have the
following:
public class Image extends MovieClip
{
private var _thumbLoader:Loader;
private var _largeLoader:Loader;
private var _thumb:Bitmap;
private var _large:Bitmap;
public function loadThumb() :void
{
_
Hi list...
What exactly is the AS3 equivalent of making a simple component,
creating a component definition, and attachMovie with the {} holding the
params?
I can't get this to work:
package {
import flash.display.MovieClip;
import flash.text.*;
public class MyButton exte
you can put the default value into the parameters in the constructor so:
package {
import flash.display.MovieClip;
import flash.text.*;
public class MyButton extends MovieClip{
public var buttonLabel:String;
public function MyButton (buttonLabel:S
So I want to do a dynamic drop cap in a text field, and I know I can do this:
var tString:String = " Cras sit amet arcu. Vestibulum
condimentum risus ac metus. Vivamus in purus id leo molestie
convallis. Donec ipsum. Sed vulputate urna sed erat. Vivamus tellus
elit, accumsan non, sodales quis, se
Matt,
You need to set the img tag's id attribute:
var tString:String = "Lorem ipsom yadda yadda...";
Then it's:
myTextField.htmlText = tString;
myTextField.DC0.txt.text = "Z";
HTH
Regards,
-Keith
http://keithreinfeld.home.comcast.net
> -Original Message-
> From: flashcoder
Hello,
I am new to Action Script 3. I am used to Java, Perl, & Python. I am
receiving the following error:
TypeError: Error #1009: Cannot access a property or method of a null object
reference.
at Slide$iinit()
at PondoShow$iinit()
All I have a PondShow class that extends Sprite. then
Hmmm... what's the rest of the Slide constructor? It sounds like maybe
that's where the error is...
Also, if you try running your Flash file in debug mode (Hit
Ctrl-Shift-Enter), the debugger will take control at the moment when you're
trying to access a null object, which usually helps you figure
Something in your Slide.iinit() function does not exist at the time it is
running.
On Tue, Jan 27, 2009 at 7:40 PM, K-Dawg wrote:
> Hello,
>
> I am new to Action Script 3. I am used to Java, Perl, & Python. I am
> receiving the following error:
>
> TypeError: Error #1009: Cannot access a prope
I am an idiot! The debug mode did just what I needed!
I was trying to add an event listener on a loader the line before doing the
loader = new Loader(). Once solved that, now it is running (not correctly
but that is another issue!).
Thanks for responding so quickly and being so helpful.
You ne
Matt,
I s'pose I focused too much on the second part of your question in my
previous message. So anyway, if this
> src='com.myclasses.DropCap'
actually works then more power to ya!
If not:
ActionScript 3.0 Language and Components Reference:
src: Specifies the URL to an image or SW
25 matches
Mail list logo