Unknown
So, you wanna change the registration point of a MovieClip at runtime? Here is some piece of code that allows you to do just that.



Based on an old AS2 class written by Darron Schall, this AS3 class extends MovieClip and adds a new set of properties (x2, y2, rotation2, scaleX2, scaleY2, mouseX2, mouseY2) that allow you to manipulate the sprite based on a contextual registration point that can be set using the setRegistration method.



Here is how it works







// Create a new instance

var square:DynamicMovieClip = new DynamicMovieClip();

addChild(square);



// Change registration coordinates at runtime

square.setRegistration(20, 20);



// From this point on, instead of using 'rotation'

// we use 'rotation2'

// Same principle applies for 'x', 'y', 'scaleX' and 'scaleY'

square.rotation2 = 45;



Here's a simple application.



http://www.oscartrelles.com/examples/DynamicMovie.zip

Sources
0 Responses

Đăng nhận xét