Using Director > Parent Scripts > Creating a child object > Checking child object properties |  |

Checking child object properties

You can check the values of specific property variables in individual child objects by using a simple `objectName.PropertyName` syntax. For example, this statement assigns the variable `x` the value of the `carSpeed` property of the child object in the variable `car1`:

    x = car1.carSpeed

Querying object properties from outside the objects themselves can be useful for getting information about groups of objects, such as the average speed of all the car objects in a racing game. You might also use the properties of one object to help determine the behavior of other objects that are dependent on it.

In addition to checking the properties you assign, you can check whether a child object contains a specific handler or find out which parent script an object came from. This is useful when you have objects that come from parent scripts that are similar but that have subtle differences.

For example, you may want to create a scenario in which one of several parent scripts might be used to create a child object. You can then determine which parent script a particular child object came from by using the `script()` function, which returns the name of an object's parent script.

These statements check whether the object `car1` was created from the parent script named Car:

    if car1.script = script("Car") then
    	beep
    end if

You can also get a list of the handlers in a child object by using the `handlers()` function, or check whether a particular handler exists in a child object by using the `handler()` function.

This statement places a list of the handlers in the child object `car1` into the variable `myHandlerList`:

    myHandlerList = car1.handlers()

The list would look something like this:

    [#start, #accelerate, #stop]

These statements use the `handler()` function to check whether the handler `on accelerate` exists in the child object `car1`:

    if car1.handler(#accelerate) then
    	put "The child object car1 contains the handler named on ¬ accelerate."
    end if