Collision Imposition

My collisions are working but my response to collisions are working on…wait for it…three sides of the box!!!

i’ve got a ship flying around and banging into a box on three sides it bounces on the fourth it sticks what the H am i doing wrong???!!!

Document:

package
{
    import flash.display.MovieClip
    import flash.utils.Timer
    import flash.ui.Keyboard;
    import flash.events.KeyboardEvent;
    import flash.events.Event;
    import fl.transitions.*;
    import fl.transitions.easing.*;
    //import flash.filters.BlurFilter;
    
    
    public class DocumentClass extends MovieClip
    {
        var redDot:RedDot=new RedDot;
        var fire:Fire = new Fire;
        var ship:Ship = new Ship;
        var rock:Rock = new Rock;
        var landScape:Array =new Array
        var bounce:Number=-.6;
        var frameCount:Number=0;
        var thrusterField:ThrusterField;
        var redBox:RedBox = new RedBox;//redBox is an alpha 0 mc that i attach all the extras(navlights and thrusters onto my ship with to avoid collision detection problems.
        
        var acollisionList=new CollisionList(rock);
        var cAngle:Number=0;
        var stearingOperative:Boolean=true;
        
        
        public function DocumentClass()
        {
            
            //rock.scaleX=2;
            //rock.scaleY=2;
            addChild(rock);
            rock.x=175;
            rock.y=150;
            landScape.push(rock);
            redBox.x=ship.x;
            redBox.y=ship.y;
            addChild(ship);
            addChildAt(redBox,0);
            ship.x=10;
            ship.y=-50;
            ship.scaleX=.3;
            ship.scaleY=.3;
            redBox.scaleX=ship.scaleX;
            redBox.scaleY=ship.scaleY;
            acollisionList.addItem(ship);
        
            stage.addEventListener(Event.ENTER_FRAME, onEnterFramey);
            stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDowny);
            stage.addEventListener(KeyboardEvent.KEY_UP,onKeyUpy);
        }
    
        private function onKeyDowny(keyDwnEvt:KeyboardEvent):void
        {
         
            
            switch(keyDwnEvt.keyCode)//keyBoard reader
            {
                    case Keyboard.LEFT :
                    ship.vr= -5;
                    ship.rMom=0;//rMom is a variable for the ships rotational momentum i was hopping to et a rotational effect from a collision but currently have bigger issues
                    break;
                
                    case Keyboard.RIGHT :
                    ship.vr= 5;
                    ship.rMom=0;
                
                    break;
                
                    case Keyboard.UP :
                    ship.thrust= 0.2;
                    redBox.thrust1.alpha=1;
                    
                    break;
                
                    default :
                    break;
                }//end switch
            
        }//end keyDowny
         public function onKeyUpy(keyUpEvt:KeyboardEvent):void
        {
            ship.vr =0;
            ship.thrust = 0;
            redBox.thrust1.alpha=0;
        }//end on KeyUpy
        
        public function onEnterFramey(onEnterFrameEvt:Event):void
        {
            ship.moveShip();
            hitTesty();
            
            frameCount=0;
            
            redBox.x=ship.x;
            redBox.y=ship.y;
            redBox.rotation=ship.rotation;
            
            
        }//end onEnterFramey
    
    
        
        public function hitTesty()
        {  
            var collisions:Array = acollisionList.checkCollisions();

            if(collisions.length)
            {
                
                
                trace ("collision is happening");
                var collision:Object = collisions[0];
                cAngle = collision.angle;
                ship.x=ship.previousx;//this is where i try to steer clear of collision boarder problems
                ship.y=ship.previousy;
                
                
                
                //switch(true)//all this is to rotate the ship in a hopefully realistic manner after a collision.....it doesn't work...very snappy rotation
                //{
//                    case  (ship.rotation>=-179 && ship.rotation<=-166):
//                    ship.rotation=-180;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-165 && ship.rotation<=-156):
//                    ship.rotation=-180;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-155 && ship.rotation<=-146):
//                    ship.rotation=-135;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-145 && ship.rotation<=-136):
//                    ship.rotation=-135;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-135 && ship.rotation<=-126):
//                    ship.rotation=-135;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-125 && ship.rotation<=-116):
//                    ship.rotation=-90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-115 && ship.rotation<=-106):
//                    ship.rotation=-90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-105 && ship.rotation<=-96):
//                    ship.rotation=-90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-95 && ship.rotation<=-86):
//                    ship.rotation=-90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-85 && ship.rotation<=-76):
//                    ship.rotation=-90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-75 && ship.rotation<=-66):
//                    ship.rotation=-90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-65 && ship.rotation<=-55):
//                    ship.rotation=-45;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-54 && ship.rotation<=-45):
//                    ship.rotation=-45;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-44 && ship.rotation<=-35):
//                    ship.rotation=-45;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-34 && ship.rotation<=-25):
//                    ship.rotation=0;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-24 && ship.rotation<=-15):
//                    ship.rotation=0;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=-15 && ship.rotation<=-1):
//                    ship.rotation=0;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation=0 ):
//                    ship.rotation=0;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=1 && ship.rotation<=15):
//                    ship.rotation=0;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=16 && ship.rotation<=25):
//                    ship.rotation=0;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=26 && ship.rotation<=35):
//                    ship.rotation=0;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=36 && ship.rotation<=45):
//                    ship.rotation=45;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=46 && ship.rotation<=55):
//                    ship.rotation=45;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=56 && ship.rotation<=65):
//                    ship.rotation=45;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=66 && ship.rotation<=75):
//                    ship.rotation=45;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=76 && ship.rotation<=85):
//                    ship.rotation=90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=86 && ship.rotation<=95):
//                    ship.rotation=90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=96 && ship.rotation<=105):
//                    ship.rotation=90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=106 && ship.rotation<=115):
//                    ship.rotation=90;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=116 && ship.rotation<=125):
//                    ship.rotation=135;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=126 && ship.rotation<=135):
//                    ship.rotation=135;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=136 && ship.rotation<=145):
//                    ship.rotation=135;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=146 && ship.rotation<=155):
//                    ship.rotation=135;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=156 && ship.rotation<=165):
//                    ship.rotation=135;//ship.rotateShip();
//                    break;
//                    case  (ship.rotation>=166 && ship.rotation<=180):
//                    ship.rotation=180;//ship.rotateShip();
//                    break;
                
                
                shipBounce1(ship,rock);
            }//end collisioncheck
        }//end hittesty
        public function shipBounce1(ball,ball2)//the two arguments are left over from before when this 
        {
            var coLisionAngle=cAngle*180/Math.PI;
            trace(coLisionAngle+"colAngle");
            
        
            switch (true) 
            {
                
                  case (coLisionAngle>=-180 && coLisionAngle<=0):
                   ship.vx*=-.5;
                ship.vy*=.5;
                break;
                 
                case (coLisionAngle>=0 && coLisionAngle<=180):
                ship.vx*=.5;
                ship.vy*=-.5;
                break;
                default:
            }//edn switch
            
        }//end shipBounce


    }//Class
}//package


