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

The Archive Base Latest Questions

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

Scene 1, Layer ‘script’, Frame 1, Line 39 1120: Access of undefined property keyUpHandler.

  • 0
Scene 1, Layer 'script', Frame 1, Line 39

1120: Access of undefined property keyUpHandler.

Ok, so I’m following this tutorial http://as3gametuts.com/2012/04/05/platformer-8/
^ Just to have a source and not claim the work myself

I have created

stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);

and later in the code i have:

function keyUpHandler(e:KeyboardEvent):void{
    if(e.keyCode == Keyboard.LEFT){
        leftPressed = false;

    } else if(e.keyCode == Keyboard.RIGHT){
        rightPressed = false;

    } else if(e.keyCode == Keyboard.UP){
        upPressed = false;

    } else if(e.keyCode == Keyboard.DOWN){
        downPressed = false;
    }   
}

My errormessage is at the top, any thoughts on why im getting this? Thanks for reading 😛

My entire code:

var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
var upPressed:Boolean = false;
var downPressed:Boolean = false;

var leftBumping:Boolean = false;
var rightBumping:Boolean = false;
var upBumping:Boolean = false;
var downBumping:Boolean = false;

var leftBumpPoint:Point = new Point(-30, -55);
var rightBumpPoint:Point = new Point(30, -55);
var upBumpPoint:Point = new Point(0, -120);
var downBumpPoint:Point = new Point(0, 0);

var scrollX:Number = 0;
var scrollY:Number = 500;

var xSpeed:Number = 0;
var ySpeed:Number = 0;

var speedConstant:Number = 4;
var frictionConstant:Number = 0.9;
var gravityConstant:Number = 1.8;
var jumpConstant:Number = -35;
var maxSpeedConstant:Number = 18;

var doubleJumpReady:Boolean = false;
var upReleasedInAir:Boolean = false;

var carrotCollected:Boolean = false;
//var carrotGathered.visible = false; //HER
var snowmanHappy:Boolean = false;
var openDoor:Boolean = false;


stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);

stage.addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event):void{
    if(back.collisions.hitTestPoint(player.x + leftBumpPoint.x, player.y + leftBumpPoint.y, true)){
        //trace("leftBumping");
        leftBumping = true;
    } else {
        leftBumping = false;
    }

    if(back.collisions.hitTestPoint(player.x + rightBumpPoint.x, player.y + rightBumpPoint.y, true)){
        //trace("rightBumping");
        rightBumping = true;
    } else {
        rightBumping = false;
    }

    if(back.collisions.hitTestPoint(player.x + upBumpPoint.x, player.y + upBumpPoint.y, true)){
        //trace("upBumping");
        upBumping = true;
    } else {
        upBumping = false;
    }

    if(back.collisions.hitTestPoint(player.x + downBumpPoint.x, player.y + downBumpPoint.y, true)){
        //trace("downBumping");
        downBumping = true;
    } else {
        downBumping = false;
    }   


    if(leftPressed){
        xSpeed -= speedConstant;
        player.scaleX = -1;

    } else if(rightPressed){
        xSpeed += speedConstant;
        player.scaleX = 1;
    }

    /*if(upPressed){
        ySpeed -= speedConstant;

    } else if(downPressed){
        ySpeed += speedConstant;

    }*/

    if(leftBumping){
        if(xSpeed < 0){
            xSpeed *= -0.5;
        }
    }

    if(rightBumping){
        if(xSpeed > 0){
            xSpeed *= -0.5;
        }
    }

    if(upBumping){
        if(ySpeed < 0){
            ySpeed *= -0.5;
        }
    }

    if(downBumping){
        if(ySpeed > 0){ 
            ySpeed = 0; 
        }
        if(upPressed){ 
            ySpeed = jumpConstant; 
        }

        //DOBBELTHOPP..
        if(upReleasedInAir == true){
            upReleasedInAir = false;
        }
        if(doubleJumpReady == false){
            doubleJumpReady = true;
        }
    } else { 

        ySpeed += gravityConstant; 

        //DOBBELTHOPP
        if(upPressed == false && upReleasedInAir == false){
            upReleasedInAir = true;

        }
        if(doubleJumpReady && upReleasedInAir){
            if(upPressed){ 
                doubleJumpReady = false;
                ySpeed = jumpConstant; //set the y speed to the jump constant
            }
        }

    }

    if(xSpeed > maxSpeedConstant){ //moving right
        xSpeed = maxSpeedConstant;
    } else if(xSpeed < (maxSpeedConstant * -1)){ //moving left
        xSpeed = (maxSpeedConstant * -1);
    }

    xSpeed *= frictionConstant;
    ySpeed *= frictionConstant;

    if(Math.abs(xSpeed) < 0.5){
        xSpeed = 0;
    }

    scrollX -= xSpeed;
    scrollY -= ySpeed;

    back.x = scrollX;
    back.y = scrollY;

    sky.x = scrollX * 0.2;
    sky.y = scrollY * 0.2;

    if(carrotCollected == false){
        if(player.hitTestObject(back.carrot)){ 

            back.carrot.visible = false;
            carrotGathered.visible = true; // HER
            carrotCollected = true;
        }
    }

    if(snowmanHappy == false){
        if(carrotCollected == true){
            if(player.hitTestObject(back.snowMan)){

                carrotGathered.visible = false; // HER
                back.snowMan.gotoAndPlay(2);
                snowmanHappy = true;
            }
        }
    }

    if(openDoor == false){
        if(snowmanHappy == true){
            if(player.hitTestObject(back.snowMan)){

                back.lockedDoor.gotoAndStop(2);
                openDoor = true;
            }
        }
    }


}

function keyDownHandler(e:KeyboardEvent):void{
    if(e.keyCode == Keyboard.LEFT){
        leftPressed = true;

    } else if(e.keyCode == Keyboard.RIGHT){
        rightPressed = true;

    } else if(e.keyCode == Keyboard.UP){
        upPressed = true;

    } else if(e.keyCode == Keyboard.DOWN){
     downPressed = true;
     /*if(openDoor && player.hitTestObject(back.other.lockedDoor)){

          gotoAndStop(2);
     }*/
}




function keyUpHandler(e:KeyboardEvent):void{
    if(e.keyCode == Keyboard.LEFT){
        leftPressed = false;

    } else if(e.keyCode == Keyboard.RIGHT){
        rightPressed = false;

    } else if(e.keyCode == Keyboard.UP){
        upPressed = false;

    } else if(e.keyCode == Keyboard.DOWN){
        downPressed = false;
    }   
 }
 }
  • 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-14T21:09:13+00:00Added an answer on June 14, 2026 at 9:09 pm

    Your keyuphandler is engulfed in the KeyDownHandler. Check your { and } since you commented it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code at frame one of the top layer: var level:Array
Scene 1, Layer 'auto button', Frame 1 Warning: The instance name 'semisideview' is declared
I have an opengl scene rendering on an EAGLView layer and some other elements
i added sprite to scene by this tutorials : http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1 but i have bad
I get this exception when i try to create a new layer. So ,
I have a child layer that I'm adding to the scene which contains a
I have a scene, a main layer and a child layer, the main layer
In anime, does frame means number of scene per second? Each scene can consist
I am adding a layer (hudLayer) to my gamePlay scene, and then adding a
I have a menu scene hierarchy like so: Scene | Background Layer | |

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.