PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Actionscript 2 inside a movie clip
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Actionscript 2 inside a movie clip

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    29

    Actionscript 2 inside a movie clip

    On my main stage, I have 10 frames. In the first frame, I have a main menu that will be navigated using the keyboard. I converted the menu on that frame into a movie clip to keep things clean (I named the movie clip "menumovie"). Inside that movie clip I have 5 frames. Each frame has a highlight on it in different positions to represent selecting different options.

    Here is the actionscript (as2) I used in the first frame to navigate to the second frame:

    Code:
    var eventListener = new Object();
    eventListener.onKeyDown = function() {
        switch(Key.getCode())
        {
            case Key.DOWN:
                _root.menumovie.gotoAndStop(2);
                break;
            case Key.ENTER:
                _root.gotoAndStop(2);
                break;
        }
    }
    The function _root.menumovie.gotoAndStop(2) is supposed to navigate to frame 2 inside the movie clip. But, nothing happens.

    What am I doing wrong?

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    Well your code looks solid, so it may be a naming issue. I suggest that you (1) place a trace in both case statements to ensure they are firing at the appropriate keyboard press and (2) make sure that your menumovie has a instance name in ALL of the keyframes that include that movie. Missing the instance name is easy and commonly done.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    you also need Key.addListener(eventListener):
    Actionscript Code:
    var eventListener = new Object();
    Key.addListener(eventListener);
    eventListener.onKeyDown = function()
    {
        switch (Key.getCode())
        {
            case Key.DOWN :
                trace("down");
                break;
            case Key.ENTER :
                trace("enter");
                break;
        }
    };

    You're you're testing in the Test Player, don't forgot to disable shortcut keys (Control menu).

    Also, if this code is inside the menu, you should just use
    Actionscript Code:
    gotoAndStop(2);

    Also, avoid using _root.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center