0

コンテナ内の画像を、別の画像と衝突したときに同じ水平線に沿ってその画像を「押す」水平方向のドラッグのみに制限するにはどうすればよいですか。

-------o------o--

4

1 に答える 1

0

    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);
    }


]]>

ファイル:///C|/Users/austink/Documents/Flex Builder 3/NewMenuSystem/src/assets/thumbs/IMG8.png ファイル:///C|/Users/austink/Documents/Flex Builder 3/NewMenuSystem/src /assets/thumbs/IMG12.png

于 2011-03-03T21:53:21.803 に答える