我有一个关于如何转换父影片剪辑而不是子影片剪辑的问题...我有一个影片剪辑,其中包含一个图像加载器和一些句柄作为影片剪辑。影片剪辑句柄用于侦听鼠标事件以执行缩放父影片剪辑的旋转和平移等功能。这里的问题是,当我缩放或旋转动画剪辑时,手柄也会旋转和缩放,尽管我希望它在父动画剪辑旋转时跟随父动画剪辑,但我不希望手柄也缩放。
有没有办法避免手柄缩放。
谢谢
我有一个关于如何转换父影片剪辑而不是子影片剪辑的问题...我有一个影片剪辑,其中包含一个图像加载器和一些句柄作为影片剪辑。影片剪辑句柄用于侦听鼠标事件以执行缩放父影片剪辑的旋转和平移等功能。这里的问题是,当我缩放或旋转动画剪辑时,手柄也会旋转和缩放,尽管我希望它在父动画剪辑旋转时跟随父动画剪辑,但我不希望手柄也缩放。
有没有办法避免手柄缩放。
谢谢
尝试这个:
inside_mc.addEventListener(Event.ENTER_FRAME, function(){
inside_mc.scaleX = 1/inside_mc.parent.scaleX;
inside_mc.scaleY = 1/inside_mc.parent.scaleY;
});
If you're not stuck with that structure I would just rearrange things. For example, I would build it sort of like this:
- container
- handles
- image loader
This way you only have to worry about placing the handles in the correct places rather than dealing with scaling issues.
If you have to maintain the same structure, then you'll need to set the handles scale to be the inverse of the scale of the parent. For example, if the parent's scale was 2, you'd want the handle's scale to be 0.5. So all you have to do to calculate the handle's scale is to divide 1 by the parents scale.
您所描述的是更复杂的方法,它不会精确地调整大小/重新定位,并且占用更多 CPU。最好的方法(顺便说一句,在我睡觉的时候找我)是创建一个新的孩子,称之为 backgroundMC(名字应该清楚)并调整背景MC,而不是父母。父窗口会自动调整大小,但子窗口不会缩放
set height
and函数(你也可以这样做)。set width
scaleX
scaleY
scaleX
(for width)或scaleY
(for height)设置为1./scaleX
(width)或1./scaleY
(height)那很简单。
在 onEnterFrame 处理程序或类似的设置 scaleX 和 scaleY 为 1/(parent.scaleX) 和 1/(parent.scaleY)。