Applying variables only once?

Hi, is there a way to apply variables only once?
Like in an MC when you can use Load to give it variables et c. Can you use anything like this for an function?

I have this problem:
[AS]
ai_foe = function (target)
{
if (target.action == undefined)
{
target.action = “idle”;
}
if (target.hitTest (_root.char))
{
target.action = “attack”;
}
switch (target.action)
{
case “idle” :
target.gotoAndPlay (target.action);
break;
case “attack” :
target.gotoAndPlay (target.action);
break;
case “dead” :
target.gotoAndPlay (target.action);
break;
}
};
[/AS]
The problem is that the target MC is going to freeze at the first frame of “action”, since this is loaded every onEnterFrame.
How do i get around this?