Hi i send sample program for progress bar and download . i hope useful for u
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.controls.Alert; private var fileRef:FileReference; private var percentage:Number = 0; private function downloadHandler(event:MouseEvent):void { fileRef = new FileReference(); fileRef.addEventListener(Event.CANCEL, fileCanceledHandler); fileRef.addEventListener(ProgressEvent.PROGRESS, fileProgress); fileRef.addEventListener(Event.COMPLETE, fileDownloadComplete); fileRef.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); try { fileRef.download(new URLRequest("assets/example.mp3"), "demo.mp3"); } catch(illegalOperation:IllegalOperationError) { Alert.show("Dialog Box is already Open."); } catch(security:SecurityError) { Alert.show("Untrusted file, can't be downloaded,"); } } private function fileProgress(event:ProgressEvent):void { if (percentage == 0) { pBar.visible = true; } txtLoaded.text = event.bytesLoaded + " loaded out of " + event.bytesTotal; percentage = Math.round(100 * (event.bytesLoaded / event.bytesTotal)); pBar.setProgress(percentage, 100); pBar.label = "Progress " + percentage + "%"; } private function fileDownloadComplete(event:Event):void { txtWarning.text = event.target.name + " successfully downloaded"; txtLoaded.text = ""; pBar.visible = false; } private function fileCanceledHandler(event:Event):void { txtWarning.text = "We're sorry you didn't download the file."; } private function ioErrorHandler(event:IOErrorEvent):void { Alert.show("Error! Could not download the file."); } ]]> </mx:Script> <mx:VBox horizontalCenter="0" verticalCenter="0"> <mx:Button id="downloadButton" label="Download MP3 File" width="200" click="downloadHandler(event)"/> <mx:Label id="txtWarning" fontWeight="bold"/> <mx:Label id="txtLoaded" color="#FFFFFF"/> <mx:ProgressBar id="pBar" label="Progress 0%" minimum="0" maximum="100" mode="manual" visible="false"/> </mx:VBox> </mx:Application> mail me if u have any doubts regards Natarajan 2009/5/7 <[email protected]> > Hi Everyone, > Is there any code available for downloading PDF from server by clicking on > Button. > I'd like to include progress bar and cancel download button. > Code would be very helpful.. > Thank you > Emelendez > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---

