The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 3 of 3

Thread: switch case executes "false"s too???

  1. #1

    switch case executes "false"s too???

    var myConstant:Number = 3
    for (var i:int = 0; i < 30; i++)
    switch (true)
    case i > 20:
    case i % myConstant == 0:
    trace(i,i % myConstant == 0,i % myConstant);

    why does it suddenly start tracing 'false' after 20???

  2. #2
    Because you forgot a break statement before your second case.
    “Who were you, Krilnon, and how did you know so much about AS4?”
    The historian sighed as she gazed up at the sky and saw… not stars. A story.

  3. #3
    Quote Originally Posted by Krilnon View Post
    Because you forgot a break statement before your second case.
    actually, it took the breaks out to test if for every "i" it indeed would execute all cases it actually matches (so if it matches more then 1 of the possible cases)

    it does but it also starts suddenly executing/matching the false cases

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012