Reputation: 5386
I'm trying to see if there's a way to change the registration point of a MovieClip that's importing an image dynamically?
Here is my code where I add an image to an "overlayHolder":
overlayBitmap = _loader.getBitmap( _data.id + "-overlay_image" );
overlayHolder.addChild(overlayBitmap);
overlayHolder.x = _data.overlay_left;
overlayHolder.y = _data.overlay_top;
What I need to do is rotate this image later on, upon interaction from someone, but need it to rotate with a center-registration.
I've seen a bunch of tutorials/forums talk about centering a registration point when you're drawing a Sprite on the stage, but not when you're importing an image.
Any help would be appreciated.
Thanks in advance!
Upvotes: 1
Views: 360
Reputation: 5386
So, i figured it out, and thought I'd share:
You can create a Sprite, that's inside of your MovieClip and move that to where it should be.
Something like this:
overlayBitmap = _loader.getBitmap( _data.id + "-overlay_image" );
overlayHolder.x = _data.overlay_left;
overlayHolder.y = _data.overlay_top;
overlayHolderInner = new Sprite();
overlayHolder.addChild(overlayHolderInner);
overlayHolderInner.addChild(overlayBitmap);
overlayHolderInner.x = 0-(overlayHolderInner.width/2);
overlayHolderInner.y = 0-(overlayHolderInner.height/2);
Thought I'd share in case anyone runs into this.
Upvotes: 1