0

I would like to use Air to build for PC, Mac, Android, Ios.

Is it possible to do this from a single code base as Adobe Suggests.

Or will I need to maintain 4 separate builds?

Some guidance would be appreciated.

Regards C

ketan
  • 19,129
  • 42
  • 60
  • 98
Craig Mc
  • 505
  • 1
  • 13
  • 30

1 Answers1

0

I have been able to maintain a single code base to date. I have done things like the following:

        private function getHostName() : void
        {
            if (NativeProcess.isSupported)
            {
                var OS : String = Capabilities.os.toLocaleLowerCase();
                var file : File;

                if (OS.indexOf('win') > -1)
                {
                    // Executable in windows
                    file = new File('C:\\Windows\\System32\\hostname.exe');
                }
                else if (OS.indexOf('mac') > -1 )
                {
                    // Executable in mac
                }
                else if (OS.indexOf('linux'))
                {
                    // Executable in linux
                }

                var nativeProcessStartupInfo : NativeProcessStartupInfo = new NativeProcessStartupInfo();
                nativeProcessStartupInfo.executable = file;

                var process : NativeProcess = new NativeProcess();
                process.addEventListener(NativeProcessExitEvent.EXIT, onExitError);
                process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutput);
                process.start(nativeProcessStartupInfo);
                process.closeInput();
            }
        }

        private function onOutput(event : ProgressEvent) : void
        {
            var strHelper : StringHelper = new StringHelper();
            formStationID.text = event.target.standardOutput.readUTFBytes(event.target.standardOutput.bytesAvailable);
            formStationID.text = strHelper.trimBack(formStationID.text, "\n");
            formStationID.text = strHelper.trimBack(formStationID.text, "\r");
        }

        private function onExitError(event : NativeProcessExitEvent) : void
        {
        }

To take care of native calls. Other than the native calls I have found few things that can't be written generically, but of those, the above approach should work with any part of the code set as well.

powelljf3
  • 119
  • 4
  • Firstly thank you for your reply, that takes care of the desktop OS stuff. Am I correct in assuming when it comes to AIR for Android and IOS I need to maintain a separate mobile project. – Craig Mc May 18 '12 at 21:38
  • I am going to say no, at least for the back-end type of programming, much like the example above, the mobile work can be called out using appropriate if conditions. I know this might sound strange, but I have been using this approach to determine if I was in a production environment or a test environment since the Fortran days. – powelljf3 May 18 '12 at 22:00
  • Odly when I was using zinc as my wrapper I had adopted much the same approach, I was just hoping that Air would unify the capabilities more so that I could create a single coherent application. (As in just hit a different compile button per platform and it would sort out the differences at the virtual machine level). – Craig Mc May 18 '12 at 23:46
  • My initial reading indicates, I would need to do view navigation differently, I am trying to figure out what else (Aside from compilation.) You have given me food for thought, I am tempted to see if I can pull off an all in one approach, the success of it will be largely dependent on what other limitations Air imposes on tablets and apple devices, like can I use the html components and so on. – Craig Mc May 18 '12 at 23:46