I managed to do what I wanted in the by basing it on the examples that you
list and by looking at the examples on livedocs.

 

This is what I ended up with:

 

The only thing I couldn't get it to do was to make the progress bar move as
data is loaded but the file I am loading is very small so it loads in a
fraction of a second.

 

package components

{

    import mx.preloaders.*;    

    import flash.events.ProgressEvent;

    import flash.events.Event;

    import flash.display.Sprite;

    import mx.events.FlexEvent;

    import mx.events.RSLEvent;

    import flash.net.URLRequest;

    import flash.net.URLLoader;

    import mx.core.Application;

            

            public class CustomPreloader extends DownloadProgressBar

            {

                        

                        

                        public function CustomPreloader()

                        {    

                            super();

                        }

                        

        // Override to return true so progress bar appears

        // during initialization.        

        override protected function showDisplayForInit(

                elapsedTime:int, count:int):Boolean {

            return true;

        }

 

        // Override to return true so progress bar appears during download.


        override protected function showDisplayForDownloading(

                elapsedTime:int, event:ProgressEvent):Boolean {

            return true;

        }

        

                        private var _preloader:Sprite; 

                         

 

                        override public function set
preloader(value:Sprite):void

                        {

                                    _preloader = value;

                        

 
value.addEventListener(ProgressEvent.PROGRESS, progressHandler);      

                                    value.addEventListener(Event.COMPLETE,
completeHandler);

                                    

 
value.addEventListener(RSLEvent.RSL_PROGRESS, rslProgressHandler);

 
value.addEventListener(RSLEvent.RSL_COMPLETE, rslCompleteHandler);

 
value.addEventListener(RSLEvent.RSL_ERROR, rslErrorHandler);

                                    

 
value.addEventListener(FlexEvent.INIT_PROGRESS, initProgressHandler);

 
value.addEventListener(FlexEvent.INIT_COMPLETE, FlexInitComplete);

                        }

        

                        private function FlexInitComplete(event:Event):void

                        {

                                    

                                    var configRequest:URLRequest = new
URLRequest("siteconfig.xml");

                                    var configLoader:URLLoader = new
URLLoader(configRequest);

                                    

 
configLoader.addEventListener("complete", configLoaded);

                                                                        

                                    //dispatchEvent(new
Event(Event.COMPLETE)); 

                                    

                        }

                        

                        private function configLoaded(e:Event):void

                        {

                                    var appMain:Object =
Application.application;

                                    

 
appMain.appSettings.processConfig(e.currentTarget.data);

                                    

                                    dispatchEvent(new
Event(Event.COMPLETE)); 

                        }

                        

            }

}

 

Giles Roadnight

  _____  

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of {reduxdj}
Sent: 15 December 2006 08:48
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] customising preloader

 

Stephen:

I've been messing around with the same thing, it's always nice when 
other people have the same challenges, which means more help. I've got 
a lot to learn and the following solution might be considered a bad 
hack, but sometimes what works, works.

Keeping preloader on the screen after intial load means you should look 
at this example how to make a custom one is made first. i think you 
said you did....

http://www.onflex.
<http://www.onflex.org/ted/2006/07/flex-2-preloaders-swf-png-gif-examples.ph
p> org/ted/2006/07/flex-2-preloaders-swf-png-gif-examples.php 
<http://www.onflex.
<http://www.onflex.org/ted/2006/07/flex-2-preloaders-swf-png-gif-examples.ph
p> org/ted/2006/07/flex-2-preloaders-swf-png-gif-examples.php>

Of course you can't tell how long your data query is going to take so 
the progress bar is just for the application.
I don't know what you want to do with the progress bar after the 
intitial load, but ok...

I was able to do this from this example and use my custom swf preloader 
with our logo in a swf from this example, thanks ted patrick!

I hope this provides you insight. if you extend the loader class you 
can do the same thing basically. 
Let me know your results. good luck

<http://www.onflex.
<http://www.onflex.org/ted/2006/07/flex-2-preloaders-swf-png-gif-examples.ph
p> org/ted/2006/07/flex-2-preloaders-swf-png-gif-examples.php>

I took Ted's example and hacked it to hell like this:

from the customPreLoaderFile:

private function FlexInitComplete( event:Event ):void
{ 
wcs.ready = true; 
dispatchEvent( new Event( Event.COMPLETE ) );
Application.application.createWCS(wcs);
}

private function dispatchMeEvent(wcs:WelcomeScreen):void{
Application.application.createWCS(wcs);

//this gives me access to this the WelcomeScreen from my main 
application, not
//the best way but it works fine for me , using my custom 
dispatcher, actually sending
// the object to my application so then i can fade it and wait 
for my query to come back
// before so. 

}

from the WelcomeScreen.as i added a flag for the fadeIn and commented 
out the fadeOut because i want to fade it on my own from my main 
application, if you don't do this, the loader will be active and fade 
in & out whenever something is loaded. I don't want to removeChild, i 
want to keep it there, it's small and at the top of
the application and it sits nicely in front of everything and can be 
used for loading images or anything

public function updateView( event:TimerEvent ):void
{
if (_started == false){


if( this.alpha < 1) this.alpha = this.alpha + 
this.fadeInRate;
this.stage.addChild(this)

this.visible=true;
if( this.ready && timer.currentCount > 
this.timeAutoClose ) closeScreen() 
_started = true;
}
}


public function closeScreenFade( event:TimerEvent ):void
{
/*
if( this.alpha > 0){
this.alpha = this.alpha - fadeOutRate;
} else {
timer.stop();

//this.parent.removeChild(this);
} 
*/
} 

Stephen Gilson wrote:
>
> There is an example in the doc starting here:
> 
> http://livedocs.
<http://livedocs.macromedia.com/flex/2/docs/00000647.html>
macromedia.com/flex/2/docs/00000647.html 
> <http://livedocs.
<http://livedocs.macromedia.com/flex/2/docs/00000647.html>
macromedia.com/flex/2/docs/00000647.html>
> 
> Stephen
>
> ----------------------------------------------------------
> *From:* [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com> ups.com
[mailto:[EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com> ups.com] 
> *On Behalf Of *Giles Roadnight
> *Sent:* Thursday, December 14, 2006 11:25 AM
> *To:* [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com> ups.com
> *Subject:* [flexcoders] customising preloader
>
> Hi All
>
> I've been trying to create a custom preloader for my flex app. I want
> to keep the DownloadProgressBar object on the screen when the app has
> finished loading and initialising and then load my own xml
> configuration file.
>
> I've been trying to extend the DownloadProgressBar class and had a
> look at extending the prelaoder class but didn't get very far.
>
> Can anyone point me in the right direction? I did find one example
> that replaced the prelaoder with an image but I couldn't alter this to
> what I want.
>
> I also tried to create my own DownloadProgressBar object and use it to
> display progress of a load after the app has finished initialising but
> this didn't work either.
>
> Unless I can get it to work I'll have to just create my own popup and
> load the xml once hte app has initialised but I'd rather it all
> happens with the 1 popup.
>
> Many Thanks.
>
> Giles Roadnight
>
> 

 

Reply via email to