Is there a way to make an iBooks widget Not reload when closing/opening book?

Hi

storing something in localStorage is as simple as

localStorage.stars = “some value”;

You do not need the “var” before it as it is already globally accessible. (It’s built in to most browsers)

You would use it something like this.

to set it -> localStorage.stars = “gold”;

to get it (and use in Hype) -> hypeDocument.showSceneNamed(localStorage.stars, kSceneTransitionCrossfade, 1.1);

Here something that may help you understand a bit better. The above method is a shorthand way of getting and setting localStorage

http://www.w3schools.com/html/html5_webstorage.asp

2 Likes

So would storing the, for me, right value in localStorage.stars be as simple as writing:
localStorage.stars = “1”;
in scene one (named 1),
localStorage.stars = “2”;
in scene 2, and so on.

Or is that too simple? :slight_smile:

I’ve been trying to get the hypeDocument.showSceneNamed()-code working for a while now with no luck.
I have tried both
hypeDocument.showSceneNamed(4)
and
hypeDocument.showSceneNamed(localStorage.stars, kSceneTransitionCrossfade, 1.1);
having declared localStorage.stars = “4”;
But my widget doesn’t want to jump to my fourth scene (which is named “4”). Or isn’t it enough to name the scene?

Time to go to bed, I’ll continue after work tomorrow, thanks for all the pointers so far! It’s getting a lot clearer! :slight_smile:

1 Like

Haha! I made it! :smiley:

I thought it would involve a lot more code, but it turned out very clean :slight_smile:

Thanks again for the pointers!

"I love it when a plan comes together."