palito
palito

Reputation: 1

Flash CS4 pass variable from javascript function to actionscript and back

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);

Upvotes: 0

Views: 978

Answers (1)

Amarghosh
Amarghosh

Reputation: 59451

ActionScript

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

javascript:

function printAlert(grp) {
   return "Received group " + grp;
}

Upvotes: 1

Related Questions