On Wed, 12 Oct 2011 06:11:33 +0200, Andrew Shellshear  
<[email protected]> wrote:

> Heya chaps,
>
> I'm writing a game in SVG. There's a (fairly crude) demo at:
> http://www.otherleg.com/games/mapGame_new/mapGame.svg
>
> (use wasd to move around)

Please use event.preventDefault() on the keyevents you handle.

> My intention is that players can login and create their own areas of the
> world. It'd be nice if people don't have to enter their username and
> password every time they go there. It appears, however, that cookie  
> creation
> isn't supported in ECMAScript.

Oh? That should work AFAIK. And if the browser is html5-enabled, then  
document.cookies should work in svg and html documents alike, and you  
should be able to get/set cookies via that interface. See  
https://developer.mozilla.org/en/document.cookie.

> What do people do in this kind of circumstance?
>
> I was thinking perhaps:
> - embed the svg in some html
> - use the html to get login details and set cookies
> - html script starts an svg ecma script on successful login.
>
> However, I'm not sure how the get the last step going.

The last step, see  
http://xn--dahlstrm-t4a.net/svg/html/get-embedded-svg-document-script.html  
for an example (reaches into a referenced svg resource from the  
surrounding html to set the fill color). That shows how to grab the svg  
document (and consequently the contentWindow), so if you combine it with  
something like  
http://stackoverflow.com/questions/251420/invoking-javascript-in-iframe-from-parent-page
  
then you should have all you need to be able to call functions inside the  
svg scripts.

> Alternately, is there anything in ECMAScript/SVG that allows persistence
> across sessions?

You can store some data with HTML5 localStorage and/or sessionStorage.  
Both should be available on the window object, so should work even if svg  
is the main document.

Cheers
-- 
Erik Dahlstrom, Core Technology Developer, Opera Software
Co-Chair, W3C SVG Working Group
Personal blog: http://my.opera.com/macdev_ed


------------------------------------

-----
To unsubscribe send a message to: [email protected]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to