A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Putting colon in between a calculated number?

  1. #1
    Spit
    Join Date
    Oct 2008
    Location
    Philly, PA
    Posts
    51

    Putting colon in between a calculated number?

    Hi,

    Can't figure out how to put ":" in between a 3 digit number that has been calculated in a function.

    Ex.

    I want to make this--> "100", into this--> "1:00"


    Thanks!

    Spit

    Forgot to say I'm using CS3 and AS2.
    Last edited by SpitSpitSpitty; 08-23-2010 at 12:08 AM.

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    use the substr() method. It takes 1 required argument and a 2nd optional argument. The 1st is where in the string to start cutting and the 2nd is how far to cut. If you don't supply the 2nd, it assumes you want the rest of the string.

    Actionscript Code:
    var firstHalf:String = String(100).substr(0,1);
    var secondHalf:String = String(100).substr(1);
    trace(firstHalf + ":" + secondHalf);

  3. #3
    Spit
    Join Date
    Oct 2008
    Location
    Philly, PA
    Posts
    51
    Got it working perfect in my project!

    Thank You!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center