首页 文章

使用Jquery为swf文件交换图像

提问于
浏览
0

我有一些缩略图,页面上有一个相机图标和一个主图像,目前你单击缩略图,主图像淡出,缩略图的全尺寸版本淡入 .

现在,如果用户点击相机图标,则完整图像应淡出并且swf视频应淡入,我该如何实现?

这是我用于图像的当前代码:

$('a.thumbnail').click(function(){
    var src = $(this).attr('href');

    if (src != $('img#full_image').attr('src').replace(/\?(.*)/,'')){
        $('img#full_image').stop().animate({
            opacity: '0'
        }, function(){
            $(this).attr('src', src+'?'+Math.floor(Math.random()*(10*100)));
        }).load(function(){
            $(this).stop().animate({
                opacity: '1'
            });
        });
    }
    return false;
});

谢谢

2 回答

  • 0

    对,所以这是我正在使用的代码:

    <script type="text/javascript" language="javascript" src="/jquery/jquery-1.5.1.js"></script> 
    <script type="text/javascript" language="javascript" src="/swfobject/jquery.swfobject.1-1-1.min.js"></script>
    
    <table>
        <tr>
            <td>
                <img id="full_image" src="1.jpg" alt="0" width="360" height="360" border="0" />
                <span id="flash" style="width:360px;height:360px;border:0px;margin:0px;padding:0px;">
                <object data="fireworks.swf" type="application/x-shockwave-flash" id="flash_99458582" width="360" height="360">
                    <param name="movie" value="fireworks.swf">
                    <param name="wmode" value="opaque">
                </object>
                </span>
            </td>
            <td>
                <table>
                    <tr>
                        <td><a href="1.jpg" class="thumbnail"><img src="1.jpg" width="70" height="70"></a></td>
                    </tr>
                    <tr>
                        <td><a href="2.jpg" class="thumbnail"><img src="2.jpg" width="70" height="70"></a></td>
                    </tr>
                    <tr>
                        <td><img src="3.jpg" width="70" height="70" class="video"></td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    
    
    <script type="text/javascript">
    $(document).ready(function() {
        $("#flash").hide();
        $('a.thumbnail').click(function(){
            $("#flash").hide();
            $("img#full_image").show();
            var src = $(this).attr('href');
            if (src != $('img#full_image').attr('src').replace(/\?(.*)/,'')){
                $('img#full_image').attr('src', src+'?'+Math.floor(Math.random()*(10*100)));                
            }
            return false;
        });
    
        $('img.video').click(function(){
            $("img#full_image").hide();
            $("#flash").show();
        });
        return false;
    });
    </script>
    

    这将使大多数人大致开始 . 您可能希望为大型图像或预加载器创建某种加载 .

    此代码只是切换图像/ swf它不是 fadeIn / fadeOut (因为闪存文件) . 当我得到一些时间时,我可能会尝试通过覆盖白色图像来创建效果(我使用的背景为白色)并增加其不透明度等 .

    谢谢

  • 0
    <html>
    <head>
        <script type="text/javascript" language="javascript" src="jquery/jquery-1.5.1.js"></script>
        <script type="text/javascript" language="javascript" src="http://jquery.thewikies.com/swfobject/jquery.swfobject.1-1-1.min.js"></script>
        <style>
            div#test {
                background: #ffffff;
                width: 360px;
                height: 360px;
                display: none;
                z-index: 5;
                position: fixed;
            }
    
            #mainimage {
                z-index: -1;
            }
        </style>
    </head>
    <body>
        <table border="1">
            <tr>
                <td>
                    <div id="test"></div>
                    <div id="mainimage"><img id="full_image" src="1.jpg" alt="0" width="360" height="360" border="0" /></div>
                    <span id="flash" style="width:360px;height:360px;border:0px;margin:0px;padding:0px;z-index:-1;">
                        <object data="fireworks.swf" type="application/x-shockwave-flash" id="flash_99458582" width="360" height="360">
                            <param name="movie" value="fireworks.swf"><param name="wmode" value="opaque">
                        </object>
                    </span>
                </td>
                <td>
                    <table>
                        <tr>
                            <td><a href="1.jpg" class="thumbnail"><img src="1.jpg" width="70" height="70"></a></td>
                        </tr>
                        <tr>
                            <td><a href="2.jpg" class="thumbnail"><img src="2.jpg" width="70" height="70"></a></td>
                        </tr>
                        <tr>
                            <td><img src="3.jpg" width="70" height="70" class="video"></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        

    <script type="text/javascript"> $(document).ready(function () { $("#flash").hide(); $('a.thumbnail').click(function () { var src = $(this).attr('href'); $("#test").fadeIn("slow", function () { //$("#test").fadeOut("slow"); $("#flash").hide(); $("#test").hide(); $("img#full_image").show(); $("img#full_image").css({ opacity: 0 }); //alert(src); if (src != $('img#full_image').attr('src').replace(/\?(.*)/, '')) { $('img#full_image').attr('src', src + '?' + Math.floor(Math.random() * (10 * 100))); } $('img#full_image').stop().animate({ opacity: '1' }, 'slow'); }); //alert("here"); return false; }); $('img.video').click(function () { $("img#full_image").fadeOut("slow", function () { $("#test").show(); $("#flash").show(); $("img#full_image").hide(); $("#test").fadeOut("slow"); }); return false; }); }); </script> </body> </html>

相关问题