在 Flash as3.0 中从 XML 加载缩略图时出现问题

发布于 2024-10-02 07:56:34 字数 10927 浏览 3 评论 0原文

我制作了一个画廊脚本,可以从 xml 加载大图像、文本和 3 个缩略图。 由于某种原因,我无法加载缩略图。 我的三个缩略图应该是上一张图像、当前图像和下一张图像。除非您单击当前图像,否则它应该加载随机图像。这些按钮适用于此,但如果我尝试加载缩略图。他们没有出现。

为了加载缩略图,我为缩略图数组创建了一个 for 循环,并且图像的数量由变量 noOfImage 记录。 1 添加到 noOfImage

然后,如果单击上一个按钮(鼠标滚轮向下或按键 dwn 或向左键),则通过将 1 减去 noOfImage 来加载其他缩略图,如果单击下一个按钮(滚轮和按键...),则将 缩略图编号的变量是它们有时似乎是正确的,有时我收到错误。

对于前。 如果我加载 swf 并单击下一步。上一个图像是“4294967295”,下一个图像是 1,但它输出“Error #2044: Unhandled IOErrorEvent:.text=Error #2035: URL Not Found”。

如果 nextImage 的值 = 1 那么我不明白为什么它没有加载。为什么应该是 0 却给出了一个奇怪的数字?我无法判断问题是否出在我用来处理 noOfImage 变量的 if 语句上,或者是否与加载器或缩略图容器有关......我一直在尝试我能想到的一切。我的原始版本用 for 循环加载了所有拇指并且可以工作,但我在将它们制作成可点击按钮时遇到了麻烦,并决定使其更简单。

这是我对脚本的了解程度的示例。 http://soulseekrecords.org/psysci/portfolio/Portfolio.swf

下面是我的全部内容代码如果混乱或不清楚,抱歉。我尽力了。

//import tweening files
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import fl.controls.UIScrollBar;
import flash.display.Sprite;
import com.greensock.plugins.*;
TweenPlugin.activate([TintPlugin]);

//create sprite background
var backgrnd:Sprite = new Sprite();

//create array of image names
var imageNames:Array = new Array();

//create array of text descriptions
var descText:Array = new Array();

//create array for dice images
var dinames:Array = new Array();

//variable for total number of images
var totalImages:uint = imageNames.length;

//add sprite variables
var thumb:Sprite = new Sprite();
var thumb2:Sprite = new Sprite();
var thumb3:Sprite = new Sprite();

// create loaders
var smImageLoader:Loader = new Loader();
var smImageLoader2:Loader = new Loader();
var smImageLoader3:Loader = new Loader();

//create a variable to load the large image
var bigImageLoader:Loader = new Loader();

//create variables for the image #
var noOfImage:int;
var prevImage:uint;
var nextImage:uint;

//create random number var
var randomNumber:uint;

prevImage = 0;
nextImage = totalImages;

noOfImage = -1;

// add sprite to display list
addChild(thumb);
addChild(thumb2);
addChild(thumb3);
thumb.graphics.beginFill(0xFFFFFF);
thumb.graphics.drawRect(25, 325, 75, 75);
thumb.graphics.endFill();
thumb2.graphics.beginFill(0xFFFFFF);
thumb2.graphics.drawRect(125, 325, 75, 75);
thumb2.graphics.endFill();
thumb3.graphics.beginFill(0xFFFFFF);
thumb3.graphics.drawRect(225, 325, 75, 75);
thumb3.graphics.endFill();
thumb.alpha = 1;
thumb2.alpha = 1;
thumb3.alpha = 1;
thumb.addChild(smImageLoader2);
thumb2.addChild(smImageLoader3);
thumb3.addChild(smImageLoader);
smImageLoader.y = 325;
smImageLoader2.y = 325;
smImageLoader3.y = 325;
smImageLoader.x = 25;
smImageLoader2.x = 125;
smImageLoader3.x = 225;

//Scroll Variables
var scrollBarAdd:Boolean = false;
var scrollBar:UIScrollBar = new UIScrollBar();

