This is the solution I settled on and I think it would work for you as well. It might not be the simplest but so far it works for me :-)
The key is using interfaces instead of classes in some places. This makes it possible to change the actual class without having to change the import statement (which would create a cascading effect).
So how I have gotten it to work:
Instead of directly creating components, mediators and proxies in classes, I create them through a ComponentFactory. This component factory is different for each version of the application and returns an instance of a mediator or something else.
Some code to clarify:
In the document class I have this:
import interfaces.IComponentFactory;
import ComponentFactory; // the component factory for this specific application
public function startApplication():void
{
facade = ApplicationFacade.getInstance();
facade.startup( this.stage, new ComponentFactory() ); // the component factory is send along
}
In the facade I store a reference to the factory so every other class can reference it
public function startup( stage:Object, factoryReference:IComponentFactory):void
{
factory = factoryReference;
}
Now if an mediator would like to create new mediators it would do something like the following. For you it would create a proxy.
import IComponentFactory;
import IMediatorPlus;
private function initializeSite():void
{
private var factory:IComponentFactory = ApplicationFacade.getInstance().factory;
site = factory.createSite() as MovieClip;
var siteMediator:IMediatorPlus = factory.createSiteMediator(site);
facade.registerMediator(siteMediator);
stage.addChild(site);
siteMediator.init();
}
So what happens in the component factory? Well, nothing much but since it's contents are 'hidden' by using a proxy it is easy to use a different component factory that creates different components without have to change any mediators or such that reference it.
public class ComponentFactory implements IComponentFactory
{
public function createSite():IBasicComponent
{
return new Site();
}
public function createSiteMediator( component:Object ):IMediatorPlus
{
return new SiteMediator(component);
}
}
As I said it might not be the simplest or best solution so if anybody has ideas on how it could be improved please post them.
Bob