1 Reply Latest reply on Oct 6, 2011 9:14 AM by ozDiGennaro

    Using project libraries for both web-based and AIR applications

    ozDiGennaro

      I need to develop substantial code to build both web-based and AIR applications.  Yes, they will have different features, especially when it comes to accessing files on the local file system.

      However, 98% of the code can be shared.

       

      I want to use a project library that can be used for both types of applications. Maybe using conditional compile when required to not use AIR API's in a web-based application.

       

      I found this (somewhat old) warning:

       

      Include Adobe AIR libraries Select this option if your library must use AIR features, such as access to the AIR APIs. Flex Builder then changes the library path of this new Flex Library project so that it includes airglobal.swc and airframework.swc. Web-based Flex projects cannot use this library.

      Do not select this option if you are writing a generic library intended to be used only in a web-based Flex application, or in either a web-based or AIR-based application.

       

      Does this apply to Flash Builder 4.5?

        • 1. Re: Using project libraries for both web-based and AIR applications
          ozDiGennaro Level 1

          I have found a workaround, but it's quite clumsy, involving a transfer vector (in old-fashioned terms) in the main application for each function in the AIR library.

          I have created a library for AIR classes only (fourdtext.fileOperations is there). 

          The AIR application provides "Function" values that any other code in the general-purpose libraries can use.

          It works, but it's nasty.

           

          In Main.mxml:

           

          import com.fourdtext.fileOperations.AxFiles;

           

          // this gets a list of native path strings, from and array of "File" objects

           

          public var AxGetListFunction:Function = AxGetListRedirect;

          private function AxGetListRedirect(list:Array):Vector.<String>{

              return AxFiles.AxGetList(list);

          }

           

           

          In general-purpose code:

           

          var list:Array = event.dragSource.dataForFormat("air:file list") as Array;

          ...

          var AxGetList:Function = FlexGlobals.topLevelApplication.AxGetListFunction;

          listFiles = AxGetList(list);

          1 person found this helpful