Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   не ловятся mouseOver у спрайта повернутого по xyz (http://www.flasher.ru/forum/showthread.php?t=173147)

djyamato 25.12.2011 08:11

не ловятся mouseOver у спрайта повернутого по xyz
 
Здравствуйте
почему-то не срабатывают события мышиные вот в какой системе:
я беру спрайт, верчу его по xyz, в него него кладу еще один, его тоже кручу по xyz
Назначаю параметры для PerspectiveProjection

Даже buttonMode не работает для вложенного спрайта

В чем причина ?

silin 25.12.2011 11:02

не удалось воспроизвести трабл
попробуй 'подправить' пример, чтоб перестал работать
Код AS3:

public class Main extends Sprite 
{
        private var outer:Sprite;
        private var inner:Sprite;
        public function Main():void
        {
                outer = new Sprite();
                outer.graphics.beginFill(0x808080, 0.5);
                outer.graphics.drawRect( -50, -50, 100, 100);
 
                outer.rotationX = 15;
                outer.x = 200;
                outer.y = 200;
                outer.name = "outer";
                addChild(outer);
 
                inner = new Sprite();
                inner.graphics.beginFill(0xFF0000);
                inner.graphics.drawCircle(0, 0, 30);
                inner.rotationY = 15;
                inner.name = "inner";
                outer.addChild(inner);
                inner.buttonMode = true;
 
                var pp:PerspectiveProjection = new PerspectiveProjection();
                pp.projectionCenter = new Point();
                pp.fieldOfView = 120;
                transform.perspectiveProjection = pp;
 
                stage.addEventListener(MouseEvent.CLICK, stage_click);
 
        }
 
        private function stage_click(e:MouseEvent):void
        {
                trace( "Main.stage_click >  " + e.target.name );
 
        }
 
}


djyamato 26.12.2011 00:47

эмм, у меня чуть позамороченнее
есть спрайт
Код AS3:

private var _content3D:Sprite;
private var wallsLayer:Sprite;
 
// массив всех стен (визуальных объектов)
protected var _walls:Vector.<WallExt2>=new Vector.<WallExt2>();
...
_content3D=new Sprite();
addChild(_content3D);
 
_content3D.x = 420;
_content3D.y = 111;
_content3D.z = 1561;
 
_content3D.rotationX=126;
_content3D.rotationY=39;
_content3D.rotationZ=19;
 
var pp:PerspectiveProjection=new PerspectiveProjection();
pp.projectionCenter=new Point(750,300);
pp.fieldOfView=2;
_content3D.transform.perspectiveProjection = pp;
 
// линии стен
var wall0:Vector.<Point>=new Vector.<Point>();
wall0.push(new Point(691,561),new Point(717,660));
 
var wall1:Vector.<Point>=new Vector.<Point>();
wall1.push(new Point(671,545),new Point(685,542));
 
_tmpWalls.push(wall0);
_tmpWalls.push(wall1);
 
wallsLayer = new Sprite();
_content3D.addChild(wallsLayer);
 
//добавление стен
for(var i:int=0;i<_tmpWalls.length;i++)
{
        var wall:WallExt2 = new WallExt2(_tmpWalls[i]);
        wall.strID=i.toString();
        wallsLayer.addChild(wall);
        _walls.push(wall);
}


Класс построения куба
Код AS3:

 
public class WallExt2 extends Sprite implements IPosition
{
protected var left:Sprite=new Sprite();
protected var front:Sprite=new Sprite();
protected var top:Sprite=new Sprite();
protected var bottom:Sprite=new Sprite();
protected var back:Sprite=new Sprite();
protected var right:Sprite=new Sprite();
public function WallExt2(data:Vector.<Point>)
{
 
        _wallPoints=data;
 
        buttonMode=true;
 
        addEventListener(Event.ADDED_TO_STAGE,addedToStageHandler);
        addEventListener(Event.REMOVED_FROM_STAGE,removedFromStageHandler);
  }
private function drawContour():void
{
var wallRect:Rectangle=wallRectFromLine(_wallPoints);
var wallRotation:Number=Math2.radiansToDegrees(Math2.angle(_wallPoints[1],_wallPoints[0]));
 
wallSprite=new Sprite();
addChild(wallSprite);
 
wallSprite.x=_wallPoints[0].x;
wallSprite.y=_wallPoints[0].y;
wallSprite.rotationZ=wallRotation-90;
 
wallSprite.addChild(left);
wallSprite.addChild(front);
wallSprite.addChild(top);
wallSprite.addChild(bottom);
wallSprite.addChild(back);
wallSprite.addChild(right);
 
// LEFT
left.y=wallRect.height+_defaultStroke.weight;
left.z=numHeight+_defaultStroke.weight;
left.rotationZ=-90;
left.rotationX=-90;
 
_defaultStroke.apply(left.graphics);
left.graphics.beginFill(numBackgroundColor, numBackgroundOpacity);
left.graphics.drawRect(0,0,wallRect.height,numHeight);
left.graphics.endFill();
 
// FRONT
front.rotationX=90;
 
_defaultStroke.apply(front.graphics);
front.graphics.beginFill(numBackgroundColor, numBackgroundOpacity);
front.graphics.drawRect(0,0,_wallWeight,numHeight);
front.graphics.endFill();       
 
//  top
top.z=numHeight+_defaultStroke.weight;
 
_defaultStroke.apply(top.graphics);
top.graphics.beginFill(numBackgroundColor, numBackgroundOpacity);
top.graphics.drawRect(0,0,wallRect.width,wallRect.height);
top.graphics.endFill();
 
// BOTTOM
_defaultStroke.apply(bottom.graphics);
bottom.graphics.beginFill(numBackgroundColor, numBackgroundOpacity);
bottom.graphics.drawRect(0,0,wallRect.width,wallRect.height);
bottom.graphics.endFill();
 
// BACK
back.y=wallRect.height+_defaultStroke.weight;
back.rotationX=90;
 
_defaultStroke.apply(back.graphics);
back.graphics.beginFill(numBackgroundColor, numBackgroundOpacity);
back.graphics.drawRect(0,0,_wallWeight,numHeight);
back.graphics.endFill();
 
// RIGHT
 
right.x=_wallWeight;
right.y=wallRect.height+_defaultStroke.weight;
right.z=numHeight+_defaultStroke.weight;
right.rotationZ=-90;
right.rotationX=-90;
 
_defaultStroke.apply(right.graphics);
right.graphics.beginFill(numBackgroundColor, numBackgroundOpacity);
right.graphics.drawRect(0,0,wallRect.height,numHeight);
right.graphics.endFill();
 
right.buttonMode=true;
right.addEventListener(MouseEvent.MOUSE_OVER,rightOverHandler);
}
}

-------------------
Прошу простить - ошибка в ДНК оказывается - было mouseChildren=false


Часовой пояс GMT +4, время: 05:37.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.