Scene Unload, variable unload


#1

Hello everyone, i´m having a hard time understanding how to resolve a problem with my code. I think the problem is when the scene unloads, i have to do something when my code and i was hopping someone could help me. When the scene loads the first time, everything works great, i have a button event and when the user clicks on it the pictures fadeToggle. But if the user navigates to another scene and then returns, the pictures appear and fade quickly, and that´s not the behavior i´m expecting, below is my code:

function clickGaleria(hypeDocument, element, event
{	
	    $("#appCoolpark").css('display','none');
	    $("#appStructures").css('display','none');
	    $("#websiteHotelLeiria").css('display','none');
	    $("#appEco").css('display','none');	
	   
              var i = 0;   
		 
               var stuff =["websiteCoolpark","appCoolpark","appStructures","websiteHotelLeiria","appEco"];
        
		$("#iconNextRight").click(function()
		{
                       i = (i+1)%stuff.length;  
                      if(i>0)
                      {
                         $(hypeDocument.getElementById((stuff[i-1]))).fadeOut();
                         $(hypeDocument.getElementById((stuff[i]))).fadeToggle();
                      }
                     else
                     {
           	       $(hypeDocument.getElementById("appEco")).fadeOut();
           	       $(hypeDocument.getElementById("websiteCoolpark")).fadeIn();	  
                     }
	    });		
}

Pls help, i´m stuck!!!.


(Mark Hunte) #2

Hi, can you post the project


(Mark Hunte) #3

It seems to work here…?

imageToggleFade.hypetemplate.zip (56.5 KB)


(Mark Hunte) #4

I suspect that your problem is you have this code running on your first scene unload but then on another onload or unload. Which in my test give the behaviour you are describing


#5

Hi, i just need help with this part of the project, the rest is irrelevant, do you know whats wrong with my code?

João santo


#6

I’m using this code on the 4 scene of my project. In this scene i have a button and the code is inside: “onsceneload”, i chose run JavaScript function and i put the this code inside.

João santo


(Mark Hunte) #7

Hi,

It works in mine thats why it would help if you posted because you might have some thing set up that is different to mine.