Copy link to clipboard
Copied
Hi
Is there a way to centre or for that matter change the registration point of a dynamically loaded movieClip.
It is pretty simple to do it on stage, but in pure as3, there seems to be no obvious way.
Thanks
Copy link to clipboard
Copied
you can use changeRegPt to change the registration point of any displayobject:
changeRegPt(mc,mc.width/2,mc.height/2);
function changeRegPt(dobj:DisplayObjectContainer,x:Number,y:Number){
var r:Rectangle = dobj.getBounds(dobj);
for(var i:uint=0;i<dobj.numChildren;i++){
dobj.getChildAt(i).x -= r.x+x;
dobj.getChildAt(i).y -= r.y+y;
}
dobj.x += r.x+x;
dobj.y += r.y+y;
}
Copy link to clipboard
Copied
Thanks a lot. Worked like a charm!!!
Copy link to clipboard
Copied
you're welcome.
p.s. please mark helpful/correct responses.