PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/aerys/minko/example/picking/PickingExample.as

https://bitbucket.org/HopeSky/mars_nd2d
ActionScript | 74 lines | 67 code | 7 blank | 0 comment | 0 complexity | 3a55dac117bdd4d510d2e0282b130216 MD5 | raw file
 1package aerys.minko.example.picking
 2{
 3	import aerys.minko.Minko;
 4	import aerys.minko.example.core.primitives.PrimitivesExample;
 5	import aerys.minko.render.geometry.primitive.CubeGeometry;
 6	import aerys.minko.render.material.basic.BasicMaterial;
 7	import aerys.minko.scene.controller.PickingController;
 8	import aerys.minko.scene.node.Mesh;
 9	
10	import flash.text.TextField;
11
12	public class PickingExample extends PrimitivesExample
13	{
14		private var _log	: TextField;
15		
16		override protected function initializeUI():void
17		{
18			_log = new TextField();
19			_log.textColor = 0xffffffff;
20			_log.height = 600;
21			_log.width = 200;
22			stage.addChild(_log);
23		}
24		
25		override protected function initializeScene() : void
26		{
27			super.initializeScene();
28			
29			var picking : PickingController = new PickingController();
30			
31			viewport.doubleClickEnabled = true;
32			picking.bindDefaultInputs(viewport);
33			picking.useHandCursor = true;
34			picking.mouseClick.add(
35				function(ctrl : PickingController, mesh : Mesh, mouseX : Number, mouseY : Number) : void
36				{
37					_log.text = 'click: ' + (mesh ? mesh.name : null) + '\n' + _log.text;
38				}
39			);
40			picking.mouseRightClick.add(
41				function(ctrl : PickingController, mesh : Mesh, mouseX : Number, mouseY : Number) : void
42				{
43					_log.text = 'right click: ' + (mesh ? mesh.name : null) + '\n' + _log.text;
44				}
45			);
46			picking.mouseDoubleClick.add(
47				function(ctrl : PickingController, mesh : Mesh, mouseX : Number, mouseY : Number) : void
48				{
49					_log.text = 'double click: ' + (mesh ? mesh.name : null) + '\n' + _log.text;
50				}
51			);
52			picking.mouseRollOut.add(
53				function(ctrl : PickingController, mesh : Mesh, mouseX : Number, mouseY : Number) : void
54				{
55					_log.text = 'roll out: ' + (mesh ? mesh.name : null) + '\n' + _log.text;
56				}
57			);
58			picking.mouseRollOver.add(
59				function(ctrl : PickingController, mesh : Mesh, mouseX : Number, mouseY : Number) : void
60				{
61					_log.text = 'roll over: ' + (mesh ? mesh.name : null) + '\n' + _log.text;
62				}
63			);
64			picking.mouseMove.add(
65				function(ctrl : PickingController, mesh : Mesh, mouseX : Number, mouseY : Number) : void
66				{
67					_log.text = 'move: ' + (mesh ? mesh.name : null) + '\n' + _log.text;
68				}
69			);
70			
71			scene.addController(picking);
72		}
73	}
74}