code:
onClipEvent (load) {
force_x=5;
}
onClipEvent (enterFrame) {
update=0;
if(this.hitTest(_root.Player._x-3,
_root.Player._y+_root.Player._height/2,true)) {
while(this.hitTest(_root.Player._x-3,
_root.Player._y+_root.Player._height/2,true)) {
_x-=1;
}
update=1;
}
if(this.hitTest(_root.Player._x+_root.Player._widt h+3,
_root.Player._y+_root.Player._height/2,true)) {
while(this.hitTest(_root.Player._x+_root.Player._w idth+3,
_root.Player._y+_root.Player._height/2,true)) {
_x+=1;
}
update=1;
}
if(this.hitTest(_root.Player._x+_root.Player._widt h/2,
_root.Player._y,true)) {
while(this.hitTest(_root.Player._x+_root.Player._w idth/2,
_root.Player._y,true)) {
_y-=1;
}
update=1;
}
if(this.hitTest(_root.Player._x+_root.Player._widt h/2,
_root.Player._y+_root.Player._height,true)) {
while(this.hitTest(_root.Player._x+_root.Player._w idth/2,
_root.Player._y+_root.Player._height,true)) {
_y+=1;
}
update=1;
}
if(update==1) {
while(_root.Level.hitTest(_x,
_y+_height/2+2,true)) {
_y-=1;
}
while(_root.Level.hitTest(_x,
_y-_height/2-2,true)) {
_y+=1;
}
while(_root.Level.hitTest(_x-_width/2-2,
_y,true)) {
_x+=1;
}
while(_root.Level.hitTest(_x+_width/2+2,
_y,true)) {
_x-=1;
}
}