AS2 SWF 独立工作,但是当包含到 AS3 SWF 中时(即使仅加载它),它的行为很奇怪,有什么想法吗?

发布于 2024-10-17 13:46:32 字数 4116 浏览 7 评论 0原文

我知道有一些关于将 AS2 SWF 加载到 AS3 SWF 的帖子,但没有一个提供解决方案!我有一个独立的图片库 - 使用 XML 文件 - 我已将其加载到 AS3 SWF 中。

该图库本身可以正常运行,但是当加载到 AS3 SWF 中时,它不会更改主图像!我创建了一个新的 AS3 SWF,并且只有将此 AS2 画廊加载到 AS3 电影中的代码,没有其他任何内容,并且在单击缩略图时它仍然拒绝更改大图像。画廊几乎运行得很好,只是大图像不起作用。有人可以帮忙解决这个问题吗?这是我的 AS2 主库代码,有人能发现可能导致错误的原因吗?

import mx.transitions.Tween;
import mx.transitions.easing.*;

var my_xml = new XML();
my_xml.ignoreWhite = true;

my_xml.onLoad = function(success){
    if(success){
        doGallery();
        }
    else{
        null;
        }
    }

my_xml.load("xml/gallery.xml");

function doGallery(){

    var imgTitles:Array = my_xml.firstChild.childNodes[0].attributes.imgtitles.split("|");
    var numImgs:Number = my_xml.firstChild.childNodes[0].attributes.num;
    var thumbprefix = my_xml.firstChild.childNodes[0].attributes.thumbprefix;
    var largeprefix = my_xml.firstChild.childNodes[0].attributes.largeprefix;
    var ext = "."+my_xml.firstChild.childNodes[0].attributes.ext;
    var imgSets:Number = Math.ceil(numImgs/10);//max possible number of image sets
    var desc:Array = my_xml.firstChild.childNodes[0].attributes.descriptions.split("|")

    _parent.mySets = imgSets;
        if(imgSets == 1){
        _parent.btnNxt._visible = false;
        }

    _parent.imgNum = "1/"+numImgs;
    _parent.imgHolder.imgAttach.loadMovie("gallery/"+largeprefix+"01"+ext);

    for(var i:Number=0;i<numImgs;i++){

        attachMovie("thumbframe", "thumb"+i, this.getNextHighestDepth(), {_x:(i * 20), _y:51});
        var clip = eval("thumb"+i);

        if(i == 0){clip._x = 39;}
        else{clip._x = 90 * (i)+39;}

        clip._y = 51;


        _parent.txtsimon = imgTitles[0];
        _parent.imgDescr = desc[0];

        eval("thumb"+i).id = i+1;

        if(imgTitles[i] == "" or imgTitles[i] == undefined){
            clip.title = "Untitled Image";
        }
        else{
            clip.title = imgTitles[i];
        }


        eval("thumb"+i).thumbhold.loadMovie("gallery/"+thumbprefix+"0"+eval("thumb"+i).id+ext);

        eval("thumb"+(i)).onRelease = function(){   

            _parent.imgNum = this.id+"/"+numImgs;
            var thumbid:Number = this.id;
            var imgOut:Tween = new Tween(_parent.imgHolder, "_alpha", Regular.easeOut, _parent.imgHolder._alpha, 0, 0.4, true)

            imgOut.onMotionFinished = function(){
                _root.container.imgHolder.imgAttach.unloadMovie();
                _root.container.imgHolder.imgAttach.loadMovie("gallery/"+largeprefix+"0"+thumbid+ext);
                trace("gallery/"+largeprefix+"0"+thumbid+ext);
                new Tween(_root.container.imgHolder, "_alpha", Regular.easeIn, 0, 100, 0.5, true);
            }
            mytitle = this.title;
            _parent.txtsimon = mytitle;
            _parent.imgDescr = this.descr;

            _parent.btnDownloadImg.onRelease = function(){
                getURL("gallery/"+largeprefix+"0"+thumbid+ext);
                }

            new Tween(activeThumb, "_x", Strong.easeOut, activeThumb._x, this._x, 1.5, true);
            }

        clip.onRollOver = function(){
            new Tween(this, "_alpha", Strong.easeOut, this._alpha, 75, 1, true);
            }

        clip.onRollOut = function(){
            new Tween(this, "_alpha", Strong.easeOut, this._alpha, 100, 1, true);
            }
        }

        _parent.btnSlideShow.onRelease = function(){
        new Tween(this._parent.slideOverlay, "_alpha", Strong.easeOut, 0, 100, 3, true);        
        }
}

        _parent.btn_requestHighRes.onRelease = function(){
            var rtitle:String = _parent.txtsimon.toString();
            getURL("mailto:HIDDEN_EMAIL?subject=Toolkit High Res Request - "+rtitle);
            }

我已经对大图像的源进行了跟踪,它正在调用正确的图像。我卸载当前图像并加载新图像,但旧图像仍然加载,就像它已缓存或其他什么?问题似乎与此代码相关:

_root.container.imgHolder.imgAttach.unloadMovie();
_root.container.imgHolder.imgAttach.loadMovie("gallery/"+largeprefix+"0"+thumbid+ext);
trace("gallery/"+largeprefix+"0"+thumbid+ext);

上面的跟踪显示正在调用正确的图像,但它根本不会加载!

我非常感谢所有的评论,因为我已经坐在这个评论上很多年了!

西蒙

