I have a movie clip that has a property doSelect().
I add the movie clip thus:
var obj:MovieClip = new Square();
addChild(obj);
obj.addEventListener(MouseEvent.CLICK, objClickListener);
function objClickListener(me:MouseEvent):void {
me.target.doSelect();
}
This works as expected when I click the instance.
HOWEVER, when I add several instances of my movie clip thus:
for (var i:int=1; i<10; i++) {
var obj:MovieClip = new Square();
addChild(obj);
obj.x = Math.random()*(stage.stageWidth - obj.width);
obj.y = Math.random()*(stage.stageHeight - obj.height);
obj.addEventListener(MouseEvent.CLICK, objClickListener);
}
function objClickListener(me:MouseEvent):void {
me.target.doSelect();
}
…clicking any one of the instances produces the following error:
[FONT=“Courier New”]ReferenceError: Error #1069: Property doSelect not found on flash.display.Sprite and there is no default value.
at myFile_fla::MainTimeline/objClickListener()[/FONT]
What am I doing wrong?