修补 Flex 框架以立即显示预加载器?
在 Flex 框架中,可以在加载站点时使用自定义预加载器。
在 Adobe 文档 中,它指定 ' 如果在下载 700 毫秒后下载的应用程序少于一半,则会显示进度条 [预加载器]。'
但是我总是希望预加载器立即出现,因为我知道我们 95% 的用户都在第一次访问者,该网站超过 500kb。 我不希望人们必须等待 0.7 秒才能出现预加载动画。
我认为理论上可以通过“猴子修补”框架来消除 0.7 秒的限制。 我没有时间弄清楚如何做,而且我以前从未这样做过。
有人帮忙吗?
In the Flex framework a custom preloader can be used while the site is loading.
In the Adobe docs it specifies that 'the progress bar [preloader] is displayed if less than half of the application is downloaded after 700 milliseconds of downloading.'
However I ALWAYS want the preloader to appear instantly since I know that 95% of our users are first time visitors and the site is over 500kb. I dont want people to have to wait .7 seconds for the preloader animation to appear.
I would think in theory that it is possible to 'monkey patch' the framework to remove this .7 second limitation. I dont have time to figure out how, and I've never done it before.
Anybody help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该只扩展 DownloadProgressBar,尝试以下代码。 我以前用过这个,我找到了杰西·沃登网站 点击这里 usful 获取有关此内容的信息(我在那里找到了它,这是他的代码的精简版本)
}
之后只需更改 main 中的预加载器属性应用程序标记到 Preloader 类。
You should just extend the DownloadProgressBar, try the following code. i've used this before and I've found jesse warden site click here usful for info on this (where I found out about it and this is a cut down version of his code)
}
after that just change the preloader property in the main application tag to the Preloader class.
这是 mx.preloaders::DownloadProgressBar.as 中
showDisplayForDownloading
函数的第 1205 行。老派的猴子补丁已经在 AS3 中消失了,但是您可以编辑 Flex 源代码并自己编译一个新的 Framework.swc(显然很痛苦),或者只是将其包含在源路径中(源路径覆盖 .swcs); 或者从 DownloadProgressBar 派生您自己的预加载器类,该类仅覆盖
showDisplayForDownloading
并返回 true。您可以在“%PROGRAMFILES%\Adobe\Flex Builder 3[ Plug-in]\sdks\3.0.0\frameworks\projects\framework\src”中找到框架源代码,然后是包路径。 如果您使用的是 3.1 或其他版本,请更改 sdk 版本。
This is in mx.preloaders::DownloadProgressBar.as, line 1205 in the
showDisplayForDownloading
function.Old school monkey-patching is out with AS3, but you can either edit the Flex source and compile yourself a new framework.swc (apparently a pain), or just include it in your source path (source paths override .swcs); or derive your own preloader class from DownloadProgressBar that just overrides
showDisplayForDownloading
and returns true.You can find the framework source in '%PROGRAMFILES%\Adobe\Flex Builder 3[ Plug-in]\sdks\3.0.0\frameworks\projects\framework\src', then the package path. Change the sdk version if you are using 3.1, or whatever.
我猜延迟有两个原因:
一旦页面已经存在,就“闪烁”
缓存
load
当我需要绝对确保立即显示预加载器时,我制作一个小型包装器 swf,其中仅预加载器并从那里加载主 swf。
I'd guess that delay is there for two reasons:
"blink" in once the page is already
cached
load
When I need to make absolutely sure a preloader is shown instantly I make a small wrapper swf that has just the preloader and load the main swf from there.
不可能立即显示预加载器,因为在显示进度之前需要下载一些类。 另一种选择是在 html 中显示进度,当加载 Flash 影片时,它会显示在此处。
its not possible to make preloader show instantly , since some classes needs to be downloaded before progress can be displayed . other alternative can be that you display a progress in html and when flash movie is loaded it shows up but here .