Javascript to Flash
The following description was my solution to creating a search feature for a cdrom application which is based on HTML pages navigated with a Flash interface. It is an ugly solution and I’m looking for a better one. SearchMakerPro creates a huge HTML page that is very slow to load, depending on what type of computer and browser is used. On IE the search works … OK … but it grinds to a halt on Mozilla. That’s on a PC.
“The Search mechanism is a web page that contains javascript functions and a large array of terms. The functions are called when the user clicks the search button which causes a search through the terms and dynamically creates and opens an html page that displays the results. SearchMaker Pro 3.0 was used to index the CDROM’s Objective pages which resulted in this html page.
The javascript was modified so that an onClick handler was added to the linked results, which passed the result URL to a Javascript function located in the “leftFrame” html page (this page hold the navigation bar Flash object). This function, called “searchResultToFlash(myURL)” accepts the URL as a string in the form of (example):
section2/module14/objective6.htm
The function uses this string to determine the integer values for section, module and objective. It then uses a javascript-to-flash method to set these variables in the Flash nav bar.
myFlashObject.SetVariable(“externalSectionNumber”, mySectionNumber);
myFlashObject.SetVariable(“externalModuleNumber”, myModuleNumber);
myFlashObject.SetVariable(“externalObjectiveNumber”, myObjectiveNumber);
There is no method at this time for directly invoking a function within Flash from Javascript, but there is a way to advane the playhead. The Nav bar stops on frame 3 at startup, but if it is moved to frame 4, it will make this function call:
setNavBarFromExternal(externalSectionNumber, externalModuleNumber, externalObjectiveNumber);
and then return to Frame 3. This will cause the nav bar to update to the appropriate content, and update itself:
myFlashObject.GotoFrame(3);
Note that from javascript, frame 1 is 0. So to reach frame 4, we send the value 3.”