I am aware that there are a few posts on loading AS2 SWF's into AS3 SWF's but none provide a solution! I have a standalone image gallery - using an XML file - that I have loaded into an AS3 SWF.

The gallery functions fine on it's own, but when loaded into an AS3 SWF, it does not change the main image! I created a new AS3 SWF, and had ONLY the code to load this AS2 gallery into the AS3 movie, nothing else, and still it refused to change the large image when the thumbnails were clicked. The gallery pretty much run's perfectly fine, it is ONLY the large image that is not working. Can anyone help on this one? Here is my AS2 main gallery code, can someone spot something that could be causing the error?

import mx.transitions.Tween;
import mx.transitions.easing.*;

var my_xml = new XML();
my_xml.ignoreWhite = true;

my_xml.onLoad = function(success){
    if(success){
        doGallery();
        }
    else{
        null;
        }
    }

my_xml.load("xml/gallery.xml");

function doGallery(){

    var imgTitles:Array = my_xml.firstChild.childNodes[0].attributes.imgtitles.split("|");
    var numImgs:Number = my_xml.firstChild.childNodes[0].attributes.num;
    var thumbprefix = my_xml.firstChild.childNodes[0].attributes.thumbprefix;
    var largeprefix = my_xml.firstChild.childNodes[0].attributes.largeprefix;
    var ext = "."+my_xml.firstChild.childNodes[0].attributes.ext;
    var imgSets:Number = Math.ceil(numImgs/10);//max possible number of image sets
    var desc:Array = my_xml.firstChild.childNodes[0].attributes.descriptions.split("|")

    _parent.mySets = imgSets;
        if(imgSets == 1){
        _parent.btnNxt._visible = false;
        }

    _parent.imgNum = "1/"+numImgs;
    _parent.imgHolder.imgAttach.loadMovie("gallery/"+largeprefix+"01"+ext);

    for(var i:Number=0;i<numImgs;i++){

        attachMovie("thumbframe", "thumb"+i, this.getNextHighestDepth(), {_x:(i * 20), _y:51});
        var clip = eval("thumb"+i);

        if(i == 0){clip._x = 39;}
        else{clip._x = 90 * (i)+39;}

        clip._y = 51;


        _parent.txtsimon = imgTitles[0];
        _parent.imgDescr = desc[0];

        eval("thumb"+i).id = i+1;

        if(imgTitles[i] == "" or imgTitles[i] == undefined){
            clip.title = "Untitled Image";
        }
        else{
            clip.title = imgTitles[i];
        }


        eval("thumb"+i).thumbhold.loadMovie("gallery/"+thumbprefix+"0"+eval("thumb"+i).id+ext);

        eval("thumb"+(i)).onRelease = function(){   

            _parent.imgNum = this.id+"/"+numImgs;
            var thumbid:Number = this.id;
            var imgOut:Tween = new Tween(_parent.imgHolder, "_alpha", Regular.easeOut, _parent.imgHolder._alpha, 0, 0.4, true)

            imgOut.onMotionFinished = function(){
                _root.container.imgHolder.imgAttach.unloadMovie();
                _root.container.imgHolder.imgAttach.loadMovie("gallery/"+largeprefix+"0"+thumbid+ext);
                trace("gallery/"+largeprefix+"0"+thumbid+ext);
                new Tween(_root.container.imgHolder, "_alpha", Regular.easeIn, 0, 100, 0.5, true);
            }
            mytitle = this.title;
            _parent.txtsimon = mytitle;
            _parent.imgDescr = this.descr;

            _parent.btnDownloadImg.onRelease = function(){
                getURL("gallery/"+largeprefix+"0"+thumbid+ext);
                }

            new Tween(activeThumb, "_x", Strong.easeOut, activeThumb._x, this._x, 1.5, true);
            }

        clip.onRollOver = function(){
            new Tween(this, "_alpha", Strong.easeOut, this._alpha, 75, 1, true);
            }

        clip.onRollOut = function(){
            new Tween(this, "_alpha", Strong.easeOut, this._alpha, 100, 1, true);
            }
        }

        _parent.btnSlideShow.onRelease = function(){
        new Tween(this._parent.slideOverlay, "_alpha", Strong.easeOut, 0, 100, 3, true);        
        }
}

        _parent.btn_requestHighRes.onRelease = function(){
            var rtitle:String = _parent.txtsimon.toString();
            getURL("mailto:HIDDEN_EMAIL?subject=Toolkit High Res Request - "+rtitle);
            }

I have run a trace on the source of the large image, and it is calling the correct image. I unload the current image and load in the new image, but STILL the old one loads in, like it's cached or something?? The issue seems to be near this code:

_root.container.imgHolder.imgAttach.unloadMovie();
_root.container.imgHolder.imgAttach.loadMovie("gallery/"+largeprefix+"0"+thumbid+ext);
trace("gallery/"+largeprefix+"0"+thumbid+ext);

The above trace shows me that the correct image is being called, but it simply will not load in!

I appreciate all comments greatly as I have sat on this one for ages!

Simon

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨落画卷 2024-10-24 13:46:32

将 AVM1 加载到 AVM2 中(将带有 Actionscript 1.0/2.0 的 SWF 加载到 SWF Actionscript 3.0 中)有一些限制,但我不认为您正在处理其中之一......

无论如何,签出 此链接

希望这会有所帮助。

Loading a AVM1 inside a AVM2 (SWF with Actionscript 1.0/2.0 into SWF Actionscript 3.0) has some restrictions, but I don't think that you are dealing with one of them...

Anyway, checkout this link.

Hopes that will help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文