Forum Topic: 2025 error and finding the caller

(83 views • 9 replies)

This topic is 1 page long.

<< < > >>
Beaten

SonOfChaos

Reply To Post Reply & Quote

Posted at: 6/29/09 09:17 PM

SonOfChaos NEUTRAL LEVEL 05

Sign-Up: 01/12/09

Posts: 73

Okay, I'm searching the web and I can't find an answer I can understand so here goes.

I have to arrays, they both hit detect against each other. When they detect a hit they each launch a method in the custom class as well as splice the entries out of the arrays. Now, I CAN NOT remove the child right their cause that causes them to immediately delete themselves from the stage, I need the death animation to play. I can't remove them in the class cause it says it can only be removed from the caller.

So, WHAT is a caller, and how do I uh, find it and uh, call it. Example code.

for(var b=0; b<blastArray.length;b++){
                for(var s=0; s<boxArray.length;s++){
                    if(blastArray[b].hitTestObject(boxArray[s])){   //test if they hit each other

                        score += 5;          //scoring and level completion
                        value1 += 1;
                        
                        boxArray[s].die();              //death animations for both objects
                        blastArray[b].hit();
                        boxArray.splice(s,1);         //remove objects from arrays
                        blastArray.splice(b,1);
                        
                    }
                }
            }

If I put removeChild(this) in the boxArray method .die, I get a 2025 error.

If I try parent.removeChild(this), I get, cannot access property of a null object. 1009 error.

__________________


None

Woadraiders

Reply To Post Reply & Quote

Posted at: 6/29/09 09:27 PM

Woadraiders DARK LEVEL 11

Sign-Up: 11/11/07

Posts: 561

You attached all of these things to the same place, right? Just keep a static reference called drawTarget or something and then you'll know to remove it from there.

DocClass.drawTarget.removeChild(this);

And your 1009 error is because parent is null. I know sometimes the parent field can be null but 'this' is still attached to something, idk why though.

Mibbygames.com
panterA

BBS Signature

None

SonOfChaos

Reply To Post Reply & Quote

Posted at: 6/29/09 10:41 PM

SonOfChaos NEUTRAL LEVEL 05

Sign-Up: 01/12/09

Posts: 73

At 6/29/09 09:27 PM, Woadraiders wrote: You attached all of these things to the same place, right? Just keep a static reference called drawTarget or something and then you'll know to remove it from there.

What does all that mean?


None

Woadraiders

Reply To Post Reply & Quote

Posted at: 6/29/09 10:54 PM

Woadraiders DARK LEVEL 11

Sign-Up: 11/11/07

Posts: 561

Are you scripting in as2 or as3?

Mibbygames.com
panterA

BBS Signature

None

SonOfChaos

Reply To Post Reply & Quote

Posted at: 6/29/09 10:57 PM

SonOfChaos NEUTRAL LEVEL 05

Sign-Up: 01/12/09

Posts: 73

At 6/29/09 10:54 PM, Woadraiders wrote: Are you scripting in as2 or as3?

AS3 only, don't know AS2 and I am a noob, I can get stuff to work, and I try and understand why, but this issue has been needling me hard.


None

SonOfChaos

Reply To Post Reply & Quote

Posted at: 6/29/09 11:00 PM

SonOfChaos NEUTRAL LEVEL 05

Sign-Up: 01/12/09

Posts: 73

I dig ur work on ur flash coding work on your blog too, very nice.


None

Woadraiders

Reply To Post Reply & Quote

Posted at: 6/29/09 11:00 PM

Woadraiders DARK LEVEL 11

Sign-Up: 11/11/07

Posts: 561

Ok good.

At 6/29/09 09:27 PM, Woadraiders wrote: You attached all of these things to the same place, right?

i.e. the stage.

:Just keep a static reference called drawTarget or something and then you'll know to remove it from :there.

public static var drawTarget:Stage;


DocClass.drawTarget.removeChild(this);

DocClass, this is your game document class, it has the static field drawTarget.

This is if you're doing AS3 in seperate classes and stuff like you should be doing with as3, OOP. If you're not then idk how I can help you.

Mibbygames.com
panterA

BBS Signature

None

SonOfChaos

Reply To Post Reply & Quote

Posted at: 6/30/09 02:03 AM

SonOfChaos NEUTRAL LEVEL 05

Sign-Up: 01/12/09

Posts: 73

At 6/29/09 11:00 PM, Woadraiders wrote: Ok good.

At 6/29/09 09:27 PM, Woadraiders wrote: You attached all of these things to the same place, right?
i.e. the stage.

Just keep a static reference called drawTarget or something and then you'll know to remove it from :there.
public static var drawTarget:Stage;


DocClass.drawTarget.removeChild(this);
DocClass, this is your game document class, it has the static field drawTarget.

This is if you're doing AS3 in seperate classes and stuff like you should be doing with as3, OOP. If you're not then idk how I can help you.

I get this error.

Error #1009: Cannot access a property or method of a null object reference.

I'm using separate classes and stuff to the best of my abilities, figuring out how to removeChild in this context has been a nightmare...UGH!


None

Woadraiders

Reply To Post Reply & Quote

Posted at: 6/30/09 02:12 AM

Woadraiders DARK LEVEL 11

Sign-Up: 11/11/07

Posts: 561

Show me the code you've got again plz.

Mibbygames.com
panterA

BBS Signature

None

SonOfChaos

Reply To Post Reply & Quote

Posted at: 6/30/09 02:50 AM

SonOfChaos NEUTRAL LEVEL 05

Sign-Up: 01/12/09

Posts: 73

At 6/30/09 02:12 AM, Woadraiders wrote: Show me the code you've got again plz.

I will pm it to you.


All times are Eastern Standard Time (GMT -5) | Current Time: 02:14 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!