...I then have a loop for nesting multiple movieclips in this "theScene" movieclip...
Where is this loop?
The key here is that you want to wrap Mediators around these children as they are created, not try to go get them later.
Wherever the loop is now, I'd consider moving it to a command. That command would assemble 'theScene' movie clip and stuff all these children inside it. And as it does this, it would either:
1) Register a new mediator for each child (StudentEntityMediator)
or
2) Register a single mediator for 'theScene (SceneMediator).
We'll get back to a discussion of this decision this in a moment.
Once the scene object is created, stuffed with its children and either it or its children are mediated, THEN, the command would send a notification like 'ADD_TO_STAGE' to the StageMediator with the scene object as it's body, and the StageMediator would respond by doing the stage.addChild(note.getBody());
So back to the mediation of the scene and its children.
If you wrap a mediator around each child (StudentEntityMediator) you need to make sure that each mediator has a unique name. You can do this in a lot of ways, but here's one:
public static const NAME:String = "StudentEntityMediator";
public static var count:int=0;
public var id:int;
// Constructor
public function StudentEntityMediator( studentEntity:StudentEntity ) {
super( NAME+String(++count), studentEntity);
this.id=count;
}
You can now send position updates and other such notifications directly to a given StudentEntity. When you send a notification, do something like this:
var location:Point3D = getLocation(entityNumber);
sendNotification( ENTITY_POSITION_CHANGE, newLocation, entityNumber );
And in your StudentEntityMediator:
override public function handleNotification(note:INotification):void
{
if ( int( note.getType() ) != this.id return // not directed to this entity
switch( note.getName() )
{
case LocationProxy.ENTITY_POSITION_CHANGE:
studentEntity.position = note.getBody() as Point3D;
break;
}
}
private function get studentEntity():StudentEntity
{
return viewComponent as StudentEntity;
}
It depends on what you're really trying to do, but the above way is probably best because an individual entity can be updated directly.
The other option was to mediate the scene and you may still want to do that to build a channel to talk to the scene object for things like changing the background or whatever. But I wouldn't have it iterating through its children and updating their positions all at once if you could avoid it.
On a final note, you might want to have a look at the HelloFlash AS3 demo, which has lots of self-directed, independently-mediated sprites.
-=Cliff>