5 Replies Latest reply on Mar 26, 2007 6:41 AM by Gib_Sllab

    Reading File Modification Date

    Gib_Sllab
      In Flash 8 I know there is the FileReference class but it seems to be geared around uploading files. Is there a way to just read an existing local files modification date? I am building an executable that loads a .swf file, and the .exe just needs to know if the file has been updated. It will periodically check for changes, ideally. Any help would be appreciated with this. Thanks, Rob
        • 1. Re: Reading File Modification Date
          Greg Dove Level 4
          I'm pretty sure you can't do that without using a third party tool which you may want to consider if you're building a local executable. Or if you're adventurous and into as3 it sounds like the type of thing that Apollo (recently released) would let you do.

          What is the purpose of your check? Is it to reload the swf if it gets changed (presumably by some other process that's happening)?
          • 2. Re: Reading File Modification Date
            kglad Adobe Community Professional & MVP
            the filereference class has a modificationDate property.
            • 3. Re: Reading File Modification Date
              Greg Dove Level 4
              kglad:

              Yes it does...but you can only access that property it after you've had the user browse and select it.

              Maybe I've misinterpreted the request from Gib Sllab, I thought it was to check the properties from a local file directly. You can't do this without asking the user to browse to it. But I think you can set the reference to the local file will the Apollo extensions... using the File Class, which may be an option if its intended to be a local "application" type projector. I assume that once you've done that you could access its modified date using the FileReference as your described, but avoid the need to have the user browse to select it. Perhaps some other 3rd party tools might be an option too... zinc or others etc... I haven't checked.
              • 4. Re: Reading File Modification Date
                Greg Dove Level 4
                Had another thought... its been puzzling me why you need to get this information....

                I can only assume that its because some external process to the the projector exe file is creating a new swf every now and then...one with the same name as the one you've loaded.

                If so, could you not get that process (whatever it is) to also save to a text file with the time/date at the time of an update to the swf?
                Have flash load this value from the text file when it starts with loadVars and (if you want more persistence use a sharedObject to retrieve/store the old value).
                Check the text file periodically - and then compare with the old value each time. I know this approach sounds clumsy but you're quite limited unless you want to add some additional file system api via a 3rd party projector tool etc. Its also difficult to suggest an option because I don't know why you need to do this... I'm just guessing.
                • 5. Re: Reading File Modification Date
                  Gib_Sllab Level 1
                  quote:

                  I can only assume that its because some external process to the the projector exe file is creating a new swf every now and then...one with the same name as the one you've loaded.


                  GWD... you are exactly on target with that guess. I have built an application which on an interval of every 10 seconds goes out and (theoretically) checks the files modification date. If a new date is found then load the swf file into the .exe. Unfortunately, it seems like this can't be done. The solution I came up with is basically what you said. I built an XML file with the modification date. The .exe checks against that and reloads appropriately. Like you said though, it's a sloppy solution but a solution none the less. Flash really needs to have the this ability, maybe not for .swfs (and I can understand the security issues here) but definately for .exes.

                  You are probably right about using a 3rd party application, but I try to avoid using those as much as possible. I could also accomplish reading the files mod date by hooking flash into a server side language, but then were talking about a whole other situation and issues with Flash's security. It's more trouble than it's worth. (I'll keep my eye on Apollo)

                  Thanks everybody!