这个图片库增加了孩子们。确实如此 它需要什么,但会引发#2007错误。
我想解决垃圾和范围问题。
有一个简单的解决方案吗?
//PICTURE GALLERY
var um0:MovieClip = new z0;
var um1:MovieClip = new z1;
var um2:MovieClip = new z2;
var um3:MovieClip = new z3;
var AR:Array = [um0,um1,um2,um3];
var i:int = 0;
//GO FORWARD THROUGH GALLERY
b.addEventListener(MouseEvent.CLICK, onClam);
function onClam(e:MouseEvent){
i++;
containerInstance.addChild(AR[i]);
}
//GO BACKWARD THROUGH GALLERY
d.addEventListener(MouseEvent.CLICK, onClum);
function onClum(e:MouseEvent){
i--;
containerInstance.addChild(AR[i]);
}
错误
TypeError:错误#2007:参数child必须为非null
答案 0 :(得分:2)
尝试这样做以使你的索引绕数组长度(你也可以使用模数,但我认为这更简单):
function onClam(e:MouseEvent){
i++;
if(i >= AR.lenght) {
i = 0;
}
containerInstance.addChild(AR[i]);
}
function onClum(e:MouseEvent){
i--;
if(i < 0) {
i = AR.length - 1;
}
containerInstance.addChild(AR[i]);
}