A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: if statement not finding greater than zero

  1. #1
    Junior Member
    Join Date
    Jun 2002
    Posts
    29

    if statement not finding greater than zero

    Why would

    if(vol > 0){
    trace("worked");
    }

    NOT work if the value is a decimal value between 0 and 1?
    The trace only works sometimes. I didn't note though at what value it worked..STUPID ME...forgot and plus, it was 2AM.

    I am reading in an array ..byteArray, and then passing readFloat to vol.

    Thanks

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I don't know what your datatype is but should be Number.

    var vol:Number = 0.023;
    if(vol > 0){
    trace("worked");
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Jun 2002
    Posts
    29
    Yea, it is number. I will post the trace results tonight.

  4. #4
    Junior Member
    Join Date
    Jun 2002
    Posts
    29
    Please view the code and trace output.
    NOTE that the ball did not scale at all, yet the trace worked. The scale works...if I mess around with the values, or do lev == 0, it will work.

    for (var i:uint = 0; i < 256; i++) {
    var lev:Number = ba.readFloat();
    if (lev > 0) {
    root.mc_ball.scaleX = root.mc_ball.scaleY = 1.2;
    trace("A"+lev)
    } else {
    root.mc_ball.scaleX = root.mc_ball.scaleY = 1;
    trace(lev)
    }
    }




    OUTPUT SAMPLE


    0
    A0.1241224929690361
    0
    0
    0
    0
    0
    0
    A0.04319121688604355
    A0.019188635051250458
    0
    A0.05263880267739296
    0
    0
    0
    0
    0
    A0.007078253664076328
    A0.0791785717010498
    0
    0
    A0.0502324253320694
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    A0.04215221107006073
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    A0.042718127369880676
    0
    0
    0
    A0.004499177914112806
    0
    0
    0
    0
    0
    A0.0007468619733117521
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    A0.08916346728801727
    0
    0
    0
    0
    0
    0
    A0.4011051058769226
    A0.2692924737930298
    A0.362539678812027
    A0.37561196088790894
    A0.2842569053173065
    0
    A0.41632094979286194
    0
    A0.20571498572826385
    A0.40514346957206726
    A0.6908797025680542
    A0.41604265570640564
    0
    A0.43618881702423096
    0
    A0.1440833956003189
    A0.07644204795360565
    A0.5030001401901245
    A0.5264102816581726
    A0.5572243332862854
    A0.5283127427101135
    A0.35679391026496887
    A0.8214821219444275
    A0.7527132630348206
    A0.7900055050849915
    0

  5. #5
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food ™
    Posts
    3,789
    Since the last value is 0 you're going to end up with scale = 1 regardless of the previous values.

    What are you trying to do here? Animate the scaling?

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