AS2 - 获取 javascript 变量值

AS2 - Get javascript variable value

我想简单地获取 JavaScript 变量值到 AS2。

JavaScript

var myNewText = 'new variable value created';
var myNewLink = 'www.whosebug.com';

如何像这样在 AS2 中获取变量值?

myText.text = myNewText;
myText.onRelease = function() {
   getURL(myNewLink);
}

为了调用一个函数,我使用了这样的函数:

// AS2  code   
myText.onRelease = function() {
      ExternalInterface.call("my_function()");
   }

//JS function
function my_function() {
   alert("This function is called from ActionScript!");
}

经过大量谷歌搜索后,我找到了它,而且效果很好:)

在 JS 中

 function myNewText() {
        return "Click to Goto - whosebug.com";
    }
function myNewLink(){
return "http://www.whosebug.com";
}

在 AS2 中

myText.onSelfEvent = function (){
    import flash.external.ExternalInterface;
    var ytext:String;
    ytext = String(ExternalInterface.call("myNewText"));
    tstate.text = ytext;
}
myText.onpress = function (){
//    import flash.external.ExternalInterface;
    var yurl:String;
    yurl = String(ExternalInterface.call("myNewLink"));
getURL(yurl);
}