Hello!
I´ve been struggling with this for a few days, and I cannot find any way to do it.. Maybe someone know how to do it!
In a mobile application you can specify a splashscreen. Mine is a SWF instead of multiple resolution static images, just to add some "life" to it. There´s also this property that allow us to keep the splashscreen visible through a given number of seconds.
<components:TabbedViewNavigatorApplication
splashScreenImage="@Embed('assets/images/splash.swf')"
splashScreenScaleMode="stretch"
splashScreenMinimumDisplayTime="5000">
Well, this is quite interesting and works ok, but I´m looking for a more specific funcionality, because the "splashScreenMinimumDisplayTime" some times is too long and some times is not enough... What I would like is to keep the splashscreen visible, until some initialize actions are totally complete (in this case, it means downloading a remote XML file and converting it to XMLLists). Then, hide the splashscreen programatically. I think it would be great to be able to manage this behaviour.
There must a way to override some methods of the splashscreen to do this, but I couldn´t find too much info about it... Please, someone just give me any clue to start searching on!
Thanks in advance
I got this workaround to show the splashscreen indefinitely until we hide it in runtime:
1- A custom SplashScreen class is needed. We cannot create one that extends from the original one (located at "frameworks/projects/mobilecomponentes/src/spark/preloaders/SplashScre en.as"), because some changes must be made in a pair of private methods. So, copy the whole file into a "CustomSplashScreen.as" (changing package path and the class name in its declaration and its constructor method).
2- Set the new CustomSplashScreen class as the default preloader in main MXML:
<components:TabbedViewNavigatorApplication
preloader="CustomSplashScreen"
splashScreenImage="@Embed('assets/images/splash.swf')"
splashScreenScaleMode="stretch"
splashScreenMinimumDisplayTime="5000">
3- Back in our CustomSplashScreen class, we declare a new static variable.
static public var DISPLAY_TIME:Number = 1000; // in ms
4- This variable will have initially the same value as the minimumDisplayTime property. To do this, we modify the "prepareSplashScreen()" method, adding the bold part:
private function prepareSplashScreen():void
{
...
...
if ("splashScreenMinimumDisplayTime" in info)
{
DISPLAY_TIME = this.minimumDisplayTime = info["splashScreenMinimumDisplayTime"];
}
...
...
}
5- Then modify the "initCompleteEnterFrameHandler()" method to check if both times were reached (again add the bold line):
private function initCompleteEnterFrameHandler(event:Event):void
{
if (currentDisplayTime <= minimumDisplayTime
&& DISPLAY_TIME > 0)
{
return;
}
dispatchComplete();
}
6- Finally, we must reset this new variable somewhere to hide the splashscreen. For example, after the creation_completeHandler actions are done:
CustomSplashScreen.DISPLAY_TIME = 0;
P.D. The code above works, but I would really like to do this without creating a new class with the same contents, but extending from the original SplashScreen class. Maybe someone could fix my solution with a better approach.
North America
Europe, Middle East and Africa
Asia Pacific