Skip to main content
Participant
June 30, 2009
Question

browseForOpen don't work outside flash?

  • June 30, 2009
  • 1 reply
  • 1042 views

I'm trying to get a full path of file. Since FileReference.browse do not allow getting a full path I referred to Air.

For testing I wrote this code

import flash.filesystem.File;
var someSprite:Sprite = new Sprite();
someSprite.graphics.beginFill(0x008000);
someSprite.graphics.drawRect(0, 0, 100, 20);
someSprite.graphics.endFill();
addChild(someSprite);
someSprite.x = 150;
someSprite.y = 140;
someSprite.addEventListener(MouseEvent.CLICK, invokeFileDialog);
function invokeFileDialog(evt:MouseEvent):void {
     var fn:File = new File();
     fn.browseForOpen("Select file...");
}

When I press Control -> TestMovie everything works OK. Pressing the green rectangle displays a FileOpen Dialog. However, if I export the movie and start it outside flash CS4, pressing the green rect shows an exception:

VerifyError: Error #1014: Class flash.filesystem::File could not be found.

     at TestAir_fla::MainTimeline/invokeFileDialog()

Starting the movie inside a browser don't throws an exception, however FileOpen Dialog is not displayed. Pressing the green rect doesn't do an action.

Am I doing something wrong?

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 30, 2009

you're publishing for air 1.x or something else?

Participant
June 30, 2009

Publish for Adobe AIR 1.5 Player and ActionScript 3.0

kglad
Community Expert
Community Expert
June 30, 2009

and when you execute your air file, where do you see an error message?