[Tutorial Index] [Prev: Using JavaScript with arcticPigs] [Next: Knowing when something has loaded]

The onCreate() handler

When the arcticPigs plugin has finished loading, it fires the onCreate event notification message. This makes the event handler an excellent place to perform any initialization functions (such as loading choreographies, starting the script, and so forth).

The usual sequence of events, as defined by the basic template files used by the arcticPigs exporter, is as follows:

<script type="text/javascript" for="arctic" event="onCreate()">
  hMain = arctic.world.newScript("main")        // Create a new script to hold the choreography
  arctic.doc.loadChor("Examples/Example1.chor") // Load the choreography
  hMain.addChoreography("Example1")             // Add the choreography to the script
  hMain.start()                                 // Start the script.
</script>

Any other initialization work, such as loading additional models, setting the render quality or adding 3D control sets, may also be performed during this handler routine.