我开发了一个基于Flash的网站,供客户使用GoDaddy帐户并成功将所有文件上传到托管服务器。该站点由名为“preloader.swf”的初始预加载器组成,该初始加载器加载名为“main.swf”的外部SWF文件,该文件包含不同部分,包括图像库部分。预加载器挂起/用“打嗝”冷冻
但是,我注意到有时(并非总是发生这种情况),基于Flash的主站点的初始Flash预加载器的加载速度比平常快于“打嗝”。这导致在必须在站点的图库部分中查看图像(其中每个图像从具有自己的预加载器的服务器的外部加载的图像)时,所选图像以“打嗝”的方式以锯齿状方式加载(例如,来自22%暂停,然后立即跳到31%,然后再次暂停并立即跳到47%,等等)。
然后,在某个时间点,preloader突然冻结/挂起整个网站,别无选择,只能刷新网站。
只有当图像的预加载器冻结并且网站被刷新或缓存被清除后,整个网站才能完美地按照假定的方式工作 - 即最初的预加载器加载得更慢更平滑,并且预加载器当图像加载的时候也更加平滑(百分比没有像以前那样突然跳跃;预加载器以正常增量加载)。
任何人都可以告诉我什么问题可能与一个可能的解决方案,我怎样才能使网站加载顺畅始终没有遇到任何打嗝,冻结和挂,因为我一直在检查我的代码一遍又一遍再次,但我找不到有什么问题呢?
我在做一些研究,并且发现原因可能是因为下面一行“ProgressEvent.PROGRESS”,因为它可能不会在IE或Firefox中有时触发。是这样吗?如果是这样,我该采取什么选择?
希望尽快回复。
谢谢&关心。
P.S.下面我已经包括AS编码我最初的预加载器加载主站点(不用于加载图像预加载):
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
//no scale;
stage.scaleMode = StageScaleMode.NO_SCALE;
//align to top left
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, onPreloaderResize);
addEventListener(Event.ENTER_FRAME, onPreloaderEnter);
angel_pic.alpha = 0;
top_left_line.visible = false;
top_right_line.visible = false;
side_left_line.visible = false;
side_right_line.visible = false;
bottom_left_line.visible = false;
bottom_right_line.visible = false;
var req:URLRequest = new URLRequest("main.swf");
var loader:Loader = new Loader();
loader.load(req);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
function showProgress(event:ProgressEvent):void
{
var percent:Number = Math.round((event.bytesLoaded/event.bytesTotal) * 100);
if ((percent > 0) && (percent <= 34))
{
top_left_line.visible = true;
top_right_line.visible = true;
top_left_line.width = percent * ((angel_pic.width/2)/34);
top_right_line.width = percent * ((angel_pic.width/2)/34);
}
else
{
if ((percent > 34) && (percent <= 66))
{
side_left_line.visible = true;
side_right_line.visible = true;
side_left_line.height = (percent - 34) * (angel_pic.height/32);
side_right_line.height = (percent - 34) * (angel_pic.height/32);
}
else
{
if (percent > 66)
{
bottom_left_line.visible = true;
bottom_right_line.visible = true;
bottom_left_line.width = (percent - 66) * ((angel_pic.width/2)/34);
bottom_right_line.width = (percent - 66) * ((angel_pic.width/2)/34);
}
}
}
}
function loadComplete(event:Event):void
{
var num:int = numChildren;
while (num--)
{
removeChildAt(num);
}
addChild(loader);
}
function onPreloaderResize(event:Event):void
{
var preloaderPadding:Number = (stage.stageWidth/1000) * 35;
angel_pic.x = (stage.stageWidth/2) - (angel_pic.width/2);
angel_pic.y = (stage.stageHeight/2) - (angel_pic.height/2);
angel_pic.width = stage.stageWidth - (preloaderPadding * 2);
angel_pic.height = angel_pic.width/4.9;
top_left_line.x = stage.stageWidth/2;
top_left_line.y = angel_pic.y;
top_right_line.x = stage.stageWidth/2;
top_right_line.y = angel_pic.y;
side_left_line.x = preloaderPadding + side_left_line.width;
side_left_line.y = angel_pic.y;
side_right_line.x = preloaderPadding + angel_pic.width;
side_right_line.y = angel_pic.y;
bottom_left_line.x = preloaderPadding + bottom_left_line.height;
bottom_left_line.y = angel_pic.y + angel_pic.height;
bottom_right_line.x = preloaderPadding + angel_pic.width;
bottom_right_line.y = angel_pic.y + angel_pic.height;
}
function onPreloaderEnter(event:Event):void
{
var preloaderPadding:Number = (stage.stageWidth/1000) * 35;
angel_pic.x = (stage.stageWidth/2) - (angel_pic.width/2);
angel_pic.y = (stage.stageHeight/2) - (angel_pic.height/2);
angel_pic.width = stage.stageWidth - (preloaderPadding * 2);
angel_pic.height = angel_pic.width/4.9;
top_left_line.x = stage.stageWidth/2;
top_left_line.y = angel_pic.y;
top_right_line.x = stage.stageWidth/2;
top_right_line.y = angel_pic.y;
side_left_line.x = preloaderPadding + side_left_line.width;
side_left_line.y = angel_pic.y;
side_right_line.x = preloaderPadding + angel_pic.width;
side_right_line.y = angel_pic.y;
bottom_left_line.x = preloaderPadding + bottom_left_line.height;
bottom_left_line.y = angel_pic.y + angel_pic.height;
bottom_right_line.x = preloaderPadding + angel_pic.width;
bottom_right_line.y = angel_pic.y + angel_pic.height;
}
我对我的网站执行了gzip测试,结果Apache服务器没有启用gzip压缩。我是否应该放置.htaccess文件,或者问题可能是其他问题? – JPF 2011-05-25 11:58:18
不是,那么它是别的 – 2011-05-25 12:00:49
正如测试告诉我“这个页面不是gzip”,我没有把你的.htaccess文件,你告诉我。如果不是gzip压缩问题,那么有什么想法可以解决问题? – JPF 2011-05-25 12:14:16