Type the answer and go to the next scene


#1

Hello !
I’m trying to use hype for digital comics and stories, and I wanted that the reader should answer a riddle to continue the story.

I’m not a programmer so I find bits of code and paste them as I can.

I found this :

    <script language="JavaScript">
function passe() {
var mot=document.form1.passew.value
if (mot=="toto") { window.location="toto.htm"; }
else{
if(mot=="toto2"){window.location="toto2.htm"; }
else {alert("Mauvais mot de passe");
}
}	
}
</script>
<form name="form1">
	<input type="text" id="passew" name="passew" style="font-size: 30px; border-style: none; background-color: lightyellow; color: black; padding: 5px;" size="9" fontsize:30px="">&nbsp;&nbsp;
	<input type="button" value="Entrer" onclick="passe()">
</form> 

I first putted it in a widget, but it did not work, then I have put it in a rectangle and it did !

But when I have tried to replace

window.location=“toto.htm”;
by
hypeDocument.showNextScene(hypeDocument.kSceneTransitionCrossfade, 1.1);

I didn’ work again…

I have also tried puting the javascript function in the functions of skype and calling it from a button (that would be my best choice) but again, it didn’t work…

I guess I should change

var mot=document.form1.passew.value

by getelementbyid but I wasn’t able to porperly do it…

Can someone help me ?


#2

(also I’m french, please pardon my not so great english)


(strmiska) #3

you can use this, i.e.:

 var check = hypeDocument.getElementById("input1").value;
 var hinweis = hypeDocument.getSymbolInstanceById('hinweis');



if (check == "SOLUTION"){

hinweis.startTimelineNamed('timelineName', hypeDocument.kDirectionForward);

hypeDocument.showSceneNamed(sceneName, optionalTransition, optionalDuration);

} else {

hinweis.startTimelineNamed('timelineName', hypeDocument.kDirectionForward);

hypeDocument.showSceneNamed(sceneName, optionalTransition, optionalDuration);


}

(Mark Hunte) #4

Hi,

There is a simpler way to do it in Hype.

Do as you have done and put the form in a Rectangle element’s innerHTML . But do not put the submit input in.
Instead add a normal Hype button and set it’s click Action to run this Hype Function code.

var mot= hypeDocument.getElementById('passew').value


     switch (mot) {
      case 'toto':
      hypeDocument.showSceneNamed('s1', hypeDocument.kSceneTransitionCrossfade, 1.1) 
        break;
      case 'toto2':
      hypeDocument.showSceneNamed('s2', hypeDocument.kSceneTransitionCrossfade, 1.1)
        break;
      
      default:
      
        alert("Mauvais mot de passe")
    }

Example.

Form_Value_Switch.hype.zip (22.9 KB)


#5

Thank you very much !!!

I tested Markhunte suggestion and it works well :slight_smile: