Nava Carmon
Nava Carmon

Reputation: 4533

open local files in AS3

How do i open file and get its content as a ByteArray in AS3. I saw examples, using FileStream & File classes from flex.filesystem, but the doc says it's for AIR only.

Thanks,

Nava

Upvotes: 3

Views: 8550

Answers (4)

5566
5566

Reputation: 224

New feature in Flash 10. Last time you can't read the file directly. But now, you can. http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/

Upvotes: 2

Christophe Herreman
Christophe Herreman

Reputation: 16085

You can use a FileReference object to browse for a file and then access the raw bytes via the "data" property on the FileReference when the "complete" event is dispatched.

Upvotes: 4

Koen Weyn
Koen Weyn

Reputation: 1004

Flex security prevents simple access to local files.

The most commonly used workaround is having the user select a file, send that to your server, and then downloading that file from your server.

There is access to some local storage (using SharedObject) for storing and reading settings.

hth,

Koen

Upvotes: 2

George Profenza
George Profenza

Reputation: 51837

You can try either URLLoader with content set for binary, or use URLStream. What do you need to load ?

Upvotes: 3

Related Questions