var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("portfolio.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event)
{
    myXML = new XML (e.target.data);
    for(var i:uint = 0; i < myXML.img.length() ; i++)
    {
        imageNames.push(myXML.img[i].text());
        descText.push(myXML.txt[i].text()); 
        dinames.push(myXML.imgd[i].text());
    }
    totalImages = imageNames.length;
}

//add background color sprite
addChild(backgrnd);
setChildIndex(backgrnd,0);

//add background properties
backgrnd.graphics.beginFill(0xFFFFFF);
backgrnd.graphics.drawRect(0, 0, 900, 500);

//add background image
var backrobe:Loader = new Loader();
addChild(backrobe);
backrobe.x = 0;
backrobe.y = 0;
backrobe.load(new URLRequest("images/background.png"));

//add bigImageLoader to the display list
addChild(bigImageLoader);
bigImageLoader.x = 225;
bigImageLoader.y = 25;

//add buttons fwd and rev
var forward:fwd = new fwd();
var reverse:rev = new rev();
addChild(forward);
addChild(reverse);
forward.x = 155;
forward.y = 365;
reverse.x = 33;
reverse.y = 365;

forward.addEventListener(MouseEvent.MOUSE_OVER, mseovr);
reverse.addEventListener(MouseEvent.MOUSE_OVER, mseovr2);
forward.addEventListener(MouseEvent.MOUSE_OUT, mseout);
reverse.addEventListener(MouseEvent.MOUSE_OUT, mseout2);
function mseovr (event:MouseEvent){
    TweenLite.to(forward, .1, {alpha:.5});
}
function mseovr2 (event:MouseEvent) {
    TweenLite.to(reverse, .1, {alpha:.5});
}
function mseout (event:MouseEvent){
    TweenLite.to(forward, .1, {alpha:1});
}
function mseout2 (event:MouseEvent) {
    TweenLite.to(reverse, .1, {alpha:1});
}

//Variable Key Press Function
var rkey:uint = 39;
var lkey:uint = 37;
var ukey:uint = 38;
var dkey:uint = 40;

//create a textField
var myText:TextField = new TextField();

//add text box to display list
addChild(myText);
myText.width = 200;
myText.height = 340;
myText.x = 5;
myText.y = 5;
myText.wordWrap = true;
myText.multiline = true;
myText.selectable = true;

var format:TextFormat = new TextFormat();
            format.font = "Arial";
            format.color = 0xFFFFFF;
            format.size = 20;
            format.underline = false;
            myText.defaultTextFormat = format;

//add button
var hotSpot:hotspot = new hotspot();

//add button to display list
addChild(hotSpot);

//Set button x and y position
hotSpot.x = 92;
hotSpot.y = 367;
hotSpot.alpha = 0;
hotSpot.width = 50;
hotSpot.height = 50;

//set buttonmode
hotSpot.buttonMode = true;

//make sure all clicks register with the thumb itself (not inner contents)
hotSpot.mouseChildren = false;

//add click listener to the button
hotSpot.addEventListener(MouseEvent.MOUSE_DOWN, buttonClickHandler);
hotSpot.addEventListener(MouseEvent.MOUSE_OVER, mouseoverhotspot);
hotSpot.addEventListener(MouseEvent.MOUSE_OUT, mouseouthotspot);

function mouseoverhotspot(event:MouseEvent){
TweenLite.to(hotSpot, .1, {alpha:.5});
}
function mouseouthotspot(event:MouseEvent){
TweenLite.to(hotSpot, 1, {alpha:0});
}

function buttonClickHandler (event:MouseEvent) 
    {
        randomNumber = Math.random()*3;
        noOfImage = randomNumber;
        loadersnlist();

    }

stage.addEventListener(MouseEvent.MOUSE_WHEEL, upmouse);

function upmouse(event:MouseEvent) 
    {
        if (event.delta == 3)
        {
            noOfImage = noOfImage + 1;
                if (noOfImage == totalImages)
                    {
                        noOfImage = noOfImage - totalImages;
                    }

        }
            if (event.delta == -3)
                {

                    if (noOfImage == -1 || noOfImage == -2)
                        {
                        noOfImage = totalImages;
                        }
                            if (noOfImage == 0)
                                {
                                    noOfImage = noOfImage + totalImages;
                                }
            noOfImage = noOfImage - 1;
                }
        loadersnlist();

    }

forward.addEventListener(MouseEvent.CLICK, fwdclck);
    function fwdclck (event:MouseEvent)
    {
        noOfImage = noOfImage + 1;
        if (noOfImage == totalImages)
            {
            noOfImage = noOfImage - totalImages;
            }
        loadersnlist();
    }

reverse.addEventListener(MouseEvent.CLICK, revclck);

function revclck(event:MouseEvent) 
    {
        if (noOfImage == -1 || noOfImage == -2)
            {
            noOfImage = totalImages;
            }
        if (noOfImage == 0)
            {
            noOfImage = noOfImage + totalImages;
            }
        noOfImage = noOfImage - 1;
        loadersnlist();
    }

//Key Right Arrow Event
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyright);

