• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Error #1009

New Here ,
May 15, 2013 May 15, 2013

Copy link to clipboard

Copied

Hey there. I have a Error #1009, I am quite new to ActionScript so any help would be very appreciated.

The error is: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at gameBETA5_fla::MainTimeline/moveplayer()
at gameBETA5_fla::MainTimeline/gameloop()

And the line where the code is:

function gameloop(e:Event) {
trace ("gameloop error");
moveplayer();
jumpgravity();
trace ("jump gravity error");
exitlevel();
pickup();
trace ("pickup error");// the function for the pickup key
enemy();

}
// everything will go inside our gameloop, but this will be huge and messy

function pickup(){
if(player.hitTestObject(key)) { // if player touches the key
key.visible =false; // the key disappears
} // this brace closes the IF statement
// code for the coins
function moveplayer(){

// code to move player
player.x+=wspeed;

if (player.x<0){
player.x=0;
}
if (player.x>1000){
player.x=1000;
}
}

I have uploaded the file to dropbox, the file is a CS5 file. This is for my College project, so ANY help would be very appreciated! Thankyou!

https://www.dropbox.com/s/mv26gdfru3x8obq/gameBETA5.fla

TOPICS
ActionScript

Views

760

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 15, 2013 May 15, 2013

Copy link to clipboard

Copied

Anyone that could help would be greatful!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2013 May 15, 2013

Copy link to clipboard

Copied

The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

 

- is declared but not instantiated

- doesn't have an instance name (or the instance name is mispelled)

- does not exist in the frame where that code is trying to talk to it

- is animated into place but is not assigned instance names in every keyframe for it

- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

 

If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

Note: For your own benefit, you should try to be patient when seeking help in the forums.  When you repost like you did, especially so soon after the initial posting you are diminishing your chances of getting help because it changes the number of replies to > 0.  Folks that help here are generally looking for postings with 0 replies.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2013 May 15, 2013

Copy link to clipboard

Copied

LATEST

first I don't find organized code inside ur fla., coding is not done in proper way,

I can suggest some points.

for coins use array or vector and push coins to it.

when you checking in
pickup() function you have many lines  around 200 lines ..of code which is not recomended.

simply write few lines

for(var i:int = 0; i<coinsary.length; i++){

if(player.hitTestObject(coinsary)){

        coinsary.x = 2000;

        score++;

        scorebox.text = score.toString();

    }

}

Also don't use more then one scene.

only use one scene.

function exitlevel() {

    if (player.hitTestObject(exit)){

        if(key.visible == false) { // only go to exit scene if key is invisible

            gotoAndPlay(1, "Scene 2");  not recomended... instead write gotoAndPlay(1);

        }

       

    }

}

anyway using ur fla i haven't replicate ur issue like mentioned above

Thanks,

Bala

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines