Skip navigation
Currently Being Moderated

remove after decimal numbers.

May 18, 2012 5:31 AM

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 );
 
Replies
  • Currently Being Moderated
    May 18, 2012 6:01 AM   in reply to Venkom

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

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

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

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 6:13 AM   in reply to Sumit Agrawal FLash

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 6:18 AM   in reply to Venkom

    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 );

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 6:19 AM   in reply to Ned Murphy

    Beat you by 5 minutes! Haha

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 7:20 AM   in reply to Venkom

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 7:35 AM   in reply to Venkom

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 7:36 AM   in reply to Venkom

    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!

     
    |
    Mark as:
  • Currently Being Moderated
    May 18, 2012 7:57 AM   in reply to Venkom

    You are welcome and good luck!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points