• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

remove after decimal numbers.

Engaged ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

i checking speed test. so this script showing like 504.254654 value.

but i don't want to after desimal(.) numbers.

(like 504 only)

value.text = String( ( ( file.size/myTimer.currentCount ) / 1024 ) * 8 );

TOPICS
ActionScript

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 18, 2012 May 18, 2012

value.text = String( int(( ( file.size/myTimer.currentCount ) / 1024 ) * 8 ));

You can just cast it to a type that doesn't support floating point values, like ints.

Votes

Translate

Translate
Guest
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

var splitString:String = String( ( ( file.size/myTimer.currentCount ) / 1024 ) * 8 );

var splitStringArra:Array =  splitString.split('.');

value.text =splitStringArra[0].toString();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

value.text = String( int(( ( file.size/myTimer.currentCount ) / 1024 ) * 8 ));

You can just cast it to a type that doesn't support floating point values, like ints.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

YOu can just convert the number to an int before you convert it to a String...

value.text = String( int( ( file.size/myTimer.currentCount ) / 1024 ) * 8 );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

Beat you by 5 minutes! Haha

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

Thank you for all.

and one more thing

in my function  >= 256 this test pass visible upPass button. but not showing in this function. what am i worng?

function show_message(e:DataEvent)

{

  tm.stop();

  value.text = String( int( ( ( file.size/tm.currentCount ) / 1024 ) * 8 ) );

  uploadTest();

}

function uploadTest()

{

  if (Number(upSpeeds) >= 256)

  {

  upPass.visible = true;

  }

  else{

  upFail.visible = false;

  }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

I think if the speed is >= 256 then you want upPass.visible = true; like you have it but if it's less then you should set upFail.visible = true;. You're currently setting its visibility to false;

Aside that, are you saying the upPass button isn't showing if the speed is greater than 256? Is the instance name (not the library name) of upPass and upFail set properly? Is the alpha also set to 1?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

upFail.visible = true; is currect, that is my mistack.

i'm using trace but showing only "Fail".

i getting value in "upSpeeds" text 256 above but showing "Fail"...

function uploadTest()

{

          if (Number(upSpeeds) >= 256)

          {

                    upPass.visible = true;

          }

          else{

 

                    upFail.visible = true;

          }

 

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

Can you run a trace inside that function to verify data?

e.g.:

function uploadTest()

{

     trace("upSpeeds: " + upSpeeds); // see what the function sees

     if (int(upSpeeds) > 256)

     {

          upPass.visible = true;

     }

     else

     {

          upFail.visible = true;

     }

}

Typically you may see the text is correct but if the variable wasn't defined in a global scope it is not available to the function and it will trace this to output:

upSpeeds: undefined

If that's the case you know upSpeeds needs to be defined on a global level so it can be utilized in that function.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

i find the problem my self.

Thankyou

sinious

(Number(upSpeeds.text) >= 256)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

Ah then it would have traced:

upSpeeds: [object TextField]

And then you'd know why it wasn't working . Trace often if you can, it's a very simple tool to debug.

Glad you got it working and good luck!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

yes really.

i am beginner, so.....some mistacks.

any way Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2012 May 18, 2012

Copy link to clipboard

Copied

LATEST

You are welcome and good luck!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines