1 Reply Latest reply on Aug 26, 2010 2:49 PM by kglad

    I added key and mouse events for a movie. Both work. If I click a button first, keys disable.

    Planet Mondo

      Does anybody have a clue why clicking a button in a movie would prevent key buttons from working? If I open the SWF file, the keys will work only if I do not interact with buttons that I created. My client will need both button interaction and keyboard functions to work no matter what. Can somebody help?

       

      Actionscript below:

       

      Actionscript in main timeline for Scene 1:

       

      import flash.events.KeyboardEvent;

       

      stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyEvent);

       

      function onKeyEvent(e:KeyboardEvent):void {

      var character:String=String.fromCharCode(e.charCode);

       

      if (e.keyCode==72) {
        gotoAndStop(1,"master");
      }
      if (e.charCode==49) {
        gotoAndPlay(1,"Distributor");
      }

      if (e.charCode==50) {
        gotoAndPlay(1,"Mirka");
      }

      }

       

       

      Actionscript in menu container of the movieclip:

       

      master.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler1);
      function mouseDownHandler1(event:MouseEvent):void {
      MovieClip(root).gotoAndPlay(1,"master");
      }

      distribute.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
      function mouseDownHandler2(event:MouseEvent):void {
      MovieClip(root).gotoAndPlay(1,"Distributor");
      }


      health.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler3);
      function mouseDownHandler3(event:MouseEvent):void {
      MovieClip(root).gotoAndPlay(1,"Mirka");
      }

      mirka.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler4);
      function mouseDownHandler4(event:MouseEvent):void {
      MovieClip(root).gotoAndPlay(1,"Farm");
      }

      transaction.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler5);
      function mouseDownHandler5(event:MouseEvent):void {
      MovieClip(root).gotoAndPlay(1,"Check2");
      }

      transaction2.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler6);
      function mouseDownHandler6(event:MouseEvent):void {
      MovieClip(root).gotoAndPlay(1,"Check3");
      }

      sceneA.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler7);
      function mouseDownHandler7(e:MouseEvent):void {
      MovieClip(root).gotoAndPlay(1,"Scene2");
      }

      sceneB.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler8);
      function mouseDownHandler8(e:MouseEvent):void {
      MovieClip(root).gotoAndPlay(1,"Scene1");
      }