0

自从我开始调试我的代码以使其工作以来,已经有 2 天了,而且它正在占用我所有的时间,如果我不开始询问,我认为我不会达到我的最后期限。

我不是专业人士,所以请对代码保持温和。:D

图库运行良好,可以顺利加载缩略图而不会返回任何错误。但是,缩略图没有按预期加载,我认为是因为最小的文件大小首先加载。因此,如果 thumbnail[3] 是最小的,它将自己附加到 thumbnail_container[0] ,它应该始终是 thumbnail[0] 到 thumbnail_container[0] 等等。

这是我的代码:

        //THIS IS THE CONTAINER         
        for (var i:int = 0; i < thumbBatches[aj]; i++)
        {
            thumbX = 44.35 + (thumbWidth + 18) * i;
            var itemThumb:thumbH = new thumbH();
            itemThumb.x = thumbX;
            itemThumb.y = thumbY;
            itemThumb.name = "" + i + (8 * aj);
            itemThumb.addEventListener(MouseEvent.CLICK, openFullItem);
            level2.addChild(itemThumb);
            IthumbList[i + (8 * aj)] = itemThumb;
        }

        //THIS WILL LOAD THE THUMBNAILS
        for (var n:int = 0; n < potteryIDnum.length; n++)
        {
            var imgLoader:Loader = new Loader();
            imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
            imgLoader.load(new URLRequest(potteryThumbs[n]));
        }

        // AFTER LOADING IT, IT'LL BE ASSIGNED TO AN ARRAY
       // THEN AFTER THE LAST IMAGE HAS BEEN LOADED WILL BE ATTACHED TO THE CONTAINER
        function loadComplete(e:Event):void
        {
            IthumbImages.push(e.target.content);
            if (IthumbList.length == IthumbImages.length)
            {
                for (var k:int = 0; k < IthumbImages.length; k++)
                {
                    var fadeInThumbs:Tween = new Tween(IthumbList[k],"alpha",Strong.easeInOut,0,1,0.3 * (k + 0.5),true);
                    IthumbList[k].addChild(IthumbImages[k]);
                }
            }
        }

提前致谢!

4

2 回答 2

0

我认为你的问题在于这条线。

 IthumbList[i + (8 * aj)] = itemThumb;

什么是aj
如果 aj == 1 且 i == 1 则数组的索引将为 9
如果 aj == 2 且 i == 1 则数组的索引将为 16

因此,您的 oncomplete 中的 for 循环应该会失败。

于 2012-04-13T21:05:38.013 回答
0

我已经回答了类似的问题。然而,那是关于URLLoader课堂的。

对于Loader类 case ,它应该是:

    dynamic class DynamicLoader extends Loader{}

最后,修改后的代码:

    var remainingLoads:uint = potteryIDnum.length; 
    //THIS WILL LOAD THE THUMBNAILS
    for (var n:int = 0; n < potteryIDnum.length; n++)
    {
        var imgLoader:DynamicLoader = new DynamicLoader();
        imgLoader.index = n;
        imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
        imgLoader.load(new URLRequest(potteryThumbs[n]));
    }

    // AFTER LOADING IT, IT'LL BE ASSIGNED TO AN ARRAY
    // THEN AFTER THE LAST IMAGE HAS BEEN LOADED WILL BE ATTACHED TO THE CONTAINER
    function loadComplete(e:Event):void
    {
        IthumbImages[ DynamicLoader(e.target.loader).index ] = e.target.content;
        if (--remainingLoads == 0)
        {
            for (var k:int = 0; k < IthumbImages.length; k++)
            {
                var fadeInThumbs:Tween = new Tween(IthumbList[k],"alpha",Strong.easeInOut,0,1,0.3 * (k + 0.5),true);
                IthumbList[k].addChild(IthumbImages[k]);
            }
        }
    }
于 2012-04-14T13:05:36.427 回答