2 Replies Latest reply on Jul 30, 2009 1:14 PM by BrendonKoz

    Best way to accomplish this?

    BrendonKoz Level 1

      I'm new to developing with Adobe AIR.  I find it both exciting, and difficult to grasp coming from a non-event driven language.

       

      What I'm trying to do (HTML/JS based):

      - Main window visibility set to false

      - Upon first run of the application (or if settings file doesn't exist), fetch JSON data from an external site and prompt the user (new window, visibility true) based on data fetched; save data to a settings/preferences file.

      - After either opening the settings file or fetching the data from the site, use those preferences to fetch further JSON data from (same) site to dynamically create GUI controls.

      - Display main window (set visibility to true).

       

      What's occuring:

      I'm using jQuery to *try* to make things easier for me, I'm not much of a JavaScript whiz.  Because I'm thinking procedurally, and the calls are happening asynchronously, I'm getting continuous errors.  The initial data (that is to be saved to the settings file) cannot be fetched, even though I've successfully done it asynchronously (when I try synchronously, it still errors out as if it's returning too fast or timing out).  The main window appears even before the error message (alert box for now) appears.  Again, I'm thinking procedurally and it seems to not work.

       

      Would I be best off to first set an event listener for the prompt windows' close (if settings file doesn't exist) and to then proceed with further actions, or is there an easier, better way to accomplish this?  How should my flow structure be handled?  (Rough pseudocode examples anybody?)  I'm having difficulty seeing how it all fits together, and it's a pretty simple application I'm trying to build.  Any help would be greatly appreciated.