Flash Player 10 – fileReference.load()

Adobe extends the features on Flash Player in the every version and some of the features modernize the web development works. In Flash Player 10, it allows to access the local content via Browser Dialog, At the same time, we can not access the local content by action script from Flash Player without the knowledge of user, so its pretty secure. Usually, in order to load/display a image file (jpg or png) from local computer to Flash Player, we had to load that file to server, and then we need to download it from the server over HTTP to load into the Flash Player. Its pretty unnecessary process for just display a image into Flash Player.


You can see this additional method(load() as well as save()) in the FileReference Object. You just launch the Browser Dialog window by executing fileReference.browse() method, it allows you to select single file and click open and it fires the SELECT event. In the SELECT event handler, just call the fileReference.load() method, it loads the binary data of the selected file to the fileReference.data property. The fileReference.data is in the form of ByteArray, so we can easily load that bytes as  a source of an Image object. That's all, it will display the selected image.

Extension Checking

Since we have the binary content of the file which selected by Browser Dialog, we can check the original extension of the file by reading the binary data. Hence we can avoid the user to allow wrong file types, even though he/she manually change the extension of the file.

Secure File Transfer

Another secure way to transfer files from Desktop to Server via Flash environment. Since we have binary data for files we can easily transfer the file by using flash.net.Socket. So we can make a wonderful web client for transferring files via FTP(File Transfer Protocol). It could be pretty fast than HTTP and we can pause, resume the file while transferring. But we can not provide a nice user interface like other professional FTP client, since we can only input the files through Browser Dialog window. But you can achieve a Rich Internet FTP Client by developing the application on Adobe AIR.


I have just worked on the FileReference Object in last weekend and just  trying to load the local content to my flex application. It works perfect now.


Example - Flash Player 10 – fileReference.load()

Note: To view full source, right click this application and select the View Source from the context menu.

Setup and Requirements

Mainly it requires two things, one is Flash Player 10 and another one is Flex SDK 3.3. Here we need to setup one thing to work with real intelligence of the Flex Builder, since the default playerglobal.swc library of the SDK does not contain the fileReference.load() method and it will does not appear in the script. So you just need to remove playerglobal.swc and add the same library from here sdks/3.3/frameworks/libs/player/10/playerglobal.swc. And maker sure the Require Flash Player version is 10.0.0 in the HTML wrapper.

Please leave your comments if you have any trouble to work on this.

Be Sociable, Share!

13 Responses to “Flash Player 10 – fileReference.load()”

  1. Gerardo says:

    Thanks for this tips, because i just have this problem.. i want to use de load function and its doesnt work untili did what you says.

    thanks a lot =)

  2. Joseph says:

    Thanks 🙂

  3. Geo Mathew says:

    This is really cool buddy!!!

  4. Ady Levy says:

    Cool article,
    i did some experiment on filereference.data ,
    i used a loader to load the data as a bitmap, then manipulate the bitmapdata and encoded the bitmap to jpg with adobe’s JPGencode class, then uploaded it to the server.
    you can check out – source code included : http://www.adylevy.com/index.php/2009/06/07/client-side-image-resize-flash-cs4-filereferencedata/


  5. Len says:

    Thanks for your article. I did try to call FileReference.load() right after browse() and got this:

    ReferenceError: Error #1069: Property load not found on flash.net.FileReference and there is no default value

    The Adobe doc does not mention this sequence of calls, it actually suggest to call upload() first.

    Any ideas what I might be doing wrong?

  6. KBala says:

    Hi Len,

    I think you are not setting up the Flex Builder as mentioned above. Please follow the “Setup and Requirements”

  7. Gilbert says:


    Do you know how to use the FileReference.load() to load a FLV or MP4 file?


  8. liuzhi says:

    I did what you said and it works well at the application project,but it dose not work at the library project.wait your help.Thanks.

  9. rade says:

    I tried to publish same project as web application and desktop application. With web application everything works just fine, but with desktop version (AIR) i get error “ReferenceError: Error #1069…” . So i figured there’s some difference in these two environments. Any suggestions ?

  10. okrutny says:

    Thanks man! I missed setting html wrapper. I’m ready to go 😉

  11. Siddharth D says:

    Good work Bala … nice and compact MXML. But sad to read thru’ the text with multiple typo and incorrect words. Won’t it be nice if it’s as correct as your flex code?


  12. Ivan says:

    I got the same Error #1069 when i work on air, i try this with 3.5 sdk and i cant fix it, someone can help me plsease :S

    i a little new with this, i try to load the image to send the byte array to amfphp to make an upload to server

  13. Venkat says:

    I am getting same error when trying to load the file, I configured Flex Builder I am using SDK3.5, Flash Player 10

    Any idea what could be the problem??

Leave a Reply

Copyright © 2008-2010 K BalaSubramanian | Credits