0

我正在创建一个拖放简单的游戏,从影片剪辑中拖放一个项目。一切正常,但后来我不得不添加更多项目,所以我创建了一个 ScrollPane 并通过它引用了影片剪辑,现在我需要重新设计如何再次引用该影片剪辑。

影片剪辑已导出,因此滚动窗格可以将其带入...

前:

package {

    import flash.display.*;
    import flash.geom.Point;
    import flash.events.*;

    public class shopping extends Sprite {

        public function shopping() {

            shoppinglist.Ketch.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
            shoppinglist.Ketch.addEventListener(MouseEvent.MOUSE_UP, dropIt);

欢迎任何帮助......希望这是有道理的......

**编辑

仍然在这方面苦苦挣扎,这是我的代码:

package {

    import flash.display.*;
    import flash.events.MouseEvent;
    import flash.geom.Point;
    import flash.events.KeyboardEvent;
    import flash.events.*;

    public class shopping extends MovieClip {

        public function shopping() {

            var counter:Number = 0;
            var startX:Number;
            var startY:Number;
            var budget:Number = 25
            scoreText.text = 'You have £'+budget+' for your weekly shop';
            priceText.text = '£'+budget;


            ScrollList.Ketch.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
            ScrollList.Ketch.addEventListener(MouseEvent.MOUSE_UP, dropIt);

            public function pickUp(e:MouseEvent):void {
                e.target.startDrag(true);
                reply_txt.text = "";
                e.target.parent.addChild(e.target);
                startX = e.target.x;
                startY = e.target.y;
            }

            public function dropIt(e:MouseEvent):void {
                e.target.stopDrag();
                if (e.target.dropTarget != null && e.target.dropTarget.parent == trolley){
                    //reply_txt.text = "Good Job!";
                    e.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
                    e.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
                    e.target.buttonMode = false;
                    //e.target.x = trolley.x;
                    //e.target.y = trolley.y;

                    if(e.currentTarget.name == 'Ketch'){
                        budget -= 1.25;
                        scoreText.text = 'You have £'+budget+' for your weekly shop';
                    }

                    counter++;
                } else {
                    //reply_txt.text = "Try Again!";
                    e.target.x = startX;
                    e.target.y = startY;
                }
                if(counter == 4){
                    reply_txt.text = "Congrats, you're finished!";
                }
            }

            ScrollList.Ketch.buttonMode = true;
        }
    }
}
4

1 回答 1

1

那么这里是可能有帮助的小代码

var Gotparent;

变量 myobj ;

公共功能pickUp(e:事件):无效{

 myobj      =  (evt.currentTarget)

 Gotparent  =   myobj.parent;

 addChild(myobj);

 myobj.startDrag(true);

}

公共函数 dropIt(e:Event):void { myobj.stop(); Gotparent.addChild(myobj); }

于 2010-07-23T13:06:28.803 回答