Flex使用碰撞水平拖动图像

如何将容器中的图像仅限制为水平拖动,当它与另一个图像碰撞时,将该图像沿同一水平线“推”。 ------- ------ØO--     
已邀请:
    
    public function hitTestIMG1(yourEvent:Event):void
    {   
        if(IMG1.hitTestObject(IMG2)) {
            if(IMG1.x < IMG2.x-(IMG2.width/2)) {
                trace("LEFT SIDE!!!");
                trace("IMG1: " + IMG1.x);
                trace("IMG1 Width: " + IMG1.width);
                trace("IMG2: " + IMG2.x);
                trace("IMG2 Width: " + IMG2.width);
                IMG2.x = IMG1.x+(IMG1.width);
            } else 
            if(IMG1.x > IMG2.x+(IMG2.width/2)) {
                trace("RIGHT SIDE!!!");
                trace("IMG1: " + IMG1.x);
                trace("IMG1 Width: " + IMG1.width);
                trace("IMG2: " + IMG2.x);
                trace("IMG2 Width: " + IMG2.width);
                IMG2.x = IMG1.x-(IMG2.width);
            }
        }   
    }   

    public function IMG1Start(IMGMove:Event):void
    {
        IMG1.startDrag(false,new Rectangle(0,IMG1.y,stage.width,0));
    }

    public function IMG1Stop(IMGStop:Event):void
    {
        IMG1.stopDrag();
    }   

    public function test():void
    {
        // stage listeners - must be set on startup!!!
        stage.addEventListener(Event.ENTER_FRAME, hitTestIMG1);
    }


]]>
                          file:/// C | / Users / austink / Documents / Flex Builder 3 / NewMenuSystem / src / assets / thumbs / IMG8.png                               file:/// C | / Users / austink / Documents / Flex Builder 3 / NewMenuSystem / src / assets / thumbs / IMG12.png                   

要回复问题请先登录注册