A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] foce number positive

  1. #1
    Senior Member Boombanguk's Avatar
    Join Date
    Jun 2000
    Posts
    1,194

    resolved [RESOLVED] foce number positive

    What's the fastest way to force a var to be positive? i've tried

    Code:
    Math.abs(nn);
    but it doesn't seem to work.
    FlashGameMaker.com - er..where I say stuff.

  2. #2

  3. #3
    Senior Member
    Join Date
    Jan 2008
    Location
    UK
    Posts
    269
    Code:
    var n:Number = -0.65;
    trace(Math.abs(n)); //0.65
    works as expected here.

  4. #4
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    I'm not sure if this is your problem but:
    Math.abs(nn);
    Wont do anything.

    You need:
    nn = Math.abs(nn);
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  5. #5
    Senior Member Boombanguk's Avatar
    Join Date
    Jun 2000
    Posts
    1,194
    Quote Originally Posted by sstalder
    It should work. Give us the rest of your code, like where you are setting "nn".
    Code:
    var nn:Number = xx2-xx1;
    Math.abs(nn);
    *EDIT*

    Ugh...as the previous poster said..... nn=Math.abs(nn);.......not sure how I missed that, btw.
    Last edited by Boombanguk; 12-14-2008 at 05:13 PM.
    FlashGameMaker.com - er..where I say stuff.

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