Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/10/2007, 12:34
eybel
 
Fecha de Ingreso: marzo-2007
Mensajes: 782
Antigüedad: 17 años, 1 mes
Puntos: 16
Clase File Reference, no me funciona...

Bueno, es la 1era vez que llego hasta esta instancia de la clase FileReference y estoy entusiasmado por que voy a resolver muchas cosas una vez que la sepa usar...

Cree un .fla donde tengo:

Código:
Nombre de instancia DataGrid = data_mc
Boton Upload = upload_btn
Boton Download = down_btn
MovieClip = load_mc
Barra de porcentaje = barra_mc
Campo de texto dinamico = label_txt
Y obviamente sus componentes en el escenario...

Y el codigo inteligente es:

Cita:

import flash.net.FileReference;
var fileUpload:FileReference = new FileReference();
var path:String = "http://www.bluephotographer.com/files"
var escucha:Object = {};
var fileTypes:Array;
var getFile:String;
function init() {
System.security.allowDomain(path);
load_mc._visible = false;
fileTypes = [{description:"Archivos de Imagen", extension:"*.jpg;*.gif;*jpeg;*.png;*.JPG;*.JPEG", macType:"JPEG;jp2_;GIFF"}];
upload_btn.label = "Upload File";
down_btn.label = "Download File";
upload_btn.addEventListener("click", doUpload);
down_btn.addEventListener("click", doDownload);
fileUpload.addListener(escucha);
escucha.onSelect = doSelect;
escucha.onComplete = doComplete;
escucha.onCancel = doCancel;
escucha.onProgress = doProgress;
data_mc.addEventListener("change", setDownload);
makeList();
}
function doComplete() {
load_mc.barra_mc._xscale = 0;
load_mc.label_txt.text = "Tranferencia Completa";
makeList();
}
function doProgress(archivo:FileReference, bLoaded:Number, bTotal:Number) {
var porcentaje = Math.round((bLoaded*100)/bTotal);
load_mc.label_txt.text = porcentaje+"% del archivo "+archivo.name;
load_mc.barra_mc._xscale = porcentaje;
}
function doCancel() {
trace("El Usuario Cancelo");
}
function doSelect(archivo:FileReference) {
load_mc._visible = true;
load_mc.barra_mc._xscale = 0;
fileUpload.upload(path+"/uploadFile.php");
}
function doDownload() {
if (getFile != undefined) {
fileUpload.download(path+"/"+getFile);
}
}
function doUpload(event) {
fileUpload.browse(fileTypes);
}
function setDownload(c:MovieClip) {
getFile = c.target.selectedItem.Nombre;
}
function makeList() {
data_mc.removeAll();
var list_xml:XML = new XML();
list_xml.ignoreWhite = true;
list_xml.load(path+"/lista.php");
list_xml.onLoad = function() {
var nodos = this.firstChild.childNodes;
for (var a in nodos) {
var size:Number = Math.ceil((nodos[a].attributes.tamanio/1024));
data_mc.addItem({Nombre:nodos[a].attributes.name, Tamaño:size+" Kb"});
}
};
}
init();
La carpeta files, esta creada.Y adentro puse los 2 arhicos .php (lista y uploadFile)
y tambien el .html con el .swf embebido...

Y bueno apreto upload.Busco una imagen acepto y me aparece la barra que carga con el porcentaje...Y despues cuando termina la carga me dice "Tranferencia Completa"...No se que pasa, pero no me sube los archivos...Que puede ser???
Y elñ boton de download no me anda, no hace nada...y el componente Data Grid esta siempre vacio...

no di ningun permiso a las carpetas...

La URL es esta

Espero alguna ayudita, bye...