我可以创建一个包含flash文件和静态图像的javascript轮播吗?

时间:2011-07-11 12:01:10

标签: javascript flash carousel

我想知道是否可以在当前只包含停滞图像的javascript轮播中包含swf。我要做的是在旋转木马中包含一个flash动画。

我想我有两个主要问题:

  • 是否可以像处理图像一样循环浏览Flash文件?
  • 我如何让javascript和flash进行交互,以便flash文件知道它什么时候被选中?

如果有帮助,这是我们正在使用的js:

$(document).ready(function(){

    var $looper = true;
    var timer;
    var currentSlide = 0;
    var cell = 0;
    var row = 1;

    var hCycles = 0;
    var aCycles = 0;

    //no. of full cycles
    var homecycles = 2;
    var aboutcycles = 2;

    //aboutSlide speed
    var fast = 1200;
    var slow = 4000;

    //hide homepage slides
    $('#slide2').fadeOut(0);
    $('#slide3').fadeOut(0);
    $('#slide4').fadeOut(0);
    $('#slide5').fadeOut(0);
    $('#slide6').fadeOut(0);    

    //hide about slides
    $('.a-slide1').fadeOut(0);
    $('.a-slide2').fadeOut(0);
    $('.a-slide3').fadeOut(0);
    $('.a-slide4').fadeOut(0);
    $('#slide-c1 .a-slide1').fadeIn(1200);

    runSlide(fast);

    function runSlide(x) {
        if ($('body').is('.about')) {
            setTimeout(function() {
                    aboutSlides();
                }, x);
            } else {
            if ($looper) {
                setTimeout(function() {
                    slideShow();    
                }, 4000);
            }
        }       

    }

    function slideShow() {
        if ($looper) {
            if (currentSlide++ < 6 && hCycles < homecycles) {
                $('#slide'+ currentSlide).fadeOut(1200);
                if (currentSlide == 6) {
                    $('#slide1').fadeIn(1200);
                    $('#slide-wrapper li').removeClass('active');
                    $('#btn1').addClass('active');
                    currentSlide = 0;
                    hCycles = hCycles+1;
                } else {
                    $('#slide'+ (currentSlide+1)).fadeIn(1200);
                    $('#slide-wrapper li').removeClass('active');
                    $('#btn'+ (currentSlide+1)).addClass('active');
                }
                runSlide();
            } else {
                $looper = false;
            }
        }
    };

    $('#slide-wrapper li').each(function(index) {
        $('#btn'+(index+1)).click(function(){
            $looper = false;
            $('.slide').fadeOut(1200);
            $('#slide'+ (index+1)).fadeIn(1200);
            $('#slide-wrapper li').removeClass('active');
            $(this).addClass('active');
        });
    });


    function aboutSlides() {
            if (cell++ < 3 && aCycles < aboutcycles) {
                if (cell == 3) {
                    if (row < 3) {
                        row = row+1;    
                    } else {
                        row = 1;
                        aCycles = aCycles+1;
                    }
                    var hide = (row-1);
                    if ((row-1) == 0) {hide = 3}
                    $('#slide-c1 .a-slide'+ hide).fadeOut(1200);
                    $('#slide-c1 .a-slide'+row).fadeIn(1200);
                    cell = 0;
                        runSlide(fast);
                } else {
                    $('#slide-c'+(cell+1)+' .a-slide'+ (row-1)).fadeOut(1200);
                    $('#slide-c'+(cell+1)+' .a-slide'+(row)).fadeIn(1200);
                    if (cell == 2) {
                        runSlide(slow);
                    } else {
                        runSlide(fast);
                    }
                }
            } else {
                // create the final strip
                $('#slide-c3 .a-slide3').fadeOut(1200);
                $('#slide-c3 .a-slide4').fadeIn(1200);  
            }
        }

});

谢谢!

1 个答案:

答案 0 :(得分:0)

对于要放入幻灯片的任何内容,没有任何问题。只要它是有效的html,它在幻灯片中有效。无数的jquery / motools / etc插件让你可以为内容指定任何你想要的东西。 闪光灯有效。
但是你可能想要恢复另一种揭示方法。根据浏览器和flash版本,根据javascript在swf上设置不透明度很复杂并产生不同的结果。如果您的Flash文件是自定义的,那么您可以创建一个将其淡化为白色的功能,并从javascript调用它。但根据经验,改变瑞士法郎的不透明度是一件麻烦事 我不知道这是否足以成为一个答案,我想将其作为评论发布,但没有任何评论按钮。哦,好吧。