A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: FScommand help -- saving in txt file

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    20
    Hi.

    Can anyone refresh my failing memory on how to save variables in a txt file using FSCommand.

    It was something like :
    FScommand("MyFile.txt", SAVE);


  2. #2
    Pillow Daddy m_andrews808's Avatar
    Join Date
    May 2001
    Location
    London England
    Posts
    924
    fscommand("save", "Text.txt");

  3. #3
    Senior Member
    Join Date
    May 2001
    Location
    London, England
    Posts
    273

    Couple of questions...

    Couple of questions...

    Where will the TXT file be saved to??

    Can more than one variable be saves to the TXT file...guess it will save ALL the varibles in that movie?

    These can be gathered again by loadVarible command??

    Cheers Oll



  4. #4
    Pillow Daddy m_andrews808's Avatar
    Join Date
    May 2001
    Location
    London England
    Posts
    924
    The file will be saved relative to the .swf so in this case it'll be saved in the same directory.

    This command saves all the variables on the level of the movie the command was called from. So if you have this command on the _root timeline it'll save all the _root variables (it won't include the variables contained in any of the movie clips used inside the movie) and if you call it from a clip called MainPanel on the _root timeline it'l save only the variables contained within that movie clip.
    So if you wanted to save only specific varaibles, you can first pass them to an empty movie clip, and then do the save command from that clip.

    And finally... yes the text file is written in such a way that the variables will be recreated when loaded using load movie, except for arrays. These will be written to the file like this:

    MyArray=val1,val2,val3,val4 etc

    So when you load the file MyArray will be created as a single string. To turn this back into an array you can use the split command, which I think goes something like this:

    MyArray = MyArray.split();

    Phew! Hope this helps

  5. #5
    Senior Member
    Join Date
    May 2001
    Location
    London, England
    Posts
    273
    One more!!!

    Say I was to use this command running from a CD_ROM where will the TXT file be stored?

    Thanks for you help buddy!!

  6. #6
    Pillow Daddy m_andrews808's Avatar
    Join Date
    May 2001
    Location
    London England
    Posts
    924
    It wouldn't. You'd have to read and write the file to the users hard drive, so you'd have to point to c:\MyText.txt (or similar), but then you've got the problem that their hard drive might not be called c: in which case you're buggered. If you can solve that one then let me know! I don't think there's much you can do about it, but then minimal people have their HD anything other than c:

  7. #7
    Senior Member
    Join Date
    Oct 2000
    Location
    Perth, Western Australia
    Posts
    103

    Post movie dimensions for EXE from CD-ROM

    I was wondering if there is a way to launch the flash projector EXE in fullscreen mode as an autorun feature from the CD-ROM? I'm still trying to figure out what the ideal dimensions for thh flash movie should be ... 800x600?

    Thanks
    Glenn

  8. #8
    the usual
    Join Date
    Jul 2000
    Posts
    1,482
    use the fscommand("fullscreen","true")

    open notepad

    add the following

    [autorun]
    open=start.exe
    icon=icon.ico

    and name it

    autorun.inf

    to create an autorun (you'll have to change the text to point to your file

  9. #9
    Senior Member
    Join Date
    Oct 2000
    Location
    Perth, Western Australia
    Posts
    103
    So do I put that FSCOMMAND in the autorun... or ???

  10. #10
    Senior Member
    Join Date
    Oct 2000
    Posts
    123

    Great thread...have a thought

    I was looking at this technique to allow a company to create their own dynamic content for an interactive.

    1. I would build a flash movie with variable text fields.

    2. When complete the user would click a button that would execute the write of a .TXT file.

    3. Then they would take the another "standardized" flash template movie that i built and the generated .TXT file and burn it onto a CD rom.

    4. When you launch that CD and run the movie...the interactive would pull the dynamic info into place from the .TXT that was earlier generated.

    --------------------------

    So I would only have to build a template for this company...and the sales agent would have a tool "flash movie #1" to create a text file that will supply the dynamic info on the CD they burn for their clients.

    This is a commercial property brokerage...and they want to use my template to show different properties. Obviously the names, prices, rate and such will be different from each CD they make and hand out to a potential purchaser.

    So what i am really making is an "template interactive" and an "administration tool" so they can change the content.

    Have not prototyped this yet...hence how I made it to your thread. I am obviously researching ways to get one flash movie "where variable fields have been filled out" to write to another source "storage of those variable, whether .TXT or such" and then allow them to burn a "closed CD" that will pull up all the generated dynamic info.

    The trick here is - it has to be internet independent. So it can work on computers without internet connections...otherwise I would use PHP for all this.

    Interesting to find out how my tests go...and this thread was very helpfull. If you have any other ideas please post!

    Thanks!

  11. #11
    Senior Member
    Join Date
    Oct 2000
    Posts
    123

    It Worked!!

    Well,

    it worked.......

    I created a movie with variable input text fields...and an execute button with this fs command:

    on (release) {
    fscommand ("save", "test.txt");
    }

    and then I created a .TXT file named "test" in the same root folder.

    Then I created a new flash movie that had the same variable fields in it, except this had a button that executed a "loadVariables" command;

    on (release) {
    loadVariablesNum ("test.txt", 0);
    }

    and DAGNABIT! IT WORKED!!

    The first movie populated the .TXT with an array and the second movie pulled them in beautifully!

    Now I can sell this admin module for few extra thousand!!

    Whoooohoooo!

  12. #12
    Senior Member
    Join Date
    Oct 2000
    Location
    Perth, Western Australia
    Posts
    103

    new problem...

    I'm really hoping you can help me with this one!

    I've created a quiz (on CD-ROM) that allows the user to 'save and quit' if they don't have time to complete the entire quiz. Next time they load up the quiz I load their variables:

    loadVariablesNum ("test.txt", 0);

    While they progress through the quiz I create a variable called lastLabel which keeps track of the last frame label they were at. When they come back to the quiz and the variables are loaded my script is:

    gotoAndPlay (_level0.lastLabel);

    BUT IT DOESN'T WORK!

    In flash, I debugged the movie and the variable seems to be loaded correctly whren I list the variables:

    Variable _level0.lastLabel = "question3"

    ANY IDEAS on why this isn't working???

    Also, when the variables are loaded back into the movie they are all loaded with quotes around them.

    For example,
    q1 = 1
    but when it's loaded back in using loadVariables
    q1 = "1"

    Is there a way to fix this so q1 remains 1?

    Thanks!!!

  13. #13
    Senior Member
    Join Date
    Oct 2000
    Posts
    123

    Hmmm

    My forst question to is how are you saving the variables... are you using the FS Command to .TXT? Sounds like you are but your did not specify.

    If so...I have read that there ar some cautions to doing this...like it will only export variables in the same scene. Not through multiple scenes...and I have no idea how it will react with loaded movies above level0.

    So i would first recommend that you use labels withing one scene to get around so you can export all your variable text fields....

    Second, Have you tries using:

    gotoAndPlay (_root.lastLabel);

    or try putting your marker in a MC like this:

    gotoAndPlay (_root.MCname, "lastLabel");

    (check this syntax...may not be right...but the concept is there)

    instead of:

    gotoAndPlay (_level0.lastLabel);

    I have to go...but I will give this more thought and reply again later.

    Cheers!

  14. #14
    Senior Member
    Join Date
    Oct 2000
    Location
    Perth, Western Australia
    Posts
    103

    still no luck...

    Yes, I am saving the variables from a TXT file on the hard drive.

    I have a frame action of:

    loadVariablesNum ("test.txt", 0);
    gotoAndPlay (_level0.lastLabel);

    and when I view the variables in debugger it says:

    Variable _level0.lastLabel = "q2"

    ...yet it won't forward the user to frame label "q2"

    The movie is all on the same level and within the same scene. I don't get it!!

    I've tried changing _level0 to _root but those did not help. I also tried with square brackets ([_level0,lastlabel]) without success.

    This is driving me nuts! I don't understand why it's not working.

    If anyone has pity for me you can download the FLA and have a go at trying to figure out what my problem is!

    http://www.revok.com/glenn/flash5_exampleX.fla

    THANKS!!!

  15. #15
    Senior Member
    Join Date
    Oct 2000
    Location
    Perth, Western Australia
    Posts
    103

    Smile fixed!

    I moved the Loadvariables script to the beginning of the movie and it worked!

    I suppose it didn;t work before because both the loadvariables and gotoAndPLay were within the same frame??

    Oh well, it works now!

  16. #16
    Senior Member
    Join Date
    Oct 2000
    Location
    Perth, Western Australia
    Posts
    103

    those dam quotes!

    Hello again,

    When I load the variables from the hard drive the variables get quotes around them for some reason.

    For example:

    quizCount = 6
    ...becomes...
    quizCOunt = "6"

    This is messing things up for me since I'm using this as a count fiunction (ie, quizCount = quizCount+1).

    Thus, instead of quizCount = 7 ...
    I'm getting quizCount = "61"

    When I look in the TXT file it seems to be save normally (&quizCount=q7) ... so why do the " " get added?


  17. #17
    Senior Member
    Join Date
    Oct 2000
    Location
    Perth, Western Australia
    Posts
    103

    hey jmstammen

    How do you specify a different fdirectory to load the variable?

    For example, the CD-ROM drive with the flash EXE is d: ... but I want to save the variables to c: using:

    on (release) {
    fscommand ("save", "C:\\test.txt");
    }

    ...but the following doesn't work when I try to load them in...

    loadVariablesNum ("C:\\test.txt", 0);

    I checked the C: and the TXT file was indeed written there... it's just a metter of figureing out how to load it!

    When I was testing I was writing the TXT file to the same folder as the flash EXE, and loading it from the same folder as the flash EXE ... but obviously this isn't possible once it's on a read-only CD-ROM!

    Any thoughts?

  18. #18
    Wow to load from 1 file (.txt) for 5 text field
    I making a High score list reader for my game.
    and how to save in 1 file 5 texte filed?

    Plz help!

  19. #19
    Senior Member
    Join Date
    May 2001
    Location
    London, England
    Posts
    273
    How come this command works fine in Flash 5 but not in FX?

    on (release) {
    fscommand ("save", "Text.txt");
    }

  20. #20

    PROBLEM

    Hello!
    I have Flash MX!
    I can load a .txt file
    but I can't save it!
    and, How to tell what texte field to save?

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