in the titleWindow you can call the PopUpManager.removePopUp(this); called from Complete Event as you have done, or you can dispatch the Complete Event to parent, and kill the popup ther , (The PopUpManager is a singleton so you can access it form enyware)
--- In [email protected], "stinasius" <stinas...@...> wrote: > > hi i am trying to show a popup progress bar will uploading file. i would like > help on how to close the popup once the file has finished uploading. here is > my code so far.. > > "popup progress bar(progress_popup.mxml)" > <?xml version="1.0" encoding="utf-8"?> > <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" > borderStyle="none" headerHeight="0" creationCompleteEffect="{customMove}"> > <mx:Script> > <![CDATA[ > import mx.managers.PopUpManager; > import mx.effects.easing.*; > > ]]> > </mx:Script> > > <mx:Parallel id="customMove" target="{this}"> > <mx:Move yFrom="0" xFrom="{(stage.width - this.width) / 2}" > xTo="{(stage.width - this.width) / 2}" yTo="{(stage.height - this.height) / > 2}" easingFunction="Elastic.easeOut" duration="1000" /> > <mx:Fade duration="500" /> > </mx:Parallel> > > <mx:ProgressBar indeterminate="true"/> > </mx:TitleWindow> > > file uploadcode > > "upload.as(where popup is called from upload form)" > private const FILE_UPLOAD_URL:String = "../cfcs/upload.cfm"; > private var fileRef:FileReference; > private function init():void > { > fileRef = new FileReference(); > fileRef.addEventListener(Event.SELECT, fileRef_select); > fileRef.addEventListener(Event.COMPLETE, fileRef_complete); > //fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler); > } > > private function browseAndUpload():void > { > fileRef.browse(); > message.text = ""; > createdprogressPopup(); > } > > private function fileRef_select(event:Event):void > { > try > { > //message.text = "size (bytes): " + > numberFormatter.format(fileRef.size); > fileRef.upload(new URLRequest(FILE_UPLOAD_URL)); > } > catch (err:Error) > { > message.text = "ERROR: zero-byte file"; > } > memPhoto.text = event.currentTarget.name; > } > > private function fileRef_complete(event:Event):void > { > message.text += " (complete)"; > progress_win.addEventListener("Close", removeMe); > } > > /* private function fileRef_progress(evt:ProgressEvent):void { > progressBar.setProgress(Number(evt.bytesLoaded), > Number(evt.bytesTotal)); > } > > private function progressHandler(event:ProgressEvent):void { > var file:FileReference = FileReference(event.target); > progressBar.setProgress( Number(event.bytesLoaded), > Number(event.bytesTotal)); > } */ > > [Bindable] > private var progress_win:progress_popup; > private function createdprogressPopup():void{ > > progress_win=progress_popup(PopUpManager.createPopUp(this,progress_popup,true)); > /* reply_win.reply_subject.text = discussion_dg.selectedItem.data; > reply_win.postsubject_msg.text = discussion_dg.selectedItem.data; > reply_win.idusr_msg.text = number.text; */ > } > private function removeMe(event:Event):void { > PopUpManager.removePopUp(progress_win); > }

