Saving a Flash CS4 file in Flash CS5 causes corruption.

I have read about this issue in the past, but I have never ran into it myself. Most likely because I don’t do a lot of work with FLA files, I usually work with Actionscript projects in Flash Builder. Well, last night, my luck ran out, and this issue hit me full force. And of course, I was working on a file I hadn’t committed to a source repository, a.k.a. – no backup. Needless to say, my stomach hit the floor when I saw the “Flash can not parse this document” error message.

CS5 error messgae

When I tried a second time, I got a different error message, something along these lines:

An error occurred opening file 'Users/smorgan/work/project/src/someFile.fla'
The following JavaScript error(s) occurred:
Cannot find file Users/smorgan/work/project/src/someFile.fla.

Before I saw these error messages I had opened up an fla file I had last worked on in Flash CS4 in my new and shiny Flash CS5 IDE. There was nothing special about this file, very minimal code on the timeline, mainly just timeline animations and library assets/MovieClips. When I attempted to save the document after I made a few changes I got the standard “This file will be converted from Flash CS4 to Flash CS5…” confirmation message.

CS5 confirm message

Pretty standard practice, this type of message has always occurred in the Flash IDE as far back as I can remember. Naturally I clicked “Save” and everything appeared to be normal. I even made a few more changes, saved my work, and published a swf without any problems. Armageddon didn’t set in until I closed the file, or the IDE and attempted to reopen the newly saved CS5 FLA again.

Normally I always check my work into a source repository and this corrupted file wouldn’t have been such a huge issue because I would have had a backup. However, this time there was no backup so naturally I thought I was screwed. Then I remembered that during the CS5 beta program I played around with the new FLA format which is really an archive of files, a ZIP file. I changed the .fla file extension to .zip and attempted to unzip the file, thinking I may be able to restore something from the original file. I’m on a Mac and by default ZIP files are unarchived with the native Archive Utility when they are double clicked on. Double clicking the .zip file didn’t unarchive the file, instead it added a second file extension .cpgz which still had the standard OSX archive file icon. I tried unarchiving this file again and nothing happened, just removed the .cpgz extension and if I clicked on the file again it added the .cpgz extension again. An endless loop of nothingness. Time to hit up Google and I came across this forum which suggested using StuffIt Expander.

Stuffit Expander successfully unarchived the .zip file. Inside the unarchived directory I could still see all of the fla assets, very promising.

xfl directory structure

Because the error message indicated Flash could not “parse” something I figured it is probably an XML issue. FLA’s saved in CS5 use the new XFL (not Vince McMahon’s Extreme Football League) file format. The XFL file format is a way to represent a Flash Professional document as an XML-based, open folder of files. Because there are numerous XML files in the XFL archive I figured one of them must be corrupted, so I opened the DOMDocument.xml, MobileSettings.xml, PublishSettings.xml, and all the XML files in the Library directory (which represents all the assets saved in the Library of your FLA). Unfortunately, none of these XML files appeared to be corrupt. The XFL archive also contains an .xfl file in the root of the archive which is essentially an FLA and can be opened by the Flash CS5 IDE. For me, attempting to open this file gave me the same “can not parse” error message.

