actionscriptlingo

Swapping information between ActionScript and Lingo


I have a lingo script which runs some data processing for a Flash movie. I can call my Lingo functions from Flash by putting the following inside one of my methods:

getURL("Lingo: myMethod");

and I can pass parameters from flash to lingo as follows:

getURL("Lingo: myMethod param");

However, if myMethod returns a value, I can't seem to send it back to ActionScript. How do I code the following:

var myVar = getURL("Lingo: myMethod");

where myMethod is defined as:

on myMethod
    --do something
    return 5
end myMethod

We are using Flash 9 with CS 3.


Solution

  • You should be able to access Lingo via ExternalInterface assuming you're in Flash 8 or greater:

    import flash.system.ExternalInterface;
    var valueFromLingo = ExternalInterface.call("myMethod");
    trace(valueFromLingo); // -> 5