2

已经有一个关于这个的问题,但它并不能完全回答我的问题,因为我对 Flash 很陌生。当我编译我的代码时,它在第 69+74 行,在两个“私人”中的“p”上给了我一个错误。这是代码:

    private function destroyMouseJoint(e:MouseEvent):void 
{
    hand.active = false;
}

private function spawnBox():void 
{
    var block:Polygon = new Polygon(Polygon.box(50, 50));
    var body:Body = new Body(BodyType.DYNAMIC);
    body.shapes.add(block);
    body.position.setxy(stage.stageWidth /2, stage.height / 2);
    body.space = space;
}

我不确定我应该做什么。提前致谢 :)

4

1 回答 1

1

看来您可能会将您的功能置于类定义之外。确保它们位于以下内容中:

package  {
import flash.display.Sprite;

public class YourClass extends Sprite {
            private var bg:Sprite;

            public function YourClass() {
                super();
            }

            private function destroyMouseJoint(e:MouseEvent):void {
                hand.active = false;
            }

            private function spawnBox():void  {
                var block:Polygon = new Polygon(Polygon.box(50, 50));
                var body:Body = new Body(BodyType.DYNAMIC);
                body.shapes.add(block);
                body.position.setxy(stage.stageWidth /2, stage.height / 2);
                body.space = space;
            }
      }
 }
于 2012-11-20T20:30:32.650 回答