function keyright(event:KeyboardEvent)
{

    if (event.keyCode==rkey || event.keyCode==ukey) 
        {
            noOfImage = noOfImage + 1;
            if (noOfImage == totalImages)
                {
                noOfImage = noOfImage - totalImages;
                }
            loadersnlist();
        }
}

//Key Left Arrow Event
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyleft);

function keyleft(event:KeyboardEvent){

    if (event.keyCode==lkey || event.keyCode==dkey) 
        {
            if (noOfImage == -1 || noOfImage == -2)
                {
                noOfImage = totalImages;
                }
    if (noOfImage == 0)
        {
        noOfImage = noOfImage + totalImages;
        }
        noOfImage = noOfImage - 1;
        loadersnlist();
        }
}

function scrollerthing ()
    {
        if (myText.textHeight > myText.height)
        {
            scrollBar.scrollTarget = myText;  //assign the target of the scrollBar to your textfield
            scrollBar.height = myText.height;  //make the height the same as the textfield
            scrollBar.move(myText.x + myText.width, myText.y);  //Move the scrollbar to the righthand side
            addChild(scrollBar);
            scrollBar.update();
            scrollBarAdd = true;
        } else 
        { 

            if((myText.textHeight < myText.height) && scrollBarAdd == true)
                {
                    scrollBarAdd = false;
                    removeChild(scrollBar);
                }
        }
    }

function loadersnlist () 
    {
        bigImageLoader.load(new URLRequest("images/" + imageNames[noOfImage] ) );
        bigImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, tweenage);
        smImageLoader.load(new URLRequest("thumbs/" + dinames[noOfImage] ) );
        smImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, tweenage2);
        prevImage = noOfImage - 1;
        nextImage = noOfImage + 1;
        if (prevImage <= -1){
            prevImage = totalImages;
        }
        if (nextImage >= totalImages){
            nextImage = 0;
        }
        trace (prevImage);
        trace (nextImage);
        smImageLoader2.load(new URLRequest("thumbs/" + dinames[prevImage] ) );
        smImageLoader2.contentLoaderInfo.addEventListener(Event.COMPLETE, tweenage2);
        smImageLoader3.load(new URLRequest("thumbs/" + dinames[nextImage] ) );
        smImageLoader3.contentLoaderInfo.addEventListener(Event.COMPLETE, tweenage2);
    }

function tweenage(e:Event)
    {
        bigImageLoader.alpha = 0;
        TweenLite.to( bigImageLoader, 5, {alpha:1, ease:Expo.easeOut} );
        myText.alpha = 0;
        TweenLite.to( myText, 5, {alpha:1} );
        myText.text = String (descText[noOfImage]);
        scrollerthing();
    }

function tweenage2 (e:Event)
    {        
        //create a variable to load small thumbnail url image        
        TweenLite.to( smImageLoader, 5, {scaleX:.6, scaleY:.6, ease:Expo.easeOut} );
        TweenLite.to( smImageLoader2, 5, {scaleX:.6, scaleY:.6, ease:Expo.easeOut} );
        TweenLite.to( smImageLoader3, 5, {scaleX:.6, scaleY:.6, ease:Expo.easeOut} );
    }

I have made a gallery script that loads from xml a large image, text, and 3 thumbnails.
I am having trouble getting the thumbnails to load for some reason.
I have it so that the three thumbnails should be the previous image, the current image, and the next image. Except when you click on the current image it should load a random image. The buttons work for this but if I try to load thumbnails. They don't appear.

