Somebody can share with me a little example in Javascript?


(Giovanni) #1

I want store a value in a scene and then collect that value to use it in a second moment (in an other scene, for example). How I can do it?

Thanks


(Mark Hunte) #2

There is already many examples on the site but really more information of what sort of storage is needed helps either point you to it or give you an example.

By this I mean is the stored value usage:

•Within one session volatile storage, so not there after closing the browser or navigating away from your page and the returning

•multiple sessions. persistant storage so there after closing the browser or navigating away from your page and the returning

• where is this value coming from and where is it going to be used.
•Type of value.

•What do you mean by stage.
Hype scenes in one project or scenes in more than one project on a page.

Can you provide an example project of what you are trying to set up.
And any other info that can help us help you


(Loves Hype) #3

Anything you store in hypeDocument.customData is accessible in any scene. So do something like this hypeDocument.customData.myValue = “hello”;

Hope this help

PS: built in volatile solution. Can be made persistent using an extensions or some direct JavaScript.


(Giovanni) #4

You’re right, I should write what kind of project I’d like to do.
In fact, I plan to do two very small tests to see if I can then develop them and create something bigger. Of course I don’t have a great experience with Javascript but some examples of this kind would help me to start something that I would then see done, even if in an elementary way.

  1. Game book
    I’d like to tell a story where the player can collect items. These objects would be numerical values that need to be preserved for future use. So I’d need a code that records a value that can be compared with other values.
    The best would be to record the variables on the server so that the player can resume the game immediately afterwards, but since it might be difficult to get, I think I could just figure out how to store the values and compare them with each other;

  2. A password protected presentation
    I would like to create a password-protected presentation. Here, too, I think you should use and maintain values

I’m sorry, my English is not good, I’m helping myself with a translator. I hope you understand what I’m asking.

Thank you