![]() |
|
||||||||||
|
|||||
|
Регистрация: Dec 2011
Сообщений: 2
|
Доброе всем.
Правлю код, позволяющий вращать стрелку часов arrow вручную. mouseTarget - вспомогательный ролик, помогающий вращать стрелку. На нулевом слое нарисован цифеблат и задний фон. //calculates degrees rotation from y-axis based on target & origin point coordinates function getCurrentAngle(target_x, target_y, origin_x, origin_y) { xChange = target_x-origin_x; yChange = target_y-origin_y; if (xChange<0) { xChange_pos = Number(-1*xChange); } else { xChange_pos = Number(xChange); } if (yChange<0) { yChange_pos = Number(-1*yChange); } else { yChange_pos = Number(yChange); } convert = 57.2957795; if (xChange>0 && yChange>0) { angle = (convert*Math.atan(xChange_pos/yChange_pos)); } if (xChange>0 && yChange<0) { angle = (convert*Math.atan(yChange_pos/xChange_pos))+90; } else if (xChange<0 && yChange<0) { angle = (convert*Math.atan(xChange_pos/yChange_pos))+180; } else if (xChange<0 && yChange>0) { angle = (convert*Math.atan(yChange_pos/xChange_pos))+270; } return angle; } //to find the x & y edges of an object, regardless of shape or rotation function getEdges() { leftEdge = _parent._x-Number(_parent._width)/2; rightEdge = _parent._x+Number(_parent._width)/2; topEdge = _parent._y-Number(_parent._height)/2; bottomEdge = _parent._y+Number(_parent._height)/2; } //mouseTarget mc gets dragged by the user's cursor, x & y coordinates will be used to calculate rotation arrow.onRollOver = function() { startDrag(_parent.mouseTarget, true); }; //rotates the mc arrow.onPress = function() { startAngle = getCurrentAngle(_parent.mouseTarget._x, _parent.mouseTarget._y, _x, _y); onEnterFrame = function () { newAngle = getCurrentAngle(_parent.mouseTarget._x, _parent.mouseTarget._y, _x, _y); changeAngle = startAngle-newAngle; getEdges(); if (leftEdge>0 && rightEdge<stageRight && topEdge>0 && bottomEdge<stageBottom) { _rotation = _rotation+changeAngle; } else { if (leftEdge<0 || rightEdge>stageRight || topEdge<0 || bottomEdge>stageBottom) { _rotation = _rotation+changeAngle; } } startAngle = Number(newAngle); }; }; //stops rotating the mc, and ensures that the edges of the clip are within the limits of the draggable area arrow.onRelease = allCorners.onReleaseOutside=function () { onEnterFrame = null; onEnterFrame = function () { getEdges(); if (leftEdge>0 && rightEdge<stageRight && topEdge>0 && bottomEdge<stageBottom) { onEnterFrame = null; } else { _parent._rotation = _parent._rotation-changeAngle; } }; }; Исходный код не мой, я его правлю. Не подскажете, где глюк? |
|
|||||
|
На первый взгляд, из-за этой замутенины с парентами, точно где-то случайно выходиш на _root. и вращаеш всю сцену.
Скорее всего сдесь:
__________________
Дети не должны знать о своих родителях |
|
|||||
|
Регистрация: Dec 2011
Сообщений: 2
|
И впрямь.
Спасибо. |
![]() |
![]() |
Часовой пояс GMT +4, время: 17:36. |
|
|
« Предыдущая тема | Следующая тема » |
|
|