有没有一种方法调用从ExternalInterface的一个Javascript类的方法?方法、ExternalInterface、Javascript

2023-09-09 21:27:21 作者:心似狂潮

我可以调用JS函数 ExternalInterface.call('的​​func_name'。参数)。确定

I can call JS functions with ExternalInterface.call('func_name',.args). OK

但是,如果我想调用一个JS类实例的方法呢?

But what if I would like to call a js class instance method instead?

ExternalInterface.call('obj.method_name',.args) //this seems not to work

有没有办法做这件事的?

Is there any way of doing it?

推荐答案

这是范围只是迟早的问题。你必须实例化的JS类的外部SWF对象。然后,我可以参考它在 ExternalInterface.call()

It was only a matter of scope. You must instantiated the swf object outside the js class. Then I can reference it in ExternalInterface.call().

window.addEvent('domready',function(){

    swf = new Swiff('../files/swf/italy.swf',{
        id:'italy',
        container:'italy-flash',
        width:280,
        height:323,
        params:{
            bgcolor:'#ffffff',
            wmode:'opaque',
            allowScriptAccess:'always'
        }
    });

    rm = new RelessersManager('regions');

});

现在从SWF我可以调用 RM 的方法。 :) (电话('rm.method_name',...... PARAMS)) previously,我建在 RM 瑞士法郎,所以没有办法引用 RM 从SWF。

Now from the swf I can call the rm methods. :) (.call('rm.method_name',...params)) Previously, I built the swf inside rm, so there was no way to reference rm from the swf.