A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Flash Studio Pro Question

  1. #1
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    Just first let me say thanks for a great program.

    I need to create a save and load option for the app I'm developing. I want to save all of the variables to the hard drive. Then if the user comes back later they can load up the variables and continue where they left of (its a bunch of input screens which create the variables before placing them into xml in the last stage). the savetofile feature seems to only do one variable (or am i mistaken). as there is no way for me to determine at what stage the user is saving i need to be able to save all variables in one swoop. is this possible. i know you can do it in flash 5 but the option was ousted for MX. suggestions?


  2. #2
    Banned By GMF Wannabe Gambini's Avatar
    Join Date
    Oct 2000
    Posts
    976
    Hi, I'm glad you like Flash Studio and thank you for the kind words.

    At the moment, you're right, you can only save one variable at a time with the savetofile command, but we're hoping to add something more similar to what you need in a future update. The original SAVE command in Flash 5 was a really neat undocumented feature and it's a shame they have removed it completely as it's something which is very difficult to replicate.

    I'm not sure, but swf studio may be able to save all variables at once. You can download it from http://www.northcode.com and I'm sure Tim (northcode) will be along shortly to clarify if this can be done with his app.

    I hope this helps, and thanks again for using Flash Studio.

  3. #3
    Senior Member
    Join Date
    Apr 2002
    Posts
    219
    Of course you can always use Flash 'N Pack.. to do just that....

    Here is a demo:

    http://www.flashnpack.com/samples/do...e=SaveVars.zip

    also you can always us a Database instead of Text File and Only Flash 'N Pack allow you to use DBase Type databases which are great for what you want to do: get flash 'N Pack from : http://www.flashnpack.com

    To Gambini: I think you can do this with your Software as well check out my Example to see how it's done..

    Enjoy!!

  4. #4
    FK's Official Mac Hater jasonsplace's Avatar
    Join Date
    Mar 2002
    Location
    Provo, Utah
    Posts
    2,245
    I am almost positive that SWF Studio will only write one variable at a time also. I agree that it was a shame when Macromedia took out the SAVE command. This is a command that the 3rd party developers should look into adding back in.

  5. #5
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766

    You can do it with ANY projector tool that allows you to save variables. The trick is to combine all the stuff you want to save so you can write it out with a single call.

    The example below works with SWF Studio, but it's just minor surgery (changing the fscommands) to adapt it for use with Flash Studio.

    It only actually writes the contents of one variable (data) but the file contains all _root variables, which can be easily loaded with loadVariables.

    Code:
    // Replacement for the Flash 5 SAVE FScommand 
    
    function Save(filename)
    
       var data = ""; 
    
       for (var v in _root) {
          if (typeof(_root[v]) == "string") {     
             if (v != "$version" && v != "dataLoaded") {
                data = data + "&" + v + "=" + escape(_root[v]);
             }
          }
       }
    
       data = data + "&dataLoaded=true";
    
       fscommand("Arg", filename);
       fscommand("Arg", data);
       fscommand("FileSys.WriteFile", "");
    
    }
    You need some ActionScript to "help" the third party tools because the Flash OCX doesn't provide a way to list all the variables in use, except from ActionScript.


  6. #6
    Senior Bumbler
    Join Date
    Dec 2000
    Posts
    522
    Not to take anything away from Flash Studio Pro (I own it also), but the simplest way is to use shared objects and northcode's code.

    I was trying to use FSP for a similar thing but found shared objects to be a much simpler route.
    Easy Popup Windows 3.0 (For MX) Easy Popup Windows 2.5.2 (For Flash 5)

    Quit hassling with javascript popup windows. Basic, centered and fullscreen! Over 150,000 users.

  7. #7
    Jace Masula
    Join Date
    Apr 2000
    Posts
    100
    imo, FSP gives you more control over the output

  8. #8
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    Northcode et al,

    Will the above code work if the majority of the variables are XML objects. If not can it be tinkered to handle both variables and XML objects?
    Incarnations

  9. #9
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The easy way is to give all your XML objects a common prefix in their names like xmlBob, xmlData, xmlObj1, xmlObj2, etc. and then change the enumeration code to work with just those objects (instead of strings).

    Then all you need to do is serialize the XML object (using the .toString method) before using escape on it and you will be able to save it just fine.

    As wdglide pointed out, you don't have to use SWF Studio or any projector tool with the Save() function I wrote, you can save the data to a local object if you like.

  10. #10
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    Well I would like to be able to save all of the variables including the xml objects. Also the have to be saved onto the client harddrive. I like the way your save function looks but am unsure how to augment it to handle the xml objects. I'm actually thinking ahead right now as I haven't gotten to this stage in the code. Right now I'm just setting up the data to be saved. It is really delicate because of what needs to happen on loading which is what I'm working on now. On loading there is an analysis of the variables which determines where in the movie the user is. The movie is actually a series of data entry screens and on load the user must be able to continue where they left off. All that said I really need to figure out a way to make sure that the save function handles the xml objects as well. Then I can write that to a file and know how it will work on loading.
    Incarnations

  11. #11
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    To keep things simple you can write two save functions and two load fuctions. You can use the original function I posted to save your regular variables and have another one to save your xml objects. I can give you a hand with that if you like...

  12. #12
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    So would this mean actually writing two files to the harddrive? The reason that I ask is because I was using a user defined variable called 'filename' to actually name the file being written. I guess I could use a numeric to deliniate if there were two files.

    Speaking of which, with FSP I've tried everything I can to actually get save function to save with an .xml extension to no avail. Is this not possible or am I missing something.

    As per the xml saver, during the process the user creates literally hundreds of xml objects. Depending upon where they are however these are all nested into one or more of the four following tags:

    < ead >
    < archdesc >
    < dsc >
    or
    < s...n >

    The last one function under a looping sequence which creates objects that all begin with s and contain numeric identifiers. Now, by example in ead there are probably fifty children with various names. Only the s objects are standardized. Could all of these be grabbed in one fell swoop?
    Incarnations

  13. #13
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    If you save the stuff using Flash MX shared local objects, there's only one file (the .SOL file) and Flash MX provides a logical "object" abstraction that frees you from worring about the file mechanics.

    Even with two save functions you could save it all in a single file or a single write operation. The two functions are just to simplify the actionscript to the point where people can take what they need and ignore the rest.

    The code I posted allows you to walk through every clip in your movie and find objects, strings, etc. You can locate them by their name, by their type, whatever works. The name is the easiest if you can give them all common prefixes but it's not the only solution.

    You don't need to walk through the XML objects themselves. The XML object has a method call .toString that will convert the whole XML object to a string that you can save easily (and the process is reversible). So the only problem is finding the XML objects themselves (which I've already solved).

    We can take this offline (or do it here) but why don't you describe EXACTLY what you need to save and I'll modify the AS I've posted to do what you want...

  14. #14
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    I'm aware of the xml.toString command and use it in the final output. I don't think it would work here because there's no way to tell exactly what needs to go toString. Let me explain the application first so you can understand the needed functionality of the save.

    It is a standalone XML compiler. Based on an existing XML dtd/rls set EAD, I've got the app prompting data entry screens which Flash automatically associates to XML objects and then arranges them so that they are valid for EAD. There are actually three components in the XML file: Header, Frontmatter, Container List. Each of these components entail a separate series of screens in which the elements are appended to appropriate parents. At the very end all of these parents are then appended to the root parent EAD and the EAD XML file is written.

    The entry process for this in application will be quite time consuming, though far less than when it had to be entered and coded. As such the client must be able to save their work at any point in the process. Because of this there is no telling exactly how many variables, xml objects there will be. I need to ensure that all of them are saved preferably in one file onto the users harddrive. This way when they load the file back into the variable a series of functions can determine exactly where they left off and direct the movie to the right screen.

    I'm not to familiar with shared objects as I just switched over to MX. I actually began developing this in 5. If shared objects is the best way to handle it could you assist me with how to go about using it. Otherwise if you could help me tweak your save function to include all variables and xml object that works as well.

    Basically I want to save: all variables, and all xml objects in use at the time of save.
    Incarnations

  15. #15
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    You don't have to worry about the children in the XML object that you're building. Just call .toString on the xml object itself and ALL of the children will be included in the string and you can load this back later to recreate a perfect copy. If you build everything with separate XML objects and combine them for the final output you can save and restore all the XML objects the same way.

    Saving the other variables on your main timeline (or in movie clips) can be handled by expanding the save function I wrote to handle more than just "string" variables.

    A shared object will work for storing data as they work, but that doesn't give you an XML file that your users can work with so for the final output it sounds like you need to create a real file. For that you'll need a third party tool or a little custom app.

    SWF Studio http://www.northcode.com
    Flash Studio http://www.multidmedia.com
    Flash 'N Pack http://www.flashnpack.com
    FlashAnts http://www.flashants.com
    Jugglor http://www.***********.com
    LPFlashEX http://www.logicplus.com.hk
    mProjector http://www.binarynoise.com

    SWF Studio is my product and it will definitely let you create XML files. There's a really basic example at www.northcode.com/studio/examples called XML if you want to see how it works. The XML example creates an XML document in a string, writes it out to a file and then loads it back.

  16. #16
    ...in human form
    Join Date
    Aug 2002
    Posts
    188
    my main concern with putting the xml objects toString is that when they are calld back they no longer haver their variable name references. by example _root["s"+n+"title"] or _root.s2title is an xml object that parses as < title >. as a child that goes to string it will it keep its variable name or is that cared for with the other variables?
    Incarnations

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center