- Home
- Tutorials
- Flash
- Intermediate
- 3D Menu in Flash CS3/CS4 using Flash Player 10 3D API

Code Part 3 - Event Listeners
Okay basically this part is all event listeners. We're going to add event listeners to all of the bottons for a roll over event, a roll out event, and a click event. The rollover/rollout events are to just kind of jitter or slightly animate the menu to add to the interactivity of the whole scene. Also we're going to add an event listener to the stage to listen for the mouse wheel, as well as add an ENTER_FRAME event to the mySpace Sprite/MovieClip. All functions referenced in these event handlers are not yet written. That part is next. Pretty straight forward code here.
stage.addEventListener(MouseEvent.MOUSE_WHEEL, travelSpace);
mySpace.addEventListener(Event.ENTER_FRAME, updatePos);
//
b1.addEventListener(MouseEvent.MOUSE_OVER, bOver);
b1.addEventListener(MouseEvent.MOUSE_OUT, bOut);
b1.addEventListener(MouseEvent.CLICK, zipTo);
//
b2.addEventListener(MouseEvent.MOUSE_OVER, bOver);
b2.addEventListener(MouseEvent.MOUSE_OUT, bOut);
b2.addEventListener(MouseEvent.CLICK, zipTo);
//
b3.addEventListener(MouseEvent.MOUSE_OVER, bOver);
b3.addEventListener(MouseEvent.MOUSE_OUT, bOut);
b3.addEventListener(MouseEvent.CLICK, zipTo);
//
b4.addEventListener(MouseEvent.MOUSE_OVER, bOver);
b4.addEventListener(MouseEvent.MOUSE_OUT, bOut);
b4.addEventListener(MouseEvent.CLICK, zipTo);
//
b5.addEventListener(MouseEvent.MOUSE_OVER, bOver);
b5.addEventListener(MouseEvent.MOUSE_OUT, bOut);
b5.addEventListener(MouseEvent.CLICK, zipTo);
//
b6.addEventListener(MouseEvent.MOUSE_OVER, bOver);
b6.addEventListener(MouseEvent.MOUSE_OUT, bOut);
b6.addEventListener(MouseEvent.CLICK, zipTo);
//
//
Tweener.addTween(mySpace, {z:-f1.z, x:f1.x - 720, y:f1.y - 700, time:2});
The last part of the code is a tween using the tweener class. For those who don't know how to use tweener it's pretty simple. It goes like this Tweener.addTween(always) then bracket ( then the item you want to manipulate. from there you add in a comma, then a '{' bracket and define the properties you want to set. It's not like the flash Tween engine where you set the to and from values you just set the value you want Tweener to arrive at. For more information check out the tweener documentation at http://hosted.zeh.com.br/tweener/docs/en-us/.
***NOTE*** This tween is essential to proper display/appearance of the final product. IF YOU REMOVE THIS, you will need to significantly change the preset placement values I've been referencing the whole tutorial.

