ok im making a fighting game i just need an enemy code i need this stuff in the code…
IF it is standing stop on frame 1
IF it is walking stop on frame 2
If it is CLOSE to player stop on either frame 3 or 4
IF hp is under 0 then stop on frame 5
i hope i can learn something from this code aswell 
thnx in advance
monster.onLoad=function(){
var standing:Boolean=true
var walking:Boolean=false
var hp:Number=100
}
monster.onEnterFrame=function(){
var CloseToPlayer:Boolean=(Math.abs(this._x-hero._x)<15)
if(standing){
gotoAndStop(1)
}
if(walking){
gotoAndStop(2)
}
if(CloseToPlayer){
//make sure it only has one 3 or 4 or you will get errors
gotoAndStop(3 or 4)
}
if(hp<0){
gotoAndStop(5)
}
}
That code doesn’t do anything. For starters, the onLoad event is only broadcast to movie clips with a different class association which I’m assuming the monster movie clip doesn’t have. And even if it did, variables declared with the var statement inside functions are local to that functions activation object and are deleted after the function has executed :hoser:
In other words the code should be changed to:
monster.standing=true
monster.walking=false
monster.hp=100
monster.onEnterFrame=function(){
var CloseToPlayer:Boolean=(Math.abs(this._x-hero._x)<15)
if(this.standing){
this.gotoAndStop(1);
}
if(this.walking){
this.gotoAndStop(2);
}
if(CloseToPlayer){
//make sure it only has one 3 or 4 or you will get errors
this.gotoAndStop(3 or 4)
}
if(this.hp<0){
this.gotoAndStop(5)
}
}
:thumb:
don’t matter i wasn’t thinking about that possibility, i put this code for him to have to re-make anyways
True, but if he is just learning AS and he is given the wrong information, it would most likely lead him to frustation over why his code isn’t working.
ok, like i said i was thinking and wrote the code like as1 in as2, plus thats what the forums are for he could just post and say it doesn’t work and i probably would have looked at his .fla and been like ok my mistake 
PSSSS… I need a cooler footer and icon thing
:lol: Way to hack poor old Bomby there
lol, that was not my day lol =(
Why always recalculate closeToPlayer?
Edit: Wasn’t thinking. You have to do it anyways. I thought you were using else-if’s… until I looked. 
monster.standing=true
monster.walking=false
monster.hp=100
monster.onEnterFrame=function(){
if(this.standing){
this.gotoAndStop(1);
}
if(this.walking){
this.gotoAndStop(2);
}
if(Math.abs(this._x-hero._x)<15){
//make sure it only has one 3 or 4 or you will get errors
this.gotoAndStop(3 or 4)
}
if(this.hp<0){
this.gotoAndStop(5)
}
}