d-nix
03-18-2009, 01:53 PM
I'm trying to select a file and load it into a mx:Image control. Here's a simplified snippet of my code:
private function addFiles():void {
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, onSelectFile);
fileRef.browse();
}
// Called when a file is selected
private function onSelectFile(event:Event):void {
txtFileName.text = fileRef.name;
fileRef.addEventListener(Event.COMPLETE, onLoadComplete);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
fileRef.load(); //getting error 1061 here
}
private function onLoadComplete(event:Event):void {
imgThumb.data = fileRef.data; //getting error 1119 here
}
For some reason, it's giving me two errors here: on the fileRef.load() line, I'm getting "1061: Call to a possibly undefined method load through a reference with static type flash.net:FileReference."
Where I'm accessing fileRef.data, I'm getting this error: "1119: Access of possibly undefined property data through a reference with static type flash.net:FileReference."
From what I understand, it doesn't think the load() method or the data property are valid for a FileReference object. The documentation says otherwise. What's going on here? What am I missing?
I'm working with Flex Builder 3 (though the same thing happens when compiling from the command line), Flash Player 10, and the Flex 3.3.0 sdk.
Thanks-
private function addFiles():void {
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, onSelectFile);
fileRef.browse();
}
// Called when a file is selected
private function onSelectFile(event:Event):void {
txtFileName.text = fileRef.name;
fileRef.addEventListener(Event.COMPLETE, onLoadComplete);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
fileRef.load(); //getting error 1061 here
}
private function onLoadComplete(event:Event):void {
imgThumb.data = fileRef.data; //getting error 1119 here
}
For some reason, it's giving me two errors here: on the fileRef.load() line, I'm getting "1061: Call to a possibly undefined method load through a reference with static type flash.net:FileReference."
Where I'm accessing fileRef.data, I'm getting this error: "1119: Access of possibly undefined property data through a reference with static type flash.net:FileReference."
From what I understand, it doesn't think the load() method or the data property are valid for a FileReference object. The documentation says otherwise. What's going on here? What am I missing?
I'm working with Flex Builder 3 (though the same thing happens when compiling from the command line), Flash Player 10, and the Flex 3.3.0 sdk.
Thanks-