A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Is it possible to have multiple cases in a switch statement

  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    198

    Question Is it possible to have multiple cases in a switch statement

    Hi,

    I made a carousel, which required that I added 44 items in order to get the 15 clips showing on the front plane..However, I only have 10 items which are repeated...
    I have a function that uses a switch statement based on the number assigned to the clip---now being that I have only 10 items the different clips in the carousel are arranged like this:
    0 is the same as 10 is the same as 20 is the same as 30 is the same as 40.
    So, I was wondering if you could do something like this:
    Code:
    			switch (arrcontentNum)
    			{
    				case 0 || 10 || 20 || 30 || 40:
    					//myContent.fade.visible = true;
    					myLoadURL = "yahoomessengervistaresizedas3.swf";
    					swfX = -275;
    					swfY = -183;
    					swfZ = swfZholder = 100;
    					break;
    That doesn't work, do I have to write out all 44 possible case numbers even if there are only 10 clips?

    Thanks,
    ---Yvette

  2. #2
    Senior Member
    Join Date
    Aug 2006
    Posts
    322
    PHP Code:
    var arr 1;

    switch (
    arr) {
        case 
    int(arr) :
            if (
    arr==1||arr==2||arr==6) {
                
    common();
            }
            break;
    }

    function 
    common() {
        var 
    my_value "Common Value";
        
    trace(my_value);

    OR

    PHP Code:
    var arr 1;

    switch (
    arr) {
        case 
    :
        case 
    :
        case 
    :
            
    common();

            break;
    }

    function 
    common() {
        var 
    my_value "Common Value";
        
    trace(my_value); 
    Last edited by marlopax; 11-29-2012 at 04:02 PM.

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Posts
    198
    Nice-Thanks so much!

    ---Yvette

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