这个问题在QQ群中以及论坛中遇见了好多人在问,所以整理一下,发个贴出来。希望对一些新手有些帮助!以前我碰到这个问题就是直接打个包装MovieClip就不管了,但是对于要访问影片内部的子影片或者其他属性就麻烦了。因为路径改变了。
www.darronschall.com上有一个更好的方法: 通过静态类方法initialize将目标MC加上了几个新属性,_x2,_y2等等新的属性。然后呢,设定新的注册点坐标。 在我们操作_x2,_y2等属性时,实际上是执行了set_x2()等get,set函数,这些函数就执行了一些换算,将我们新设置的值_x2与新设置的注册点位置进行偏移折算,转换成了真正的_x值,这样target_mc就等到了转换之后的_x值,并执行了相应的变化。
以下内容来自http://www.darronschall.com/weblog/archives/000054.cfm 先点击此处下载工具类 然后,使用方法如下:
//使用前,先导入类 import com.darronschall.DynamicRegistration;
// Assume there is an instance named square_mc on the stage //你要操作的MC var square_mc:MovieClip;
// updated 7/28/05 - add the dynamic registration stuff at runtime to our square movieclip //使用DynamicRegistration初始化你的目标MC DynamicRegistration.initialize(square_mc);
// The square_mc has an original registration at 0,0 so // let's change that to 10, 60 at runtime. //输入新注册点的坐标 square_mc.setRegistration(10, 60);
// Now whenever we access a property of the square_mc that deals // with the registration point, use a "2" after the property name... // These are the available properties: //然后要操作这个MovieClip时就用如下的新属性来操作,只不过是在原来的尾部上加一个2 square_mc._x2 = 4; square_mc._y2 = 7; square_mc._rotation2 = 40; square_mc._xscale2 = 140; square_mc._yscale2 = 80; // square_mc._xmouse2 is readonly // square_mc._ymouse2 is readonly
|