2 Replies Latest reply on Apr 24, 2013 11:33 PM by shoggoth000

    Using same project for Desktop and Web (?)

    Santanu Karar Level 1

      Is it possible to manage a same codebase/project for compiling both for AIR and web release (?) Also, on a distant thinking, can ANT able to help this way?

        • 1. Re: Using same project for Desktop and Web (?)
          CWBenccw

          Not exactly same code base ,unless you dont use those AIR exclusivly API.

           

          I have experience on developing actionscript project on both Flash and AIR for the same project.

           

          90% of code are the same.

           

          for those 10% differences are:

           

          1. AIR -> the downloaded modules have to be written to AppData, Flash-> no update and download need

          2. AIR -> difference stage will be loaded into Native windows , Flash->  difference stage will be loaded in the same stage.

          3. AIR -> have to implement Browse involve action , Flash -> use swfObject

          • 2. Re: Using same project for Desktop and Web (?)
            shoggoth000

            To elaborate further, in Flash Builder create:

             

            Core Library : Actionscript Library Project - This project contains 90% of your code as CWBenccw mentioned.

             

            AIR Core Library : ActionScript Library Project (Linking AIR libraries) - This project contains AIR-specific implementations of core functionality.

             

            Web App: ActionScript Project (Web) - This project links with Core Library and contains a basic entry point for web (a Main Sprite)

             

            Desktop App: ActionScript Project (Desktop) - This project works like the above, but with a Desktop entry point and Application descriptor, and links with AIR Core Library

             

            Mobile App:  ActionScript Mobile Project - Same as above, but for mobile

             

            The way you use your AIR Core Library is to provide overrides for things that are different in AIR.  For instance you might want to be able to save files differently, but transparaently to the Core Library.  In this case you create an interface for saving in Core Library, e.g.

             

            interface Saver

            {
            function save(filename:String, data:String) : void;

            }

             

            You also create an implementation for your non-AIR core:

             

            class FlashSaver implements Saver

            {

            function save(filename:String, data:String) : void

            {

                 var so : SharedObject = SharedObject.getLocal("something");

                 so.data[filename] = data;

                 so.flush();

            }

            }

             

            And then an AIR implementation that might use AIR features like direct File IO.

             

            Your various entry points are responsible for providing the correct implementation of Saver to your Core Libraries via some form of dependency injection.