The Director Object Model


The Director Object Model, or DOM, is new in Director MX 2004. Web developers will likely notice the similarity between the Director DOM and the Document Object Model in use on the Web. The DOM provides a tree-like interface that exposes the entire Director environment through a series of logically organized objects. Those objects fall into four general classifications: Core Objects, Media Types, Scripting Objects, and 3D Objects.

The Core Objects provide access toyou guessed itthe core functionality and features such as sprites, movies in a window, the player engine, and more. You probably didn't realize it, but you've already used the DOM to loop on a frame using _movie.go(_movie.frame). In fact, that single line of code accesses the DOM twice: to call the movie's go() method, and to get the movie's current frame.

Media Types take the basic cast member object and extend it with methods and properties specific to the kind of media you're working with. This includes Flash assets, RealMedia, DVD Members, and others. Take for example a DVD cast member that you've imported. You can use member("dvdMember").rect to get the RECTangle of the cast member. The rect property is a standard command available to all cast members allowing you to get and set the dimensions of the cast member. However you can also use the member("dvdMember").titleMenu() method on a DVD member to get to the title screen. The titleMenu() method is available only to DVD media types.

The Scripting Objects, aka Xtra extensions, extend the core functionality of Director and are created by Macromedia and by many third-party developers. Xtras enable Director to do things not available with the core functionality, including reading and writing files, playing video, hooking into a database, and accessing operating system features. To see a complete list of available Xtras, visit macromedia.com and select Exchange from the Downloads menu, then choose the Director Exchange.

3D objects allow you to add 3D functionality to your movies. Although a 3D member appears in the cast like any other member, it's a lot different internally; 3D members contain complete 3D worlds, including the geometry, lights, cameras, and texture maps.

Examine the following image to see the relationship of the different objects. You can see how the core member object is extended to include the media types, as well as the 3D object.

A great thing about the DOM is that it is global in scope, meaning you can access it anytime and anywhere. For example, because the _player object manages all instances of running movies, you now have direct and easy access to movies running in a window as well as Linked Director Movies (LDMs), Flash sprites and more.

Recall that in Lesson 3 you swapped a sprite's member using Lingo like sprite(3).member = member("button_hi"). Now, if you'll look at the preceding image you'll notice that the sprite object is subordinate to the movie object, which itself is subordinate to the player object. However, you didn't need to specify the entire hierarchy from _player down in order to access the sprite object. This is because Macromedia provides top-level functions and properties for commonly used items.

Top-Level Functions and Properties

There are a number of top-level functions and properties that provide direct access to core objects without having to traverse the hierarchy to get to them. The sprite() function, which you used previously, is a top-level function that returns a reference to a sprite in the Score. You've also used the top-level _movie property for looping on a frame. The _movie property returns a reference to a movie objectwhich is the currently active movie running in the player.

As you progress with your learning of Lingo you'll make extensive use of the top-level functions and properties, as well as using the DOM's hierarchy to access items such as a Movie In A Window (MIAW).

A complete list of the top-level functions and properties appears in the following table. For a detailed description of each item you should consult Director's Help using Help > Director Help from the top menu.

Top-level Functions

castLib()

randomVector()

color()

rect()

channel()

script()

date()

showLocals()

image()

sound()

isBusy()

sprite()

list()

symbol()

member()

timeOut()

point()

trace()

propList()

vector()

put()

window()

random()

xtra()

Top-level Properties

_global

_player

_key

_sound

_mouse

_system

_movie

 


Let's get back to the portfolio project and create the generalized button behavior that will allow you to use the same behavior for multiple buttons.



Macromedia Director MX 2004. Training from the Source
Macromedia Director MX 2004: Training from the Source
ISBN: 0321223659
EAN: 2147483647
Year: 2003
Pages: 166
Authors: Dave Mennenoh

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net