View Full Version : AIR Error 1120: Access of undefined property air
nikel
September 13th, 2009, 04:01 PM
I'm new with Air and I've found following code on the net:
ActionScript 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:
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?
IQAndreas
September 13th, 2009, 05:00 PM
I'd just remove all the words "air." and it should work just fine.
I'm quite sure that Air doesn't use a separate set of classes or framework.
You might also need some "import" statements:
import flash.filesystem.File;
import flash.events.Event;
var file = File.applicationStorageDirectory.resolvePath("test.txt");
var str = "Hello.";
file.addEventListener(Event.COMPLETE, fileSaved);
file.save(str);
function fileSaved(event)
{
trace("Done.");
}
IQAndreas
September 13th, 2009, 05:03 PM
I'm using Flash CS4. I also tried publishing but it didn't work. Can anyone help me?
Also, make sure you are publishing it AS an air application. You can change the target format in the same setting where you change it from AS2 to AS3 application. (Somewhere in the stage properties)
nikel
September 13th, 2009, 05:44 PM
IqAndreas, thanks for help. Your code gave different error:
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.
IQAndreas
September 13th, 2009, 06:57 PM
Perhaps it would be easier if you point me towards this tutorial and I can look it over and help sort it out. ;)
nikel
September 13th, 2009, 07:32 PM
http://help.adobe.com/en_US/AIR/1.5/devappshtml/WSAA022E3E-090D-4003-B31E-1D2C7A53867A.html
nikel
September 15th, 2009, 06:20 PM
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/beginners-adobe-air-tutorial-part-2/
Thanks for helps
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.