fl.findObjectInDocByName()

Availability

Flash CS3 Professional.

Usage

fl.findObjectInDocByName(instanceName, document)

Parameters

instanceName A string that specifies all or part of the instance name of an item in the specified document.

document The Document object in which to search for the specified item.

Returns

An array of generic objects. Use the .obj property of each item in the array to get the object. The object has the following properties: keyframe, layer, timeline, and parent. You can use these properties to access the hierarchy of the object. For more information on these properties and how to access them, see fl.findObjectInDocByName().

You can also access methods and properties for the layer and timeline values; they are equivalent to the Layer object and the Timeline object, respectively.

Description

Method; exposes elements with instance names that contain specified text in a document.

Examples

The following example searches the current document for text fields that contain "text" in their instance names, and then changes the contents of the text fields:

var nameToSearchFor = "text";
var doc = fl.getDocumentDOM();
var results = fl.findObjectInDocByName(nameToSearchFor, doc); 
if (results.length > 0) {
    for (var i = 0; i < results.length; i++) {
        results[i].obj.setTextString("new text");
    }
    alert("success, found " + results.length + " objects");
}
else { 
    alert("failed, no objects of type "" + nameToSearchFor + "" found");
}

See also

fl.findObjectInDocByType()