A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Conditional vs. Conversion

  1. #1
    Senior Member
    Join Date
    Jan 2006
    Posts
    133

    Question Conditional vs. Conversion

    Which, in theory would be faster... using a conditional or allowing the Flash engine to automatically convert the values?

    Conditional
    Actionscript Code:
    var output:int;
    var b:Boolean = true;
    var i:int = 5;
    output = i + ((b) ? 1 : 0);
    trace(output); // 6

    Conversion
    Actionscript Code:
    var output:int;
    var b:Boolean = true;
    var i:int = 5;
    output = i + b;
    trace(output); // 6

    Obviously, allowing Flash to convert the Boolean to a int value is easier to read, but would it be faster?

  2. #2
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    I didn't even know Flash could convert Boolean into the 1 and 0 by itself, I thought it was stricter than that. But is this really something you need to worry about? What's the time difference gonna be, like 5 milliseconds?

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