dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Error 1120: Access of undefined property air

  1. #1
    Member
    Join Date
    Nov 2007
    Posts
    83

    Error 1120 (save file)

    I'm new with Air and I've found following code on the net:

    code:
    var file = air.File.applicationStorageDirectory.resolvePath("  test.txt");
    var str = "Hello.";
    file.addEventListener(air.Event.COMPLETE, fileSaved);
    file.save(str);
    function fileSaved(event)
    {
    air.trace("Done.");
    }





    But I get following errors:

    Code:
    1120: Access of undefined property air.    air.trace("Done."); 
    
    1120: Access of undefined property air.    var file = air.File.applicationStorageDirectory.resolvePath("test.txt"); 
    
    1120: Access of undefined property air.    file.addEventListener(air.Event.COMPLETE, fileSaved);
    I'm using Flash CS4. I also tried publishing but it didn't work. Can anyone help me?
    Last edited by onurcan1977; 09-15-2009 at 06:12 PM. Reason: title has been changed

  2. #2
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    remove .air from each of those lines.

    It's not needed as you are programming in flash and not using the Air sdk
    New sig soon

  3. #3
    Member
    Join Date
    Nov 2007
    Posts
    83
    dudeqwerty, thanks for help. But this time it gave different error:

    Code:
    ReferenceError: Error #1069: Property save not found on flash.filesystem.File and there is no default value.
        at deleteme_fla::MainTimeline/frame1()[deleteme_fla.MainTimeline::frame1:7]
        at runtime::ContentPlayer/loadInitialContent()
        at runtime::ContentPlayer/playRawContent()
        at runtime::ContentPlayer/playContent()
        at runtime::AppRunner/run()
        at global/runtime::ADLEntry()
    I made some corrections (var file:File / var str:String). But it gave different error: 1061: Call to a possibly undefined method save through a reference with static type flash.filesystem:File.

  4. #4
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    Ok, the problem here is that you are trying to use Air features, such as the file class, in Flash.

    In order to use those features you will have to use the Air SDK: http://www.adobe.com/products/air/tools/sdk/
    New sig soon

  5. #5
    Member
    Join Date
    Nov 2007
    Posts
    83

    Thumbs up I've found a solution

    Code:
    var data = "sdfs";
    var target=File.documentsDirectory.resolvePath("airitems.txt");
    if (target.exists) {
    	return;
    }
    var fileStream = new FileStream();
    fileStream.open(target, FileMode.WRITE);
    fileStream.writeMultiByte(data, File.systemCharset);
    fileStream.close();
    source: http://learnola.com/2008/11/10/begin...torial-part-2/
    thanks for helps
    Last edited by onurcan1977; 09-15-2009 at 06:16 PM. Reason: added source link

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center