【问题标题】:Flash Builder 4.5 Mobile App ... Scroller and Preloaded ImagesFlash Builder 4.5 移动应用程序...滚动器和预加载图像
【发布时间】:2011-10-26 15:42:25
【问题描述】:

我的滚动条组件中有一些图像...滚动滚动条时有时会挂起一秒钟...我认为图像正在加载...是否可以在滚动条就位之前加载图像? !....

【问题讨论】:

  • 当您说“Scroller”时,您是指 List 组件吗?还是别的什么?
  • 我想他的代码看起来像<s:Scroller><s:Image source="someImage"/></s:Scroller>。您的图像是嵌入的还是链接到路径?
  • 一些代码:<s:Scroller id="snapper" x="0" y="0" width="100%" height="100%"> <s:HGroup gap="0" width="100%" height="100%"> <s:Image width="{snapper.width}" height="100%" source="1314004166_768x1024_elegant-scenery-iphone-5-wallpaper.jpg"/> .... // more Images </s:HGroup> </s:Scroller>

标签: apache-flex image mobile air preload


【解决方案1】:

尝试加载每个图像,然后将它们添加到滚动条。您可以使用 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);
    }
}

【讨论】:

  • 好的...但是如果手机内存不足怎么办...是否有从内存中删除该图像的功能?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-22
  • 2011-12-24
相关资源
最近更新 更多