从 actionscript 调用 javascript 函数
我正在尝试从actionscript 调用javascript 函数。
截至目前,我正在使用“ExternalInterface”并且可以取得部分成功。
我可以调用函数(无需任何范围解析),例如“scanDNA()”,该函数对所有人都可见。但我无法像这样调用函数(指定范围) “真核动物.脊索动物.脊椎动物.颌口目.四足动物.哺乳动物.scanDNA()”。
请让我知道,我怎样才能实现这一目标。
感谢和问候,
SachinJadhav。
I am trying to make a call to javascript function from actionscript.
As of now, I am using 'ExternalInterface' and could achieve partial success.
I could make a call to function(without any scope resolution) like "scanDNA()", which is visible to all. But am not able to make a call to function(scope specified) like
"Eukarya.Animalia.Chordata.Vertebrata.Gnathostomata.Tetrapoda.Mammalia.scanDNA()".
Please let me know, how can I achieve this.
Thanks and Regards,
SachinJadhav.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在JS中创建一个方法来调用该函数怎么样?
并使用
ExternalInterface
调用scanDNAinSomeScope
。更新:
是的,在这种情况下,您需要为每个范围创建一个函数。但是,您实际上仅为需要调用的函数创建。我相信在很多情况下您都不需要从 Flash 中调用不同范围的函数。
有一个解决方法,使用 JS 函数,例如:
它可能是一个安全漏洞。但我不是安全专家,所以我无法判断它实际上有什么问题......我只知道“eval isvilly”:P
How about creating a method in JS to call the function?
And call that
scanDNAinSomeScope
usingExternalInterface
.UPDATE:
Yes, in that case you need to create a function for every scope. But, you actually only create for functions that you need to call. I believe there wouldn't be many cases you need to call functions from different scope from Flash.
And there is a workaround, using a JS function like:
It may be a security hole. But I'm not security expert, so I can't tell what problem it actually has... I know "eval is evil" only :P
我从来没有注意到这有什么问题。你的 javascript 作用域结构是如何设置的?
也许在ExternalInterface调用中省略“()”可以解决这个问题。
如果我这样做
并且在flash(CS4)中
我会得到正确的结果。
I have never noticed any problems with this. How is your javascript scope structure set up?
Maybe leaving out the "()" in the ExternalInterface call could do the trick..
If I do
and in flash (CS4)
I get the correct result.
使用 javascript 伪协议效果很好。
Using the javascript pseudo protocol works well.