7 Replies Latest reply on Jun 16, 2007 3:56 PM by Jimmathy

    Saving Clips

    Jimmathy Level 1
      I was thinking. If u took a blank holder movieclip and used action script to attachmovies to it; could u then have the action script save the holder and its contents as either a movie clip or something so that way it can be used and will be able to be loaded when the .swf starts up again. So can u attachmovies and save them as a single MC and have it saved somewhere so when started again the MC is still there(or to be loaded). So basically, im looking fora "savegame" feature. Im tired so i hope this all makes sense.
        • 1. Re: Saving Clips
          MaxManNH Level 2
          Makes perfect sense, but unfortunately you can't do it. When an SWF leaves memory it basically purges all of its memory and that includes dynamically created movieclips. If you wanted to implement a save game routine you would either need to create some kind of structure that could be saved out as a shared object or some kind of XML structure that could be saved to a database. Once an swf is unloaded its gone.
          • 2. Re: Saving Clips
            SymTsb Level 2
            You actually might be able to do something like this with SharedObjects. Save the state of every mc on the screen, the score, etc. Then just have your movie load that data and render the screen. As long as the clips still act as they would normally from a new game, it can be done. You just can't save the game as it is onto the hard-drive you have to go about it from a different mind set.
            • 3. Re: Saving Clips
              Jimmathy Level 1
              hmm... okay. Does flash have the capability of creating folders in the users MyDocuments or C:\programfiles that it can export the score/scene name/etc. to in say a .txt file? Or if such a thing is not possible could the user set up a folder for use/export by the swf?
              • 4. Re: Saving Clips
                Greg Dove Level 4
                No... the only data you can save locally from the swf itself is via flash sharedObjects. Some people call them 'flash cookies' but actually its much better than that. If the swf is viewed by the same user from the same location (website) the default settings for sharedObjects in the player should allow you save data. I think the default settings allow up to 100K.

                The doc on this page talks about using it for saving game data.

                http://livedocs.adobe.com/flash/8/main/00002661.html#wp430748

                Bear in mind that a individual user can change their settings for sharedObjects and can decide to delete the data. But that's no different to a text file if they had one. And the sharedObject data file is held in a reasonably obscure location, easy enough to find if you're looking for it. But you have to know really where to look. However you don't need to worry about that part. Flash finds it next time no problem if it hasn't been deleted.
                • 5. Re: Saving Clips
                  Jimmathy Level 1
                  now thats cool! where does it save them do you happen to know? just incaze i need to delete one from testing it out.
                  • 6. Re: Saving Clips
                    Greg Dove Level 4
                    well it varies.

                    Mine (win xp), for example start inside :
                    C:\Documents and Settings\ USER ACCOUNT\Application Data\Macromedia\Flash Player\#SharedObjects

                    But you can read more here:
                    http://en.wikipedia.org/wiki/Local_Shared_Object

                    If you want to delete them you can just right click on flash, choose Settings ..and then the folder icon which is for local storage. You can move the slider to zero. Later on you'll have to increase it again. I think the Flash IDE also behaves differently to a browser... can't remember exactly - something about it not having a limit.
                    I guess you're better off using the SharedObject clear() method when you're building and testing.
                    • 7. Re: Saving Clips
                      Jimmathy Level 1
                      Thanks guys, this works great! what i did was every frame in the scene game is a new area of the map. So i made the shared object save several variables, and I may add more: name, map, and money. So when the swf opens it look at what map equals and then goto and stop at that scene. :D the only problems which i am working on now is how to get the variable "map" to fit in gotoAndStop(like would it be "gotoAndStop([map])" or wat. And the other is how to test a hit between the designated objects while walking to tell if he can go there.
                      but thanks a lot guys