Hi All,
I'm fairly new to pureMVC so sorry in advance if this is an obvious question. What I'm trying to do is move movieclips around my stage. they're new locations are calculated based on where the mouse is clicked. This is my workflow is as follows
StartUpCommand is called and registers my stageMediator
I cast the viewComponent to a type of Stage
protected function get stage():Stage{
return viewComponent as Stage;
}
on StageMediator I add a movie clip to my stage as follows
stage.addChild(theScene);
I then have a loop for nesting multiple movieclips in this "theScene" movieclip
if (pointsArray != null)
{
for (i=0; i < pointsArray.length; i++){
var studentEntityInstance:MovieClip = new StudentEntity();
studentEntityInstance.name = "studentEntity" + i;
studentEntityInstance.visible = true;
studentEntityInstance.x = pointsArray.x;
studentEntityInstance.y = pointsArray.y;
studentEntityInstance.z = pointsArray.z;
var attachedObj = theScene.addChild(studentEntityInstance);
}
So this is my initial scene setup. i have an eventlistener on my stage listening for a mouseClick
A mouseclick then calls a command which calculates the new nested movieclips locations. This array is set in the proxy which sends a notification to the mediator letting it know the locations have changed. The mediator then updates the stage. This is where I'm having an issue - I'm not able to access the movieclips on my stage. I've tried the following
var currBalloon:MovieClip = MovieClip(viewComponent.getChildByName("studentEntity"+i))
var currBalloon:MovieClip = MovieClip(stage.getChildByName("studentEntity"+i))
var currBalloon:MovieClip = stage["studentEntity" + i];
var currBalloon:MovieClip = viewComponent["studentEntity" + i];
var theScene:MovieClip = MovieClip(viewComponent.getChildByName("theScene"))
var currBalloon:MovieClip = MovieClip(theScene.getChildByName("studentEntity"+i))
var theScene:MovieClip = MovieClip(stage.getChildByName("theScene"))
var currBalloon:MovieClip = MovieClip(theScene.getChildByName("studentEntity"+i))
But everything results in the following error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Anyone have any ideas where i'm going wrong? Any help really would be greatly appreciated as this is really starting to drive me insane.
Thanks,
Derm