• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

FileStream openAsync throws Error #1009

Explorer ,
Feb 22, 2017 Feb 22, 2017

Copy link to clipboard

Copied

Hi AIR devs.

Have a problem regarding FileStream openAsync

here my code

    var file:File = File.applicationStorageDirectory.resolvePath(fName+'.'+EXT);

    var fileStream:FileStream = new FileStream(); 

     if (!file.exists) {

              this.dispatchEvent(new AppEvent(AppEvent.DATA, null, false));                                        

     }else {

         fileStream.addEventListener(Event.COMPLETE, fileReadCompleteHandler);

         fileStream.openAsync(file, FileMode.READ);

         fileStream.addEventListener(Event.CLOSE, fileClosedHandler);

         fileStream.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHandler);

     }

     private function fileReadCompleteHandler(event:Event):void {

        var ob:Object;

        var fileStream:FileStream = FileStream(event.currentTarget);

        try {

            ob.source = fileStream.readObject();

        }catch (e:Error) {

            trace('error:' + e.message)

        }

        fileStream.removeEventListener(Event.COMPLETE, fileReadCompleteHandler);

        fileStream.close();

      }

onComplete returns Error #1009: Cannot access a property or method of a null object reference.

what I am missing? fileStream.open(file, FileMode.READ) works as expected.

TOPICS
Development

Views

366

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Engaged , Feb 22, 2017 Feb 22, 2017

"ob" Object is null in your fileReadCompleteHandler function. You need to initialize "ob" Object:
var ob:Object = new Object();

Votes

Translate

Translate
Engaged ,
Feb 22, 2017 Feb 22, 2017

Copy link to clipboard

Copied

"ob" Object is null in your fileReadCompleteHandler function. You need to initialize "ob" Object:
var ob:Object = new Object();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

LATEST

itlancer​ you are right, this was my mistake

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines