1 Reply Latest reply on Apr 1, 2011 6:07 AM by Darshan Rane

    SWITCH CASE PROBLEM?

    screeeenName234

      CODE

      function Position(object:MovieClip, location:top || left):void

      {

           switch(top:Boolean, bottom:Boolean)

           {

                case top = true:

                     object.y = 0;

                     break;

                case bottom = true:

                     object.x = 0;

                     break;

           }

      }

       

      Position(object,location);

       

       

       

      COMPILER ERRORS

       

      Scene 1, Layer 'Actions', Frame 1, Line 1 1084: Syntax error: expecting rightparen before logicalor.

      Scene 1, Layer 'Actions', Frame 1, Line 3 1084: Syntax error: expecting rightparen before colon.
      Obviously there is some problems with the code.
        • 1. Re: SWITCH CASE PROBLEM?
          Darshan Rane Level 3

          I thinl u need something like this

           

          function Position(object:MovieClip, location:String):void

          {

               switch(location)

               {

                    case "top":

                         object.y = 0;

                         break;

                    case "bottom":

                         object.x = 0;

                         break;

               }

          }

           

           

          Position(object,"top");

           

          or

           

          Position(object,"bottom");

           

           

          http://www.darshanrane.com