Re: [Flashcoders] removeChild - targeting question

2008-04-01 Thread Forrest Maready
Steven said "event.currentTarget"
Leandro said "emitter.parent"

Thanks guys!
I think the removeChild is working below (event.currentTarget), but now I'm
getting the "Cannot access property or method of a null object reference"
which is usually what happens when the EventListener is calling a
non-existent object. Can you suggest a change for the first line to remove
the event listener properly?

Thanks again


emitter.removeEventListener (Event.ENTER_FRAME, removeDead);   //NOW
I THINK THIS LINE IS WRONG
event.currentTarget.parent.removeChild(event.currentTarget);



Code for reference:

> function removeDead(event:Event)

> > {
> > if (emitter.pParticle.pArray.length == 0)
> > {
> > trace ("No more particles");
> >   *parent.removeChild(emitter); // THIS LINE NEEDS HELP-- DO
> > YOU
> > KNOW WHAT PATH WILL REMOVE THE ABOVE EMITTER INSTANCE?
> > emitter.removeEventListener (Event.ENTER_FRAME,
> > removeDead);
> > }
> > }
> >
> > }
>
>
___
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] removeChild - targeting question

2008-04-01 Thread Leandro Ferreira
emitter.parent?


   Leandro Ferreira

On 4/1/08, Forrest Maready <[EMAIL PROTECTED]> wrote:
>
> The code below has a problem. The  line within the removeDead function
> is supposed to removeChild on the emitter object.
> I can't for the life of me figure out what the path is- is it
> event.target.parent.removeChild(event.target) or is it parent.removeChild(
> event.target) or what? I've tried everything I can think of to no avail-
> lots of "The supplied DisplayObject must be a child of the caller".
>
> Any ideas? Thank you Flashcoders. May your brightness never dim.
>
>
>
>
> public class Main extends MovieClip
> {
>
> var emitter:PEmitter;
> var pArray:Array;
>
> public function Main()
> {
> stage.addEventListener(MouseEvent.MOUSE_MOVE, createPEmitter);
> }
>
> public function createPEmitter(event:MouseEvent)
> {
> if (event.buttonDown == true)
> {
> emitter = new PEmitter(event.target.mouseX,
> event.target.mouseY, "circle", 5, 0x00, 3, 3, 95, 90);
> //  PEmitter (PositionX:Number, PositionY:Number,
> spriteType:String, amount:Number, color:uint, velocity:Number,
> velocityRandom:Number, emissionRange:Number, emissionAngle:Number)
> addChild(emitter);
> emitter.mouseChildren = false;
> emitter.addEventListener (Event.ENTER_FRAME, removeDead);
> }
> }
>
> function removeDead(event:Event)
> {
> if (emitter.pParticle.pArray.length == 0)
> {
> trace ("No more particles");
>   *parent.removeChild(emitter); // THIS LINE NEEDS HELP-- DO
> YOU
> KNOW WHAT PATH WILL REMOVE THE ABOVE EMITTER INSTANCE?
> emitter.removeEventListener (Event.ENTER_FRAME,
> removeDead);
> }
> }
>
> }
> ___
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] removeChild - targeting question

2008-04-01 Thread Steven Sacks

try event.currentTarget

___
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders