Stop the animation from playing when you come back to a page


#1

Hi. Is it possible for animation to just play once per viewing? Meaning that when you come back to a page already seen your animation dont play again?


#2

Sure. Do a search and you’ll find your answers :wink:


#3

Doesn’t help very much. Where should I search? And english is not my first language.


#4

You asked a question and I answered it :wink: Use the button above and type in what you want to search for.

By the way, your question is a little vague. If you can be more specific and maybe not ask a question that only requires a yes or no answer then I or someone else could probably be a bit more helpful. Also, what language would you like to converse in. Español, Francais, Deutsch, Cymraeg?

when you come back to a page

Do you mean page as in web page? or scene within the Hype document.

Do you need it to only play once and then never again or just for the current session?

As Hype can use Javascript then you can store a variable after the animation has played once and then store this variable in the browser for the session only (until the user closes the browser) [localStorage] or indefinitely (as a cookie with a finite expiry).

The localStorage way:

//The following should be stored in a New Function... and executed as a timeline action at the end of the animation.
localStorage.visited = "true";

then at the beginning of the same animation you can check against the variable and play depending on the result.

if (!localStorage.visited) {
    hypeDocument.startTimelineNamed('YOUR_TIMELINE');
} else {
    hypeDocument.pauseTimelineNamed('YOUR_TIMELINE');
}

You can also change this to control scenes and not timelines.

If you tell us more then we can be more specific with answers.

Helpful enough?

P.S a document that you are working on would be helpful. If you can’t make it public then PM would be the way to go.


#5

Hi. This is going to finish as an app for the ipad. I mean in a scene in an Hype document. The tool I’m developing is a digital sales aid. When the client has seen the animation once He doesn’t want to see it anymore. They want to be able to get the numbers and the facts. So I need the animations in scene to play only once and when they will come back to that scene it is going to be at the end of the scene where all the info will be viewable. Am I clearer?


#6

sorry but what do you mean in your ps by PM?


#7

Can you share what you have so far?

You would use @dbear’s technique above, but jump to a specific time if the ‘visits’ variable is true. You can find Tumult Hype’s JavaScript documentation here: http://tumult.com/hype/documentation/3.0/#javascript

The key thing you would want to do is this: hypeDocument.goToTimeInTimelineNamed(timeInSeconds, 'timelineName')


#8

http://fusioncd.ca/flexadin_final_duncan/Flexadin%20Final%20Duncan_2.html


#9

I can’t get your .hype document from that, and I’m going to need more information about where you’re already using the code that @dbear mentioned above

(Drag your .zip file into this forum – don’t reply via email please because it includes your entire email footer)


#10

Here it is


#11

Can you drag and drop a Zip file when you login to this thread at this URL?


#13

I¹ve tried twice now. Can I send my file somewhere else?


#14


#16

I Œm not getting the result you are getting. When I put my document over the
reply window I get uploading () and then it disappears without loading


#21

Got your file, @marts - Here’s what you can add to the first scene to skip it if it has already been opened once:

var LS = localStorage.getItem('visited');
if (LS == "Yes") {
  hypeDocument.showNextScene(hypeDocument.kSceneTransitionInstant)
} else {
  //
}

localStorage.setItem('visited', 'Yes');

#22

Can I have code that is going to stop everyscene from playing again or do I have to add this code in every scene?


#23

Hello Bernard. And where do I put these line of code?


#24

Here’s updated code, with comments which explains how it works:

// get the value of (SceneNameVisited)
	
var LS = localStorage.getItem(hypeDocument.currentSceneName() + 'visited');

// if the value has been already set to Yes, that means that the lines below have already been 
// executed and this scene has been viewed. 

if (LS == "Yes") {


   // if this scene has been visited, go to 4 seconds into the Main Timeline of the current scene. 
   hypeDocument.goToTimeInTimelineNamed(4, 'Main Timeline')


} else {
  //
}

localStorage.setItem(hypeDocument.currentSceneName() + 'visited', 'Yes'); 

Here’s your file: http://cl.ly/3b180M1H0j1n

Sorry, but your reply reminds me of:


#25

In what way please???


#26

Your questions have become more and more unclear. Can you let me know what you’re asking?

If you want to skip the first 4 seconds of each scene on the 2nd load, then the script I wrote above is what you want. Otherwise, you’ll need to modify it, or make multiple versions.

If you download this file and open it in Hype, you’ll see that it loads an ‘On Scene Load’ function for your 1st and 2nd scene as an example.