Me again, trying to get something to happen after ~1 second in a for loop. If I put in my for loop incrementer parameter counter += FP.elapsed, I found it counting in an instant, I imagine because for loop is called very quickly over and over. If I try to use a counter as a global varial and have it updating in update() I find it is not updating during the for loop and is stuck at 0, causing an infinite loop. Here is my code
if (counter > time && !thisIsBack) disappear();
if (counter > time && thisIsBack)
{
disappear();
reappear();
}
if (inReappear)
{
counter += FP.elapsed;
}
} // End update function
private function disappear():void
{
// Add some effect of removal here. puff of smoke or something? unless covered in final sprite
FP.world.remove(this);
} // End disappear function
private function reappear():void
{
inReappear = true;
var quickBool = true;
counter = 0;
for (; counter < 1.5; )
{
trace(counter);
if (counter > 1 && quickBool)
{
// var newAgain = new DisappearingBlock(x, y, width, thisAssetSprite, time, thisIsBack);
// world.add(newAgain);
trace("time");
}
if (counter > 1)
{
quickBool = false;
inReappear = false;
}
}
}