Event Driven Programming... I always thought that event driven programming could still use procedural style programming, and use event-driven only when necessary. ...and although that may be the case, I'm finding that Adobe AIR is built primarily as a fully event driven model. I've tried to coerce it in to doing procedural things and it just scoffs at me. I'm sure there are ways to have it work procedurally, but I'm not versed well-enough in it yet to know how, as it apparently expects all actions to be asynchronous.
Here's what I'm learning I need to do in order to invoke a "setup" window prior to invocation of my main program for the first time.
...and that's just to get the app to open properly. I'm not even sure if I've thought it through well enough. It's currently all still in procedural spaghetti code with errors abound. I thought of this after leaving work...so who knows if this'll even work. Ha!
Here's what I'm learning I need to do in order to invoke a "setup" window prior to invocation of my main program for the first time.
- Invoke main application, hidden.
- Detect if the settings file exists (hey, procedural, sweet!), if not...
- Open a new window (hidden), set an event listener for its close.
- In the new window, retrieve optional settings choices from the server; in the "success" event listener, dynamically fill the window with the options/controls...in the "fail" listener, close the new window and application window after displaying an error message (initial setup absolutely requires communication from the server).
- Upon submit of the setup window, close the window, revert data back to the calling/parent window.
- The closed window event runs...we re-fetch data from the server based on the setup window's choices (or from the settings file, if it existed - but that's another path that reaches the same point).
- On success, we build the main window's GUI from fetched data and then set the window to visible. On failure, at this point in development, we also close with an error.
...and that's just to get the app to open properly. I'm not even sure if I've thought it through well enough. It's currently all still in procedural spaghetti code with errors abound. I thought of this after leaving work...so who knows if this'll even work. Ha!