MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual page 193

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

To detect a collision between a movie clip and a point on the Stage:
Create a new movie clip on the Stage, and enter
1.
Property inspector.
Select the first frame on Layer 1 in the Timeline.
2.
Select Window > Development Panels > Actions to open the Actions panel, if it is not
3.
already open.
Add the following code in the Actions panel:
4.
this.createTextField("status_txt", 999, 0, 0, 100, 22);
status_txt.border = true;
box_mc.onEnterFrame = function() {
status_txt.text = this.hitTest(_xmouse, _ymouse, true);
};
Select Control > Test Movie, and move the pointer over the movie clip to test the collision.
5.
The value
appears whenever the pointer is over a non-transparent pixel.
true
To perform collision detection on two movie clips:
Drag two movie clips to the Stage, and give them the instance names
1.
Select the first frame on Layer 1 in the Timeline.
2.
Select Window > Development Panels > Actions to open the Actions panel, if it is not
3.
already visible.
Enter the following code in the Actions panel:
4.
this.createTextField("status_txt", 999, 10, 10, 100, 22);
area_mc.onEnterFrame = function() {
status_txt.text = this.hitTest(car_mc);
};
car_mc.onPress = function() {
this.startDrag(false);
updateAfterEvent();
};
car_mc.onRelease = function() {
this.stopDrag();
};
Select Control > Test Movie, and drag the movie clip to test the collision detection.
5.
Whenever the bounding box of the car intersects the bounding box of the area, the
status is
.
true
For more information about the methods of the Color class, see the Color class entry in
ActionScript Dictionary Help. For more information, see
Dictionary Help.
as the instance name in the
box_mc
car_mc
MovieClip.hitTest()
Creating interactivity and visual effects
and
.
area_mc
in ActionScript
193

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents