I’m trying to create a simple text file via Flash, and I’m following the code given by Adobe in its help documents:
var file:File = file.applicationStorageDirectory.resolvePath("test.txt");
var str:String = "Hello";
file.addEventListener(Event.COMPLETE, fileSaved);
file.save(str);
function fileSaved(event:Event):void
{
trace("Done.");
}
The problem being Flash spits out the error 1406: type not found. I tried to search about this error, and it’s usually about movie linkage or tweening. My problem rises from the fact that I use this code:
var file:File
The presence of that code alone causes the error. The SWF exports just fine without it. The type “File” also doesn’t appear in IntelliSense. I’m stumped. I think I don’t have the proper package, but how come I don’t have the proper package?
The
Fileclass is in theflash.filesystem.Filenamespace so make sure you are importing that if you want to use it. What is probably tripping you up though is theFileclass is only available when targeting the AIR runtime not the normal flash player runtime. Make sure you are trying this in an AIR project.