![]() |
|
||||||||||
|
|||||
|
Регистрация: Sep 2010
Сообщений: 2
|
Начал знакомство с flash, пишу upload файлов. Наткнулся на странную вещь и не пойму то ли лыжи не едут..
Установил AdobeFlashProf CS5 (11.0.0.485). Пишу скриптик (ActionScript3) используя FileReferenceList: пользователь выбирает файлы, затем они добавляются из FileReferenceList.fileList в массив состоящий из FileReference (это для того, чтобы пользователь мог несколько раз открывать окно выбора файлов и формировался большой список файлов). Когда я запускаю это дело под фаерфоксом вот в этом месте: filesToUpload.push(FileReference(event.target.fileList[i])); trace('PUSHED! filesToUpload.length:'+filesToUpload.length); trace(filesToUpload.toString()); Причем длина не меняется только после первого добавления. Следующие добавления все идет нормально. Весь в растерянности.. Вот всё целиком: buttonSelect.addEventListener(MouseEvent.CLICK, buttonSelectClick); buttonUpload.addEventListener(MouseEvent.CLICK, buttonUploadClick); var fileReference:FileReferenceList = new FileReferenceList(); fileReference.addEventListener(Event.SELECT, onSelectFile); fileReference.addEventListener(Event.CANCEL, onCancelDialog); var filesToUpload:Array = new Array(); var fileFilter:FileFilter = new FileFilter("Images", "*.png;*.gif;*.jpg"); function buttonSelectClick(event:MouseEvent):void{ try { fileReference.browse([fileFilter]); }catch(illegalOperation:IllegalOperationError) { trace(illegalOperation.toString()); } } function buttonUploadClick(event:MouseEvent){ var urlRequest:URLRequest = new URLRequest("http://test/pub/fileUploader.php"); var i; for(i=0;i<filesToUpload.length;i++){ try{ filesToUpload[i].upload(urlRequest); }catch(e){ trace(e.toString()); } trace('Uploaded file: '+filesToUpload[i].name); } } function onSelectFile(event:Event):void { var i,ii; var found; buttonUpload.enabled=true; for(i=0;i<event.target.fileList.length;i++){ //trace('i: '+i); found=false; for(ii=0;ii<filesToUpload.length && !found;ii++){ //trace('ii: '+ii); //trace('filesToUpload[ii].name:'+filesToUpload[ii].name); //trace('event.target.fileList[i].name:'+event.target.fileList[i].name ); if(filesToUpload[ii].name==event.target.fileList[i].name && filesToUpload[ii].size==event.target.fileList[i].size && filesToUpload[ii].creationDate.time==event.target.fileList[i].creationDate.time){ found=true; } //trace('found: '+found); } if(!found){ filesToUpload.push(FileReference(event.target.fileList[i])); filesToUpload[filesToUpload.length-1].addEventListener(ProgressEvent.PROGRESS, onFileProgress); //trace('PUSHED! filesToUpload.length:'+filesToUpload.length); ExternalInterface.call( "callback_addFile", event.target.fileList[i].name, event.target.fileList[i].size, event.target.fileList[i].type, event.target.fileList[i].creationDate.time, filesToUpload.length-1 ); trace('Addng file '+event.target.fileList[i].name); }else{ trace('file '+event.target.fileList[i].name+'is already in array'); } } trace('filesToUpload: '+filesToUpload.toString()); } function onFileProgress(event:ProgressEvent):void { trace( event.bytesLoaded + " of " + event.bytesTotal + " bytes"); ExternalInterface.call( "callback_progress", filesToUpload.length-1 ); } function onCancelDialog(event:Event):void { trace(event.target); } Последний раз редактировалось serafxx; 28.09.2010 в 12:24. |
![]() |
Часовой пояс GMT +4, время: 13:51. |
|
|
« Предыдущая тема | Следующая тема » |
|
|