To load the thumbnails I have created a for loop for the array of thumbnails and the number of the image is recorded by the variable noOfImage.
I then load the other thumbnails by subtracting 1 to noOfImage if the prev button is clicked(mousewheel down or key dwn or key left) and adding 1 to noOfImage if the next button is clicked(wheel and keys...)

When I trace what the variables for the thumbnail number is they seem to be correct at times and other times I am receiving errors.

For ex.
If I load the swf and click next. The previous image is "4294967295" and the next is 1 but it outputs this "Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found."

If the value of nextImage = 1 then I dont see why it isn't loading. And why is it giving a weird number for what should be 0? I can not tell if the problem is with the if statements I use to handle the noOfImage variables or if it has something to do with the loaders or thumbnail containers... I keep trying everything I can think of. my original version loaded all the thumbs with a for loop and worked but I was having trouble making them into clickable buttons and decided to make it simpler.

here is an example of how far i've gotten with the script.
http://soulseekrecords.org/psysci/portfolio/Portfolio.swf

below is all my code sorry if it is messy or unclear. I try my best.

//import tweening files
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import fl.controls.UIScrollBar;
import flash.display.Sprite;
import com.greensock.plugins.*;
TweenPlugin.activate([TintPlugin]);

//create sprite background
var backgrnd:Sprite = new Sprite();

//create array of image names
var imageNames:Array = new Array();

//create array of text descriptions
var descText:Array = new Array();

//create array for dice images
var dinames:Array = new Array();

//variable for total number of images
var totalImages:uint = imageNames.length;

//add sprite variables
var thumb:Sprite = new Sprite();
var thumb2:Sprite = new Sprite();
var thumb3:Sprite = new Sprite();

// create loaders
var smImageLoader:Loader = new Loader();
var smImageLoader2:Loader = new Loader();
var smImageLoader3:Loader = new Loader();

//create a variable to load the large image
var bigImageLoader:Loader = new Loader();

//create variables for the image #
var noOfImage:int;
var prevImage:uint;
var nextImage:uint;

//create random number var
var randomNumber:uint;

prevImage = 0;
nextImage = totalImages;

noOfImage = -1;

// add sprite to display list
addChild(thumb);
addChild(thumb2);
addChild(thumb3);
thumb.graphics.beginFill(0xFFFFFF);
thumb.graphics.drawRect(25, 325, 75, 75);
thumb.graphics.endFill();
thumb2.graphics.beginFill(0xFFFFFF);
thumb2.graphics.drawRect(125, 325, 75, 75);
thumb2.graphics.endFill();
thumb3.graphics.beginFill(0xFFFFFF);
thumb3.graphics.drawRect(225, 325, 75, 75);
thumb3.graphics.endFill();
thumb.alpha = 1;
thumb2.alpha = 1;
thumb3.alpha = 1;
thumb.addChild(smImageLoader2);
thumb2.addChild(smImageLoader3);
thumb3.addChild(smImageLoader);
smImageLoader.y = 325;
smImageLoader2.y = 325;
smImageLoader3.y = 325;
smImageLoader.x = 25;
smImageLoader2.x = 125;
smImageLoader3.x = 225;

//Scroll Variables
var scrollBarAdd:Boolean = false;
var scrollBar:UIScrollBar = new UIScrollBar();

