views:

30

answers:

1

I have MovieClips on my Flash Stage that when clicked on--they toggle ON/OFF. My goal is that when a user clicks either ON/OFF--then leaves the flash website--another user can visit the site--and see that state of that MovieClip was either left ON/OFF.

I would need a way that when a user toggles ON/OFF--that state is saved in a variable--passed onto PHP--saved in an XML file--and then when that is done--Flash calls a function to update--to read the XML file--see if it needs to update the ON/OFF state of the MovieClip toggle button.

Multiple people would be able to go to this flash site--and toggle (ON/OFF) the objects on the stage. When more than one person is toggling--those people should instantly see objects being toggled (ON/OFF).

A: 

To instantly see objects being toggled on or off would take a little more than this actually. the server would have to inform flash that a button has been toggled. if you save your application state in a text file , the state will only be updated when the application loads the file.

If you have many users toggling the buttons, it sounds like a lot of server calls. You could use a remote SharedObject but you would need Flash Media Server for that. Local SharedObject would work but only for one browser, meaning a user could flip switches and return to the application as she left it.

In any case , whatever your solution to save your objects data, you would need for your objects to get their status from a common object so that updating this object would update each object status. Similarly , each time a specific object status changes, it should update this common object.

Then this object can be saved/retrieved as a SharedObject, or saved in a text file (JSON ) or as an XML...

PatrickS
@PatrickS so it sounds like if I want multiple people changing the toggle states at the same time--I would need Flash Media Server. And if I want to do it only one person at a time use Local SharedObject. For now, I'll go with one browser at a time, and not multiple browsers. I believe I can do that with PHP and XML.
jc70
For one browser, you just need to use SharedObject, you won't need PHP or XML. Check this link:http://jaycsantos.com/flash/the-trick-to-using-sharedobject/
PatrickS
@PatrickS thanks for the link. SharedObject sounds good. but for this project i'm required to pass variables to PHP. (but for the future, i'll look into SharedObject, if it's more efficient/better than using PHP.)
jc70
@PatrickS the variables that I'm planning to pass to PHP are the "house objects" (ie. computer, light bulb, tv...etc) and (for now) currentPower (which will be the total power). i've seen examples where the data is saved in an XML file.
jc70
@PatrickS i'm going to start trying to get the flash piece to work first, then try to pass data to PHP. the problem that i think i'll run into--is having the MovieClips "house objects" be updated...when the user leaves...and comes back and sees that the light they turned on...is still on.
jc70
Actually if doesn't have to be SharedObject against PHP , you could use both. SharedObject is like a cookie and if enabled on a user's computer it would work faster than PHP since there's no need for a server call. PHP on the other hand would be persistent across browsers.
PatrickS