我正在制作我的第一张Flash照相馆,当我点击缩略图时,它应该以完整尺寸打开照片,并以百分比显示预照片。它在闪存下载模拟器上都是脱机工作但在线上的百分比不会显示。它有时开始出现在100%左右或者根本没出现。 图库链接:http://solarratko.netii.net/ 下面是我班上的一些加载全尺寸图像的代码
public function kreni(f:String) //function that start when user click on thumbnail
{
URLrequest=new URLRequest(f); //URLrequest for image in full size
dspLoader.load(URLrequest); //loading the image
preloader.visible = true;//prelaoder that shows up is visible
h.visible=true;//text area for percentage is visible
dspLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progres);//adding progress event
dspLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, kraj);//adding complete event
}
public function progres(e:Event):void
{
var perc:Number = e.target.bytesLoaded / e.target.bytesTotal;//calculatin percentage
h.text = Math.ceil(perc*100).toString();//displaying percentage wich is not working online or it start too late
}
public function kraj(e:Event):void
{
h.text="";
preloader.visible = false;
h.visible=false;
}
答案 0 :(得分:0)
似乎对我来说工作正常。你清理了缓存了吗?预加载器是否未显示且未加载图像?
如果要强制预加载器运行,可以为加载序列分配一个计时器,以检查加载的内容。加载时启动计时器并确保百分比等于或大于您在计时器回调中检查时所显示的百分比 - 使用进程回调来获取加载的字节数。所以定时器可以是.5秒,如果图像在缓存中,你会在图像加载之前看到一个快速预加载器。
*编辑*
public function kreni(f:String) //function that start when user click on thumbnail {
preloader.visible = true;//prelaoder that shows up is visible
h.visible=true;//text area for percentage is visible
URLrequest=new URLRequest(f); //URLrequest for image in full size
dspLoader.load(URLrequest); //loading the image
dspLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progres);//adding progress event
dspLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, kraj);//adding complete event
}