1 Reply Latest reply on Jan 17, 2011 9:52 AM by yalp.com.br

    Why do I have to press with the mouse key to get app going in HTML

    gross770

      When publishing the app to HTML, the down arrow and space bar not initially  working till I click on the window with the mouse first. Also in  authoring mode if I click on the help icon and then come back it doesn't  start till I click on the mouse first.

       

      Could someone please advise  me on this.

       

      below is my code from my sample presentation scene.  And then below this I have the code from my help scene:

      ****************************************************************************************** ******************************************

      var totFrames:Number = totalFrames - 1; //for some reason the totalFrames is one over the total frames we see on the actual timeline so we adjust totFrames to one less then what is recored by totalFrames.  I think the extra frame is coming from the movie clip on anotation which contains one frame.

       

      helpSample_btn.buttonMode = true;

       

      helpSample_btn.addEventListener(MouseEvent.CLICK, samplePresentationhelp);

       


      function samplePresentationhelp(event:MouseEvent):void
      {
          stage.removeEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);
          MovieClip(this.root).gotoAndPlay(1, "HelpScreen");
      }

       

      //**************************************************************************************** ******
      // Key board events to move backwards, forwards, start and stop the and move back 5 frames.    *
      //**************************************************************************************** ******
      stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);

       


      function fl_KeyboardDownHandler(event:KeyboardEvent):void

       

      {
          switch (event.keyCode)
          {
                  //Down Arrow press
              case 40 :
                  trace("Down");
                  //*************************************** insure it doesn't go past last frame
                  if (currentFrame == totFrames)
                  {
                      stop();
                      trace(currentFrame);
                      break;
                  }

       

                  // Space Bar press
              case 32 :
                  trace("space bar");
                  //*************************************** insure it doesn't go past last frame
                  if (currentFrame == totFrames)
                  {
                      stop();
                      trace(currentFrame);
                      break;
                  }

       

              case 39 :
                  trace("RIGHT ARROW");
                  //*************************************** insure it doesn't go past last frame
                  if (currentFrame == totFrames)
                  {
                      stop();
                      trace(currentFrame);
                      break;
                  }

       

              case 40 :
              //Down Arrow Press
                  trace("Down");
                  play();
                  trace(currentFrame);
                  break;

       

                  // Space Bar press
              case 32 :
                  trace("space");
                  play();
                  trace(currentFrame);
                  break;
                  // Right Arrow press
              case 39 :
                  trace("space");
                  play();
                  trace(currentFrame);
                  break;
          }

       

          //***********************************************************************************
          //UP Arrow press but first check that we are not further than 4 frames from beginning.

       

          if (event.keyCode == 38 && currentFrame >= 10)
          {
              trace("up");
              trace(currentFrame);
              gotoAndStop( currentFrame - 5 );
              trace("up");
              trace(currentFrame);
          }
          else if (event.keyCode == 38 && currentFrame <= 5)
          {
              gotoAndStop(1);
              trace("up");
              trace(currentFrame);
          }
         
          //***********************************************************************************
          //Back Arrow press but first check that we are not further than 4 frames from beginning.

       

          if (event.keyCode == 37 && currentFrame >= 10)
          {
              trace("up");
              trace(currentFrame);
              gotoAndStop( currentFrame - 5 );
              trace("up");
              trace(currentFrame);
          }
          else if (event.keyCode == 37 && currentFrame <= 5)
          {
              gotoAndStop(1);
              trace("up");
              trace(currentFrame);
          }
         
         
      }
      stop();

      ****************************************************************************************** ***************************************

      Here is the code for the Help scene

      ****************************************************************************************** *****************************************
      back_btn3.buttonMode = true;
      back_btn4.buttonMode = true;

       

      back_btn3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_9);
      back_btn4.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_10);

       

      function fl_ClickToGoToScene_9(event:MouseEvent):void

       

      {
          stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler);
          MovieClip(this.root).gotoAndPlay(1, "SamplePresentation");
      }

       


      function fl_ClickToGoToScene_10(event:MouseEvent):void
      {
          MovieClip(this.root).gotoAndPlay(1, "SamplePresentation");
      }

       

      stop();