Rive 101 logoRive 101
β„Ή AboutπŸ“‹ ChangelogδΈ­
0%
Progress0/88
8.7

Control Rive Files in Code

5m 18s
How to Control Rive Files in CODE

This lesson introduces how to programmatically control Rive files at runtime using code. The primary educational objective is to bridge the gap between design assets and frontend engineering by demonstrating how to expose Data Binding properties to external environments. Using a responsive button layout built by Dimitri Novacov, the video details a complete production pipeline: enabling view model exports, configuring the HTML canvas environment, overriding default rendering engines for advanced vector effects, and deploying a two-line JavaScript solution to mutate textual values on the fly.

  • The Crucial Export Instance Flag: When creating View Models destined for engineering handover, always ensure the Export Instance flag is activated in the inspector. Omitting this step results in JavaScript returning undefined when trying to call r.viewModelInstance at runtime, severing the data connection.
  • Autobind Runtime Parameter Requirements: When initializing the Rive runtime container inside an app, webpage, or game engine code template, explicitly adding the autobind: true dictionary key is a required operational flag to instruct the graphics engine to parse and map asset data tracks.
  • Advanced Blurs and Context Choices: If a design leverages high-end Vector Feathering or complex blending modes, standard canvas engines fall short. Forcing the canvas instantiation script to run on a webgl2 graphics context guarantees identical vector fidelity between the editor and web browsers.