Flash Builder 4.5移动应用程序…滚动和预加载图像



我得到了一些图像在我的滚动组件…而滚动滚动条有时挂一秒钟…我想图像正在加载…是否有可能在滚动轮上的位置之前加载图像?!....

尝试加载每个图像,然后将它们添加到滚动条。您可以使用Multiloader库(http://code.google.com/p/multiloader/)来了解所有图像何时已加载。

例如:

var multiloader:MultiLoader();
function loadImages():void
{
   multiLoader = new MultiLoader();
   multiLoader.addTask("image1.jpg", "img1", MultiLoader.MOVIE);
   multiLoader.addTask("image2.jpg", "img2", MultiLoader.MOVIE);
   multiLoader.addTask("image3.jpg", "img3", MultiLoader.MOVIE);
   multiLoader.addTask("image4.jpg", "img4", MultiLoader.MOVIE);
   multiLoader.addEventListener(Event.COMPLETE, onComplete);
   multiLoader.start();
}
function onComplete(e:Event):void
{
    var image:Image;
    for (var i:uint=0;i<4;i++)
    {
        image = new Image();
        image.percentHeight = 100;
        image.width = snapper.width;
        image.source = multiloader.getItemLoader(i);
        snapper.addElement(image);
    }
}

最新更新