I have something similar working. Try something like this
.....
private function fileBrowse():void {
var
imagesFilter:FileFilter = new FileFilter("Images",
"*.jpg;*.jpeg");
configureListeners(imageFileRef);
imageName.text
= "";
imageFileRef.browse([imagesFilter]);
}
private
function configureListeners(dispatcher:IEventDispatcher):void
{
dispatcher.addEventListener(Event.COMPLETE,
onComplete);
dispatcher.addEventListener(ProgressEvent.PROGRESS,
progressHandler);
dispatcher.addEventListener(Event.SELECT,
onSelect);
}
|---------+----------------------------->
|
| |
| | "Shannon Hicks" |
| | <[EMAIL PROTECTED]com> |
| | Sent
by: |
| | [EMAIL PROTECTED]ups.com
|
| | 07/13/2006 01:00 PM |
| | Please respond to |
| | flexcoders
|
| |
|
|---------+----------------------------->
>----------------------------------------------------------|
|
|
| To: <[EMAIL PROTECTED]ups.com>
|
| cc: |
| Subject: [flexcoders] File Upload problem?
|
>----------------------------------------------------------|
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]);
}
private function
fileUpload():void {
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);
}
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
--
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
----------------------------------------------------------
This
e-mail message (including attachments, if any) is intended for the use
of the
individual or entity to which it is addressed and may contain
information
that is privileged, proprietary , confidential and exempt from
disclosure. If
you are not the intended recipient, you are notified that
any dissemination,
distribution or copying of this communication is
strictly prohibited. If you
have received this communication in error,
please notify the sender and erase
this e-mail message
immediately.
----------------------------------------------------------