Make MCs go to a certain location

Ok, so I have a button (called “MC_Star”) that can be dragged around, and when a certain other button is clicked, I want MC_Star to go from wherever it is to the top center, just out of frame. What I have now only allows it to move relative to where it is. Here’s the code:

//Enterframes
MC_Star.onLoad = function(){
    easeSpeed = 0; // the higher, the slower
    target_xscale = target_yscale=100; // start at a scale of 100%
};
MC_Star.onEnterFrame = function(){
    _xscale += (target_xscale - _xscale)/easeSpeed;
    _yscale += (target_yscale - _yscale)/easeSpeed;
};


//Functions

MovieClip.prototype.mfade = function(prop, de, rem) {
    this.onEnterFrame = function() {
        for (i in prop) {
            this* += (prop*-this*)/de;
        }
    
    };
};
MovieClip.prototype.aligncenter = function() {
    this.xt = Math.round(Stage.width/2-this._width/2);
    this.yt = Math.round(Stage.height/2-this._height/2) - 350;
    this.mfade({_x:this.xt, _y:this.yt}, 5);
};
MovieClip.prototype.stageresizealign = function(listenername) {
    this
[listenername] = new Object();
    this
[listenername].clip = this;
    this
[listenername].onResize = function() {
        this.clip.aligncenter();
    };
    Stage.addListener(this
[listenername]);

};
MC_Star.aligncenter();
MC_Star.stageresizealign("MC_Star");


stop();

I think I know WHERE the problem is, I’m just not sure how to make it do what I want. In the Functions section, MovieClip.prototype.aligncenter is what gives the location.

I thought by checking for the center of the stage, then telling the y to go up 350 pixels (WELL more than half the height of the stage), it would work, but rather the star simply moves over and up relative to its original position, not wherever its been dragged to.

How might I tell the star to go to a position on the stage, not relative to where it is or was?

I’m not sure if I understand your problem exactly, but telling it where to go is extremely simple. Just use something like:


otherbutton.onRelease = function(){
star._x = 0
star._y = 40
}

Yes, that is true, but I’m trying to get them to like, slide there, not just static jump.

I did figure it out, though, and your post was very helpful. I don’t know why I was trying to get all intense, calculating the stage width and such. I gave it regular coordinates, and combining that with changing all the buttons to movieclips (realized I could put button actions on movieclips, duh) instead of having buttons inside of my movieclips, and now it works! Here’s the final code for any future people with similar problems:

//Enterframes
MC_Star.onLoad = function(){
    easeSpeed = 0; // the higher, the slower
    target_xscale = target_yscale=100; // start at a scale of 100%
};
MC_Star.onEnterFrame = function(){
    _xscale += (target_xscale - _xscale)/easeSpeed;
    _yscale += (target_yscale - _yscale)/easeSpeed;
};


//Functions

MovieClip.prototype.mfade = function(prop, de, rem) {
    this.onEnterFrame = function() {
        for (i in prop) {
            this* += (prop*-this*)/de;
        }
    
    };
};
MovieClip.prototype.aligncenter = function() {
	this.xt = 352.1;
	this.yt = -80;
 this.mfade({_x:this.xt, _y:this.yt}, 5);
};
MovieClip.prototype.stageresizealign = function(listenername) {
    this
[listenername] = new Object();
    this
[listenername].clip = this;
    this
[listenername].onResize = function() {
        this.clip.aligncenter();
    };
    Stage.addListener(this
[listenername]);

};
MC_Star.aligncenter();
MC_Star.stageresizealign("MC_Star");


stop();

So yes, make sure you don’t have multiple layers of MCs and buttons and such if you’re going to execute this code, or it will all be relative to the position of the child element, not the actual movieclip you’re trying to control’s location.