从flash调用jQuery函数

时间:2013-01-28 15:16:06

标签: javascript jquery actionscript-3 actionscript

我正在尝试从单击按钮时从我的flash文件中调用jQuery函数。 我试图搜索stackoverflow和谷歌类似的问题,但我无法解决这个问题。

仅供参考,我在本地和网上对此进行了测试,没有结果。

Actionscript 3.0调用:

    import flash.external.ExternalInterface;

    open_mc.buttonMode = true;
    open_mc.useHandCursor = true;

    open_mc.addEventListener(MouseEvent.CLICK, ClickFunc);
    function ClickFunc(evt:MouseEvent):void
    {
    ExternalInterface.call("openContainer", "open_god_dammit");
    }


jQuery的:

    $(document).ready(function() {

        $("#eas_sidekick_container").hide();
        $("#eas_sidekick_container").css('width', '0px');

        function openContainer(open_god_dammit)
        {
            $("#eas_sidekick_container").show();
            $("#eas_sidekick_container").animate({
                width: '850px'              
            });
            $('html, body').animate({
                scrollLeft: '850'
            });
        }   
    });

2 个答案:

答案 0 :(得分:1)

我终于找到了问题,这是由于我在html中嵌入flash的方式。

因为我在调用函数时以某种方式使用了swfobject它不能同时工作,所以我移动了我的document.ready call之外的函数,因此它是解决方案的一部分。

因此,如果您想调用外部jQuery函数,请不要使用swfobject将flash嵌入到html文件中。

答案 1 :(得分:0)

你的openContainer函数应该在内部jQuery函数之外:

$(document).ready(function() {

    $("#eas_sidekick_container").hide();
    $("#eas_sidekick_container").css('width', '0px');

});

function openContainer(open_god_dammit)
{
    $("#eas_sidekick_container").show();
    $("#eas_sidekick_container").animate({
        width: '850px'              
    });
    $('html, body').animate({
        scrollLeft: '850'
    });
}   
相关问题