views:

27

answers:

1

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  A: 

ActionScript

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

javascript:

function printAlert(grp) {
   return "Received group " + grp;
}
Amarghosh
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);}
palito