打印

[编程] 错误:由于指定的对象不存在,'with' 动作失败。

一个xml加载图片的swf文件
正常运行正常代码如下
复制内容到剪贴板
代码:
Stage.scaleMode = "noScale";
Stage.showMenu = false;
Stage.align = "T";
nextLineCount = 0;
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = initPhotos;
myXML.load("file/links.xml");
function initPhotos(a) {
    if (a == true) {
        txTitle._width = PageWidth;
        txTitle.text = this.firstChild.attributes.title;
        _root.PageWidth = Number(this.firstChild.attributes.width);
        for (i=0; i<this.firstChild.childNodes.length; i++) {
            if (i>0) {
                photoBox0.duplicateMovieClip("photoBox"+i, i);
                with (_root["photoBox"+i]) {
                    targetBox = _root["photoBox"+(i-1)];
                    _x = targetBox._x+targetBox._width-5;
                    _y = targetBox._y;
                    if (_x>(_root.PageWidth-_width)) {
                        _x = _parent.photoBox0._x;
                        _parent.nextLineCount++;
                        _y = _parent.photoBox0._y+(_parent.photoBox0._height-5)*_parent.nextLineCount;
                    }
                }
            }
            var targetBox = _root["photoBox"+i];
            targetBox.mcSmallImageBox.loadMovie(this.firstChild.childNodes[i].attributes.small);
            targetBox.onEnterFrame = function() {
                if (this.mcSmallImageBox._width>5) {
                    delete this.onEnterFrame;
                    this.mcSmallImageBox._width = 102;
                    this.mcSmallImageBox._height = 77;
                }
            };
            targetBox.imageURL = this.firstChild.childNodes[i].attributes.large;
            targetBox.onRelease = function() {
                getURL(this.imageURL, "_blank");
            };
        }
        //getURL("javascript:setHeight("+_root._height+")");
        //myLater = setInterval(initLater, 2000, true);
    }
}
function initLater(delOption) {
    getURL("javascript:setTitle('"+myXML.firstChild.attributes.title+"')");
    if (delOption == true) {
        clearInterval(myLater);
    }
}
如果把里面的部件包进一个MC里面
或者用新的flash从外部导入空白MC就会报错
错误:由于指定的对象不存在,'with' 动作失败。

错误:由于指定的对象不存在,'with' 动作失败。

错误:由于指定的对象不存在,'with' 动作失败。

错误:由于指定的对象不存在,'with' 动作失败。

错误:由于指定的对象不存在,'with' 动作失败。

错误:由于指定的对象不存在,'with' 动作失败。

错误:由于指定的对象不存在,'with' 动作失败。

错误:由于指定的对象不存在,'with' 动作失败。

错误:由于指定的对象不存在,'with' 动作失败。

要怎么解决这个问题啊
请教各位游客和版主了

TOP

复制内容到剪贴板
代码:
......
......
......
with (_root["photoBox"+i]){
......
......
......
提示很明确
这里明确指明路径是_root 你改变MC的路径却不修改这里 当然报错!

TOP

回复 Abner 在 2# 的帖子

要怎么改啊
话没说完呢

TOP

.....问题已经找到你还不知道怎么改那我就没法了
我哪知道你的是什么路径

TOP

通过这句话
复制内容到剪贴板
代码:
photoBox0.duplicateMovieClip("photoBox"+i, i);
可以得出
复制内容到剪贴板
代码:
with (_root["photoBox"+i]) --> with (photoBox0["photoBox"+i])
you will never know what you can do till you try

TOP

好遗憾
大家的帮助对我几乎没有帮助
是我太肤浅,还是这个问题有这么复杂

它不就是以上那个实例现在我要放进新mc里运行吗
什么路经不路经的,不可能不明白我要表达的

TOP

问题解决
答案是
自己探索发现,靠自个

TOP