# 1046: Type was not found or was not a compile-time constant: KeyBoardEvent

**URL:** <https://forum.kirupa.com/t/1046-type-was-not-found-or-was-not-a-compile-time-constant-keyboardevent/286126>\
**Category:** Uncategorized\
**Created:** [April 10, 2009, 12:49pm UTC](https://forum.kirupa.com/t/1046-type-was-not-found-or-was-not-a-compile-time-constant-keyboardevent/286126 "2009-04-10T12:49:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwallace](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jwallace](https://forum.kirupa.com/u/jwallace)\
**Post date:** [April 10, 2009, 12:49pm UTC](https://forum.kirupa.com/t/1046-type-was-not-found-or-was-not-a-compile-time-constant-keyboardevent/286126/1 "2009-04-10T12:49:34Z")

</div>

Okay, I am new to AS3, and I am going through the classroom in a book for Fash 4, AS3. In Chapter 3, it says I should be able to make a ball bounce from 2 or more sides of the stage. I haven’t been able to figure out how to do that(I can make it move in different directions - but not bounce and change directions), so I found a tutorial online, but it is in AS2. I have tried to rewrite the code so that it is in AS3, but I keep getting this error:  
[FONT=Times New Roman][SIZE=3]1046: Type was not found or was not a compile-time constant: KeyBoardEvent.[/SIZE][/FONT]  
[FONT=Times New Roman][SIZE=3][/SIZE][/FONT]  
The code is on the timeline and I have included the following in my script.

[FONT=Times New Roman] import flash.display.Stage;  
import flash.events.\*;  
import flash.events.KeyboardEvent;  
import flash.display.MovieClip;  
import flash.ui.Keyboard;[/FONT]  
[FONT=Times New Roman][/FONT]  
[FONT=Times New Roman]stage.addEventListener(KeyboardEvent.KEY\_DOWN, moveBall);  
stage.addEventListener(KeyboardEvent.KEY\_DOWN, applyMovement);[/FONT]  
[FONT=Times New Roman][/FONT]  
The error comes on the first line of the function code(s) in the following (specific line in italics):

[FONT=Times New Roman]function moveBall(event:KeyBoardEvent): void {

- if (event.keyCode == 39) {\*  
xSpeed += ballSpeed;  
}  
if (event.keyCode == 37) {  
xSpeed -= ballSpeed;  
}  
if (event.keyCode == 40) {  
xSpeed += ballSpeed;  
}  
if (event.keyCode == 38) {  
xSpeed -= ballSpeed;  
}  
}[/FONT]  
[FONT=Times New Roman]function applyMovement(event:KeyBoardEvent): void {  
ball.x = xSpeed;
- ball.y = ySpeed;
- ball.rotation = xSpeed;[/FONT]

I have looked online and in the AS3 bible and not found a solution. I can’t seem to find a solution on any other forums either. Your help is appreciated. Also if this thread a repeat of another one on this site. I apologize.

Thanks!
