Image load with site load

瘦欲@ 提交于 2020-01-07 02:19:09

问题


Hello I make simple site but I have a little trouble with loading images. As you can see with new category there is new image. There is a problem, beacause only then img is loading, and I want to load all images when my site is loading. sample code how I operate with those img.

imgUrls.push("img/01.jpg");
imgUrls.push("img/02.jpg");
var k3:Boolean=false;

btn1.addEventListener(MouseEvet.CLICK, clickFunc);
function clickFunc(e:MouseEvent):void
if (k3==false)
{
    img1.myUILoader.source = imgUrls[0];
    k3=true;

}else
{
    img2.myUILoader.source = imgUrls[0];
    k3=false;
}

btn2.addEventListener(MouseEvet.CLICK, clickFunc2);
function clickFunc2(e:MouseEvent):void
if (k3==false)
{
    img1.myUILoader.source = imgUrls[1];
    k3=true;

}else
{
    img2.myUILoader.source = imgUrls[1];
    k3=false;
}

So my question is: How can I load all img with site.?


回答1:


Your code currently is telling the program to load the images when either btn1 or btn2 is clicked. You need to tell the program to load the images right away, before user input, then have btn1 and btn2 display them.



来源:https://stackoverflow.com/questions/8701202/image-load-with-site-load

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!