i’m trying to make a little nav system where the buttons are mcs and are arranged horizontally. when you click on a button it moves to the first position and the button that was originally in the first position switches places with it.
i think i’ve just about got it and am using a custom function to move the clips. I can’t seem to get the first clip to switch places though.
my AS:
//this is on each mc
on(release){
if(this.newposition!=1){
positionclicked=this._x;
trace(positionclicked);
trace(_root.movieclip1);
_root.movieclip1.flyTo(positionclicked, 178, 2.4, 1);
this.flyTo(145, 178, 2.4,1);
this.newposition=1;
_root.movieclip1="blue";
}
}
the only difference is where I set the _root.movieclip1=“blue” which is the instance name of this clip. I change it to be “red” for the red clip, etc.
the variables trace okay but passing the “positionclicked” variable to the flyTo function on movieclip1 doesn’t seem to be working…
arrgghhh… am I even doing this the right way ?
here’s the function that moves the clips if you’re interested (i didn’t write it)
//flyTo prototype created by Brendan Dawes & Andy Beaumont
MovieClip.prototype.flyTo = function(targetX,targetY,startSpeed,precision){
if(this.moveProto.targetX == null){
this.createEmptyMovieClip("moveProto",this.depthCount+1);
++this.depthCount;
};
this.moveProto.targetX = targetX;
this.moveProto.targetY = targetY;
this.moveProto.startSpeed = startSpeed;
this.moveProto.precision = precision;
this.moveProto.onEnterFrame = function(){
if(Math.abs(this._parent._x - targetX) < precision && Math.abs(this._parent._y - targetY) < precision){
this._parent._x = targetX;
this._parent._y = targetY;
removeMovieClip(this);
}
this._parent._x -= (this._parent._x - targetX)/startSpeed;
this._parent._y -= (this._parent._y - targetY)/startSpeed;
}
}
blue.newposition=1;
pink.newposition=2;
orange.newposition=3;
red.newposition=4;
green.newposition=5;
_root.movieclip1="blue";
trace(movieclip1);
stop();