Passing a variable from a JS function back to Hype


#1

Hello.

I’m very new to Hype, as a matter of fact I’m still using the Trial version. I want to see if it’s suitable for my needs and I’m just testing it out. I’m also looking at xCode and Livecode.

I was wondering how I can pass a variable from a JavaScript function back to be used in Hype. It seems like a simple concept but I haven’t figured it out.

Here is my function for speech recognition:-

var recognition = new webkitSpeechRecognition();
recognition.onresult = function(event) {
var interim_transcript = ‘’;
var words = ’ ';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
words = (event.results[i][0].transcript);
}
}
}
recognition.start();

In Chrome, this creates the variable words which I’d like to use within the context of Hype’s main environment (i.e the timeline and scenes and so forth).

For example, how could I take the variable words and put it into a Text element within a scene so that the Text element now displays the variable?

Thankyou!


#2

Not to worry!

I’ve just found the answer myself:-

hypeDocument.getElementById(‘mytextbox’).innerHTML = words;


(Jonathan Deutsch) #3

Glad you figured it out!