代码
import flash.net.FileReferenceList;
import flash.net.FileReference;
// 初始化按扭的label..
select.label = "选图";
del.label = "删除";
updata.label = "上传";
// 定义侦听器
var listener:Object = new Object();
// 定义上传图片的容器
var total:Array = new Array();
// 检测函数,测试用!
function ceshi()
{
trace(total.length);
for (var j = 0; j < total.length; j++)
{
trace(total[j].name);
}
}
updata.enabled = false;
//..
var fileRefList:FileReferenceList = new FileReferenceList();
listener.onSelect = function(fileRefList:FileReferenceList)
{
trace("onSelect");
updata.enabled = true;
my_list.removeAll();
var list:Array = fileRefList.fileList;
var item:FileReference;
for (var i:Number = 0; i < list.length; i++)
{
item = list[i];
trace("name: " + item.name);
total.push(item);
trace(".+++++++++++++++======================");
// 调用测试函数
ceshi();
}
for (var j = 0; j < total.length; j++)
{
my_list.addItem({label: total[j].name, data: j});
}
};
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
{
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
};
listener.onComplete = function(file:FileReference):Void
{
trace("onComplete: " + file.name);
};
var fileRef:FileReferenceList = new FileReferenceList();
fileRef.addListener(listener);
select.onPress = function()
{
fileRef.browse();
};
updata.clickHandler = function()
{
fileRefList.fileList = total;
var fileRef:FileReference = new FileReference();
for (var i = 0; i < total.length; i++)
{
fileRef = total[i];
fileRef.addListener(listener);
fileRef.upload(" your_url ");
}
trace(total.length);
total = [];
};
var det_listener:Object = new Object();
det_listener.click = function(evt:Object)
{
xx = my_list.selectedIndex;
total.splice(xx, 1);
my_list.removeItemAt(my_list.selectedIndex);
// 调用测试函数
ceshi();
};
del.addEventListener("click", det_listener);
import flash.net.FileReference;
// 初始化按扭的label..
select.label = "选图";
del.label = "删除";
updata.label = "上传";
// 定义侦听器
var listener:Object = new Object();
// 定义上传图片的容器
var total:Array = new Array();
// 检测函数,测试用!
function ceshi()
{
trace(total.length);
for (var j = 0; j < total.length; j++)
{
trace(total[j].name);
}
}
updata.enabled = false;
//..
var fileRefList:FileReferenceList = new FileReferenceList();
listener.onSelect = function(fileRefList:FileReferenceList)
{
trace("onSelect");
updata.enabled = true;
my_list.removeAll();
var list:Array = fileRefList.fileList;
var item:FileReference;
for (var i:Number = 0; i < list.length; i++)
{
item = list[i];
trace("name: " + item.name);
total.push(item);
trace(".+++++++++++++++======================");
// 调用测试函数
ceshi();
}
for (var j = 0; j < total.length; j++)
{
my_list.addItem({label: total[j].name, data: j});
}
};
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
{
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
};
listener.onComplete = function(file:FileReference):Void
{
trace("onComplete: " + file.name);
};
var fileRef:FileReferenceList = new FileReferenceList();
fileRef.addListener(listener);
select.onPress = function()
{
fileRef.browse();
};
updata.clickHandler = function()
{
fileRefList.fileList = total;
var fileRef:FileReference = new FileReference();
for (var i = 0; i < total.length; i++)
{
fileRef = total[i];
fileRef.addListener(listener);
fileRef.upload(" your_url ");
}
trace(total.length);
total = [];
};
var det_listener:Object = new Object();
det_listener.click = function(evt:Object)
{
xx = my_list.selectedIndex;
total.splice(xx, 1);
my_list.removeItemAt(my_list.selectedIndex);
// 调用测试函数
ceshi();
};
del.addEventListener("click", det_listener);