Of course you want to retain a synchronous relationship (much faster than
LocalConnection).
I'm not sure if this UI object you create is a singleton but the best way to
handle this situation is to use it's class to hold a static pointer to the
instance.
for example
class UI {
private static var instance:UI;
public static function getInstance():UI {
if (instance == undefined) {
instance = new UIController;
}
return instance;
}
}
on frame 1 of the swf: var ui = UI.getInstance();
same thing in your controller: UI.getInstance();
even if it's not a singleton you can use a similar method with only some
minor tweaks.
class UI {
public static var instance:UI;
function UI() {
if (instance == undefined) {
instance = this;
}
}
}
this way your class will hold a reference to the first instance created, and
you'd still have on your timeline:
var ui = new UI()
This is the perfect way of getting a reference to a major object because now
the instance and class are always shipped together, one nice little
package. Your AS 2.0 classes are defined on the _global object so everyone
has reference to them, and you're not making some extra (non-oop) reference
floating on the _global object that you can't track where it came from or
who's using it.
hope this helps!
Tyler
On 12/3/05, Mike Britton <[EMAIL PROTECTED]> wrote:
>
> I'd look into LocalConnection. It sounds like you're trying to figure
> out how to avoid dependencies between objects, which (to me) makes
> sense. Rather than over-design and make things work in a complicated
> way, you can use LocalConnection to init your child clips from your
> controller:
>
> receiving_lc = new LocalConnection;
>
> receiving_lc.init = function() {
> this.c.init(); // Calls your clip's init
> };
>
> receiving_lc.connect("lc_name");
>
> In your main application:
>
> var sending_lc2:LocalConnection = new LocalConnection();
> sending_lc2.send("lc_name", "init");
>
>
> hth,
>
> Mike
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders