I found the solution. We must define it when application is created. So first, use it:
private var app:Object;
protected function init(event:FlexEvent):void
{
app = FlexGlobals.topLevelApplication;
}
private function doSomething():void
trace(app)
}