0

I want to pass the result of a js function into actionscript when the js function is called from actionscript. The js parses a url and returns the var in the url. In actionscript the functions are declared:

function gup(name1:String) :void {
flash.external.ExternalInterface.call("gup", name1);

}

function printAlert(group2:String) :void {
flash.external.ExternalInterface.call("printAlert", group2);

} 

then later in actions I call gup() which should return the var which I turn around and print as an alert to check what value is there. "group" is the name of the var I want to get out of the url to use for branching in the swf. If I just define whichGroup the alert works fine. trying to get the return value of the js function the alert value is null

var whichGroup = gup("group");

printAlert(whichGroup);
1
  • Are printAlert and gup functions defined in the javascript? Your functions doesn't seem to handle the return value of js functions at all Commented Sep 1, 2010 at 4:12

1 Answer 1

1

ActionScript

function printAlert(group2:String):void {
    var retValue:String = ExternalInterface.call("printAlert", group2);
    trace(retValue);
} 

javascript:

function printAlert(grp) {
   return "Received group " + grp;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I got it working with something very similar. function printAlert(group:String) :void { flash.external.ExternalInterface.call("printAlert", group); } Using var retData:String = ExternalInterface.call("gup","group"); in later frame javascriptfunction gup is a function that has a regular expression to get the vars out of a url printAlert(group){ alert("grouppa=" + group); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.