Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: preloader for the application and puremvc startup  (Read 10195 times)
marcink
Jr. Member
**
Posts: 13


View Profile Email
« on: February 28, 2009, 05:59:52 »

hi,

how can i make a preloader that displays the flex application loading status, and on complete event starts showing the puremvc startup?

thanks
Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #1 on: February 28, 2009, 06:33:09 »

You can use the mx.Application.onCreationComplete event to launch a PureMVC ApplicationStartupCommand. The Flex preloader is automatically integrated before any application launch. One of the best entry point for your code to execute when the application launches is the onCreationComplete event.

The Flex AS3 EmployeeAdmin demo or most of Flex applications here use it as default.
Logged
marcink
Jr. Member
**
Posts: 13


View Profile Email
« Reply #2 on: February 28, 2009, 07:39:10 »

@tek:

yes, but when i want to use the same preloader for the flex app, and after flex fires the creationcomplete event, i want the same preloader to show the loading progress for the ressources.

for the first part, i extend the DownloadProgressBar. but when the preload ends, flex removes DownloadProgressBar.

can i prevent DownloadProgressBar from beeing removed, and pass an instance of it to puremvc, then register a mediator to it?

thanks
Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #3 on: February 28, 2009, 07:58:28 »

Ok, you want to display an InitIalizationProgressBar. To do this, you just have to use the same skin for your Flex DownloadProgressBar (there is plenty of tutorials on how to customize it on the internet or even adobe official documentation) and simply use the same skin for your own InitializationProgressBar. So, when the Flex preloading as been made, the Application.CreationComplete event dispatched you can display the InitializationProgressBar with a mediator that you will interest in all Initialization notification needed. Each time a notification is received, your InitializationProgressBar gain a level. Use custom property in your notification to tell the IntializationProgressBarMediator how much initialization steps are needed to complete the initialization.

I think that looking at StartupManager, StartupAsOrdered, StartupForAssets demos will help you a lot.
« Last Edit: February 28, 2009, 08:00:54 by Tek » Logged
marcink
Jr. Member
**
Posts: 13


View Profile Email
« Reply #4 on: February 28, 2009, 05:34:16 »

thanks tek,

it was a little tricky though.
the DownloadProgressBar class doesn't implements the IUIComponent, so i couldn't add it to the application.

so, after Application.CreationComplete i registred my PreloaderMediator. in the constructor i created a new UIComponent instance and added the Preloader to it. this way i could add it to the application displaylist.

also i made a get function that returns the 1st child of the UIComponent, hence my Preloader instance.

it works local, but i have to test it on a webserver. not that it would not work, but i don't want the change from the application preloader to the resources preloader to be visible.
Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #5 on: March 01, 2009, 04:01:18 »

To test locally, you could use an HTTP proxy like ServiceCapture or Charles. After a little bit of configuration, they both be able to throttle your connection speed and you'll be able to test it locally as if you were on a server.

On a project I've worked for, a colleague of mine has successfully make the transition between download and initialization invisible. The best we can do is to hack the DownloadProgressBar to let it progress from the start to the middle and follow with the initialization from the middle to the end.
Logged
marcink
Jr. Member
**
Posts: 13


View Profile Email
« Reply #6 on: March 01, 2009, 05:37:53 »

@tek:
thanks, i will try the proxies.
you know, i wouldn't mind the progressbar going to full until the app initialized, and then start for the ressources from the start.
i mean, this is how every install bar works. i just wouldn't like it if there would be a visible change inbetween.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #7 on: March 01, 2009, 07:57:53 »

You can display it again, but I don't think you can keep flex from removing it.

-=Cliff>
Logged
krange
Newbie
*
Posts: 8


View Profile Email
« Reply #8 on: March 22, 2009, 08:56:17 »

You can display it again, but I don't think you can keep flex from removing it.

-=Cliff>

Yup, Flex will try to remove it from the display list once the Flex Application initial load has completed. You can get around this by creating a new Sprite and have it implement IPreloaderDisplay and set that class as the preloader in your Application Class. Then delay the Event.COMPLETE that gets fired from it until everything in your PureMVC application has loaded. There are a few tricky things with this solution, but it allows you to use your own Preloader and keep it until you want it removed ( ie. once all your init views have loaded ). 

I use a home grown PreloadManager that keeps track of different phases ( Flex Application Intialize, Data Load, View Load, etc ) and and my preloader listens for events from that to know when the entire load has completed.

Theres a bunch of good articles ( just google "flex custom preloader" ) that show you how to do the IPreloaderDisplay setup.

Thanks,
Kris

Logged
Pages: [1]
Print