i'm having trouble getting a ProgressBar to update when linked to a 
URLLoader (the ProgressBar is configured to be in event mode).  i can 
see that ProgressEvents are being fired as the large (50 MB) file is 
being read, but they don't result in an update in the ProgressBar's 
display.  i can also see that the ProgressBar is internally calling 
setProgress, but still the progress meter does not increase.  it does 
however jump to 100% after the file is fully read.

i also tried using a ProgressBar in manual mode and calling 
setProgress manually in my handler of the URLLoader ProgressEvent.  
again i could see the setProgress call inside ProgressBar, but the 
meter did not update itself.  however if i use a ProgressBar in 
manual mode that is not linked in any way to a URLLoader (e.g. like 
the one at 
http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html) 
the ProgressBar updates fine.

the source code for my apollo app is below - i needed to use apollo 
to allow the user to browse the local file system for the file to 
import.  i also created a non-apollo variant that hardcoded the url 
to be passed to the URLRequest and it had the same behavior.

any thoughts on what i'm doing wrong would be appreciated.

thanks.

<?xml version="1.0" encoding="utf-8"?>
<mx:ApolloApplication 
        xmlns:mx="http://www.adobe.com/2006/mxml"; 
        layout="vertical" 
        xmlns:local="*"
        width="700"
        height="800">

        <mx:Script>
                <![CDATA[
                        import flash.filesystem.FileMode;
                        import flash.filesystem.File;
                        import flash.events.ProgressEvent;
                                        
                        private var file:File;
                        
                        [Bindable]
                        private var loader:URLLoader;           
                                                                
        
                        private function fileBrowse():void {
                                file = new File();
                                file.addEventListener(Event.SELECT, 
selectHandler);
                                file.browse();
                        }
                        
                        private function selectHandler
(event:Event):void {
                                loader = new URLLoader();       
                                loader.addEventListener
(ProgressEvent.PROGRESS, fileProgressHandler);
                                loader.addEventListener
(Event.COMPLETE, fileCompleteHandler);
                                var request:URLRequest = new 
URLRequest(file.url);
                                loader.load(request);
                        }
                        
                        private function fileCompleteHandler
(event:Event):void {
                                var str:String = loader.data;
                                loader.close();
                                trace("read full file");
                        }
                        
                        
                        private function fileProgressHandler
(event:ProgressEvent):void {
                                trace("read " + event.bytesLoaded + " 
bytes out of " + event.bytesTotal);
                        }
                        
                ]]>
        </mx:Script>
        
        <mx:Button click="fileBrowse()" label="Import File" />
        
        <mx:ProgressBar id="progressBar" source="{loader}" 
label="Loaded: %3%%"/>
                
</mx:ApolloApplication>


Reply via email to