在行动script3链接按钮+淡出jQuery的整合按钮、行动、链接、jQuery

2023-09-08 14:26:21 作者:哎呀卧槽

我需要帮助。我是一名平面设计师,我新来的jQuery。在AS3中我找到很多不错的jQuery脚本 - 如果你点击链接的网站它的淡出和新的网站淡入

I need help. I'm a graphic designer and i new to jQuery. In AS3 i find nice jQuery script - if you click to link the website its fade out and new site fade in.

我使用HTML5页面custom.js

I use custom.js in html5 page

$(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按钮和我的动作脚本使用code 3(这个效果 HTTP:/ /youtu.be/_p6vB6pG2lE )Ofcourse我不使用声;)仅用于动画

And I make 3 animated buttons in Flash and I use this code in Action Script 3 (this effect http://youtu.be/_p6vB6pG2lE) Ofcourse I don't use sound ;) Only animation.

  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脚本连接与本站不淡出。

And all it's working very nice but flash doesn't connect with jQuery script and site doesn't fadeout.

我通过测试这种方法的http://board.flashkit.com/board/showthread.php?768778-how-to-get-AS3-talking-to-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例如,因为我不点击我的按钮。

But my site fadeout automatic after 3 seconds and doesn't load contact.html for example because I don't click my button.

我只需要一种方法来与jQuery连接AS3 - 我点击btn3闪光灯和我的网站它的淡出和负载接触

I only need a method to connect AS3 with jQuery - I click btn3 in flash and my site it's fadeout and load contact.

推荐答案

我建议从你的jQuerymyfadeout功能处理导航,最好是只有一个计时功能比有两个。 你需要通过网页的网址为myfadeout功能作为一个变量,它的后完全淡出处理。 您的AS3 code应该看起来财产以后是这样的:

I suggest to handle the navigation from your jQuery "myfadeout" function , it is better to have only one timing function than having two. You need to pass the page url to "myfadeout" function as a variable and handle it after your fade complete. your AS3 code should looks somthing like this :

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应该看起来财产以后是这样的:

and your javascript should looks somthing like this:

<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>