Search code examples
actionscript-3flashactionscriptairadobe

How do I save the current frame to be loaded later?


Hello everyone and thanks in advance for any answers.

What I am trying to develop is quite difficult and I fear it may be beyond ActionScript and Adobe Flash CC, however I will try and see.

I wish to create an app that allows users to upload their own image (bitmap) and that becomes the background of the frame, they can then drag shapes onto points in the image and add text so that they can click the circles and see what info is said about that point.

I am unsure how to achieve certain aspects of this.

The main functionality I require assistance with is saving the scene as a swf so that it can be loaded back into Flash Player from within the Flash App.

Is any of this achievable?


Solution

  • Yes, this app is rather non-trivial, but very doable (and it has been done many times before.)

    The main functionality I require assistance with is saving the scene as a swf so that it can be loaded back into Flash Player from within the Flash App.

    This isn't necessary to do what you describe. If the user has uploaded the image to a server, you can also store user information on a server that describes the other aspects of the user's screen (shapes, text, etc). Then you only need to load in the data and reconstruct the scene.

    The basic flow would be:

    • User selects an image using FileReference/browse() then use FileReference/upload() to send it to a server-side script (for example PHP) that stores the file to a database.
    • User performs the actions you describe to create shapes, text, etc, and you record it as XML or JSON format.
    • You send the XML or JSON scene data to the server using URLLoader.
    • You associate the scene with some kind of identifier. A server-side query can now take that identifier and return the XML or JSON scene data.
    • To display the scene, you load the XML or JSON scene data using URLLoader and reconstruct it using Loader to load remote images, and re-create the shapes, text, etc from the scene data.

    The end result would enable you to share the scene with anyone using the SWF that is able to reconstruct the scene.

    You could use this same approach without a server, and instead store the scene data locally using SharedObject or FileReference/save() in the Flash Player, or File or EncryptedLocalStore in AIR. All these methods would also allow you to store the data as AMF (ActionScript objects).