Search code examples
phpxmlflashtogglemulti-user

How to save a toggle state that is created using a MovieClip in Flash. How to save state in variable and pass to PHP, and save to XML?


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).


Solution

  • 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...