# Why don't you fade?

**URL:** https://forum.kirupa.com/t/why-dont-you-fade/117034
**Category:** Uncategorized
**Created:** [July 23, 2004, 4:30pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034 "2004-07-23T16:30:43Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 8:28pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/21 "2004-07-23T20:28:00Z")

</div>

> [@2nd day](#):
>
> Thanks a lot!! Again! You sure helped me today! Thanks

a pleasure

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 8:42pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/22 "2004-07-23T20:42:42Z")

</div>

> [@stringy](#):
>
> a pleasure

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 8:54pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/23 "2004-07-23T20:54:19Z")

</div>

yeah that’s the problem, do you know how to fix it?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 9:12pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/24 "2004-07-23T21:12:40Z")

</div>

> [@2nd day](#):
>
> 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 don`t need so i`ve 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);  
}  
};

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 9:22pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/25 "2004-07-23T21:22:01Z")

</div>

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

```auto

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?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 9:33pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/26 "2004-07-23T21:33:00Z")

</div>

> [@2nd day](#):
>
> Another great solution by stringy!! 😃

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 9:43pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/27 "2004-07-23T21:43:36Z")

</div>

> [@stringy](#):
>
> 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…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 9:56pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/28 "2004-07-23T21:56:09Z")

</div>

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!!)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 10:00pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/29 "2004-07-23T22:00:46Z")

</div>

> [@2nd day](#):
>
> label -\> like giving them an instance name? They already have an instance name…

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);  
};  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 10:07pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/30 "2004-07-23T22:07:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 10:13pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/31 "2004-07-23T22:13:16Z")

</div>

> [@2nd day](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 23, 2004, 10:30pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/32 "2004-07-23T22:30:58Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 5:14am UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/33 "2004-07-24T05:14:42Z")

</div>

> [@2nd day](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 10:15am UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/34 "2004-07-24T10:15:50Z")

</div>

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

```auto

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

```

to

```auto

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!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 11:22am UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/35 "2004-07-24T11:22:31Z")

</div>

> [@2nd day](#):
>
> 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
> 
> ```auto
> 
> if (this._x == this.startX) {
> for (var j = this.ivar; j<startArray.length; j++) {
> move(startArray[j], startArray[j].endX);
> }
> 
> ```
> 
> to
> 
> ```auto
> 
> 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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 12:19pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/36 "2004-07-24T12:19:23Z")

</div>

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.

```auto

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

```auto

 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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 12:38pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/37 "2004-07-24T12:38:50Z")

</div>

> [@2nd day](#):
>
> 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.
> 
> ```auto
> 
> 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
> 
> ```auto
> 
> 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?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 1:23pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/38 "2004-07-24T13:23:43Z")

</div>

yep here it is!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 1:48pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/39 "2004-07-24T13:48:08Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 2:17pm UTC](https://forum.kirupa.com/t/why-dont-you-fade/117034/40 "2004-07-24T14:17:25Z")

</div>

> [@2nd day](#):
>
> yep here it is!

still not sure what you are trying to do,when you say name =this.txt are you trying to make the text on the main buttons disappear and then fade in?

[Previous page](https://forum.kirupa.com/t/why-dont-you-fade/117034.md?page=1)

[Next page](https://forum.kirupa.com/t/why-dont-you-fade/117034.md?page=3)
