dynamic registration point of flash

In flash, the display object has a lot of properties. Such as width, height, rotation, alpha and so on. Recently, i have been writting a class to control display object with dynamic registration. here is the demo: It takes me a lot of time. So i think I should recode something that you should pay attention to. 1: the registration point in mc is  always to be (0, 0). So, when you set the width/height/rotation property of a mc, the mc changes according to point(0, 0). To dynamic set registration point doesnot change the real registration point BUT let the mc looks like. 2:I change the x and y properties of the mc to let it look like been changed registration point: //dynamic set mc's registration point to (20, 20); var globalPoint:Point = mc.localToGlobal(new Point(20, 20)); //control the mc. mc.width += 100; mc.height += 50; mc.rotaion += 10; //move mc to fit the original point var nowGlobalPoint:Point = mc.localToGlobal(new Point(20, 20)); mc.x += globalPoint.x - nowGlobalPoint.x; mc.y += globalPoint.y - nowGlobalPoint.y; 3:the flex component is not so easy to do that. You must notice that. When you change the component's properties(width/height/rotation...), the component do update immediately. So, the code here is just for flash. 4:size control of mc. get the original size of mc: var size:Rectangle = mc.getRect(mc); get current size of mc: var tmp:Number = mc.rotation; mc.rotation = 0;//make sure the mc's rotation property is 0 var currentSize:Rectangle = mc.getRect(mc.parent); mc.rotation = tmp; set the mc's size: var tmp:Number = mc.rotation; mc.rotation = 0; mc.width += 30; mc.height = 50; mc.rotation = tmp; 5:scale and size is the same thing in flash. That is, if you change the mc's width/height, the scaleX /scaleY will change too. But to flex components, it's not. 6:the simplest way to change the rotation property of a mc accoding to you mouse position is that: var rp:Point = mc.localToGlobal(new Point(0, 0)); var ro:Number = Math.atan2(stage.mouseY - rp.y, stage.mouseX - rp.x); mc.rotation = Math.round(ro / Math.PI * 180)  [ + N];// N is a indent value. …… be careful...

转载于:https://www.cnblogs.com/laan860102/archive/2008/12/10/1509260.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值