简体   繁体   English

从mxml调用外部javascript函数

[英]call external javascript function from mxml

I am new to flash. 我是新手。 But I have some little bit knowledge about what am I doing. 但是我对自己在做什么有所了解。 I am developing an application in which I need to pass value of clicked button in external js file which I have added in html file. 我正在开发一个应用程序,我需要在html文件中添加的外部js文件中传递clicked按钮的值。 (html files embeded flash src). (将HTML文件嵌入flash src)。

MXML code (function) : MXML代码(功能):

private function sendDTMF(tone:String):void {
        JSLog.debug("Sending DTMF tone "+tone);
        ExternalInterface.call("sendDTMF",tone);
        //connectionManager.sendDTMF(tone);
        JSLog.debug("last Send DTMF tone "+tone);

    }

This function is working but when I call this function and pass argument to function at that time, function give me log in console. 该函数正常工作,但是当我调用该函数并将参数传递给函数时,函数让我登录控制台。 But javascript function hasn't been called from mxml file. 但是尚未从mxml文件中调用javascript函数。

I have added library for external interface and JS function in JS file also. 我还在JS文件中添加了用于外部接口和JS函数的库。

You can call JS function from Flex like this 您可以像这样从Flex调用JS函数

In AS3 在AS3中

if(ExternalInterface.available){
ExternalInterface.call(“openNotes”, parameter);
}

In Javascript 用JavaScript

function openNotes(notesUrl){
window.open(notesUrl, ”, ‘width=1000,height=600′);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM