我希望简单地将JavaScript变量值传递给AS2。
的JavaScript
var myNewText = 'new variable value created';
var myNewLink = 'www.stackoverflow.com';
如何在AS2中获取vars值?
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!");
}
答案 0 :(得分:0)
function myNewText() {
return "Click to Goto - StackOverFlow.Com";
}
function myNewLink(){
return "http://www.stackoverflow.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);
}