Object Scope
To handle multiple object instances efficient and effectively in Multimedia Fusion, it is imperative that
we understand the "Object Scope".
The Object Scope is an invisible list of all the objects (and their instances) in your frame. Every time MMF2 reads a single line of code and before it checks the conditions, it creates a new List. When it runs through the conditions, it starts REMOVING objects from the list.
Please observe the following event:
- Health of
< 20
: Change animation sequence to Injured
Now, lets add a create object action:
- Health of
< 20
: Change animation sequence to Injured
: Create
at (0,0) from
Now, lets add an action referring to the Blood object:
- Health of
< 20
: Change animation sequence to Injured
: Create
at (0,0) from
: Set Speed to 100
Now, lets insert another action:
- Health of
< 20
: Change animation sequence to Injured
: Set Speed to 50
: Create
at (0,0) from
: Set Speed to 100
The Object Scope is also relevant when retrieving data from an object. If multiple object instances meet the conditions, then the data is only retrieved from the most recently created instance (out of those still remaining in the Scope).
For example, observe the following event:
- Always
: Set Global Value A to Health( "
" )
By using conditions which directly refer to that instance:
- Mouse pointer is over
: Set Global Value A to Health( "
" )
It should also be noted that:
Alterable Value A of
= Alterable Value A ( "
" )


Alterable Value A of
= Alterable Value A ( "
" )


The first condition loops through EVERY SINGLE Enemy object checking if it's Alterable Value A is equal to the Alterable Value A of the most recently created Blood object instance, and THIS INSTANCE ONLY! If they don't match, then that Enemy instance is removed from the Object Scope and any actions will no longer effect those Enemy instances.
However, and this is the interesting part, any actions will effect ALL instances of the Blood object! Regardless as to whether their Alterable Value A matches the Alterable Value A of any Enemy objects. This is because the object you are comparing to is NOT removed from the Object Scope.
The second condition is the same, only reversed. So in this case, MMF2 will compare every Blood object against ONLY the newest Enemy object. To specify which particular Enemy instance to compare to, we would have to remove all other Enemy instances from the Object Scope, by using conditions which directly reference that instance and that instance alone, as we did with the mouse pointer condition.
The are exceptions however:




At least in terms of Object Scope, the above conditions can be regarded as the same thing. In both cases, for obvious reason, every Enemy object and every Blood object not overlapping the other is removed from the Object Scope.
However, these two conditions do differ in terms of collision detection. At the beginning of every frame, MMF2 records the location of every object. Say at the start of the frame, both an Enemy and Blood objects are overlapping, but then in a later event, you move the Blood object and now they are not overlapping. If, in a later event, you check if the Enemy is overlapping the Blood object, then a collision will be incorrectly detected because MMF2 is checking the CURRENT location of the Enemy object against the RECORDED location of the Blood object. If you were to reverse the events, making it "Blood overlapping Enemy", then a collision would be correctly be not detected, because MMF2 is now checking the current location of the Blood object (which has moved) against the recorded location of the Enemy object (which has not moved). Fortunately in most cases, you will never have to worry about this, because at the beginning of the next frame the new locations will be recorded and a collision either correctly detected or not detected.
As you can see, there is much more to Multimedia Fusion 2 than first meets the eye and understanding exactly what goes on behind the scenes is essential if you wish to enter the perilous realms of advanced programming.
Until next time, my friend.