Skip navigation
Robert Barr
Currently Being Moderated

file work

Jul 12, 2011 9:34 AM

How does one actually go about writing a file out to a directory from inside a class or is there an actual class that handles that like in other languages?

 
Replies
  • kglad
    72,274 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 12, 2011 9:56 AM   in reply to Robert Barr

    if you're using adobe air, you can use the file class.

     

    otherwise, you'll use the urlloader class to call a server-side executable (eg, a php file) that will write the file to your server.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 12, 2011 10:07 AM   in reply to Robert Barr

    Also you can enable user to save file on their local hard drive via using FileReference class. This though doesn't have any access to file structure - it behaves exactly like when you save, say, image from a web page with OS' interfaces etc.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 12, 2011 11:30 AM   in reply to Robert Barr

    You can ALLOW USER save it with FileReference. Other wise, unless it is an air application - you cannot save anything on user's harddrive without him being aware that it was saved. SharedObject is, of course, an exception but it is a slippery road because user can always reject/remove this info.

     

    How are you going to reuse this saved file if ever?

     
    |
    Mark as:
  • kglad
    72,274 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 12, 2011 3:43 PM   in reply to Robert Barr

    use the sharedobject.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 12, 2011 9:02 PM   in reply to Robert Barr
     
    |
    Mark as:
  • kglad
    72,274 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 12, 2011 10:54 PM   in reply to Robert Barr

    var so:SharedObject = SharedObject.getLocal("yourso");

    if(so.data.whatevervariable){

    // use so.data.whatevervariable etc

    }

     

    //  some place when you have the data that's needed to be saved:

     

    so.data.whatevervariable=thedata;

     
    |
    Mark as:
  • kglad
    72,274 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 16, 2011 10:24 PM   in reply to Robert Barr

    no, you don't have to apply the flush() method to write to your so.  if you apply flush(), data is written to the so immediately.  if don't apply flush(), data is written when your swf closes.

     

    p.s.  i notice you marked many of your threads as answered but gave noone credit for giving a helpful or correct response.  if someone gives a helpful/correct response, you should mark their response.

     
    |
    Mark as:
  • kglad
    72,274 posts
    Jul 21, 2002
    Currently Being Moderated
    Mar 20, 2012 1:54 PM   in reply to Robert Barr

    that's your prerogative.

     

    good luck in the future.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points