Why does this not work in flash? It makes it through the first if statement where if done==1 and changes “done” to “2”, but once it moves left one increment it moves right again and continues to loop back and forth, and done remains “2”. Its like its ignoring “if done==2”.
box.onEnterFrame = function(){
//set a variable to switch between right & left movement
var done = "1";
if(done == "1"){
//Move right
if(this._x < 530){
this._x += 10;
}
//Threshold for right movement, set variable to move left
if(this._x > 530){
var done = "2";
}
trace(this._x);
trace(done);
}
if(done == "2"){
//Move left
if(this._x > 24){
this._x -= 10;
}
//Threshold for left movement
if(this._x < 24.15){
var done="3";
}
trace(this._x);
trace(done);
}
if(done == "3"){
// Do nothing, we're done.
trace("Done!");
}
}