• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Centering the registration point in pure as3

Community Beginner ,
Aug 09, 2012 Aug 09, 2012

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

TOPICS
ActionScript

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 09, 2012 Aug 09, 2012

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;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 10, 2012 Aug 10, 2012

Copy link to clipboard

Copied

Thanks a lot. Worked like a charm!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2012 Aug 10, 2012

Copy link to clipboard

Copied

LATEST

you're welcome.

p.s. please mark helpful/correct responses.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines