Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple file uploader throwing script timeout error

Status
Not open for further replies.

clemrock

Programmer
May 20, 2004
118
US
Hello,

I'm loving the new flash 8 file uploading capability and have come very far w/ a multiple file uploader.

It works great most of the time but it seems to throw up the "script is causing Flash to run slowly" error about 20% of the time.

Here's the full actionscript I am using below:

Code:
import flash.net.FileReferenceList;
import flash.net.FileReference;


//---- init ---------------------------------------------------
//-------------------------------------------------------------
//// visibility
mc_loader._visible         = false;
upload_button._visible     = false;
upload_button.enabled      = false;


var files_to_upload       = new Array();
//-------------------------------------------------------------



//---- instantiat reference list ------------------------------
//-------------------------------------------------------------
var fileRef:FileReferenceList = new FileReferenceList();
var listener = new Object();
fileRef.addListener(listener);
//-------------------------------------------------------------



//---- onSelect -----------------------------------------------
//-------------------------------------------------------------
listener.onSelect = function( fileRefList:FileReferenceList ) 
{
	upload_button.enabled  = true;  
	upload_button._visible = true;
	
	var list              = new Array();
	var temp_upload_array = new Array();  //var item:FileReference;
	
	list = fileRefList.fileList;
	
	for( var i:Number = 0; i < list.length; i++ ) 
         {
                   temp_upload_array.push( list[i] );  	
         }
	
	files_to_upload = files_to_upload.concat( temp_upload_array );
		
}
//-------------------------------------------------------------




//---- the event for the browse buttons -----------------------
//-------------------------------------------------------------
browse_button.clickHandler = function()
{
	 fileRef.browse( [ { description: "JPEGs", extension: "*.jpg;*.gif;*.png;*.tif;*.doc;*.swf;*.txt" } ] );
}
//-------------------------------------------------------------




//---- the event for the upload button ------------------------
//-------------------------------------------------------------
upload_button.clickHandler = function():Void
{
      	 for( var i:Number = 0; i < files_to_upload.length; i++ ) 
      	 {     
            	    files_to_upload[i].addListener( listener ); 
	             files_to_upload[i].upload("[URL unfurl="true"]https://scopeprogram.com:443/cgi-bin/upload/upload_flash.cgi");[/URL]  
	}
	
}
//-------------------------------------------------------------




//---- basic listener functions -------------------------------
//-------------------------------------------------------------
listener.onCancel = function():Void {  trace("onCancel");  }


listener.onOpen = function( file:FileReference ):Void {  trace("onOpen: " + file.name);}
 

listener.onProgress = function( file:FileReference, bytesLoaded:Number, bytesTotal:Number ):Void 
{
	  percentLoaded = Math.round( bytesLoaded / bytesTotal * 100);				  
       _root.mc_loader.bar._xscale = percentLoaded;
       _root.mc_loader.txt_percent = percentLoaded + " % (" + _root.upload_file_cnt + ")"; //( " + Math.round( bytesLoaded ) + " of " + Math.round( bytesTotal ) + " Bytes Loaded )";	 
}


//---- onComplete function ------------------------------------
//-------------------------------------------------------------
listener.onComplete = function( file:FileReference ):Void 
{  
          trace( "(onComplete): file_name: " + file.name );   
}
//-------------------------------------------------------------



listener.onHTTPError = function( file:FileReference, httpError:Number ):Void 
{
        trace( "onHTTPError: " + file.name + " httpError: " + httpError );
}


listener.onIOError = function( file:FileReference ):Void { trace( "onIOError: " + file.name ); }


listener.onSecurityError = function( file:FileReference, errorString:String ):Void 
{
        trace("onSecurityError: " + file.name + " errorString: " + errorString);
}
//-------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top