Cole, Ha ha, thank you for the compliments. The good news is you shouldn't have to use the same agreed upon name. Thats the great thing about singleton!
for example main.swf loads in ui.swf when ui.swf is loaded it has on it's timeline something like: obj:UI = UI.getInstance(); right? So now the 'obj' object in ui.swf is the one instance of UI that can exist (singleton). so later, when main.swf asks for the same thing: // calling it 'myUIObj' cause I can var myUIObj = _global.UI.getInstance(); // instance is defined, so we get the same object that was defined on ui.swf's timeline it returns the single instance of UI, or ui.swf's 'obj' object. So test it by inserting this code trace(myUIObj == ui_mc.obj); // returns true -- they are the same instance of the UI class This works because your agreed upon point of reference is the class UI. As long as you've implemented singleton correctly you can from get that same object from anywhere. Note: This works because AS 2.0 classes are defined on the _global object. If your class is in a package you'll need to reference it through the package objects like this: myUIObj = _global.package.subpackage.UI.getInstance(); also, the reason you use _global.packagename.classname instead of simple importing the class and referencing it directly is so that Flash doesn't compile the UI class (and every other class it references) in both swfs. It should only be compiled in ui.swf and simple be referenced in main.swf. I really hope this all makes sense. If not I know there's some great articles out there. Watch the Singleton tutorial by Rob Taylor ( http://www.flashextensions.com) in the Design Patterns section. It's really helpful. Play around with it a bit and see what you get. Good luck! Tyler On 12/4/05, Cole Peterson <[EMAIL PROTECTED]> wrote: > > Thanks a lot for your time Tyler Wright. > That helped a lot! > > I have implemented your suggestion. singleton. everything is great. > My controller loads in the swfs that make up the diff parts of the app. > > The only disconnect is that all swfs have to agree to implement their ui > using ... > for example .... the name 'obj'. > > var obj:Someclass > obj = Someclass.getInstance(); > then my controller can target that class in any swf by using the mc that > it loaded the swf into and calling > > mc.obj.getInstance().doSomething(); > > or just > > mc.obj.doSomething(); > > Does that make sense or am I missing something? > > If the above does make oop sense I now have a controller that loads in > swfs and can then create pointers, if needed, to the main UI object in each > swf. The only problem I see is forcing the use of an agreed upon name. > > > Thanks again! > Cole > > > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders