Initiate Actions Based on _x?

Ok…after several hours tinkering I’ve set up a movie to initiate a set of actions triggered by a movieclips _x position. Im using Math.round to keep my intergers whole and im using ease on my movie clip. If the movie clip starts at 0,0 and the buttons are hit 1,2,3,4 everything is fine, but hit the buttons out of order (2,4,1,3) or set the start point of the mc to anything but 0,0 and the movie becomes a mess.

I don’t understand what im doing wrong. I tried some simple loop commands and my comp just locked up repeatedly so I broke down and used frameloops, it’s closer to complete but still so far.

I’ve attached a my test document. Any help would be greatly appreciated.

Take Care,
John

Sorry but i don’t see whats wrong? Can you please explain the problem again :-/

The _x position needs to be…
30 to initiate the home actions.
-620 to initiate the about actions.
-1280 to initiate the portfolio actions.
-1930 to initiate the contact actions.

when script moves the my MC from right to left everything is fine but to go from left to right the x position is off by 4 pixels. The text field with the number is a trace for the x position. Check it out you’ll see what I mean.

Thanks for taking the time to look.

Heres my mc code

onClipEvent (load) {
	new_posi = _x;
	ease = 5;
}
onClipEvent (enterFrame) {
	_x += Math.floor((new_posi-_x)/ease);
}

my function

function sectionopen() {
	if (_root.sectionName == "home") {
		_root.section.new_posi = 30;
	}
	if (_root.sectionName == "about") {
		_root.section.new_posi = -620;
	}
	if (_root.sectionName == "portfolio") {
		_root.section.new_posi = -1280;
	}
	if (_root.sectionName == "contact") {
		_root.section.new_posi = -1930;
	}
}

example of the button scripts

on (press) {
	_root.sectionName = "home";
	_root.sectionopen();
	_root.gotoAndPlay("home");
}

example of my timeline loop

new_posi = _root.section._x;
this.xplacement.text = new_posi;
trace(new_posi);
if(_root.section._x <> 30){
	_root.section.home._visible = false;
	_root.gotoAndPlay(11);
} else if(_root.section._x == 30){
		_root.section.home._visible = true;
			_root.gotoAndStop(10);
}

:jail:
-John

Anybody? ;(

wats interesting is that wen u try and go from right to left, it keeps repeating wer its at - look at your trace the scrollbar gets smaller and smaller…

replace your mc AS with this and it works: [AS]onClipEvent (load) {
new_posi = _x;
ease = 5;
}
onClipEvent (enterFrame) {
_x += (new_posi-_x)/ease;
if(new_posi<_x && (new_posi-_x)> -0.5){
_x = new_posi
}
if(new_posi>_x && (new_posi-_x)< 0.5){
_x = new_posi
}
}[/AS] but its a little slower getting there and it jumps a little (to do with the ‘buffer’ - the if(new_posi>_x && (new_posi-_x)< 0.5){_x = new_posi} bit) but this is why it is at 0.5 and no bigger - it is harder to notice…
however to fix this, you CAN do this…
[AS]onClipEvent (load) {
new_posi = _x;
ease = 5;
}
onClipEvent (enterFrame) {
_x += (new_posi-_x)/ease;
if(new_posi<_x && (new_posi-_x)> -0.5){
_x = new_posi
}
if(new_posi>_x && (new_posi-_x)< 0.5){
_x = new_posi
}

 if(new_posi&gt;_x && (new_posi-_x)&lt; 4){
     easeVIncr = setInterval(easeIncr,20)
 }
 if(new_posi&lt;_x && (new_posi-_x)&gt; -4){
     easeVIncr = setInterval(easeIncr,20)
 }

}


 with a function in your first frame as

function easeIncr(){
ease = ease-0.2
}


 and remembering to clear the interval with your button code eg. 

on (press) {
_root.sectionName = “about”;
_root.sectionopen();
_root.gotoAndPlay(“about”);
clearInterval(easeVIncr)
}


 its not perfect but it aint too bad... and the main thing: it works...
 
 Prophet.
 
 EDIT:- oh and you may want to check those X values - i think they are a little off...