Movement with AS

Hi, i have a problem with mving a object. I can move the object, but i need to have some restrictions on it. I need to disable the moving function, when it reaches 0 and 300 on the x-axis. Also i need when its being moved, that its easing, and i dont know how to do this either. I know i need some kind of if-else command for the restrictions, but i really need some help. This is all i got:

[AS]
on (keyPress “<Left>”) {
currentX = this._x;
this._x = currentX - 5;
}
on (keyPress “<Right>”) {
currentX = this._x;
this._x = currentX + 5;
}
[/AS]