PDA

View Full Version : Error 1119 with FileReference.data


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-

wvxvw
03-18-2009, 04:38 PM
You're not compiling for FP10. Check your compiler settings and path to playerglobals.swc. FileReference.data and FileReference.load() exist only in FP10.

d-nix
03-18-2009, 05:54 PM
That did the trick. I also found info here: http://opensource.adobe.com/wiki/display/flexsdk/Targeting+Flash+Player+10.

Todah rabah-

Dave

wvxvw
03-18-2009, 08:22 PM
Al lo davar! :)
[you're welcome]