Scripted mc registration point

I’m importing an image that I’ll use as my pointer(arrow) in a speedometer.
My problem is that I need to manually set the movieClip’s registration point so that I’ll get the rotation right.

If I manually drag the image on stage and use F8 to convert it to a MovieClip, I can set the registration point in the dialog box popping up. The only thing I’m trying to do is just that, **[COLOR=black]but [/COLOR]**with ActionScript since I create this thingie dynamically :sleep:

See attachment for more details :slight_smile:

Any suggestions?

You’ll have to make the content of the movie clip into a movie clip, then align that relative to its parent movie clip.

Hey TheCanadian, and thanks for taking time to help me out! :smiley:
I didn’t quite get that I’m afraid. Please have a look at the code below:

class speedometer {
    private static var target_mc:MovieClip;
    private static var container_mc:MovieClip;
    
    private static var bgImg:String;
    private static var pointerImg:String;
    
    /* ---------- CONSTRUCTOR ---------- */
    public function speedometer(c:MovieClip, i:String, p:String){
        container_mc = c;
        bgImg = i;
        pointerImg = p;
        
        setBackground(bgImg, pointerImg);
    }
    
    /* ---------- FUNCTION: setBackground ---------- */
    private function setBackground(bgImg:String, pointerImg:String):Void {
        container_mc.createEmptyMovieClip("background_mc", 1);
        container_mc.background_mc.loadMovie(bgImg, this);
        
        container_mc.createEmptyMovieClip("p_mc", 2);
        container_mc.p_mc.loadMovie(pointerImg, this);
        
        container_mc.p_mc._x = 150;
        container_mc.p_mc._y = 180;
    }    
}

When the p_mc is created, I try to rotate it by using:

container_mc.p_mc._rotation = 45;

This works, but it rotates it from the top registration point, not the bottom one - which is, like you already know, where the problem lies :smiley:

One last thing though. I create a new speedometer object this way (from the FLA file):

var bgImage:String = "img/someImage.jpg";
var pointerImage:String = "img/someImage.gif";
var speedo:speedometer = new speedometer(this, bgImage, pointerImage);

And there’s pretty much everything! Thanks again.