Error #1009 in my Platform Game! Please Help!!!

In my basic platform game I have a "hero" that can walk and jump on the "ground." There is also a door to the next scene, which is the next level.The first scene works fine, but "TypeError: Error #1006: value is not a function. at Charles3_fla::MainTimeline/frame1()" pops up once in the output. It works however, and I'm not worried about it. The second I go throught the door though, Scene 2 opens, but then starts flashing as "TypeError: Error #1009: Cannot access a property or method of a null object reference. at Charles3_fla::MainTimeline/onenter()" pops up A LOT in the output. I don't know how to fix it, and would like help. P.S. I am using Adobe CS5 with actionscript 3
Here is the code for Scene 1:
hero.gotoAndStop('still');
var Key:KeyObject = new KeyObject(stage);
var vy:Number=0;
var gravity:Number=2;
var jumped:Boolean = false;
stage.addEventListener(Event.ENTER_FRAME,onenter)(true);
function onenter(e:Event):void{
vy+=gravity;
if(! ground.hitTestPoint(hero.x,hero.y,true)) {
  hero.y+vy;
if(ground.hitTestPoint(hero.x+(hero.width/2), hero.y-(hero.height/2), true)) {
  hero.x-=13;
if(ground.hitTestPoint(hero.x-(hero.width/2), hero.y-(hero.height/2), true)) {
  hero.x+=13;
if (vy>10) {
  vy=10;
for (var i:int = 0; i<10; i++) {
  if (ground.hitTestPoint(hero.x,hero.y,true)) {
   hero.y--;
   vy=6;
   jumped=true;
if(door.hitTestObject(hero)){
    gotoAndPlay(1,"Scene 2");
if(hero.y>300){
  vy=6;
  jumped=true;
  if(Key.isDown(Key.UP) && jumped){
   vy=-13;
   jumped=false;
   hero.y+=vy;
if(Key.isDown(Key.RIGHT)){
  hero.x+=10;
  hero.scaleX=1;
  hero.gotoAndStop('walking');
  }else if(Key.isDown(Key.LEFT)){
  hero.x-=10;
  hero.scaleX=-1;
  hero.gotoAndStop('walking');
  }else{
   hero.gotoAndStop('still');
And for Scene 2...
hero.gotoAndStop('still');
var Key1:KeyObject =KeyObject(stage);
var vy1:Number=0;
var gravity1:Number=2;
var jumped1:Boolean = false;
stage.addEventListener(Event.ENTER_FRAME,onenter1)(true);
function onenter1(e:Event):void{
vy1+=gravity;
if(! ground.hitTestPoint(hero.x,hero.y,true)) {
  hero.y+vy;
if(ground.hitTestPoint(hero.x+(hero.width/2), hero.y-(hero.height/2), true)) {
  hero.x-=13;
if(ground.hitTestPoint(hero.x-(hero.width/2), hero.y-(hero.height/2), true)) {
  hero.x+=13;
if (vy1>10) {
  vy1=10;
for (var i:int = 0; i<10; i++) {
  if (ground.hitTestPoint(hero.x,hero.y,true)) {
   hero.y--;
   vy1=6;
   jumped1=true;
if(door.hitTestObject(hero)){
    gotoAndPlay(1,"Scene 2");
if(hero.y>300){
  vy1=6;
  jumped1=true;
  if(Key.isDown(Key.UP) && jumped1){
   vy1=-13;
   jumped1=false;
   hero.y+=vy;
if(Key.isDown(Key.RIGHT)){
  hero.x+=10;
  hero.scaleX=1;
  hero.gotoAndStop('walking');
  }else if(Key.isDown(Key.LEFT)){
  hero.x-=10;
  hero.scaleX=-1;
  hero.gotoAndStop('walking');
  }else{
   hero.gotoAndStop('still');
Please reply as soon as possible, and thanks for your time
swiatekalex555

Ok sorry about my misunderstanding. Here's the code with the errors Highlighted. I also downloaded a "KeyObject.as" package, and the contents of that are on the bottom.
hero.gotoAndStop('still');
var Key:KeyObject = new KeyObject(stage);
var vy:Number=0;
var gravity:Number=2;
var jumped:Boolean = false;
stage.addEventListener(Event.ENTER_FRAME,onenter)(true);
function onenter(e:Event):void{
vy+=gravity;
if(! ground.hitTestPoint(hero.x,hero.y,true)) {
  hero.y+vy;
if(ground.hitTestPoint(hero.x+(hero.width/2), hero.y-(hero.height/2), true)) {
  hero.x-=13;
if(ground.hitTestPoint(hero.x-(hero.width/2), hero.y-(hero.height/2), true)) {
  hero.x+=13;
if (vy>10) {
  vy=10;
for (var i:int = 0; i<10; i++) {
  if (ground.hitTestPoint(hero.x,hero.y,true)) {
   hero.y--;
   vy=6;
   jumped=true;
if(door.hitTestObject(hero)){
    gotoAndPlay(1,"Scene 2");
if(hero.y>300){
  vy=6;
  jumped=true;
  if(Key.isDown(Key.UP) && jumped){
   vy=-13;
   jumped=false;
   hero.y+=vy;
if(Key.isDown(Key.RIGHT)){
  hero.x+=10;
  hero.scaleX=1;
  hero.gotoAndStop('walking');
  }else if(Key.isDown(Key.LEFT)){
  hero.x-=10;
  hero.scaleX=-1;
  hero.gotoAndStop('walking');
  }else{
   hero.gotoAndStop('still');
And for Scene 2...
hero.gotoAndStop('still');
var Key1:KeyObject =KeyObject(stage);
var vy1:Number=0;
var gravity1:Number=2;
var jumped1:Boolean = false;
stage.addEventListener(Event.ENTER_FRAME,onenter1)(true);
function onenter1(e:Event):void{
vy1+=gravity;
if(! ground.hitTestPoint(hero.x,hero.y,true)) {
  hero.y+vy;
if(ground.hitTestPoint(hero.x+(hero.width/2), hero.y-(hero.height/2), true)) {
  hero.x-=13;
if(ground.hitTestPoint(hero.x-(hero.width/2), hero.y-(hero.height/2), true)) {
  hero.x+=13;
if (vy1>10) {
  vy1=10;
for (var i:int = 0; i<10; i++) {
  if (ground.hitTestPoint(hero.x,hero.y,true)) {
   hero.y--;
   vy1=6;
   jumped1=true;
if(door.hitTestObject(hero)){
    gotoAndPlay(1,"Scene 2");
if(hero.y>300){
  vy1=6;
  jumped1=true;
  if(Key.isDown(Key.UP) && jumped1){
   vy1=-13;
   jumped1=false;
   hero.y+=vy;
if(Key.isDown(Key.RIGHT)){
  hero.x+=10;
  hero.scaleX=1;
  hero.gotoAndStop('walking');
  }else if(Key.isDown(Key.LEFT)){
  hero.x-=10;
  hero.scaleX=-1;
  hero.gotoAndStop('walking');
  }else{
   hero.gotoAndStop('still');
the KeyObject.as
package {
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.utils.Proxy;
import flash.utils.flash_proxy;
  * The KeyObject class recreates functionality of
  * Key.isDown of ActionScript 1 and 2
  * Usage:
  * var key:KeyObject = new KeyObject(stage);
  * if (key.isDown(key.LEFT)) { ... }
dynamic public class KeyObject extends Proxy {
  private static var stage:Stage;
  private static var keysDown:Object;
  public function KeyObject(stage:Stage) {
   construct(stage);
  public function construct(stage:Stage):void {
   KeyObject.stage = stage;
   keysDown = new Object();
   stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
   stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
  flash_proxy override function getProperty(name:*):* {
   return (name in Keyboard) ? Keyboard[name] : -1;
  public function isDown(keyCode:uint):Boolean {
   return Boolean(keyCode in keysDown);
  public function deconstruct():void {
   stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
   stage.removeEventListener(KeyboardEvent.KEY_UP, keyReleased);
   keysDown = new Object();
   KeyObject.stage = null;
  private function keyPressed(evt:KeyboardEvent):void {
   keysDown[evt.keyCode] = true;
  private function keyReleased(evt:KeyboardEvent):void {
   delete keysDown[evt.keyCode];
Help if you can,
swiatekalex555

Similar Messages

  • Please Help!! I deleted the folder System en Macintosh HD and now when i on my mac it says Disk Error Press Any  Key To Restart Please HELP !!

    I deleted the folder System en Macintosh HD and now when i on my mac it says Disk Error Press Any  Key To Restart Please HELP !!

    Reinstall Mac OS X.
    (59450)

  • HT201210 My iPhone has crashed and i went to iTunes to restore it and after waiting for it to be restored it said "The iPhone could not be restored. An unknown error occurred (2006). Can anybody please help suggest what i should do now?

    My iPhone has crashed and i went to iTunes to restore it and after waiting for it to be restored it said "The iPhone could not be restored. An unknown error occurred (2006). Can anybody please help suggest what i should do now?

    This error normally appears if you attempted to downgrade or modify your iOS. See here http://support.apple.com/kb/TS3694#error1015

  • HT1414 I have iphone 4; tried to sync it said I need to update software so I clicked ok - it then said I need to restore and did above got to stage 3, clicked restore and update, but it comes up with an error saying iphone cannot be found Please help!!!

    I have iphone 4; tried to sync it said I need to update software so I clicked ok - it then said I need to restore and did above got to stage 3, clicked restore and update, but it comes up with an error saying iphone cannot be found Please help!!!

    Dear Jody..jone5
    Good for you that can't update your iphone because I did it and my iphone dosen't work for example I can't download any app like Wecaht or Twitter..
    Goodluck
    Atousa

  • I keep trying to update my itunes and it keeps coming up with error 87... could someone please help me.

    recently i downloaded I.O.S 7 and a few days later it says Activation Error.... This device is not register as part of the iphone developer program. If you are a member of the iphone developer program, please register your device in the iphone developer program portal at developer.apple.com/iphone
    im trying to restore my phone but i cant without the newest version of itunes.... and i cannot download the newest version of itunes cause when i try it says error 87....
    someone please help me would be greatly appreicated

    Hi there exiledsoul,
    You may find the troubleshooting steps in the article below helpful.
    Trouble installing iTunes or QuickTime for Windows
    http://support.apple.com/kb/HT1926
    -Griff W. 

  • When attempting to start iTunes, I get the following: "The iTunes library file cannot be saved. An unknown error occurred (-50)." Can someone please help me get this fixed?

    When attempting to start iTunes, I get the following: "The iTunes library file cannot be saved. An unknown error occurred (-50)." Can someone please help me get this fixed?

    Same problem here since latest update.  As usual poor support from Apple with no answer or fix for this bug.

  • Cannot download trial version. This always appear "You are running an operating system that After Effects no longer supports. Refer to the system requirements below for a full list of supported platforms." PLEASE HELP.

    Cannot download trial version. This always appears "You are running an operating system that After Effects no longer supports. Refer to the system requirements below for a full list of supported platforms." PLEASE HELP.

    Hello,
    in this case please have a look here where you can compare it with your equipment : System requirements | After Effects.
    Good luck!
    Hans-Günter

  • My ipad mini is in recovery  mode after upgrading to ios 7. When i tried to restore it through itunes it says an error occured in restoring ... please help.......

    my ipad mini is in recovery  mode after upgrading to ios 7. When i tried to restore it through itunes it says an error occured in restoring ... please help.......

    Force iPad into Recovery Mode. Follow step 1 to 6 very closely.
    http://support.apple.com/kb/HT1808
    Note: You may have to repeat the above a few times.

  • I have iPhone 3gs. I was trying to update the software using itunes but it is showing Error "-3259" saying  connection timeout. Please help.

    I have just bought iPhone 3gs in Sept.11. I was trying to update the software using itunes but it is showing Error "-3259" saying  connection timeout. Please help.

    Did you already check your securit software settings? iTunes has to contact Apple during the update process.
    See this article: iTunes for Windows: Troubleshooting security software issues

  • TS3682 i plug in my iphone 4 and i loss all contact... i try to backup restore but its error say not enough space.  please help me. i want only my contact backup restore not everything. so i dont know how can i do ?

    i plug in my iphone 4 and i loss all contact... i try to backup restore but its error say not enough space.  please help me. i want only my contact backup restore not everything. so i dont know how can i do ?

    Try to connect in recovery mode to restore, without using the latest backup, explained here:
    iOS: Unable to update or restore

  • The iphone could not be restored an unknown error occurred 14 ...  please help me

    the iphone could not be restored an unknown error occurred 14 ...  please help me

    Hello ahmedhelmy41
    That error is typically related to USB issues when trying to update or restore. Check out the article below to troubleshoot the issue further. There are also a few things to try that are quoted down below.
    Resolve issues between iTunes and security software
    http://support.apple.com/kb/TS3125
    To narrow down the issue, you can also change up your hardware:
    Use another USB cable.
    Plug your cable into a different USB port on your computer.
    Try a different dock connector (or no dock).
    Add (or remove) a USB hub between your device and computer.
    Connect your computer directly to your Internet source, with no routers, hubs, or switches.
    Regards,
    -Norm G.

  • I want to set up home sharing on a laptop but it won't let me. Error code (-3252) comes up. Please help.

    I want to set up home sharing on a laptop (nothing on this iTunes library apart from the purchases from the iTunes store made on my ipod touch) but it won't let me. Error code (-3252) comes up. Please help.

    What version of iPhoto?
    As a Test:
    Hold down the option (or alt) key and launch iPhoto. From the resulting menu select 'Create Library'
    Import a few pics into this new, blank library. Is the Problem repeated there?

  • No sound on most games--please help!

    Hi,
    I am having some kind of problem with my sound on my iMac. I don't know what caused it, or if I did something wrong myself, but here is the problem...
    On most--but not all, of my games...there is no sound. Some games DO have sound (not many), some games have sound only on an opening screen & then have no sound afterwards, and a few won't load at all (I get a pop-up notice saying there is some sort of error w/ the sound (I forget the exact wording) and the game will not load).
    I am pretty sure that I'm having no hardware problems as all the chips, drives & everything else--passed all the tests on "Tech Tool Deluxe" and there is no problem with the sound on any other type of app other than games (iTunes, Quicktime, Dvd Player, etc.--sound works fine).
    I have run permissions repair on Disk Utility (nothing came up to be repaired BTW) and I have restarted (including completly shutting down--and pulling the power cord out of the wall), and I have tried reinstalling several games (the problem does not seem to be with the games...they have exactly the same problem after reinstall. That makes me think the problem is w/ OSX software that communicates the sound data between the game software and the speakers or whatnot).
    I hope somebody out there can advise me on what best to do.
    ~Just FYI...my entire disc is cloned to an ext. HD using "SuperDuper" (I'm a bit worried that the problem could be cloned to the HD along w/ everything else though). I never had to do a system restore or anything like that, but I should be able to do one if it is necessary.
    Please help! ~Thanx a lot!

    ¡¡¡Dude It freaking worked/___sbsstatic___/migration-images/migration-img-not-avail.png I am SOOO stoked/___sbsstatic___/migration-images/migration-img-not-avail.png That was so easy...I don't believe it.
    Thank you So, SOOO much
    --and you are from the city of my birth too/___sbsstatic___/migration-images/migration-img-not-avail.png I should've known a Chicago guy would know the answer. We ARE a cut above after all.
    Thanx again/___sbsstatic___/migration-images/migration-img-not-avail.png YAY/___sbsstatic___/migration-images/migration-img-not-avail.png

  • Compilation Error in stored Proc !! Please help

    Hi,
    This is my stored procedure , it is giving error at line 20 . The error description is : ERROR line 20, col 1, ending_line 20, ending_col 6, Found 'ELSEIF', CASE is expected
    CREATE OR REPLACE PROCEDURE proc_MDM_GetCountry_tst
    Exist IN INTEGER,
    Search IN VARCHAR2,
    Country_c OUT SYS_REFCURSOR
    AS
    BEGIN
    IF Exist IS NOT NULL AND Search IS NOT NULL THEN
    OPEN Country_c FOR SELECT
    MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,
    MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,
    DAT_INSERTED_BY,DAT_MODIFY_DATE,DAT_MODIFIED_BY
    from MDM_COUNTRY_MASTER WHERE MDM_EXIST = Exist and MDM_STATUS='approved' AND MDM_DESCRIPTION LIKE '%'+Search+'%';
    ELSEIF Exist IS NULL AND Search IS NOT NULL THEN (Error line 21)
    OPEN Country_c FOR SELECT
    MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,
    MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,
    DAT_INSERTED_BY,DAT_MODIFY_DATE,DAT_MODIFIED_BY
    from MDM_COUNTRY_MASTER WHERE MDM_STATUS='approved';
    ELSEIF Exist IS NOT NULL AND Search IS NULL THEN
    OPEN Country_c FOR SELECT
    MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,
    MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,
    DAT_INSERTED_BY,DAT_MODIFY_DATE,DAT_MODIFIED_BY
    from MDM_COUNTRY_MASTER WHERE MDM_STATUS='approved' and MDM_EXIST = Exist;
    ELSE
    OPEN Country_c FOR SELECT
    MDM_CODE,MDM_MASTER_CODE,MDM_DESCRIPTION,
    MDM_USER,MDM_EXIST,MDM_STATUS,MDM_ACTION,DAT_INSERT_DATE,
    DAT_INSERTED_BY,DAT_MODIFY_DATE,DAT_MODIFIED_BY
    from MDM_COUNTRY_MASTER WHERE MDM_STATUS='approved' AND MDM_EXIST = 1;
    END IF;
    END proc_MDM_GetCountry_tst;
    Could any of you geeks please help me. I am new to oracle PL/SQL development. I used to work on SQL Server 2005 earlier.
    Thanks for your help.
    Edited by: user11342315 on Jul 2, 2009 10:00 PM

    ELSEIF should be ELSIF.
    See the documentation: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/if_statement.htm#LNPLS01324
    Regards,
    Rob.

  • Nano wont update because of error (-50)...?please help

    i put my ipod in.
    it registered and then put all of the itunes songs onto my ipod without me selecting any. so i didnt want some of the songs on there. I tried to delete them and it says Cannot delete / update ''my ipod'' due to error (-50)
    can you please help?
    thankyou.

    I am having a similiar problem... I could not transfer all of my songs due to an "error -69". Anyone know what this might mean?
    I'm very frustrated!!

Maybe you are looking for

  • All in one C4580 printer - not connecting via wireless

    hi i've purchased this to have a wireless printer but i can only print via the USB port, which isnt much use!  i've tried turning off all firewalls but still no luck.  My wireless router works fine all round the house but i cannot get the printer to

  • 27 inch imac when reset is press nothing happens

    When I press the reset icon my imac show the revolving icon on the screen but this continues until I do a manual reset. Any ideas of why this is occuring?

  • Digital Copy code redeemed, where's the movie?

    After redeeming a digital copy code for a movie on itunes, note said session timed out. Movie isn't in downloads, code has been redeemed. Now what?

  • Display long text in an ABAP Query.

    Hi all, Could any one please help me in guiding me, to tell how can I display the long text which is got from the function module 'READ_TEXT'  in an ABAP query. The issue here is that Iam able to loop at the <itab> table and get the long text for eac

  • Dual e-mail accounts showing separately

    I am checking out something for one of my users here. She has a Blackberry Curve & currently has it set to get her personal e-mail. She would like to add her work account, but not have them all together. Is it possible to view both accounts separatel