Hi! Some months ago I used some example from a book, recreated it and created a Stepmania-replica.
It should’nt be that hard, and it isn’t since I managed it in AS2, can’t in AS3 though (I’m remaking it in AS3 to learn…).
clip.addEventListener(Event.ENTER_FRAME, initiate);
function initiate(e:Event):void {
var currentTime:int = getTimer();
var elapsedTime:int = currentTime - startTime;
if(elapsedTime >= pauseTime) {
var whatStep = routine[stepCount];
var step:Step = new Step();
step.y = 400;
step.name = "step" + count;
step.gotoAndStop(whatStep);
clip.addChild(step);
if(stepCount >= routine.length) {
stepCount = 0;
}
stepCount++;
count++;
startTime = getTimer();
step.addEventListener(Event.ENTER_FRAME, checkStep);
}
}
function checkStep(e:Event) {
var target = e.target;
target.y = target.y - 4;
if(target.y <= 200) {
clip.removeChild(target);
}
}
First I check my “clip” (Empty MovieClip put on Stage) with an ENTER_FRAME. I have a pause-time on 1000 so every 1000 It creates a new arrow. So far so good.
Then my problem comes, I want to send the arrow upwards so I set for the “step” and ENTER_FRAME aswell. This also works well but I want to remove the clip after it passes a certain value. I did the removeChild but get’s the error “The supplied DisplayObject must be a child of the caller.”.
I kinda understand the error but can’t figure out how the logic behind the game really should be set up.
Any pointer would be great, or direct comments.