Tài liệu Making the Most of Attaching Mouse Events to Movie Clips - Pdf 92


< Day Day Up >

Making the Most of Attaching Mouse Events to Movie Clips
Movie clip instances can also have attached mouse events (as shown in the preceding
exercise). To make the most of this powerful capability, you need to be aware of a few
things:

To cause a movie clip to be treated as a button, simply attach a mouse event to it.
Under most circumstances, you cannot attach both mouse events and clip events to
a single instance. However, you can use event handler methods (discussed later in
this lesson) to set a movie clip instance to react to both mouse and clip events.

When a movie clip instance is assigned mouse events so that Flash recognizes it as
a button, it retains all of its movie clip functionality.

When a movie clip instance is assigned mouse events so that Flash recognizes it as
a button, a hand cursor will appear when the user places his or her mouse over it.
If you want a movie clip instance to act like a button but don't want the hand
cursor to appear, set the useHandCursor property of the instance to false with a
rollOver event:



on (rollOver) {



this.useHandCursor = false;





}
• However, if you were to place the same script on a button, the button's parent will
rotate. Think of it this way: movie clip instances are timelines, even when
attaching mouse events so that Flash recognizes them as buttons. In addition to
having properties and methods, buttons can be given instance names. They are still
part of a timeline, not timelines themselves.
You might ask, because movie clips can be treated as buttons while they maintain
all of their powerful movie clip instance capabilities, why use standard buttons at
all? Primarily because a button's up, over, and down states are still much easier to
re-create and implement using an actual button. For quick and easy button
functionality, use button instances. For highly sophisticated button functionality,
use movie clip instances with mouse events attached to them.

If you use a movie clip instance as a button, you can place three special frame
labels (_up, _over, _down) on a movie clip's timeline to easily facilitate the movie
clip button's appearance when the mouse interacts with it (though you aren't
required to do this in order to use a movie clip instance as a button).


By default, the hit area of a movie clip button will be the shape and area of any
graphical content it contains. You can change the hit area at any time by defining
its hitArea property. For example, this script will set a movie clip instance as the
hitArea of a movie clip button:



Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status