# \[F8\] learning to use switch

**URL:** <https://forum.kirupa.com/t/f8-learning-to-use-switch/285644>\
**Category:** flash\
**Created:** [April 3, 2009, 11:12am UTC](https://forum.kirupa.com/t/f8-learning-to-use-switch/285644 "2009-04-03T11:12:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![capdetrons](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@capdetrons](https://forum.kirupa.com/u/capdetrons)\
**Post date:** [April 3, 2009, 11:12am UTC](https://forum.kirupa.com/t/f8-learning-to-use-switch/285644/1 "2009-04-03T11:12:58Z")

</div>

I need to check for certain conditions in the code of a game I’m trying to finish. It’s a blackjack like game where you can hit a new card if your previous one is not revealed even if you’re over the total, but I need to set a condition so that one cannot ask for a card if the value of the visible cards is over the maximum score.

I solved the first situation where I am only going to have three cards dealt like so:

function dealFirstCard() {  
if ((!notRevealed[0] && !notRevealed[1]) && (card0 +card1 \> 7.5)){  
showDealerHand();  
gotoAndPlay(“Done”);  
} else {  
dealCard(playerHand);  
showCards2();  
}  
}

but I would like to know if the switch form could be used when dealing the next card, so I could break the function when the condition was met.

with else it would look like this:

function dealSecondCard() {  
if ((!notRevealed[0] && !notRevealed[1] && notRevealed[2]) && (card0+card1+card2\> 7.5)){  
showDealerHand();  
gotoAndPlay(“Done”);  
} else if ((!notRevealed[0] && !notRevealed[1]) && (card0+card1\> 7.5)){  
showDealerHand();  
gotoAndPlay(“Done”);  
} else if ((!notRevealed[0] && !notRevealed[2]) && (card0+card2\> 7.5)){  
showDealerHand();  
gotoAndPlay(“Done”);  
} else if ((!notRevealed[1] && !notRevealed[2]) && (card1+card2\> 7.5)){  
showDealerHand();  
gotoAndPlay(“Done”);  
} else {  
dealCard(playerHand);  
showCards2();  
}  
}

thanks
