Interactivity

With Kinemac you can easily add interactivity to your animations such a way to create multimedia applications. For example you can let the user click on an object and go to a given frame of your animation or open and play a different animation file. To do that you just create a Script sprite or attach a Script to any object on the Stage.

Create a Loop
You can tell Kinemac that when the animation playback head reaches the End of the sprite Cube it has to go to the Start of the sprite Cube (or even another sprite) such a way to repeat the animation of the Cube again and again. To do that you have to select the sprite Cube on the Sprites window or on the Stage window then set the Inspector:Script panel as shown by the outlets of picture here aside.


  1. Event: End Sprite.

  2. Action: Go to start of sprite: me.


Then you have to define a way which lets the user exit from this loop. Look at the Inspector panel shown here aside. You can choose to exit from the loop when the user clicks on the object or hits a given key or a set of keys, or some seconds after the first event of the script or after a given number of repetitions. When the script exits, the playhead continues ahead from the time point it is actually. To exit from a script you can also add a new script to some other object, or create a new object Script (choosing the menu item Objects:Script) and assign a script to it.

Go to Start/End of Sprite action
As default, when you choose the Action Go to Start/End of Sprite, the Sprite field is set to me meaning the same sprite containing the script. You could specify a different sprite just selecting a Sprite from the Hierarchical Sprite list of the pop-up menu Sprite.

Open and play a Kinemac animation file
As written here above, any script is always associated to a Sprite therefore it has effect only when that sprite is currently playing. For example you can say that when the object Cube is playing on the Stage and the user hits the key "j", Kinemac has to open and play the animation Promo.kmc.


To define a set of Hot Keys, just separate the keys with comma (not comma plus space, just comma like "j,a,c,u,"). If you want to define special keys as the return key of arrow keys, write the string-codes reported at the right side of the table here below:


  1. Enter key: enter

  2. Return key: return

  3. Escape key: escape

  4. Left Arrow key: leftArrow

  5. Right Arrow key: rightArrow

  6. Top Arrow key: topArrow

  7. Bottom Arrow key: bottomArrow


For example, in the Hot Keys field you could write: enter,return,p,j,6

Script Sprite Object
If you need to create a script not linked to an existing object on the Stage, you can create an independent Script–Sprite calling the menu item Objects:Script. Then assign a script to it on the Inspector:Script panel. In the sample here below, the script will have effect for the whole duration of the animation. Therefore if the user clicks on the Stage window while the animation is playing Kinemac will execute that action (Go to frame Zero).


 

Events and Actions
A script is always defined by an Event and an Action. For example you can tell Kinemac that:


  1. Event: When the user clicks on the object Cube.
    Action: Go to frame 200.


You can choose one of the following events:

  1. When Start Sprite

  2. When End Sprite

  3. When the user hits a key

  4. When the user clicks on an object

  5. When the user clicks on the stage



You can choose one of the following actions:

  1. Tell Safari to open the web page...

  2. Call a link

  3. Execute Apple Script

  4. Go To Frame

  5. Go to the start of sprite (choose the sprite)

  6. Go to the end of sprite (choose the sprite)

  7. Pause

  8. Set Stage Size

  9. Set Stage to Window

  10. Set Stage to Full Screen

  11. Toggle Stage Window/Full Screen

  12. Open and Play a Kinemac Application File

  13. Quit

Create a Button
You can make any object on the Stage clickable and behaving like a button executing a given Action (e.g. when the user clicks on the object Cube, go to frame 200). To do that you have to select the Cube on the Stage window or on the Sprite window, then go to the Inspector:Script panel and set the outlets as shown by the picture here aside.

Call a Link action
This action is useful to report to your web server the user's feedback on a given survey. You can tell Kinemac that:


  1. Event: When the user hits one of the keys: 0,1,2,3,4,5,6,7,8,9

  2. Action: Call link: http://www.mysite.com/survey.html?vote=


Then activate the check-box Append key to the link. So if the user hits the key 8, your server will receive a request for the page:


  1. http://www.mysite.com/survey.html?vote=8


The page http://www.mysite.com/survey.html could not even exist on your server. Anyway, your server will write this call to the web log file, so you will have a trace of these calls all the time and be able to make your statistics. You can distribute your animation with the Player application coming within the Kinemac package and let your clients vote for a given survey.

Enable the interactivity
In order to make your animation interactive you have to enable the Animation:Interactivity menu item. This way when the animation is playing, and only when it is playing, the user will not be able to click and select any object on the screen nor hit a key to change camera/view or to change the current tool. When the user will click the mouse or will hit a key, Kinemac will execute the scripts, if any.




Create a Script
Any script is always associated to a Sprite on the Sprites window therefore it has effect only when that sprite is currently playing. You can assign a script to an existing sprite or create a brand new Script-Sprite choosing the menu item Object-Script and define a script for this sprite in the Inspector:Script panel. A script is defined by an Event and an Action. For example:


  1. Event: When the user clicks on the object.

  2. Action: Go to frame 200.


You can combine Events and Action such a way to create a button (clickable object) or a loop, a pause, open a different animation file, go to a given frame or to the start/end of a given sprite. See the complete list of Events and Actions at the end of this chapter. Here below we report some sample about creating buttons, loops,...

KINEMACkinemac.html