Flash to Lectora template book marking
December 2, 2006 12:00 AM
Are you using Flash 8? Because if you are there is a great new way to interface with external "shells", most commonly javascript. And the new feature is called ExternalInterface. Below are the steps for bookmarking anything in Flash using Lectora as a "wrap". This means you can bookmark ANYTHING. So far I have bookmarked video location and course location. Because essentially what Lectora is doing is writing all that crazy "cookie" code for you or if using an LMS it is actually storing that info on an online database, which makes all of our lives that much easier. So let's look at a simple example of bookmarking the frame that the user is on.Create a new variable in Lectora called BookmarkSet it to retain the value between sessions and set the Initial Value to 0Add an External HTML Object onto your title level with the following javascript functions written into it:function setBookmark(bm){ VarBookmark.set(bm);}function getBookmark(){ bm = VarBookmark.getValue(); return bm; }In Flash 8 you have to import the ExternalInterface class with actionscript, this is really easy. Just add import flash.external.*; to the top of your actions, generally below any stop() statements.Then make a call to the javascript functions to either SET the Bookmark variable or GET it. To do this you use the following code (If for example, you were bookmarking the the frame in flash):To set the bookmark type:ExternalInterface.call("setBookmark", _currentframe); //_currentframe can be any variable that you need to storeTo get the bookmark that has been stored in cookies or on the LMS, you need to store the returned value into a flash variable:var FlashBookmark:Number = ExternalInterface.call("getBookmark");Of course then you'll have to write some actionscript in the flash file that looks for the Bookmark variable and send the user to the appropriate location. It might look like this:var FlashBookmark:Number = ExternalInterface.call("getBookmark");gotoAndStop(FlashBookmark);You'll also need to set up your AWT in a certain way as well. You'll need an Initialize Page, Reset Vars Page, and a Main Page. Continue reading for a description of each page.The Initialize Page just gives the LMS a few seconds to see if the user has visited before and if they have it will prompt them, so just add an action that goes to the next page after 2 seconds and also some text that says "Initializing Module..." or something else that seems impressive. When the prompt comes up they can hit OK which should take them to the Main Page and then flash will look for the bookmark variable and set itself to the bookmarked frame, if they hit Cancel then it will just send them to the Reset Vars Page which will reset the bookmark as if they had never visited the module before. The Reset Vars Page resets the Bookmark variable and then goes to the next page. The Main Page contains an action that includes the bookmark variable onto that page and it also contains your swf (animation). Additionally, a comment about the Include VarBookmark action on this page. This action ADDS 0 to the Bookmark variable, which ensures that the variable is written into the header script of the page but doesn't alter the variable. Remember to ADD 0 not SET the variable to 0.You'll also need to double-click the animation object on the Main Page and add a parameter in the parameters tab. This requires Lectora 2005 or greater. Add the following:Parameter Name: allowScriptAccessParameter Value: alwaysAnd now that I've spent way too much time on this post, I will just hope that I've included everything. If anyone can think of a missed step than I leave it up to you to fill in the gaps. Of course if anyone has questions I will try to answer them quickly. I also have a post in the works for the ultimate flash version detection in Lectora. I will make a library object for it too. It will test for a specified version of flash and then do one action if the user has that version or greater and another action if they do not. Laters,MastaShake
Discussions have been disabled for this post