<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" 
    width="400" 
    height="48" 
    paddingLeft="10" paddingRight="10" paddingBottom="10" paddingTop="10">
    <mx:Script>
        <![CDATA[
            import mx.core.Window;
            
            // This file is not used at the moment.
            // It was an attempt to show a progress bar...            
            
            public function init(file:File):void{
                file.addEventListener(ProgressEvent.PROGRESS, progressEvent);
            }
            
            public static function open(file:File):void {
                var newWindow:Window = new Window();
                newWindow.systemChrome = NativeWindowSystemChrome.ALTERNATE;
                newWindow.title = "New Window";
                newWindow.width = 400;
                newWindow.height = 80;
                newWindow.open(true);
                var progress:progress = new progress();
                progress.init(file);
                newWindow.addChild(progress)
            }
            
            private function progressEvent(e:ProgressEvent):void{
                pb.setProgress(e.bytesLoaded, e.bytesTotal);
                var labelText:String = "Uploading " + toSizeString(e.bytesLoaded) + " of " + toSizeString(e.bytesTotal);
                pb.label = labelText;
            }
            
            private function toSizeString(i:int):String {
                if(i < 1024){
                    return String(Math.round(i)) + 'b'
                } else {
                    return String(Math.round(i/1024.0)) + 'kb'
                }
            }
            
        ]]>
    </mx:Script>
    <mx:ProgressBar width="100%" id="pb"/>
</mx:VBox>