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.
Enable the interactivity
In order to make your animation interactive you have to enable the menu item Animation:Interactivity. 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.
Creating a Script
Any script is always associated to a Sprite on the Sprite window therefore it has effect only when that sprite is currently playing. You can assign a script to an existing object on the stage 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:
- Event: When the user clicks on the object.
- 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,...
Creating 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 click on the object Cube, go to frame 200). To do that you have to select that object in the Stage window or in the Sprite window, then set the Inspector:Script panel as shown in the picture here aside.
- Event: When the user clicks on me.
- Action: Go to frame 200.
Creating a Loop
You can tell Kinemac that when the animation playback "head" reaches the End of the sprite "Sphere" it has to go to the Start of the sprite "Sphere" (or the start/end of some other sprite) such a way to repeat the animation of the Sphere again and again. To do that you have to select the sprite "Sphere" in the Sprite window (see picture here below) or in the Stage window then set the Inspector:Script panel as shown in the picture here aside.
- Event: End Sprite.
- Action: Go to start of sprite "me".
Then usually you have to define a way which lets the user exit from this loop. Look at the Inspector panel shown here above at your right. 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 (in the case shown here above, after the first End Sprite) or after a given number of repetitions. When the script exits, the playhead just 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 dragging a Sprite from the Hierarchical Sprite list onto the field "Sprite". To set back the sprite to "me", click on the icon "chain" .
Call a Link action
This action is useful to report to your web server the user's feedback on your animation. Let's suppose that the current animation regards the latest DVD/CD of a given artist or a TV show or any product or service you are promoting with that animation. Now you want to ask to the user to vote the movie/song/product currently playing by pressing a key from zero to 9. Therefore you tell Kinemac that:
- Event: When the user hits one of the keys: 0,1,2,3,4,5,6,7,8,9
- Action: Call link: http://www.mysite.com/dvd_xyz.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:
The page http://www.mysite.com/dvd_xyz.html could not even exist on your server (and this is better because it doesn't generate traffic). 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.
We think to release a free Kinemac Player application so you can distribute your animations together with (or embedded into) the Kinemac Player on CD, DVD, by download...
Open and play a Kinemac animation file
As written here above, any script is always associated to a Sprite on the Sprite window therefore it has effect only when that sprite is currently playing. For example you can say that when the object "Sphere" 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:
- Enter key: enter
- Return key: return
- Escape key: escape
- Left Arrow key: leftArrow
- Right Arrow key: rightArrow
- Top Arrow key: topArrow
- Bottom Arrow key: bottomArrow
For example, in the Hot Keys field you can write: enter,return,p,j,6
Script Sprite Object
If you need to create a script not constrained to the duration of an existing object on the Stage, you can create an independent ScriptSprite calling the menu item "Objects:Script". Then select its sprite and assign a script to it in the Inspector panel. In the sample here below, the script will have effect for the whole duration of the scriptsprite.
Therefore if the user clicks on the Stage window while the animation is playing the sprite "Script" (between 0 and 220 time point) Kinemac will execute that script (go to Zero time point) so it will repeat the animation of the cube and of the sphere again and again.
Events and Actions
A script is always defined by an Event and an Action. For example you can tell Kinemac that:
Event: When the user clicks on the object "Cube".
Action: Go to frame 200.
You can choose one of the following events:
You can choose one of the following actions:
- Tell Safari to open the web page...
- Call a link
- Execute Apple Script
- Go To Frame
- Go to the start of sprite (choose the sprite)
- Go to the end of sprite (choose the sprite)
- Set Stage Size
- Set Stage to Window
- Set Stage to Full Screen
- Toggle Stage Window/Full Screen
- Open and Play a Kinemac Application File