在Flash AS3中的另一部电影中引用movieclip

时间:2010-07-15 10:32:11

标签: flash actionscript-3 movieclip scrollpane

我正在创建一个drap and drop简单游戏,从影片剪辑中拖放项目。一切都工作正常,但后来我不得不添加更多项目,所以我创建了一个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;
        }
    }
}

1 个答案:

答案 0 :(得分:1)