Is this code correct?

_global.mainTimeline = this;
function moveball () {
mainTimeline.ball._x += 10;
mainTimeline.ball._y += 10;
}
moveBall();

This is an exercise im doing from Colin Moocks’ “Actionscript For Flash MX” book.
I put the code on frame 1 layer 1 of a movie. Then added a movie clip of a ball to the stage with the instance name “ball”.
The code should move the ball but when I export it, nothing happens.
Any reasons why? I added the code like it said in the book.
thanks