0

我正在尝试将一些影片剪辑放到一个对象上。

var br1_txt:TextField = new TextField();
br1_txt.text = "t";
br1_txt.defaultTextFormat = tfB;
br1_txt.setTextFormat(tfB);
br1_txt.textColor = 0x000000;
br1_txt.x = -3;
br1_txt.y = -3;

var br1_mc:MovieClip = new MovieClip();
br1_mc.addChild(br1_txt);
addChild(br1_mc);

var array:Array = new Array();

var object1:Object = new Object;
var s1:MovieClip = this.getChildByName("squared2") as MovieClip;
var piece1:MovieClip = this.getChildByName("br1_mc") as MovieClip;
object1.s1 = s1; // or object["movieClip"] = movieClip
object1.piece1 = piece1;
array.push(object1);
trace(s1); // Outputs [object MovieClip]
trace(piece1); // Outputs null, why?
4

1 回答 1

1

问题出在这里: this.getChildByName("br1_mc") br1_mc 是变量名而不是实例名。插入这个L br1_mc.name = "br1_mc"; 在创建 br1_mc 之后和调用 this.getChildByName("br1_mc") 之前的某个地方

于 2013-09-17T13:31:12.483 回答