Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8538961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:14:53+00:00 2026-06-11T11:14:53+00:00

Basically I’m trying to just barely add keyboard event listeners in my program, then

  • 0

Basically I’m trying to just barely add keyboard event listeners in my program, then start building on them iteratively. The problem is that even getting the simplest stuff in there, derived from multiple tutorials, is apparently something an issue. I’m not too sure what I’m missing right now. I’ve tried adding stuff, changing stuff, and taking stuff out. But given the following code, I don’t see any messages showing up on the screen. Why?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:local="*" xmlns:mx="http://www.adobe.com/2006/mxml" width="480" height="600" layout="absolute" creationComplete="onCreationComplete()">
<mx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import flash.events.KeyboardEvent;

        private function onStart(pEvent:Event):void {
            vs.selectedChild = mm;
        }

        private function onNewGame(pEvent:Event):void {
            vs.selectedChild = game;
        }



        private function onCreationComplete():void {
            addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
            stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);

            addEventListener(KeyboardEvent.KEY_UP, onKeyDown);
            stage.addEventListener(KeyboardEvent.KEY_UP, onKeyDown);
        }

        private function onKeyDown(pEvent:KeyboardEvent):void {
            Alert.show("spam");
            Alert.show(pEvent.toString());
        }
    ]]>
</mx:Script>
<mx:ViewStack id="vs" creationComplete="vs.selectedChild = ts">
    <local:TitleScreen id="ts" creationComplete="ts.addEventListener(TitleScreen.START, onStart);" />
    <local:MainMenu id="mm" creationComplete="mm.addEventListener(MainMenu.NEW_GAME, onNewGame);" />
    <local:Game id="game" />
</mx:ViewStack>
</mx:Application>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:14:54+00:00Added an answer on June 11, 2026 at 11:14 am

    You can not use stage directly. Instead this use this code:

        private function onCreationComplete():void {
            systemManager.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
            systemManager.stage.addEventListener(KeyboardEvent.KEY_UP, onKeyDown);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
Basically I'm attempting to add rows to a table, I need to do this
Basically what I'm trying to do is make a very simple vertical bullet projectile
Basically I'm trying to improve on the Ghosts in a Pacman game I'm making.
Basically i'm trying to build a comment system. The user looks at a photo
Basically, what I am trying to do is to find last section of PE
Basically I am trying to restart a service from a php web page. Here
Basically, I'm trying to tap into the Soap pipeline in .NET 2.0 - I
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
Basically, when I type these commands in the terminal by hand, the sift program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.