Skip to main content
March 21, 2009
Answered

How can i make this code loop forever???

  • March 21, 2009
  • 1 reply
  • 355 views
import flash.display.*;
import flash.events.*;

var directionInt:Number = 1;

addEventListener(Event.ENTER_FRAME, function(){
if(((test.y+test.height) < stage.stageHeight) && (test.y > 0)){
test.y = test.y+directionInt;
}
else if((test.y+test.height) >= stage.stageHeight){
directionInt = -1;
test.y = test.y + directionInt;
}
else if(test.y <= 0){
directionInt = 1;
test.y = test.y + directionInt;
}
})
This topic has been closed for replies.
Correct answer Ned Murphy
Chances are it is running forever since the ENTER_FRAME is in effect.

There must be something else wrong with what you've done because as is, that code works fine, assuming the object is supposed to move from top to bottom to top... continuously

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
March 21, 2009
Chances are it is running forever since the ENTER_FRAME is in effect.

There must be something else wrong with what you've done because as is, that code works fine, assuming the object is supposed to move from top to bottom to top... continuously