Skip navigation
chipmunk{}{}
Currently Being Moderated

Centering the registration point in pure as3

Aug 9, 2012 10:49 AM

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

 
Replies
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 9, 2012 11:03 AM   in reply to chipmunk{}{}

    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;

    }

     
    |
    Mark as:
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Aug 10, 2012 9:26 AM   in reply to chipmunk{}{}

    you're welcome.

     

    p.s. please mark helpful/correct responses.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points