查看: 1695|回复: 2
打印 上一主题 下一主题

away3d鼠标感应效果教程

[复制链接]

907

主题

1

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
16139
精华
6

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2013-5-8 16:30:13 |只看该作者 |倒序浏览
away3d鼠标感应效果教程
  1. package
  2. {

  3.         import away3d.entities.Mesh;
  4.         import away3d.events.MouseEvent3D;
  5.         import away3d.materials.ColorMaterial;
  6.         import away3d.primitives.CubeGeometry;
  7.         import away3d.primitives.SphereGeometry;

  8.         public class PickingTutorialListing01 extends PickingTutorialListingBase
  9.         {
  10.                 public function PickingTutorialListing01() {
  11.                          super();
  12.                 }

  13.                 private var _inactiveMaterial:ColorMaterial;
  14.                 private var _activeMaterial:ColorMaterial;

  15.                 override protected function onSetup():void {

  16.                         _cameraController.panAngle = 20;
  17.                         _cameraController.tiltAngle = 20;

  18.                         // Init materials.
  19.                         _activeMaterial = new ColorMaterial( 0xFF0000 );
  20.                         _activeMaterial.lightPicker = _lightPicker;
  21.                         _inactiveMaterial = new ColorMaterial( 0xCCCCCC );
  22.                         _inactiveMaterial.lightPicker = _lightPicker;

  23.                         // Create 2 objects.
  24.                         var cube:Mesh = new Mesh( new CubeGeometry(), _inactiveMaterial );
  25.                         cube.x = -75;
  26.                         _view.scene.addChild( cube );
  27.                         var sphere:Mesh = new Mesh( new SphereGeometry(), _inactiveMaterial );
  28.                         sphere.x = 75;
  29.                         _view.scene.addChild( sphere );

  30.                         // Enable mouse interactivity.
  31.                         cube.mouseEnabled = true;
  32.                         sphere.mouseEnabled = true;

  33.                         // Attach mouse event listeners.
  34.                         cube.addEventListener( MouseEvent3D.MOUSE_OVER, onObjectMouseOver );
  35.                         cube.addEventListener( MouseEvent3D.MOUSE_OUT, onObjectMouseOut );
  36.                         sphere.addEventListener( MouseEvent3D.MOUSE_OVER, onObjectMouseOver );
  37.                         sphere.addEventListener( MouseEvent3D.MOUSE_OUT, onObjectMouseOut );

  38.                 }

  39.                 private function onObjectMouseOver( event:MouseEvent3D ):void {
  40.                         event.target.material = _activeMaterial;
  41.                 }

  42.                 private function onObjectMouseOut( event:MouseEvent3D ):void {
  43.                         event.target.material = _inactiveMaterial;
  44.                 }
  45.         }
  46. }
复制代码
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

0

主题

2

听众

3482

积分

中级设计师

Rank: 5Rank: 5

纳金币
2
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

沙发
发表于 2014-1-17 09:00:02 |只看该作者
不错的资源,感谢楼主分享,支持下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-24 19:28 , Processed in 0.085017 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部