Getting the most of...

MMF2 Behaviours

  The behaviours may be one of the most powerfull addition to Multimedia Fusion and certainely one of the most ignored feature of the entire package! The tutorial will explain what exactly are behaviours, where to find them, how to use them and what are the benefits of using them.

What are behaviours.

Behaviours are small lists of events, specific to one kind of objects. They are stored as a property within the other properties. This alow you to pre define the reactions of one object, and create automated objects that work immediatly when dropped on the frame, with no need of extra events.

Applications are endless :

puce_rouge2.gif (933 octets) Automated buttons, that reacts under the mouse
puce_rouge2.gif (933 octets) Objects with complex movements, and preset rebounds
puce_rouge2.gif (933 octets) Preprogrammed system objects, for example a MCI object that plays sounds from the disc and manage them automatically.
puce_rouge2.gif (933 octets) Etc!
A proper use of the behaviours in a complex project can dramatically reduce the number and the complexity of the main list of events.

We are going to discover the behaviours by creating an automated button that automatically highlights under the mouse.

puce_rouge2.gif (933 octets) Start Multimedia Fusion, create a blank application and open the frame editor.
puce_rouge2.gif (933 octets) Open the library window (Control R, or from the menu View, Toolbars, Library window) , and choose Buttons and pointers / Media - Widgets #1. Drag and drop the object Play 2 on your frame.

This button contains two images, the flat button affected to the right direction of the stopped animation (direction number 0), the highlighted button affected to the left direction of the same animation (direction number 16). So, if we want to highlight the button, we simply should chage the direction of the button to the right or to the left, when the mouse is above it or not.


Direction 0

Direction 16

puce_rouge2.gif (933 octets) Highlight the Play 2 object and in the Properties Toolbar select the Events tab and click on the New button.

 

This will create a new behavior named "Behaviour #1". Click on the edit area and finally on the New button. This will open the usual event editor editing the behaviour of the button. Notice that the icon of our button has a "shortcut" arrow appended to it, like a Windows shortcut. More on this later.

puce_rouge2.gif (933 octets) Enter the following events:


This very simple list of events makes the object react to the mouse. Run the application and you will see the object change when the mouse crosses over it.

puce_rouge2.gif (933 octets) Lets rename the behaviour to a proper name: in the Properties toolbar right click on the name "Behavior #1" choose "rename" and enter : "Automatic Highlight", click OK to save.

Properties are stored within the object.

puce_rouge2.gif (933 octets) Now close the event editor, close the frame editor so that only the project window is left,
puce_rouge2.gif (933 octets) Open a new, blank application.
puce_rouge2.gif (933 octets) Open the frame editor of the blank application.
puce_rouge2.gif (933 octets) In the project window, display the list of objects of our first application, and drag and drop our button onto the newly created frame.
puce_rouge2.gif (933 octets) Click in the frame editor to select the window, and run the new frame: the button works automatically, its behaviour was stored inside of it and dropped at the same time in the application.
puce_rouge2.gif (933 octets) Now, open the library window (Contol R), and drag & drop the button named Cancel 1 into the frame. If you run the frame, you will see that this button does not react to the mouse.
puce_rouge2.gif (933 octets) Select the Play 2 button and from the Properies toolbar right click on the Automatic Highlight behavior and choose copy. , Now select the Cancel 1 button and in the Properties toolbar right click on the blank area next to the New button, and select Paste..



puce_rouge2.gif (933 octets) Run the frame, you should see both buttons reacting to the mouse.

This little demonstration has made you understand hope the hidden power of the behaviors. They will make you gain time, they are re-useable, and will greatly reduce the number of events in the main event list (imagine that you have 10 buttons like these two!).

Behaviours in details.

puce_rouge2.gif (933 octets) A simple list of events, stored in the object itself.
puce_rouge2.gif (933 octets) A behaviour does not contain direct references to the objects (as in the event editor), but shortcuts to the object. This is the reason why a small arrow is pasted over the icon of the object.

 
Shortcuts to objects

