[Xerte] Re: Setting Focus on the SWF

Deborah Delin admin at strivney.com
Thu Jul 21 06:45:07 BST 2011


Well thanks to everyone for trying to help!

The reason I am trying to avoid the "Click here to start" workaround is that
my viewers are English language learners who can't read yet so they won't
understand the instruction.

Dave, I tried adding the SWF in a component but Xerte didn't like that at
all. (Maybe I didn't do it right - I put the file location of the SWF in the
component directly in the RLO?).

Paul, thanks for those links.  There is a lot about it on the internet but
most of the fixes were beyond my ability/understanding.

This one that you sent seems quite simple:


import flash.external.ExternalInterface;
ExternalInterface.call("s = function() {
document.getElementById('mymovie').focus(); }");



where 'mymovie' is ID of embedded swf object in html script.


I added the script to the SWF but I'm not sure about the ID.  Do I put the
name of the swf, without the .swf extension in place of mymovie?  If that is
correct then I tried it and it didn't work.


Another suggests putting the following script in the containing HTML page.
 I am displaying the Xerte in Moodle.  I tried adding the code to the page
via the Moodle interface and the Moodle editor just deleted it.  I haven't
got a clue how to locate that page via FTP.  Also this script is
Actionscript in a Java tag - can I put that in an HTML page?


I hoped to make variations of this game, which is rather cute for the level
I am aiming at, so I would love to resolve this.


Thanks again,


Deborah


<script language="javascript">

    if (navigator.appName.indexOf("Microsoft") != -1)
    {
        document.attachEvent("onkeydown", ieKeyHandler);
        window.attachEvent("onkeydown", ieKeyHandler);

        function ieKeyHandler(event)
        {
                sendToFlash(event.keyCode);
        }
    }
    else
    {
        document.onkeydown = function(e)
        {
                sendToFlash(e.keyCode);
        }
    }

    function sendToFlash(s)
    {
        var flashCtl = thisMovie("yourFlashObjectID");
        flashCtl.callIntoFlashFromJavascript(s);
    }

    function thisMovie(movieName)
    {
        if (navigator.appName.indexOf("Microsoft") != -1)
        {
                return window[movieName];
        }
        else
        {
                return document[movieName];
        }
    }

</script>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nottingham.ac.uk/pipermail/xerte/attachments/20110721/96c3e082/attachment-0001.html>


More information about the Xerte mailing list