Error 1120: Access of undefined property air

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

 ActionScript Code:
 [LEFT][COLOR=#000000]**var**[/COLOR] file = air.[COLOR=#000080]File[/COLOR].[COLOR=#000080]applicationStorageDirectory[/COLOR].[COLOR=#000080]resolvePath[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"test.txt"[/COLOR][COLOR=#000000])[/COLOR]; 

[COLOR=#000000]var[/COLOR] str = [COLOR=#ff0000]“Hello.”[/COLOR];
file.[COLOR=#000080]addEventListener[/COLOR][COLOR=#000000]([/COLOR]air.[COLOR=#000080]Event[/COLOR].[COLOR=#000080]COMPLETE[/COLOR], fileSaved[COLOR=#000000])[/COLOR];
file.[COLOR=#000080]save[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]function[/COLOR] fileSavedCOLOR=#000000[/COLOR]
[COLOR=#000000]{[/COLOR]
air.[COLOR=#0000ff]trace[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]

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?