i tried a lot but couldn’t fix the problem…
why is the following code is not working?
(please see fla too)…
thanks a lot!
the code:
/*
i tried to create nested movieClip, and then to add it eventListener, and to it's nested mc too.
i can't control neither the "mySquare_mc" MovieClip, and neither it's nested MovieClip ("circle_mc")
while i'm trying to control the inner MC i get this Error:
"TypeError: Error #1009: Cannot access a property or method of a null object reference.
at example_fla::MainTimeline/moveIt()"
what can be the problem?!
*/
import flash.events.MouseEvent;
var mySquare_mc:MovieClip = new sq();
mySquare_mc.name = "sq";
mySquare_mc.x = 20;
mySquare_mc.y = 20;
addChild(mySquare_mc);
var circle_mc:MovieClip = new cc();
circle_mc.x = 10;
circle_mc.y = 10;
mySquare_mc.addChild(circle_mc);
mySquare_mc.addEventListener(MouseEvent.CLICK,moveIt);
function moveIt(event:MouseEvent){
mySquare_mc.x+=50;
mySquare_mc.circle_mc.alpha-=0.1;
}
//this is not working too:
/*function moveIt(event:MouseEvent){
mySquare_mc.x+=50;
getChildByName("mySquare_mc").getChildByName("circle_mc").alpha-=0.1;
}*/