正在加载问题缩略图
我在加载缩略图时遇到问题,我为每个缩略图在舞台上加载设置了一个时间间隔。其中一些无法按顺序加载,它们丢失,滞后......
实际上,我将预加载器设置为文件大小,但由于我从 XML 动态加载,因此文件大小较小。
有谁知道解决该问题的解决方案? 不过,这确实让我很烦恼...
我加载了 XML 文件,并且解析过程没有任何问题。
有时,所有缩略图都可以加载到舞台上,如果带宽有点慢,则表示滞后意味着第一个缩略图正在加载,然后它突然跳过第二个缩略图,而是加载第三个缩略图,依此类推...
有时它可以加载整个缩略图...这很奇怪
,我在这里设置了一个计时器来加载每个缩略图
protected static const INTERVAL_TIME:uint = 1000;
initLoadTime = new Timer(INTERVAL_TIME);
initLoadTime.addEventListener(TimerEvent.TIMER, handleLoadedEachThumbnail, false, 0, true);
initLoadTime.start();
protected function handleLoadedEachThumbnail(event:TimerEvent):void
{
var container:MovieClip = new MovieClip();
if (currentIndex < tabPhoto.length) {
thumbnailPositionMC = positionEachThumbnail();
container.addChild(thumbnailPositionMC);
addChild(container);
currentIndex++;
}
if (currentIndex == tabPhoto.length) {
currentIndex = 0;
initLoadTime.removeEventListener(TimerEvent.TIMER, handleLoadedEachThumbnail);
initLoadTime.stop();
}
}
I'm having issue while loading thumbnail, I set an interval of time for each thumb to load on stage. Some of them can't load sequential in order, they are missing, are lagging...
Actually, I set a preloader to the file size but since I load dynamically from XML, file size is smaller.
Does anyone know a solution to solve that issue?
It's really bug me though...
I load with XML file and don't have any issue with parsing process.
Sometimes all thumbnails can be loaded on Stage, if bandwidth a bit slow it's lagged mean first thumb is loading then it's suddenly skip the second thumbnail, it loads third thumbnail instead and so on...
Sometimes it can load the whole thumbnails... it's weird
Here, I set a timer to load each thumbnail
protected static const INTERVAL_TIME:uint = 1000;
initLoadTime = new Timer(INTERVAL_TIME);
initLoadTime.addEventListener(TimerEvent.TIMER, handleLoadedEachThumbnail, false, 0, true);
initLoadTime.start();
protected function handleLoadedEachThumbnail(event:TimerEvent):void
{
var container:MovieClip = new MovieClip();
if (currentIndex < tabPhoto.length) {
thumbnailPositionMC = positionEachThumbnail();
container.addChild(thumbnailPositionMC);
addChild(container);
currentIndex++;
}
if (currentIndex == tabPhoto.length) {
currentIndex = 0;
initLoadTime.removeEventListener(TimerEvent.TIMER, handleLoadedEachThumbnail);
initLoadTime.stop();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为最好创建一个循环并使用加载器的 Event.COMPLETE 来知道何时加载下一个缩略图,而不是使用间隔。这样你就会避免冲突。
评论后编辑
我修复了 loadThumbComplete 以获取事件参数。为了获取加载的拇指的宽度,我更喜欢从 imageLoader 中获取内容并将其放入 Sprite 中。
I think it would be better to create a loop and use the loader's Event.COMPLETE to know when to load the next thumbnail instead of using an interval. That way you will avoid conflicts.
Edited after comments
I fixed the loadThumbComplete to take the event parameter. To get the width of the loaded thumb I prefer to take the content from the imageLoader and put it in a Sprite.
我已将 tabPhoto 和 tabThumbWidthIncrement 声明为 Vector
I have declared tabPhoto and tabThumbWidthIncrement as Vector