views:

614

answers:

1

I have a page with two Flash movies. When one (a content application) reaches a particular state (i.e. the user is now logged in), I'd like to completely refresh the other (a menu) to reflect the new overall state of the user's session (i.e. the user is logged in, so now include a "logout" item). The state is actually kept server-side, so no detailed communication is required, just a general "update yourself" command of some kind.

It seems like I can do this by setting up a LocalConnection and sending commands from the first movie to the second, but this seems like overkill.

Is there a simpler way for the first movie to cause a reload/refresh/rewind of the second?

+3  A: 

LocalConnection, especially since you're running with both SWFs in the page context, actually sounds like a fairly straightforward way to go. Another approach would be to use ExternalInterface to wire the SWFs together with JavaScript, but that'd probably be more complicated and error-prone than implementing LocalConnection, and possibly less secure as well, depending on the details of your application.

Other than messaging one another directly, via LocalConnection or ExternalInterface, the only other options that come to mind would involve some sort of polling on the part of the second SWF (the menu) -- polling for a browser-session/cookie value (and updating its state accordingly), polling for changes to some JavaScript variable, polling for a SharedObject value, or the like.

Actually, now that I think of it, SharedObject might actually be a good way to go in this case. I haven't used it personally, so I don't have any code to share, but it looks from the documentation like it's well suited to the task, and probably more appropriate than LocalConnection or ExternalInterface, in that it leaves the two SWFs less tightly coupled.

Christian Nunciato
Very helpful suggestions ... thanks!
Eric
Awesome, glad to hear it. Good luck!
Christian Nunciato
Thanks, glad this worked out. Did you end up using SharedObject, then?
Christian Nunciato