MouseEvent

Example with Switch/Case
stage.addEventListener(MouseEvent.CLICK, kitchenFunction);

function kitchenFunction(evt:MouseEvent):void {	// make a variable named kitchenSelected and pass the selected movieclip name to it	var kitchenSelected = evt.target.name; // use a Switch/case statement to evaluate what is selected switch (kitchenSelected) {

case "microwave_mc" : trace("You clicked on the microwave!"); break; case "fridge_mc" : trace("You clicked on the fridge!"); break; case "pot_mc" : trace("You clicked on the pot!"); break; case "stove_mc" : trace("You clicked on the stove!"); break; case "cuttingboard_mc" : trace("You clicked on the cuttingboard!"); break; case "plate_mc" : trace("You clicked on the plates!"); break; case "bowl_mc" : trace("You clicked on the bowl!"); break; case "house" : trace("Its just the house"); break; } }

In this example, the listener for the MouseEvent is on the stage, so anything on the stage will return its name. Trace "evt.target.name" to see what is the selected item.

MouseEvent and mouseX and mouseY
I made a star shape in the library and gave it the class name "Star". Now wherever you click, a star will appear.

http://dreamsyntax.org/patterns/swf/mouseevent_01.swf

stage.addEventListener(MouseEvent.CLICK, makeStar); function makeStar(evt:MouseEvent):void { var myStar:Star; myStar = new Star; myStar.x = mouseX; myStar.y = mouseY; addChild(myStar); }

Dragging Example
 draggableXbar.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

function mouseDownHandler(e:MouseEvent):void {	stage.addEventListener(Event.ENTER_FRAME, drag); stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); offsetX = mouseX - draggableXbar.x; }

function mouseUpHandler(e:MouseEvent):void {	stage.removeEventListener(Event.ENTER_FRAME, drag); stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); draggableXbarPos = draggableXbar.x; // use the draggableXbarPos to determine what to do when it is scrolled at a certain place

} 