blackberry/Samples-for-AIR — pull request #17 by UberschallSamsara (2013-02-06 02:06:24+00:00)
Title: Added check/init for starshipSettings SharedObject

I added a function to StarshipSettingsView.as to check whether the starshipSettings SharedObject has been created and initialized (which it won't be immediately after the app is installed for the first time), and initialize it with default values only on the first use of the app. Without this function, the app as written will not properly come up with the desired default settings on first use. The loadSettings() function checks for existence of the SharedObject with "if (so)". This check appears to be trying to only set values if the SharedObject is initialized, but the "if (so)" will never fail, even on first use, when the SharedObject does not yet exist and therefore is not initialized, unless the operating system has no space to create it or the user has disabled its creation in their AIR settings. The checks in the checkFirstUse() function that I added will set default values properly in the SharedObject, so that even on the first use of the app, loadSettings() gets what it should. Try running the app on a first install with and without my changes - the slider is not initialized to the intended value, and the WarpImage instance does not animate on the first use on a fresh install. Add in the checkFirstUse() function, and this first-install misbehavior is fixed.