var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("portfolio.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(e:Event)
{
    myXML = new XML (e.target.data);
    for(var i:uint = 0; i < myXML.img.length() ; i++)
    {
        imageNames.push(myXML.img[i].text());
        descText.push(myXML.txt[i].text()); 
        dinames.push(myXML.imgd[i].text());
    }
    totalImages = imageNames.length;
}

//add background color sprite
addChild(backgrnd);
setChildIndex(backgrnd,0);

//add background properties
backgrnd.graphics.beginFill(0xFFFFFF);
backgrnd.graphics.drawRect(0, 0, 900, 500);

//add background image
var backrobe:Loader = new Loader();
addChild(backrobe);
backrobe.x = 0;
backrobe.y = 0;
backrobe.load(new URLRequest("images/background.png"));

//add bigImageLoader to the display list
addChild(bigImageLoader);
bigImageLoader.x = 225;
bigImageLoader.y = 25;

//add buttons fwd and rev
var forward:fwd = new fwd();
var reverse:rev = new rev();
addChild(forward);
addChild(reverse);
forward.x = 155;
forward.y = 365;
reverse.x = 33;
reverse.y = 365;

forward.addEventListener(MouseEvent.MOUSE_OVER, mseovr);
reverse.addEventListener(MouseEvent.MOUSE_OVER, mseovr2);
forward.addEventListener(MouseEvent.MOUSE_OUT, mseout);
reverse.addEventListener(MouseEvent.MOUSE_OUT, mseout2);
function mseovr (event:MouseEvent){
    TweenLite.to(forward, .1, {alpha:.5});
}
function mseovr2 (event:MouseEvent) {
    TweenLite.to(reverse, .1, {alpha:.5});
}
function mseout (event:MouseEvent){
    TweenLite.to(forward, .1, {alpha:1});
}
function mseout2 (event:MouseEvent) {
    TweenLite.to(reverse, .1, {alpha:1});
}

//Variable Key Press Function
var rkey:uint = 39;
var lkey:uint = 37;
var ukey:uint = 38;
var dkey:uint = 40;

//create a textField
var myText:TextField = new TextField();

//add text box to display list
addChild(myText);
myText.width = 200;
myText.height = 340;
myText.x = 5;
myText.y = 5;
myText.wordWrap = true;
myText.multiline = true;
myText.selectable = true;

var format:TextFormat = new TextFormat();
            format.font = "Arial";
            format.color = 0xFFFFFF;
            format.size = 20;
            format.underline = false;
            myText.defaultTextFormat = format;

//add button
var hotSpot:hotspot = new hotspot();

//add button to display list
addChild(hotSpot);

//Set button x and y position
hotSpot.x = 92;
hotSpot.y = 367;
hotSpot.alpha = 0;
hotSpot.width = 50;
hotSpot.height = 50;

//set buttonmode
hotSpot.buttonMode = true;

//make sure all clicks register with the thumb itself (not inner contents)
hotSpot.mouseChildren = false;

//add click listener to the button
hotSpot.addEventListener(MouseEvent.MOUSE_DOWN, buttonClickHandler);
hotSpot.addEventListener(MouseEvent.MOUSE_OVER, mouseoverhotspot);
hotSpot.addEventListener(MouseEvent.MOUSE_OUT, mouseouthotspot);

function mouseoverhotspot(event:MouseEvent){
TweenLite.to(hotSpot, .1, {alpha:.5});
}
function mouseouthotspot(event:MouseEvent){
TweenLite.to(hotSpot, 1, {alpha:0});
}

function buttonClickHandler (event:MouseEvent) 
    {
        randomNumber = Math.random()*3;
        noOfImage = randomNumber;
        loadersnlist();

    }

stage.addEventListener(MouseEvent.MOUSE_WHEEL, upmouse);

function upmouse(event:MouseEvent) 
    {
        if (event.delta == 3)
        {
            noOfImage = noOfImage + 1;
                if (noOfImage == totalImages)
                    {
                        noOfImage = noOfImage - totalImages;
                    }

        }
            if (event.delta == -3)
                {

                    if (noOfImage == -1 || noOfImage == -2)
                        {
                        noOfImage = totalImages;
                        }
                            if (noOfImage == 0)
                                {
                                    noOfImage = noOfImage + totalImages;
                                }
            noOfImage = noOfImage - 1;
                }
        loadersnlist();

    }

forward.addEventListener(MouseEvent.CLICK, fwdclck);
    function fwdclck (event:MouseEvent)
    {
        noOfImage = noOfImage + 1;
        if (noOfImage == totalImages)
            {
            noOfImage = noOfImage - totalImages;
            }
        loadersnlist();
    }

reverse.addEventListener(MouseEvent.CLICK, revclck);

function revclck(event:MouseEvent) 
    {
        if (noOfImage == -1 || noOfImage == -2)
            {
            noOfImage = totalImages;
            }
        if (noOfImage == 0)
            {
            noOfImage = noOfImage + totalImages;
            }
        noOfImage = noOfImage - 1;
        loadersnlist();
    }

//Key Right Arrow Event
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyright);

function keyright(event:KeyboardEvent)
{

    if (event.keyCode==rkey || event.keyCode==ukey) 
        {
            noOfImage = noOfImage + 1;
            if (noOfImage == totalImages)
                {
                noOfImage = noOfImage - totalImages;
                }
            loadersnlist();
        }
}

