Skip to main content
Known Participant
June 9, 2009
Question

Converting onClipEvent (enterFrame) to AS3 timeline code?

  • June 9, 2009
  • 1 reply
  • 3959 views

Hi, the following code was attached to a "control" movieclip in a nightmarishly old fla...I'm unsure of how to convert "onClipEvent" into AS3.  The code is intended to listen for the space bar either being pressed down or released...I think I can get it going if I would understand how to replicate this "listening" behavior over the span of the half a dozen frames which the control movie clip spanned. 

How can this onClipEvent code be changed to code on a timeline?  Thanks...very, very appreciated.

// 32 is the space bar key code

onClipEvent (enterFrame) {

    if (Key.isDown(32)) {

         with (root.hot_mc) {

               stopDrag();

            }

         global.mode = "hide_hotbox";

    } else if (global.mode == "show_hotbox") {

         root.hot_mc._x = 479;

         root.hot_mc._y = 225;

         play();

     } else if (global.mode == "hide_hotbox") {

          with (root.hot_mc) {

          gotoAndStop("starthotbox");

             }

     } else {

          with (root.hot_mc) {

          gotoAndStop("starthotbox");

              }

       }

}

      

This topic has been closed for replies.

1 reply

Known Participant
June 9, 2009

sorry, haven't had much sleep...I think the following should work...I hope....

addEventListener(Event.ENTER_FRAME, hotbox);

function hotbox(e:Event):void {

    if (Key.isDown(32)) {

         with (root.hot_mc) {

               stopDrag();

            }

         global.mode = "hide_hotbox";

    } else if (global.mode == "show_hotbox") {

         root.hot_mc._x = 479;

         root.hot_mc._y = 225;

         play();

     } else if (global.mode == "hide_hotbox") {

          with (root.hot_mc) {

          gotoAndStop("starthotbox");

             }

     } else {

          with (root.hot_mc) {

          gotoAndStop("starthotbox");

              }

       }

}