Ok... I've been
playing with the file upload stuff all morning, and am 80% of the way there.
Here's a quick sample of what my Browse button fires:
private function fileBrowse():void
{
var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.jpeg");
imageFileRef.addEventListener(Event.COMPLETE, onComplete);
imageFileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
imageFileRef.addEventListener(Event.SELECT, onSelect);
imageName.text = "";
imageFileRef.browse([imagesFilter]);
}
var imagesFilter:FileFilter = new FileFilter("Images", "*.jpg;*.jpeg");
imageFileRef.addEventListener(Event.COMPLETE, onComplete);
imageFileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
imageFileRef.addEventListener(Event.SELECT, onSelect);
imageName.text = "";
imageFileRef.browse([imagesFilter]);
}
private function fileUpload():void
{
uploadProgressPopup = uploadProgressBar(PopUpManager.createPopUp(this, flexComponents.uploadProgressBar, true));
uploadProgressPopup = uploadProgressBar(PopUpManager.createPopUp(this, flexComponents.uploadProgressBar, true));
var urlVars:URLVariables = new
URLVariables();
urlVars.userID = model.currentUser.userID;
urlVars.mouseID = model.editMouse.mouseID;
uploadTarget.data = ""> uploadTarget.method = URLRequestMethod.POST;
for (var i:int=0; i < imageFileRef.fileList.length; i++){
imageFileRef.fileList[i].upload(uploadTarget);
}
}
private function progressHandler(event:ProgressEvent):void {
var percentLoaded:Number = Number((event.bytesLoaded / event.bytesTotal) * 100);
uploadProgressPopup.doUpdateProgress(percentLoaded);
Alert.show("The file is " + percentLoaded.toString() + "% loaded.");
}
private function onComplete(event:Event):void {
Alert.show("Done.");
PopUpManager.removePopUp(uploadProgressPopup);
}
urlVars.userID = model.currentUser.userID;
urlVars.mouseID = model.editMouse.mouseID;
uploadTarget.data = ""> uploadTarget.method = URLRequestMethod.POST;
for (var i:int=0; i < imageFileRef.fileList.length; i++){
imageFileRef.fileList[i].upload(uploadTarget);
}
}
private function progressHandler(event:ProgressEvent):void {
var percentLoaded:Number = Number((event.bytesLoaded / event.bytesTotal) * 100);
uploadProgressPopup.doUpdateProgress(percentLoaded);
Alert.show("The file is " + percentLoaded.toString() + "% loaded.");
}
private function onComplete(event:Event):void {
Alert.show("Done.");
PopUpManager.removePopUp(uploadProgressPopup);
}
Now, I can browse
just fine, and my upload button fires off the upload, and the files make it
safely to the server, where ColdFusion saves them to the filesystem. The only
problem is that my progressHandler() and onComplete() methods never
fire.
Is there some trick?
Do I need to have ColdFusion return something?
Shan
__._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Web site design development | Computer software development | Software design and development |
Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/387 - Release Date: 7/12/2006