views:

24

answers:

0

I am trying to create a modular structure that will eventually live inside another actionscript/flex application. I am using cairngorm in the outside application and I'd like to create more than one instance of this new component in the inside application. Cairngorm doesn't work for creating multiple duplicate components because of the singleton nature of the model.

The component I'm creating is a pseudo video viewer. I'd like to have a shared model within this component instance. I'm struggling with a way to share a single model within the component. If I use the singleton pattern, I can't create more than one instance of this component. If I create an instance and let the component make sure there is only one, then I have trouble passing the model easily to all components that want it. This is especially hard because .mxml components can't have a constructor where I would pass in the model.

I was thinking of having each component ask its parent for the module until a component had it. This would require that each component have that interface implemented and feels a bit icky to me.

Does anyone know a way to create an instance variable within a component so that multiple components can be create, but also share that model easily throughout that component?