2 Replies Latest reply on Mar 10, 2010 11:26 AM by Joe ... Ward

    Open text file to use in swf within air

    gcollins2

      Hello,

       

      I am very NEW to flash and air and have recently been given the task of taking some older flash content and making an air application. The swf were initally published for Flash 4 and done by a programmer who is no longer here.

       

      I have created an html page that is the initial page for the app and clicking on the links opens a swf file in a jquery lightbox.

       

      Everything is working fine until I get to the swf's that are quizzes. These quizzes used the following lines of code in the swf to load the data needed from text files:

       

      loadVariablesNum("ImmuneSystem_Data/questions.txt", 0);
      loadVariablesNum("ImmuneSystem_Data/answers.txt", 0);
      loadVariablesNum("ImmuneSystem_Data/correct.txt", 0);
      loadVariablesNum("ImmuneSystem_Data/wrong.txt", 0);

       

      But when I view them in my air application this data doesn't show up. I have been looking at the air documentation and how to read text files with the filestream object (and getting very confused) but I can't seem to get anything to work.

       

      I will keep on trying but any suggestions (or explanations) would be greatly appreciated getting me over this hurdle.

       

      Thanks in advance (even if it was just looking at this post).

       

      G

        • 1. Re: Open text file to use in swf within air
          gcollins2 Level 1

          Ok, after looking at my flash files I was able to include the variables that were in the text files in the flash file. Problem Solved!

           

          But gettting further in this project a much bigger issue has come up. I now have swfs that use LoadMovieNum to load other swf's into that movie. But when viewing in adobe air the swf's dont' get loaded. I think this is a sandbox issue that I am still trying to get my head around.

           

          How do I load swf's that my main swf relies on when making an html air application?

          • 2. Re: Open text file to use in swf within air
            Joe ... Ward Level 4

            Is the loading SWF in the application directory (or a subdirectory thereof)?

             

            If so, you are probably running into an AIR bug which prevents proper resolution of relative file paths by SWFs running in an HTML page. There are two workarounds (that I am aware of):

             

            1. Use absolute paths instead of relative paths. (This is the simplest workaround, but if you don't have control of the SWF code, then you might not be able to do it.

             

            2. Arrange for the loading SWFs to be outside the application sandbox. There's a couple of ways you could do this, but for testing, the easiest way is to move them to a directory outside the application directory. This workaround is significantly more complex than the first. Not only do you have to load the SWF differently, if that SWF needs to communicate with other parts of your application, you need to handle the sandbox bridge.

            1 person found this helpful