from cliff
Good point, Carl.
Most times, your Proxies will only have one instance created, though we won't go to the trouble to make them Singletons. So having a NAME constant to register and retrieve the Proxy with makes sense most of the time.
But lets imagine you have a particle system, where a Proxy is responsible for holding a single particle and you have thousands of particles. The ParticleProxy holds the physics implementation; the math for affecting the particle state. Its Data Object is a ParticleVO that holds the properties for a single particle.
You probably have a ParticleFactoryProxy that dynamically creates and registers these ParticleProxies, giving them unique names and properties at creation time.
The only thing that changes since we have multiple instances registered is the fact that we can't predetermine the name assign it to a constant and refer to with a singular idiom.
The ParticleFactoryProxy will only have a single instance created, so to retrieve it:
Quote
var facade:ApplicationFacade = ApplicationFacade.getInstance();
var pfProxy:ParticleFactoryProxy = facade.retrieveProxy(ParticleFactoryProxy.NAME) as ParticleFactoryProxy;
However since we have more than one instance of ParticleProxy, we'll have to have a different way of getting the name of the one we want. We'll probably have the ParticleFactoryProxy keep a list of all the names of the particles it has generated. Then to access them, perhaps from a command, we might do something like this:
Quote
var particleNames:Array = pfProxy.getParticleNames();
for (var k:int = 0; k< particleNames.length; k++) {
var particleProxy:ParticleProxy = facade.retrieveProxy(particleNames[k]) as ParticleProxy;
particleProxy.updateVector();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment