AS3 Simple Bounce Not Rendering at Boundary

Hi guys I’m running some AS3-based animation, a simple bounce effect. A ball lies above a line, gravity as acceleration increases it’s negative velocity by 1 each frame. When it penetrates an arbitrary line it is move up accordingly and velocity is set to a high positive number (24).

At 40FPS, and with a high positive velocity set to the ball, the critical frame where it hits the “ground” doesn’t always render (maybe four out of five times fails), yet tracing outputs that it did indeed go across the bounce areas. Here are the 4 critical positions where 456 would be where it was wrapped to the ground:


Yet sometimes it seems to drop ONLY the render at 456, making it look really unpleasant. Since it is such simple code, the problem doesn’t lie in the efficiency. Does anyone know anything about this? Any suggestions to alleviate or work around it?

Thanks very much :slight_smile:

Edit: An isolated example! :slight_smile: The red box would represent the “ball” and it has the same stutter effect going on in my end - periodically the frame where the ground and it are touching isn’t rendered. This is 800x600 running at 60FPS:

import flash.display.Sprite;

var redblock:Sprite = new Sprite();
redblock.y = 456;, 0xFF0000, 1);, 1);,0);,400);,400);,0);;

var stick:Sprite = new Sprite();, 0x000000, 1);, 1);,0);,-40);,-40);,0);;

var velocity:Number = 0;

stick.x = 300;

addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(event:Event):void
        // Fake Gravity
	if(velocity > 10) velocity -= 1;
	else velocity -= 0.8;
	// Apply velocity
	stick.y -= velocity;

        // Penetrated Red Box, Move up and set high "bounce" velocity
	if(stick.y > 456)
		stick.y = 456;
		velocity = 30;