Insert multiple text strings into single text box

Hello everyone.

I have 50 buttons on the stage. When each button is clicked, I’d like a different sentence inserted into a text box on the stage. When ever another button is clicked, a new sentence is inserted. 50 buttons, 50 sentences.

Could anyone give me some advice about achieving this?

Thanks in advance.

S

This is one possibility, no java script needed:

  • put all sentences in one timeline
  • every button has the “go to time in timeline” -function.
  • change movement to “instant”.

Ilkka

Hi Ilkka,

Thanks so much for your reply. Yes, that is what I will do if I don’t find another solution. It’s just that I’ll end up with a freakishly complicated timeline with 100 layers and 50 transitions etc.

But yes your suggest will work.

Thanks.

S

I'm not sure this will work, but it might be something to try. Make each button's "Unique Element ID" name the same as the sentence you want to enter.

Each button loads a custom JavaScript. That JavaScript changes the innerHTML of the text box to the name of the button clicked. The text box has an ID of "textbox"

Once again, I'm not sure this will work... but I'm thinking the code might look like (or something like) this...

textbox.innerHTML = element.id;

I was so curious to see, if it should be done in hard way, so i made a tiny test.
This took something like 20 minutes to create and it worked for me. I’m not sure if this is what you are looking for, but how i understood it. Sry the crappy design, its just a test.ButtonsAndSentences.hype.zip (27,7 Kt)

Thanks Ilkka,

Unfortunately I could open your file. Got a message that it was a file from a newer version of Hype. I have the most recent version though.

Anyway, I did as you suggested. Was pretty fiddly but worked in the end. I’m sure a couple of lines of JavaScript would have made things simpler.

Thanks.

Hey Michael,

I couldn’t get this to work but thanks for your response.

Simon

It’s such a piece of art and worthy for second try:
ButtonsAndSentences.hype.zip (28,0 Kt)

Hi Simon,

With @ilkka_kumpunen’s permission I am uploading a copy that will work with the latest official release of Hype.

Glad to see you’ve found a solution. This will make it clear what ilkka was saying and available for anyone else that needs it. (Note* it is a template file).

Hope this helps!

D

ButtonsAndSentences.zip (17.9 KB)

1 Like