Customizing the mouse behaviour and active area

The 3DPlane creates a rectangular area around the 3D object for mouse control. You may wish to create your own mouse sensitive area (for example, in shape of a butterfly), so that mouse clicks do not register in transparent areas. You may also want to change the mouse behaviour, for example, you can rotate the object on mouse move instead of on mouse drag.

1. Select the 3DPlane component in the 'scroller3d.fla' movie and uncheck the 'Allow mouse control' checkbox. This will allow you to control this yourself.

2. Edit the 'mc2' MovieClip (double click on its icon in the library to edit it).

3. Create a make a button in the 'mc2' MovieClip. In this example, we'll make the button the exact size of the loaded object (342x220) and center it on the stage. You may also choose to make the button transparent.

4. Select the button that you just created and add either of the following ActionScript codes to it:

a. This code reacts on mouse rollOver:

on (rollOver) {
rootObject.activeMouse = true;
}
on (rollOut) {
rootObject.activeMouse = false;
}
//rootObject - link to the root 3DPlane instance.
//activeMouse - public parameter of the 3DPlane, indicates when the 3DPlane rotates with the mouse.

b. This code reacts on mouse press and is more suited to most cases:

on (press) {
rootObject.activeMouse = true;
}
on (release, releaseOutside) {
rootObject.activeMouse = false;
}


5. Test the movie again. You should notice that the scroll buttons now work correctly and that there is no conflict with the 3D rotation.

6. You may want to add additional 3D rotation actions. For example, you can highlight the object on mouse press by adding the following code:

on (press) {
rootObject.activeMouse = true;
new Color(this).setTransform({ra:150,ga:150,ba:150});
}
on (release, releaseOutside) {
rootObject.activeMouse = false;
new Color(this).setTransform({ra:100,ga:100,ba:100});
}

7. Finally, if you prefer to remove the hand cursor which appears over the button, give the button an instance name, for example 'button1' and add the following ActionScript to the first frame of 'mc2':

button1.useHandCursor = false;