我需要帮助。我是一名平面设计师,也是jQuery的新手。在AS3中我找到了很好的jQuery脚本 - 如果你点击链接网站它的淡出和新网站淡入。
我在html5页面中使用custom.js
$(document).ready(function() {
$("body").css("display", "none");
$("body").fadeIn(2000);
$("a").click(function(event){
event.preventDefault();
linkLocation = this.href;
$("body").delay(2000).fadeOut(2000, redirectPage);
});
function redirectPage() {
if (location.href.indexOf('reload')==-1) location.replace(location.href+'?reload');
window.location = linkLocation;
}
});
我在Flash中制作3个动画按钮,我在动作脚本3中使用此代码(此效果http://youtu.be/_p6vB6pG2lE)当然我不使用声音;)只有动画。
btn1.addEventListener(MouseEvent.CLICK, onClick);
btn1.addEventListener(MouseEvent.ROLL_OVER, btnOver);
btn1.addEventListener(MouseEvent.ROLL_OUT, btnOut);
btn2.addEventListener(MouseEvent.CLICK, onClick2);
btn2.addEventListener(MouseEvent.ROLL_OVER, btnOver);
btn2.addEventListener(MouseEvent.ROLL_OUT, btnOut);
btn3.addEventListener(MouseEvent.CLICK, onClick3);
btn3.addEventListener(MouseEvent.ROLL_OVER, btnOver);
btn3.addEventListener(MouseEvent.ROLL_OUT, btnOut);
function btnOver(event:MouseEvent){
event.target.gotoAndPlay("over");
}
function btnOut(event:MouseEvent){
event.target.gotoAndPlay("out");
}
function onClick(event:MouseEvent):void {
navigateToURL(new URLRequest("index.html"), "_self");
}
function onClick2(event:MouseEvent):void {
navigateToURL(new URLRequest("portfolio.html"), "_self");
}
function onClick3(event:MouseEvent):void {
navigateToURL(new URLRequest("contact.html"), "_self");
}
所有它的工作非常好但闪存不与jQuery脚本连接,网站也没有淡出。
我通过这种方法http://board.flashkit.com/board/showthread.php?768778-how-to-get-AS3-talking-to-jQuery
测试将flash与jQuery集成function myfadeout(){
// alert("myfadeout is called");
$('#box1').delay(3000).fadeOut(500);
}
Then in the last frame of my flash movie I called the function with actionscript2.0:
import flash.external.ExternalInterface;
stop();
ExternalInterface.call("myfadeout");
但是我的网站在3秒后自动淡出并且没有加载contact.html,例如因为我没有点击我的按钮。
我只需要一个方法来连接AS3和jQuery - 我在flash中点击btn3,我的网站就是fadeout并加载联系。
答案 0 :(得分:1)
我建议从jQuery“myfadeout”函数处理导航,最好只有一个计时功能而不是两个。 您需要将页面URL作为变量传递给“myfadeout”函数,并在淡入淡出完成后处理它。 您的AS3代码看起来应该是这样的:
import flash.external.ExternalInterface;
btn1.addEventListener(MouseEvent.CLICK, onClick);
btn1.addEventListener(MouseEvent.ROLL_OVER, btnOver);
btn1.addEventListener(MouseEvent.ROLL_OUT, btnOut);
btn2.addEventListener(MouseEvent.CLICK, onClick2);
btn2.addEventListener(MouseEvent.ROLL_OVER, btnOver);
btn2.addEventListener(MouseEvent.ROLL_OUT, btnOut);
btn3.addEventListener(MouseEvent.CLICK, onClick3);
btn3.addEventListener(MouseEvent.ROLL_OVER, btnOver);
btn3.addEventListener(MouseEvent.ROLL_OUT, btnOut);
function btnOver(event:MouseEvent){
event.target.gotoAndPlay("over");
}
function btnOut(event:MouseEvent){
event.target.gotoAndPlay("out");
}
function onClick(event:MouseEvent):void {
ExternalInterface.call("myfadeout","index.html");
}
function onClick2(event:MouseEvent):void {
ExternalInterface.call("myfadeout","portfolio.html");
}
function onClick3(event:MouseEvent):void {
ExternalInterface.call("myfadeout","contact.html");
}
你的javascript应该看起来像这样:
<script type="text/javascript">
function myfadein(){
// alert("myfadein is called");
$('body').hide().fadeIn(3000);
}
function myfadeout(newURL){
// alert("myfadeout is called : " + newURL);
$("body").fadeOut(3000,function(){
window.location.href = newURL;
});
}
</script>