Extending Flash |
|
|
|
| Introduction > The Flash Document Object Model > The Document object | |||
An important property of the top-level flash object is the fl.documents property. (See fl.documents property.) The fl.documents property contains an array of Document objects that each represent one of the FLA files currently open in the authoring environment. The properties of each Document object represent most of the elements that a FLA file can contain. Therefore, a large portion of the DOM is composed of child objects and properties of the Document object. For more information, see Document object.
To refer to the first open document, for example, use the statement flash.documents[0] or fl.documents[0]. The first document is the first Flash document that was opened during the current session in the authoring environment. When the first opened document is closed, the indexes of the other open documents are decremented.
To find a particular document's index, use flash.findDocumentIndex(nameOfDocument) or fl.findDocumentIndex(nameOfDocument). See fl.findDocumentIndex().
To access the document that is currently focused, use the statement flash.getDocumentDOM() or fl.getDocumentDOM(). See fl.getDocumentDOM(). The latter is the syntax used in most of the examples in this document.
To find a particular document in the fl.documents array, iterate through the array and test each document for its document.name property. See fl.documents and document.name.
All the objects in the DOM that aren't listed in the previous table (see The Flash Document Object Model) are accessed from the Document object. For example, to access the library of a document, you use the document.library property, which retrieves a library object:
fl.getDocumentDOM().library
To access the array of items in the library, you use the library.items property; each element in the array is an Item object:
fl.getDocumentDOM().library.items
To access a particular item in the library, you specify a member of the library.items array:
fl.getDocumentDOM().library.items[0]
In other words, the library object is a child of the Document object, and the Item object is a child of the library object. For more information, see document.library, library object, library.items, and Item object.
|
|
|
|