Why don't you fade?

Allright, another problemā€¦ this is very hard to explainā€¦ so here is the .fla The problem is about the menu collaps backā€¦ play with the menu and youā€™ll see what i meanā€¦

a pleasure

do you mean that you want the buttons to go back to their original position if pressed again

yeah thatā€™s the problem, do you know how to fix it?

this is a way without rewriting your functions altogether, you have stuff in your move function which you dont need so ive taken the liberty of removing
function move(obj, endx) {
obj.onEnterFrame = function() {
speed = 10;
x = endx-this._x;
this._x += x/speed;
if (this._x == endx) {
delete this.onEnterFrame;
}
};
}

then for one of your buttons
BIO.onRelease = function() {
if (this.pressed == false) {
this.pressed = true;
} else {
(this.pressed=false);
}
if (!this.pressed) {
move(PICS, 500, 184);
move(MAIL, 592, 276);
move(LINKS, 684, 368);
} else {
move(PICS, 184, 500);
move(MAIL, 276, 592);
move(LINKS, 368, 684);
}
};

Another great solution by stringy!! :smiley:
But inst there a shorter way for


BIO.onRelease = function() {
if (this.pressed == false) {
this.pressed = true;
} else {
(this.pressed=false);
}
if (!this.pressed) {
move(PICS, 500, 184);
move(MAIL, 592, 276);
move(LINKS, 684, 368);
} else {
move(PICS, 184, 500);
move(MAIL, 276, 592);
move(LINKS, 368, 684);
}
};

because this is nearly 3 times more scripting then before? cant this be 1 function or something?

well at least you have got the hang of functions quickly.
If i were making something like this from scratch, i`d label the buttons btn0,btn1,btn2 etc and then put them in an array and just loop through the array. Much less code but not really any better.

label -> like giving them an instance name? They already have an instance nameā€¦

I discovered that your code didnā€™t work correctly, sometimes you have to click 2 times before something moves. I want that, if you click bio pics,mail and links will move to the right and then if you click bio again OR if you click for example mail from the menu pics and mail go back to their original place and links stays at the right side. Do you know what i mean and do you think that is possible without rewriting the whole code?

(Everybody is welcome to help, not only stringy!!)

yes i know, but if you label them like i said, it is easier to loop through them and also easier to follow what is going on if you put them in an array.
for example
6 movieclips labelled btn0,btn1,btn2ā€¦
numbbut = 6

for (var i = 0; i<numbbut; i++) {
this[ā€œbtnā€+i].onPress = function() {
this.pressed = true;
trace(this.pressed);
};
}

But what should i do then with the move function when i use the loop (if itā€™s a very obvious answer, itā€™s getting lateā€¦)

Because I read the button text from a label iā€™m putting these in an array too so i can use the array for the .onPress

if you can wait while tomorrow, i`ll remake it for you but its late here too.

Thanks alot! I already have the array for the names ready, so everything is ready except the moving part.

on each of the buttons add
on (releaseOutside) {
fade();
}
on the main timeline

function init() {
speed = 5;
numbbut = 5;
gap = 100;
startArray = ;
for (var i = 0; i<numbbut; i++) {
this[ā€œbtnā€+i].ivar = i;
this[ā€œbtnā€+i].startX = this[ā€œbtnā€+i]._x;
this[ā€œbtnā€+i].endX = this[ā€œbtnā€+i].startX+gap;
startArray.push(this[ā€œbtnā€+i]);
}
}
init();
for (var i = 0; i<startArray.length; i++) {
startArray*.onPress = function() {
if (this._x == this.startX) {
for (var j = this.ivar; j<startArray.length; j++) {
move(startArray[j], startArray[j].endX);
}
} else if (this._x == this.endX) {
for (var k = this.ivar; k>-1; kā€“) {
move(startArray[k], startArray[k].startX);
}
}
};
}
function move(obj, targetx) {
obj.onEnterFrame = function() {
x = targetx-this._x;
this._x += x/speed;
if (Math.abs(targetx-this._x)<1) {
this._x = targetx;
delete this.onEnterFrame;
}
};
}

Seems to be working ok and we have retained your function.
Time for work.

if you click on a button the buttons goes to the right aswell, i dont know if that was what you wanted, but i changed (a little tiny bit) of your code, so it looks like i want it to look. iā€™ve changed this


if (this._x == this.startX) {
for (var j = this.ivar; j<startArray.length; j++) {
move(startArray[j], startArray[j].endX);
}

to


if (this._x == this.startX) {
for (var j = this.ivar+1; j<startArray.length; j++) {
move(startArray[j], startArray[j].endX);
}

so if you click know, the clicked button wonā€™t go to the right, but i guess you could figured this out by yourself. But thanks for all this scripting again!

yeh i wasn`t really sure exactly what you wanted but glad you figured it out on your own.

well now iā€™m about to make submenuā€™sā€¦ so here is another problem: iā€™ve made a function (againā€¦) and again it doesnā€™t work.


function submenu(loc) {
	setProperty(loc, _visible, true);
	loc.onEnterFrame = function() {
		trace("boe");
		this._alpha = this._alpha + 2;
		if (this._alpha>=100) {
			delete this.onEnterFrame;
		}
	};
}

well, the making visible works, but then it wont do the onEnterFrame function! the function wont start! and i dont get it because this


 function move(obj, targetx) {
	obj.onEnterFrame = function() {
		x = targetx-this._x;
		this._x += x/speed;
		if (Math.abs(targetx-this._x)<1) {
			this._x = targetx;
			delete this.onEnterFrame;
		}
	};
}

DOES work. and it seems like almost the same code to me.

Any chance of uploading the file?

yep here it is!

Also i would like the gap to depend on the button you clickedā€¦ i tried a lot, but nothing works.