//Key Left Arrow Event
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyleft);

function keyleft(event:KeyboardEvent){

    if (event.keyCode==lkey || event.keyCode==dkey) 
        {
            if (noOfImage == -1 || noOfImage == -2)
                {
                noOfImage = totalImages;
                }
    if (noOfImage == 0)
        {
        noOfImage = noOfImage + totalImages;
        }
        noOfImage = noOfImage - 1;
        loadersnlist();
        }
}

function scrollerthing ()
    {
        if (myText.textHeight > myText.height)
        {
            scrollBar.scrollTarget = myText;  //assign the target of the scrollBar to your textfield
            scrollBar.height = myText.height;  //make the height the same as the textfield
            scrollBar.move(myText.x + myText.width, myText.y);  //Move the scrollbar to the righthand side
            addChild(scrollBar);
            scrollBar.update();
            scrollBarAdd = true;
        } else 
        { 

            if((myText.textHeight < myText.height) && scrollBarAdd == true)
                {
                    scrollBarAdd = false;
                    removeChild(scrollBar);
                }
        }
    }

function loadersnlist () 
    {
        bigImageLoader.load(new URLRequest("images/" + imageNames[noOfImage] ) );
        bigImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, tweenage);
        smImageLoader.load(new URLRequest("thumbs/" + dinames[noOfImage] ) );
        smImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, tweenage2);
        prevImage = noOfImage - 1;
        nextImage = noOfImage + 1;
        if (prevImage <= -1){
            prevImage = totalImages;
        }
        if (nextImage >= totalImages){
            nextImage = 0;
        }
        trace (prevImage);
        trace (nextImage);
        smImageLoader2.load(new URLRequest("thumbs/" + dinames[prevImage] ) );
        smImageLoader2.contentLoaderInfo.addEventListener(Event.COMPLETE, tweenage2);
        smImageLoader3.load(new URLRequest("thumbs/" + dinames[nextImage] ) );
        smImageLoader3.contentLoaderInfo.addEventListener(Event.COMPLETE, tweenage2);
    }

function tweenage(e:Event)
    {
        bigImageLoader.alpha = 0;
        TweenLite.to( bigImageLoader, 5, {alpha:1, ease:Expo.easeOut} );
        myText.alpha = 0;
        TweenLite.to( myText, 5, {alpha:1} );
        myText.text = String (descText[noOfImage]);
        scrollerthing();
    }

function tweenage2 (e:Event)
    {        
        //create a variable to load small thumbnail url image        
        TweenLite.to( smImageLoader, 5, {scaleX:.6, scaleY:.6, ease:Expo.easeOut} );
        TweenLite.to( smImageLoader2, 5, {scaleX:.6, scaleY:.6, ease:Expo.easeOut} );
        TweenLite.to( smImageLoader3, 5, {scaleX:.6, scaleY:.6, ease:Expo.easeOut} );
    }

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

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

发布评论

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

评论(1

素食主义者 2024-10-09 07:56:35

您已经快要找出缩略图值了。我的下一步是找出您尝试加载的实际网址。

这样做将显示您实际引用的内容。看起来您正在跟踪 prevImage,并在它小于 1 时将其设置为图像数量。不过,缩略图数组是从零开始的,因此对于 3 个缩略图,缩略图位于 0、1 和 2,并且您正在尝试加载 dinames[3]。

将 loadersnlist 函数更改为
prevImage =totalImages-1; 应该修复它。

顺便说一句,我建议将所有资产创建代码放在布局函数中,然后将所有内容添加到舞台后调用加载器函数来提取数据。

You're nearly there in tracing out the thumbnail value. My next step would be to trace out the actual url that you are trying to load.

Doing this will show what you are actually referencing. It looks like you are tracking the prevImage, and setting it to the number of images when it is less than 1. The array of thumbnails is zero-based though, so with 3 thumbnails, the thumbs are at 0, 1, and 2 and you are trying to load dinames[3].

Changing the loadersnlist function to
prevImage = totalImages-1; should fix it.

As an aside, I'd suggest placing all your asset creation code in a layout function, and then once everything has been added to the stage then calling you loader functions to pull in the data.

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