3 Replies Latest reply on Mar 29, 2011 4:49 AM by Ned Murphy

    error 1034

    charles_ccent

      Any help would be great.

       

      import fl.motion.MotionEvent;
      import flash.events.MouseEvent;

       

      function calculateTotal(evtObject:MotionEvent):void
      {
          var price:Number;
          var totalCost:Number;
          var numberOfJerseys:Number;
          if (jerseyType.text == "1")
          {
              price = 10;
          }
          if (jerseyType.text == "2")
          {
              price = 12;
          }
          if (playerNames.text == "Y" || playerNames.text == "y")
          {
              price +=  1.50;
          }
          numberOfJerseys = int(numberOfPlayers.text) + int(numberOfCoaches.text);
          totalCost = numberOfJerseys * price;
          total.text = String(totalCost);
      }
      calc_btn.addEventListener(MouseEvent.CLICK, calculateTotal);

       

      error is:

       

      TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@3310f559 to fl.motion.MotionEvent.

       

      Thanks,

       

      charles_ccent

        • 1. Re: error 1034
          Ned Murphy Adobe Community Professional & MVP

          Your events are not in agreement... the function is getting a MouseEvent but you say it's a MotionEvent

           

          function calculateTotal(evtObject:MotionEvent):void

          .

          .

          .

          calc_btn.addEventListener(MouseEvent.CLICK, calculateTotal);

          • 2. Re: error 1034
            charles_ccent Level 1

            Thank You that helped with the error.

             

            Now when I use "y" it caculates the total 1, if I enter "n" it calculates correctly.

             

            Any suggestions. I'm using Flash CS5

            • 3. Re: error 1034
              Ned Murphy Adobe Community Professional & MVP

              I don't see anything wrong with the code that would lead to that error, though if you are declaring numberOfJerseys as a Number, then you may as well cast the number of players and coaches as numbers as well.  If the code you are now using differs from what you showed, then I cannot tell what you might have changed to make it work as you say it does.

              1 person found this helpful