2006/01/24 | Flash 8文件上传
类别(Flash&AS2) | 评论(9) | 阅读(371) | 发表于 00:22
早就听说Flash 8支持文件上传了,今天研究了一下,虽然不是我想象中的那样(本以为Flash 8可以完全脱离后台直接上传呢),但还是方便了很多,上船的代码在帮助里就能找到如下:
import flash.net.FileReference;
var allTypes:Array = new Array();
var imageTypes:Object = new Object();
var listener:Object = new Object();

listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
if(!file.upload("http://www.yourdomain.com/yourUploadHandlerScript.cfm")) {
trace("Upload dialog failed to open.");
}
}
listener.onCancel = function(file:FileReference):Void {
trace("onCancel");
}
listener.onOpen = function(file:FileReference):Void {
trace("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
listener.onComplete = function(file:FileReference):Void {
trace("onComplete: " + file.name);
}
listener.onHTTPError = function(file:FileReference):Void {
trace("onHTTPError: " + file.name);
}
listener.onIOError = function(file:FileReference):Void {
trace("onIOError: " + file.name);
}

var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse();
很简单的,关键是后台语言的代码难写,本人有一个asp的上传组件,建个IIS就可以了,我测了没问题的,需要的可以和我联系哦。
0

评论Comments

日志分类
首页[116]
Flash&AS2[56]
FMS[3]
Flex&AS3[5]
Asp[5]
My Works[13]
My Life[34]