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 8506271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:32:52+00:00 2026-06-11T02:32:52+00:00

1st time using an EventListener for a KeyboardEvent and I cant make it work:

  • 0

1st time using an EventListener for a KeyboardEvent and I cant make it work:

Here is the code:

stage.addEventListener(KeyboardEvent.KEY_DOWN, Cal);

function Cal(event:KeyboardEvent):void 
{
    if (event.keyCode == Keyboard.ENTER) {
        Calco();
    }
}

The errors I get are:

Scene 1, Layer ‘Actions’, Frame 1, Line 95 1136: Incorrect number of arguments. Expected 1.

line 94 is the if line and 95 the Calco thing…
I dont get where is the problem. I have another sample of code that works fine and I used it as an example.

  • 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-11T02:32:53+00:00Added an answer on June 11, 2026 at 2:32 am

    Some thoughts… and working example:

    import flash.events.KeyboardEvent;
    import flash.ui.Keyboard;
    
    
    // #1 - use the proper variables / function  names, upper and lower cases:
    // Classes: Xxxxxx
    // function : xxxxxx, xxxXxxxx
    // variables : xxxxXxxx, xxxxx
    // constants : XXXXXX
    // #2 - use the readable function name, no shotcuts... ( just few advices );
    
    stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyboardDown);
    
    function handleKeyboardDown(    e   :KeyboardEvent):void
    {
        // #3 - for keyboard events use switch instead...
    
        // The error which was here is that the variable which parsed is named 'event' and you are using 'e',
        // you need to use the same name as it being initialized
        switch(e)
        {
            case Keyboard.ENTER :
    
                // the error for your 'Calco()' function, is because
                // function Calco (value.... expects for an variable.
                        // in this case this function does not required any variables
                calculate();
                break;
        }
    }
    
    function calculate():void
    {
        trace (this);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using storyboards for the 1st time, and I cant figure out what
This is the 1st time I am using stackoverflow, I usually find answers to
Is there any reason behind using date(January 1st, 1970) as default standard for time
I'm using Entity Framework (1st time) on a SQL 2005 database for a data
I’m doing a patient registration system to a hospital, here we have 1st time
I'm trying to deploy a Rails3 application, for the 1st time, to Dreamhost using
How do i load a test.html multiple time using jQuery . function loadScreen() {
Hello i am using PDO 1st time and getting error ... dont no where
I am using MyEclipse 7.0 for the 1st time. Previously I was using MyEclipse
I am using Win7. I use java to rename a file the 1st time

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.