1 Reply Latest reply on Apr 2, 2008 4:28 AM by lindz_nl

    Unable to use URLRequest to open swf from AIR?

      My AIR Application runs in the Applications directory (or where the user installs it).

      It is a training programme and different users require different lesson content, which is stored in their user documents folder. I have cracked the process of detecting the content, downloading a zip where it's missing and constructing the folders required to path it correctly, but I am having difficulty loading the swfs.

      I'm using a standard Loader with URLRequest.

      If I place a symbolic link to the user's documents folder inside the AIR app folder (which was just a test) I am able to load them using relative pathing.

      If I use
      appContentSwf:File = File.documentsDirectory.resolvePath("path/content.swf");
      appFolder:File = File.applicationDirectory;
      relativePath:String = appFolder.getRelativePath(appContentSwf)

      I always get null returned as the relative path.

      I have also tried resolving the relative path in the opposite direction.

      The most bizarre thing is that if I use the absolute path from the appContentSwf.url property the swf loads but immediately crashes, giving a TypeError: Error #1034: Type Coercion failed: cannot convert com.package::MyClass@13ed0d1 to com.package.MyClass

      Yes ... it is complaining that it can't convert something to what it already is.

      Is there a 'magic' way of resolving the path from the application directory to the user documents directory in a way that can be used by those good old file loaders and URLRequests?

      The only alternative solution I have thought of is to subpath the application directory so that the user lesson content can be downloaded into there ... ?

      This project is very urgent (the client only decided to go for an AIR based installation system when the main release came out a couple of weeks ago) and I've been banging my head for hours. All and any suggestions very gratefully received!
        • 1. Re: Unable to use URLRequest to open swf from AIR?
          lindz_nl Level 1
          I've solved my own problem.

          Rather sensibly the loaded swfs are very much restricted in their interactions between the parent AIR app and the swf.

          All data is passed serialised rather than as references, and data is largely untyped.

          This explains my com.package.MyClass is not a com.package.MyClass error.

          Fortunately the loaded swfs only interact very minimally with the parent swf, and I had used strongly typed events and static properties where I will now substitute just strings and numbers.

          Fingers crossed ...