Question about collisions

Hello,

I’m pretty new to Flash and Actionscript, and currently just doing random experiments to get the hang of it. Now after finally understanding keyboard input (my mistake was to put the keyboardevent on the object, not to the stage) I want to control a ‘player’ (which is a simple ball for now).

I have a document class which creates a ball and an ‘obstacle’ out of the library. This document class also keeps track of the buttons which are pressed, by using 4 booleans. Then every frame it will call a function in the Player class, telling which keys are down. The called function will then move the ball. So far so good. But the problem comes when I want to test collisions. Here’s my function:


public function move(left:Boolean, up:Boolean, right:Boolean, down:Boolean, piet:Obstakel1):void
        {
            tempx = x;
            tempy = y;
            
            if(left)
            {
                xspeed -= acc;
            }
            if(right)
            {
                xspeed += acc;
            }
            if(jumping)
            {
                yspeed += acc;
                yspeed *= friction;
            }
            else
            {
                if(this.hitTestObject(piet))
                {
                }
                else
                {
                    yspeed += acc;
                    yspeed *= friction;
                }
            }
            
            tempx += xspeed;
            tempy += yspeed;

            x = tempx;
            y = tempy;
            rotation += xspeed;
            
            if(this.hitTestObject(piet))
            {
                if(yspeed <= 0.1)
                {
                    yspeed = 0;
                    jumping = false;
                }
                else
                {
                    yspeed *= -1;
                }
            }
        }

Something in this code must not be right. As long as I don’t move the ball left or right it’s all good. But when I do that the ball randomly floats in the air, and not on the object. Can anyone help me point out any errors?
Thanks in Advance.