[flexcoders] Re: popup progress bar will uploading file

2009-04-30 Thread Cato Paus
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 flexcoders@yahoogroups.com, 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);
 }




[flexcoders] Re: popup progress bar will uploading file

2009-04-30 Thread stinasius
do you mind sharing an example?



[flexcoders] Re: popup progress bar will uploading file

2009-04-30 Thread Cato Paus

Main App:

?xml version=1.0 encoding=utf-8?

mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
layout=absolute creationComplete=initApp();



@

mx:Script

![CDATA[

import mx.managers.PopUpManager;

import mx.containers.TitleWindow;

private var popUp:PopUp = null;



private function initApp():void

{

popUp = new PopUp();

popUp.width = 100;

popUp.height = 100;

popUp.title = PopUp;

popUp.addEventListener(Event.COMPLETE, removePopUp);

PopUpManager.addPopUp(popUp,this);

}



private function removePopUp(event:Event):void

{

if(popUp !=null)

{

PopUpManager.removePopUp(popUp);

}

}



]]

/mx:Script

/mx:Application

And the popUp, that dispatch the Complete Event, What I have done here
is faking the Complete event by using a button, hope you figure it out
:)



PopUp.mxml put it in the same dir as your running app..

?xml version=1.0 encoding=utf-8?

mx:TitleWindow xmlns:mx=http://www.adobe.com/2006/mxml;
layout=absolute width=400 height=300

mx:Button label=event complete click=dispatchEvent(new
Event(Event.COMPLETE)); /

/mx:TitleWindow




--- In flexcoders@yahoogroups.com, stinasius stinas...@... wrote:

 do you mind sharing an example?