FileReference.load() does not as excepted

Posted by Yang Bo on Stack Overflow See other posts from Stack Overflow or by Yang Bo
Published on 2009-12-26T15:27:30Z Indexed on 2010/03/24 21:43 UTC
Read the original article Hit count: 493

Filed under:
|
|

I used Flash player 10, and Flex SDK 3.4. The code as followings:

// Following comes callbacks
function imageLoadOpenCallback(evt:Event):void
{
    trace("in--open");
}

function imageLoadCompleteCallback(evt:Event):void
{
    trace("in--load");
    var fr:FileReference = evt.target as FileReference;
    trace(fr.data);
}

function imageLoadErrorCallback(evt:IOErrorEvent):void
{
    trace("in--ioerror");
}

function imageSelectCancelCallback(evt:Event):void
{
    trace("in cancel");
}

function imageSelectCallback(evt:Event):void
{
    trace("in -- select");
    for (var i:int=0; i<frl.fileList.length; i++)
    {

    	frl.fileList[i].addEventListener(Event.OPEN, imageLoadOpenCallback);
    	frl.fileList[i].addEventListener(Event.COMPLETE, imageLoadCompleteCallback);
    	frl.fileList[i].addEventListener(IOErrorEvent.IO_ERROR, imageLoadErrorCallback);
    	frl.fileList[i].load();
    	trace(frl.fileList[i]);
    	trace(frl.fileList[i].creationDate);
    	trace(frl.fileList[i].creator);
    	trace(frl.fileList[i].data);
    	trace(frl.fileList[i].name);
    }	
}


// Following comes UI handlers
function onAddPictures():void
{
    var imageFilter:FileFilter = new FileFilter("Images", "*.jpg;*.png");
    frl.addEventListener(Event.SELECT, imageSelectCallback);
    frl.addEventListener(Event.CANCEL, imageSelectCancelCallback);
    frl.browse([imageFilter]);
}

Only the imageSelectCancelCallback handler get called when I select some files in the dialog. But no load/open/io_error handler get called at all. I have Google some code example, in which it used FileReference instead of FileReferenceList. I don't know the reason, could you please help me?

© Stack Overflow or respective owner

Related posts about flex

Related posts about as3