1

我正在制作我的第一个 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;
    }
4

1 回答 1

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

}
于 2012-12-01T20:40:30.720 回答