0

This simple code compiles in Flash develop, but nothing happens:

var f:File = new File();
f.browseForOpen("fsd");
Marcelo Assis
  • 5,136
  • 3
  • 33
  • 54
user1480049
  • 1,109
  • 2
  • 7
  • 3

2 Answers2

1

That code works fine for me in FlashDevelop. Are you certain your project is an AIR app? The File.browseForOpen is only available in AIR: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#browseForOpen%28%29

Alternatively, as their code sample suggests, you could wrap it in a try block and see if you get an error:

        try 
        {
            fileToOpen.browseForOpen("Open", [txtFilter]);
            fileToOpen.addEventListener(Event.SELECT, fileSelected);
        }
        catch (error:Error)
        {
            trace("Failed:", error.message);
        }
Jude Fisher
  • 11,138
  • 7
  • 48
  • 91
1

I might be to do with the security sandbox.

Try to put browseForOpen inside the MouseEvent.CLICK handler for some button:

btn.addEventListener( MouseEvent.CLICK, browseOpen )

function browseOpen( e:MouseEvent ):void
{
    f.browseForOpen("fsd");
}
sanchez
  • 4,519
  • 3
  • 23
  • 53