MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 576

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

8.
Enter the following code into the Actions panel:
balance_mc.top = balance_mc._y;
balance_mc.bottom = balance_mc._y;
balance_mc.left = balance_mc._x;
balance_mc.right = balance_mc._x + 100;
balance_mc._x += 50;
balance_mc.handle_btn.onPress = function() {
startDrag(this._parent, false, this._parent.left, this._parent.top,
this._parent.right, this._parent.bottom);
};
balance_mc.handle_btn.onRelease = function() {
stopDrag();
var level:Number = Math.ceil((this._parent._x - this._parent.left -
50) * 2);
this._parent._parent.song_sound.setPan(level);
};
balance_mc.handle_btn.onReleaseOutside =
balance_mc.handle_btn.onRelease;
The
startDrag()
movie clip action.
9.
Select Control > Test Movie to use the balance slider.
For more information about the methods of the Sound class, see Sound in the
ActionScript 2.0 Language Reference.
Detecting collisions
The
method of the MovieClip class detects collisions in a SWF file. It checks to
hitTest()
see if an object has collided with a movie clip and returns a Boolean value (
You would want to know whether a collision has occurred either to test if the user has arrived
at a certain static area on the Stage, or to determine when one movie clip has reached another.
With
, you can determine these results.
hitTest()
You can use the parameters of
the Stage or use the target path of another movie clip as a hit area. When you specify
returns
hitTest()
true
target is passed to
hitTest()
they intersect,
hitTest()
returns
.
false
You can also use
hitTest()
The following example shows how to detect a collision between a mouse and movie clips on
the Stage.
576
Creating Interaction with ActionScript
parameters
,
left
top
to specify the
hitTest()
if the point identified by (
, the bounding boxes of the two movie clips are compared. If
returns
. If the two boxes do not intersect,
true
to test a collision between two movie clips.
,
, and
right
bottom
and
coordinates of a hit area on
x
y
,
) is a non-transparent point. When a
x
y
are variables set in a
or
true
false
x
hitTest()
).
and
,
y

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents