Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Setting up WebSockets in Animate (HTML5)?

New Here ,
Nov 12, 2017 Nov 12, 2017

Hello!

Let me preface this by saying I'm not a dev by any means and I'm doing this for learning and fun. You might have to go slow with me

I'm trying to make an animation which plays when someone follows on Twitch. This is what I have so far: I've set up and subscribed to the appropriate follow webhook on Twitch. When someone follows, Twitch sends me a JSON string of the follower's details, which I use to get their profile name. I have also implemented a basic WebSocket which then relays the profile name to a terminal that is listening to the WebSocket address.

I would like to be able to setup something in Animate where, when the profile name is relayed to it, the animation plays and displays the follower's name. I'm more used to AS3/Flash but I know that support is going away so I'm trying to do this in HTML5, but I'm not sure how to actually go about creating the WebSocket in Animate and what the workflow looks like, and I can't find much documentation about this (at least, doing it in Animate). Outside of Animate, I'm using node.js.

Any help or guidance in the right direction would be much appreciated!

Thank you!

1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 12, 2017 Nov 12, 2017

The scripting language in Animate Canvas documents is bare-metal JavaScript executing natively in the browser. So you do whatever it is you want to do however you'd do it without Animate. Unless it's some massive library of code, you're probably fine just typing it all into the actions window for a frame of your movie.

Translate
LEGEND ,
Nov 12, 2017 Nov 12, 2017

The scripting language in Animate Canvas documents is bare-metal JavaScript executing natively in the browser. So you do whatever it is you want to do however you'd do it without Animate. Unless it's some massive library of code, you're probably fine just typing it all into the actions window for a frame of your movie.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2017 Nov 12, 2017

Okay, thank you! I did try this earlier but I couldn't work out how to 'require' the node module I was using ( https://www.npmjs.com/package/ws ) - is this possible?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 12, 2017 Nov 12, 2017

Um. You might want to pay a little more attention to the bolded "Note" on that page.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 12, 2017 Nov 12, 2017
LATEST

Oops! I'm an idiot. The funny thing is I read that this morning when I was installing it.

I implemented a native WebSocket and tested it and it's now reading perfectly, so I just need to keep messing around and get it to trigger the animation Thanks for your help! I'll probably be back soon with more stupid questions.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines