Javascript/Lingo wrapper

From Director Online Wiki
Jump to: navigation, search

There are some functions in Lingo that I simply can't find the Javascript equivilent for (like 'the platform' to determine the Operating System your application is running on). In these cases, it's often handy to have a global Lingo function that returns results back to Javascript. Here is the recipe:

1) Create a Lingo global method like so:


on evalLingo sCode
   -- This opens the legacy Lingo interpreter
   -- to be invoked by Javascript and returns
   -- the results to Javascript.
   return do(sCode)
end

2) Now you can use the generic lingo function from Javascript. The following displays the platform information in an alert box when the movie starts (coded in Javascript):


function startMovie(){
   result = evalLingo("return the platform");
   _player.alert(result);
}