我有一个 Flash 介绍,我希望<body>
在介绍完成后立即加载。我怎样才能做到这一点?
我不想在动画完成后重定向到新的 URL,我希望它在同一页面上。
我可以使用 jquery 代码捕获的 actionscript3 返回一个变量,还是 jQuery 本身可以检测动画何时完成?
1) Flash intro: bad practice, especially as so many users are now surfing with devices that either don't come with Flash, or have disabled Flash entirely. Flash also completely destroys search engine results. #1 recommendation: learn how to do animation in HTML5/CSS3, if you absolutely must, but intro screens are incredibly harmful to usability in general. The only real excuse for using them is to provide some sort of feedback to users if you're trying to front-load assets (image sprites for a game, or data for a dashboard, for example).
2) You can't load Flash before the <body>
of a page. It just doesn't work. However, given that, you could put together a structure like this:
<body>
<div id="flashObj"><!-- object for Flash --></div>
<div id="mainContent"><!-- rest of your page --></div>
</body>
Then you could call a javascript function from the end of your Flash animation (see http://www.kirupa.com/flash/calling_javascript_flash_using_as3.htm for a tutorial) using the ExternalInterface object, but note that there are several browsers that still have issues with that object, so your cross-platform usability goes even further down.
Essentially, in your html, you would have:
<style>
#mainContent { display:none; }
</style>
<script type="text/javascript">
function startMainContent(){
var flash = document.getElementById("flashObj");
var main = document.getElementById("mainContent");
if(flash && main){
flash.style.display == "none";
main.style.display == "block";
}
}
</script>
Then in your ActionScript, after your animation completes, you would add something like:
ExternalInterface.call("startMainContent()");
Assuming ExternalInterface is working correctly, and you've followed Adobe's documentation for setting the proper flags in your <object />
tag to enable access to Javascript from your Flash object, that should do the trick.
See this for an official Adobe guide to ExternalInterface: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf626ae-7fe8.html#WS2db454920e96a9e51e63e3d11c0bf69084-7f31
嘿,伙计,我在以愚蠢的方式回答这个问题时嘲笑我,但你可以这样做。你知道你的介绍播放了多少秒吗?如果是,请执行以下操作:假设您的介绍为 10 秒:
$(document).ready( function() {
$("INTRO_DIV").delay(10000).hide();
$("body").delay(10500).fadeIn();
});
我增加了 500 毫秒,以便您的介绍可以正确完成。