Now that I had confirmed none of the xml files were corrupted, I started to think how long it would take me to rebuild this file from scratch. Not a fun thought because I had no idea what was in the original file, well not everything anyway, only the few things I touched. Then I had a brilliant idea (IMO) which ended up restoring my corrupted file. That’s right, I fixed the corrupted FLA, it was a very tedious process but it worked, and that’s all that mattered. Here are the steps I took.

    1. Open Flash CS5 if it isn’t already open.

    2. Create a new CS5 Flash file and save it as a “Flash CS5 Uncompressed Document (*.xfl)”.

    CS5 uncompressed document

    The uncompressed *.xfl document is really a directory of files just like the unarchived .fla I mentioned above.

    3. Once saved, a directory is created instead of a single FLA, this directory contains the same files I showed above, only differences being most of the files are empty and the bin, LIBRARY, and META-INF directories are empty.

    4. Now the tedious fun begins, I started dragging over files 1 by 1, after each file I attempted to open the .xfl until I once again saw the “Flash can not parse this document” error message. For me, it was the second last xml file in the LIBRARY directory that was causing the issue. I read on a couple sites the corruption usually occurs when there are blank nodes within a , like so.

    <DOMLayer name="Layer 1" color="#FFFF00">
      <frames/>
    </DOMLayer>

    In my scenario blank frame nodes was not the issue. I had a few of these in my “corrupted” library xml file, when I removed these nodes like a few sites suggested nothing changed, still got the “Can not parse” error message. The next thing I did was started deleting lines in the “corrupted” XML file until I could open the .xfl in the IDE. I finally figured out that deleting the following XML “fixed” my corrupted file.

    <DOMFrame index="0" duration="2" keyMode="9728">
      <elements>
        <DOMSymbolInstance libraryItemName="playerOpen" name="">
          <matrix>
            <Matrix tx="-1.2"/>
          </matrix>
          <transformationPoint>
             <Point x="5.6" y="6.15"/>
          </transformationPoint>
        </DOMSymbolInstance>
      </elements>
    </DOMFrame>

    I tried to figure out what was corrupted in the above XML. I added data into the name attribute, I changed the negative coordinates to positive coordinates, I changed all the coordinates to whole numbers, I changed the libraryItemName ensuring it was unique, changed the duration, and index, and other random things. Nothing. The only way to fix my file was to delete this whole chunk of XML. When I opened up the XFL file and found this item in the library the frame was empty and I had to recreate it. After I recreated the frame and saved the file the above “corrupted” XML looked like this.

    <DOMFrame index="0" duration="2" keyMode="9728">
      <elements>
        <DOMSymbolInstance libraryItemName="playerOpen" name="" centerPoint3DX="4.4" centerPoint3DY="6.15">
          <matrix>
            <Matrix tx="-1.2"/>
          </matrix>
          <transformationPoint>
            <Point x="5.6" y="6.15"/>
          </transformationPoint>
        </DOMSymbolInstance>
      </elements>
    </DOMFrame>

    The only difference is the centerPoint3DX and centerPointCDY attributes were added to the DOMSymbolInstance node. Not sure why these attributes matter because other SymbolInstances in the same file and other files don’t use these attributes. Anyone have an explanation for this?

Anyway, hope my approach helps someone. I can’t believe this critical bug made it past the Adobe QA. Thankfully XFL exists, without it I would never have been able to fix this issue.

UPDATE: There is a patch on Adobe.com that fixes this issue. However, if the file is already corrupted this patch does nothing. So make sure you udpate your IDE before opening legacy files. I missed this update because the Adobe Updater is so fricking annoying. The IDE should inform users of critical updates as soon as you open it, I have trained myself to ignore the Adobe Updater because it is so annoying (that’s a whole other post, and may others have already posted on that exact topic).

11 Comments

  1. Carole van Almelo

    Wow.. are you a lifesaver. Thank you for taking the time to write about this issue and provide such clear instructions on how to resolve. And what eerie timing.. as I just has the issue the same day that you posted. And of course.. the problem was on a file we need for a major presentation tomorrow.

    Thanks again, I can sleep tonight.

  2. Nicolas Baptista

    Lifesaver is the word who better describe you and this post.

    Thank you.

  3. The patch helped me move a file from cs5 to cs4. was getting xml problems before.

    I’m moving to cs4 on a theory about cs5’s projector not playing the correct frame rate.

    Thanks!

  4. gersonm

    You are my personal salvator, my hero! u.u

    Thanks a lot!

  5. You just saved me a boatload of work. Thank you!

  6. tanx
    you saved my life
    you are very goooooooood hero

  7. Amazing… thank you sir. I owe you a beer.

  8. You’re a lifesaver, really.
    I love Calgary … and now plus & plus!
    Thanks, thanks a lot

  9. Thanks a lot, you just saved my day!

  10. Awesome, this saved me a good few hours of painstaking rework when I got the corruption bug

    thanks!

  11. I used to get this problem all the time, thanks for the tip. Flash is still well buggy though! Even CS6. Good article.

Trackbacks/Pingbacks

  1. Swf.hu 2.0 – flash és webfejlesztés » Heti link gyűjtemény 2 - [...] Saving a Flash CS4 file in Flash CS5 causes corruption. Vigyázat Flash CS4-es filok mentése Flash CS5-ben kellemetlen meglepetéseket…

Leave a Comment

Your email address will not be published. Required fields are marked *