When you write
var anim = AnimationPlayer
anim to the
AnimationPlayer class. This is why you get an error.
What you want is to assign it to your specific animation player node. You can do this with
get_node("AnimationPlayer") or the shortcut
$AnimationPlayer. In addition, you need to make sure the node is ready first:
onready var anim = $AnimationPlayer