00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

[AS3] Bullet impact child issue..

665 Views | 7 Replies
New Topic Respond to this Topic

[AS3] Bullet impact child issue.. 2012-05-19 15:03:39


Here is the current work in progress. Use the mouse to fire arrows at things. You may also move with the "A" and "D" keys.

Okay, I just put this code on the third frame of my "Impact" movie clip's third timeline frame:

stop();
stage.removeChild(this);

and now I am getting this error, despite the fact that the game is running "properly":

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Impact/frame3()

I figured it would work and it seems to be doing so, but what is Flash's problem?

I would have tried removing the movie clip in the body code of my document class, but I'm not quite sure how to do that after a certain amount of time (I, of course, want the image to be visible for a short while).

Response to [AS3] Bullet impact child issue.. 2012-05-19 15:37:50


At 5/19/12 03:03 PM, Barzona wrote: I would have tried removing the movie clip in the body code of my document class, but I'm not quite sure how to do that after a certain amount of time (I, of course, want the image to be visible for a short while).
if(this.currentFrame == 3)
{
     parent.removeChild(this);
}

I implore you to reconsider.

Response to [AS3] Bullet impact child issue.. 2012-05-20 01:15:24


At 5/19/12 03:37 PM, Khronosis wrote:
At 5/19/12 03:03 PM, Barzona wrote: I would have tried removing the movie clip in the body code of my document class, but I'm not quite sure how to do that after a certain amount of time (I, of course, want the image to be visible for a short while).
if(this.currentFrame == 3)
{
parent.removeChild(this);
}

I tried your code (assuming on the impact object's timeline) and it did the same thing; worked, but got an error.

Response to [AS3] Bullet impact child issue.. 2012-05-20 08:48:57


Have you tried putting the code in the main timeline?

if(impact.currentFrame == 3)
{
     impact.removeChild(this);
}

and instead of this, the name of the variable you declared. "arrow" or whatever it may be.


BBS Signature

Response to [AS3] Bullet impact child issue.. 2012-05-20 09:30:21


At 5/20/12 08:48 AM, stretch1one wrote: Have you tried putting the code in the main timeline?

if(impact.currentFrame == 3)
{
impact.removeChild(this);
}

and instead of this, the name of the variable you declared. "arrow" or whatever it may be.

:(
No dice.

Response to [AS3] Bullet impact child issue.. 2012-05-20 11:54:04


The purpose of frames is to do animation.

If you want to get rid of an Object after a certain amount of time, use a Timer.

Response to [AS3] Bullet impact child issue.. 2012-05-20 12:41:06


At 5/20/12 01:15 AM, Barzona wrote: I tried your code (assuming on the impact object's timeline) and it did the same thing; worked, but got an error.

That code was intended to be placed inside the onEnterFrame event listener in the object's class file, not the timeline.

On that note, you really shouldn't be placing code on the timeline; it defeats the purpose of AS3's benefits.


I implore you to reconsider.

Response to [AS3] Bullet impact child issue.. 2012-05-21 01:45:52


I agree. I'll give your code a try. :)