0
votes

I created a movieclip symbol with multiple animated layers in flashcs5.5 that i need transfer to a programmer working in AS3. I need to define a registration (not transformation) point to either (0,0) or the exact center of the movie clip. the thing is, since the movie clip is animated, its dimensions changes depending on the specific frame i stand on in the timeline, so what i defined as center in the first frame, would not be so in a later one... to my understanding, this causes a lot of trouble positioning the movieclip on stage at AS3. how should approach this? do i define the registration point by the first frame? or the "largest" one? or simply by the middle frame of the time line in the movieclip?

any help would be much appreciated! (pls remember i'm an animator, and though i understand basic rules of AS3, i am not a programmer...)

1

1 Answers

0
votes

You could try something like:

//example point to (0,0)
changeRegistrationPoint(yourMovieClipInstanceName, 0, 0);
//example point to exact center (width/2, height/2)
changeRegistrationPoint(yourMovieClipInstanceName, yourMovieClipInstanceName >>1, yourMovieClipInstanceName >>1);


function changeRegistrationPoint(displayObject:DisplayObjectContainer, xPos:Number, yPos:Number):void 
{
    var rectangle:Rectangle = displayObject.getRect(displayObject);
    for (var i:int=0, displayObjectNumChildren = displayObject.numChildren; i < displayObjectNumChildren; i++) 
    {
        displayObject.getChildAt(i).x-=rectangle.x+xPos;
        displayObject.getChildAt(i).y-=rectangle.y+yPos;
    }
    displayObject.x+=rectangle.x+xPos;
    displayObject.y+=rectangle.y+yPos;
    rectangle = null;
}