Hi, i’ve made a simple example here to show you my problem. I have basically created a stage object (“box”), with the nested children, box->b->c. I have exported box for as, with class “box” and base class movieclip. Now i create 4 instances of my box class and add an eventlistener to the nested child c. When i later on try to remove the eventlisterner for myinstance.b.c i get: [COLOR=“Red”]TypeError: Error #1010: A term is undefined and has no properties.
at DocumentClass/removeSomething()[/COLOR]
Here is my code:
package
{
import ....
public class DocumentClass extends Sprite
{
private var holder:MovieClip = new MovieClip;
private var one:box; [COLOR="SeaGreen"]//box is a stage obeject[/COLOR]
[COLOR="SeaGreen"]//its class is set to box, and base class to movieclip[/COLOR]
public function DocumentClass()
{
for( var i:int = 0; i<4; i++)
{
one = new box();
one.x = 160*i;
one.y = 200
one.name = "p" + i;
one.b.c.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
holder.addChild(one);
}
addChild(holder);
stage.addEventListener(MouseEvent.CLICK, removeSomething);
}
private function removeSomething(evt:Event):void
{
[COLOR="SeaGreen"]//the error occurs here[/COLOR]
holder.p1.b.c.removeEventListener(MouseEvent.MOUSE_OVER, doSomething);
}
private function doSomething(evt:Event):void
{
trace(evt.target.name);
}
}
}
I can’t figure out why i can’t access holder.p1
thanks.