ship

package
{
    import flash.display.MovieClip;
    import flash.display.Sprite;
    //import idv.cjcat.emitter.*
    import flash.events.Event;
    import flash.filters.BitmapFilter;
    import flash.filters.BitmapFilterQuality;
    import flash.filters.GlowFilter;
    import flash.filters.BlurFilter;
    
    public class Ship extends MovieClip
    {
        trace("shipHere");
        var vr:Number=0;
        var thrust:Number=0;
        var vx:Number=0;
        var vy:Number=0;
        var gravity:Number=0.03
        var mass:Number=1;
        var previousx:Number;
        var previousy:Number;
        var rMom:Number=0;
        //var thrust1:Thrust =  new Thrust;
        
        var thrusterField:ThrusterField;
        
        var thrustVisible:Boolean=false;
        
        public function Ship():void
        {
            //thrust1.x=-38;
//            thrust1.y=60;
//            thrust1.alpha=0;
//            addChild(thrust1);
        }
        
        public function moveShip()
        {    vr+=(rMom*.5);
            previousx=this.x;
            previousy=this.y;
            
            this.rotation +=vr;
            var angle:Number=this.rotation * Math.PI /180;
            var ax:Number =Math.sin(angle)*thrust;
            var ay:Number=Math.cos(angle)*thrust;
            vx += ax;
            vy += ay;
            
            vy -= gravity;
            this.x +=vx;
            this.y -=vy;
            rMom=0;
            trace(rMom);
            
            
            
            
        }
        public function ThrustCheck():void
        {
            if (thrustVisible==true)
            {
                var thrusterField= new ThrusterField;
                addChild(thrusterField);
                trace("thrustVisible!!!!");
                
            }
            else
            {
                trace("thrustInvisible");
            }
        }
        public function rotateShip():void
        {
            if (vx>vy)
            {
                rMom+=vx;
            }
            else if (vy>vx)
            {
                rMom +=vy;
            }
        }
    
        
            
    }
}