1. Computing & Technology

Discuss in my forum

Animating with ActionScripts

By , About.com Guide

Lastly, we need to tell Flash what to do in all other existing conditions that don’t satisfy the if statement (in this case, in any point where this._x is greater than 625). To do this, add a new else statement below and outside of the if statement, but still nested inside the onClipEvent(enterFrame):

onClipEvent (load){
this._x = 10;
}
onClipEvent (enterFrame) {
if (this._x<=625)
this._x = this._x+5;
}
else {
this._x = 10;
}
}

What that tells Flash is that in all other conditions, when this._x is not less than or equal to 625, then this._x needs to return to x coordinate 10, taking the movie clip symbol back where it started.

You can see mine sliding across the screen here.

©2012 About.com. All rights reserved.

A part of The New York Times Company.