The main object in a behaviour, is the object who owns it. This object will always be present in the behaviour event editor, and cannot be removed. If you drag & drop the behaviour from one object to another, the main object and icon will be renamed to the new object (in the example above, Play 2 has been replaced by Cancel 1 after the drop.

puce_rouge2.gif (933 octets) Behaviours can reference other objects from the frame. The reference is made from the name of the object: if the referenced object is present on the frame, then the events are activated, if not, they simply will have no effect. This feature make them even more powerful : you can prepare objects that will automatically trigger other objects if they are lying beside them, or stay quiet if not.

Lets program a quick demonstration.

puce_rouge2.gif (933 octets) Close the second application (the one with the Cancel button), we do not need it.
puce_rouge2.gif (933 octets) Reopen the frame of the first application (the one with the Play button),
puce_rouge2.gif (933 octets) Create an AVI object in the frame. Make it point to whatever video you want, and uncheck "Play at start" in the video Properties toolbar.
puce_rouge2.gif (933 octets) Rename this object to "Video".
puce_rouge2.gif (933 octets) Reopen the behaviour event-editor of our play button as before (Properties toolbar / Events tab / Edit). You can see a new object displayed on the right of the object bar : the "Import" object.
puce_rouge2.gif (933 octets) Click on this import object will display the other objects present in the frame at that moment.

puce_rouge2.gif (933 octets) Select the "Video" object and click OK: it should appear in the event editor.

Add the following events to the list:


These basic events will start the video when the user left-clicks on the button, and stop it when he right-click.

Of course, if you run the frame, it should work : the behaviour of the button changes the state of the video.

Lets redo the same manipulation as before.

puce_rouge2.gif (933 octets) Open a second application, open the frame editor;
puce_rouge2.gif (933 octets) Drag and drop our new Play 2 button into the frame.
puce_rouge2.gif (933 octets) Now create a second video, same as before (not to play at start), but do not rename it : leave the default name AVI. If you run the application, it won't be triggered by a click on the play button : upon running the application, Fusion links the different objects shortcuts with the objects themselves. Our behaviour contains references to a Video object, thus Fusion cannot find it, and inactivates the play/stop actions.
puce_rouge2.gif (933 octets) Rename the AVI object to Video, and run the frame : it works now, the link is established.
puce_rouge2.gif (933 octets) Once the link is established, you can safely rename the other objects, Fusion will preserve the links by renaming the shortcuts inside the behaviours. For example rename Video to Video 2, open the Automatic highlight and see that it has been updated.

Things to know about the behaviours and shortcuts.

puce_rouge2.gif (933 octets) You can create or shoot objects from within a behaviour, but the original object must have been previously dropped in the frame, otherwise, Fusion will not estabish the link.
puce_rouge2.gif (933 octets) You cannot drag & drop a behaviour from one kind of object to a different kind (example active object behaviour onto edit box)
puce_rouge2.gif (933 octets) You can play sounds and musics from within a behaviour, but here too, the sound must be inserted somewhere in the real list of event. The link is established from the name of the sound.
puce_rouge2.gif (933 octets) As behaviours are dealing with shortcuts and not the real objects, there is a small limitation related to user animation of objects and names of alterable values: Fusion cannot safely get the real name of the alterable values of an object, they wll always be displayed as "Alterable value A/B/C...", regardless of their true name.


Alterable value are not displayed with their true names

puce_rouge2.gif (933 octets) When using Change animation sequence action, Fusion will only display the 12 first animations of an active object (the default animations). Extra animations, will not be displayed. You can access them though by using a calculation instead of a direct link to the animation : the first user animation is number 12, the second 13 etc...

Behaviours welcomed !

Please send us your behaviours (with a small documentation for each), we will propose them for upload on Clickteam. If everyone shares his own work with the other, we will quickly build a library of premade behaviours that will save a tremendous amount of time for everyone!

 

Copyright © 2006 Clickteam. All rights reserved.
Written by François Lionet & D.T. Holder. Please do not copy or re-use without written permission.