FileReference.load() not populating FileReference.data

jeffcook2150 picture jeffcook2150 · Nov 11, 2009 · Viewed 7.4k times · Source

I am trying to use the load method of FileReference object to load the data and use it to display a thumbnail of the selected image.

However, after calling fr.load(), fr.data remains null.

I'm using Flex Builder 3.0.2 on Windows 7 with Flex SDK 3.4 and Flash Player 10 Debug. If I evaluate fr.load() in Eclipse's watch variables list, I get an error reading "No such variable: load."

Anyone know why this is happening?

Answer

dustmachine picture dustmachine · Nov 11, 2009

Are you waiting for the load() to complete? Try adding an EventListener to listen for the load to be finished.

FileReference docs

fr.addEventListener(Event.COMPLETE, function(e:Event):void {
                                        handleLoad(e);
                                    });

The handleLoad function that you write can then get at the data via e.target.data