我现在无法解决几个小时;(。我想在容器中添加一个孩子。这是我到目前为止所做的。所有问题都在 Creator 类中。这一行 par2.addChild(ship); // 有效, 但是这一行 par2.containerSDv.addChild(ship); //error:1119.
谢谢
public class Main extends MovieClip
{
private var containerSD:Container = new Container;
private var ship:Ship2;
public function Main()
{
// constructor code
stage.addChild(containerSD);
//ship = new Ship2;
//containerSD.addChild(ship);
}
}
.
public class AddChild2 extends SimpleButton
{
private var creatorche:Creator = new Creator;
private var s:Ship2;
public function AddChild2()
{
// constructor code
addEventListener(MouseEvent.CLICK, onCLICK)
}
private function onCLICK(e:MouseEvent)
{
s = new Ship2;
creatorche.onCreator(s, stage);
}
}
.
public class Creator extends MovieClip
{
private var ship:MovieClip;
private var containerSDv:Container = new Container;
public function Creator()
{
// constructor code
}
public function onCreator(par1:MovieClip, par2:Stage)
{
ship = par1;
//par2.addChild(ship); //works
par2.containerSDv.addChild(ship); //error:1119
ship.x = Math.random() * 200;
ship.y = Math.random() * 200;
}
}
.