I am having an issue with adding dynamic content through an interval. The content is being added to the screen, but the X position, as well as the tween, seem to be completely out of sink.
The below is a screenshot when the interval is at 100 milliseconds, as it shows it best. The application needs to work at 200 milliseconds (where the error is not as clear, but the lines are still occationally too close, roughly every 4th).

As can be seen, there is a clear discrepancy between positioning. It remains fine for a few, then changes, changes again and then finally reverts back to what it was.
Here is my code that controls this section:
function XYZ(){
Score = 90
var timeBefore = Score
if(timeBefore <= 2.4){
timeBefore = 2.5
Score = "2.5"
}
else if(timeBefore > 75){
timeBefore = 2.5
Score = "2.5"
}
trace(timeBefore)
var signInterval:uint = setInterval (addThis, 100);
var finishInterval:uint = setInterval (checkThis, timeBefore*200);
MCArray.push(signInterval), MCArray.push(finishInterval)
}
function addThis(){
trace("Adding this!")
timeElap++
var floorNum:sign = new sign
//floorNum.visible = false
floorNum.y = 325
floorNum.x = 0 - floorNum.width
floorNum.dtf_num.text = timeElap+""
addChildAt(floorNum, 1)
trace(stage.stageWidth+floorNum.width)
trace(floorNum.width)
TweenMax.to(floorNum, 1.5, {x:stage.stageWidth+floorNum.width, ease:Linear.easeNone})
floorSigns.push(floorNum)
}
Anyone with any ideas as to what is causing this to happen?
Note: It also happens with 200 and 300 milliseconds, although less prominent.
setInterval()andsetTimer()aren’t nearly as precise as you might think they are. They are, at best, hints to the avm of when you would like a function to run. Here is a article that is about JavaScript but is applicable to actionscript as well.You will need to change your architecture and the way that you are approaching the problem. You want to create an
ENTER_FRAMEhandler and then usegetTimer()to determine how much time is elapsed, and what you need to create/position and schedule.