# Hide MC using action scripting?

**URL:** <https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899>\
**Category:** Uncategorized\
**Created:** [December 20, 2002, 4:03pm UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899 "2002-12-20T16:03:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![blurqueen](https://avatars.discourse-cdn.com/v4/letter/b/8797f3/32.png) [@blurqueen](https://forum.kirupa.com/u/blurqueen)\
**Post date:** [December 20, 2002, 4:03pm UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/1 "2002-12-20T16:03:45Z")

</div>

Hi all,  
does anyone knows how i am able to hide a MC on the stage when i click a button  
and how i can make it visible by clicking another?

i cannot do this by telling them to goto frames becoz that will mess up my other functions.

can this be done using simple actionscripting?

any tutorials / sample files would be appreciated.

thanks…

flash 5 user

---

<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:** [December 20, 2002, 4:14pm UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/2 "2002-12-20T16:14:25Z")

</div>

Just place these actions on your buttons and give your MC a instance name of “myMC”  
Button 1

```php

on (release){
	myMC._alpha = 0
}

```

Button 2

```php

on (release){
	myMC._alpha = 100
}

```

---

<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:** [December 20, 2002, 7:46pm UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/3 "2002-12-20T19:46:26Z")

</div>

You can change the alpah but that will mean it still exists o nyour stage. IF you want it truely gone use the \_visable property.

on (release){  
myMC.\_visible = flase; //Hides the MC  
}

on (release){  
myMC.\_visible = true; // Shows the MC  
}

If you have a lot of objects on the screen this is best because it frees up some proccessor power for other things.

---

<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:** [December 21, 2002, 6:57am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/4 "2002-12-21T06:57:10Z")

</div>

I see…thanks for all your help, i’ll try it out  
\<:} \<:} 🙂 🙂

---

<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:** [December 21, 2002, 6:58am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/5 "2002-12-21T06:58:53Z")

</div>

Yes, the \_visible way is more effective. I read somewhere on this forum (I believe from david) that if you alpha something to 0, it can still be seen on machines that have low res and color monitors. (vaguely, but it is still there).

Of so I have read somewhere.

---

<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:** [December 21, 2002, 7:15am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/6 "2002-12-21T07:15:08Z")

</div>

how can i make it do a gradual fade like from 0 alpha to 100 alpha

---

<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:** [December 21, 2002, 7:17am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/7 "2002-12-21T07:17:25Z")

</div>

```auto
onClipEvent (load) {
this._alpha = 0;
}
onClipEvent (enterFrame) {
this._alpha += 5;
if (this._alpha >= 100){
this._alpha = 100;
}

```

---

<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:** [December 21, 2002, 7:19am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/8 "2002-12-21T07:19:48Z")

</div>

thank you

---

<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:** [December 21, 2002, 7:20am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/9 "2002-12-21T07:20:49Z")

</div>

No problem 😉

---

<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:** [December 21, 2002, 7:24am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/10 "2002-12-21T07:24:49Z")

</div>

one problem  
it doesnt 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:** [December 21, 2002, 7:26am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/11 "2002-12-21T07:26:42Z")

</div>

OOOPS, it would help to close the if statement I think.

That is what I get for typing it up in here :-\

```auto
onClipEvent (load) {
	this._alpha = 0;
}
onClipEvent (enterFrame) {
	this._alpha += 5;
	if (this._alpha>=100) {
		this._alpha = 100;
	}
}

```

---

<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:** [December 21, 2002, 7:28am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/12 "2002-12-21T07:28:02Z")

</div>

■■■■ now i feel stupid for missing that  
thank you 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:** [December 21, 2002, 7:28am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/13 "2002-12-21T07:28:58Z")

</div>

No problem.

I feel stupider for forgetting to close it in the first place 😛

---

<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:** [December 21, 2002, 7:32am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/14 "2002-12-21T07:32:29Z")

</div>

It is a slow night, and I am bored, so while I am at it, to fade it in and out, you can do this…

```auto
onClipEvent (load) {
	this._alpha = 0;
	trigger = 0;
}
onClipEvent (enterFrame) {
	if (trigger == 0) {
		this._alpha += 5;
		if (this._alpha>=100) {
			this._alpha = 100;
			trigger = 1;
		}
	}
	if (trigger == 1) {
		this._alpha -= 5;
		if (this._alpha<=0) {
			this._alpha = 0;
			trigger = 0;
		}
	}
}

```

---

<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:** [December 21, 2002, 7:39am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/15 "2002-12-21T07:39:27Z")

</div>

omg you wer reading my mmind  
i was trying to figure out how to make it do that with like a for loop and if then statements  
lol much easier  
thanks yet 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:** [December 21, 2002, 7:53am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/16 "2002-12-21T07:53:13Z")

</div>

No problem, it sounds like you were going about it wrong anyway 🙂

Ok, I am still bored so… If you wanted it to look like a ball bouncing as seen from directly above, you could do this…

```auto
onClipEvent (load) {
	this._alpha = 0;
	trigger = 0;
	this._xscale = this._yscale=0;
}
onClipEvent (enterFrame) {
	if (trigger == 0) {
		this._alpha += 5;
		this._xscale = this._yscale += 5;
		if (this._alpha>=100 && (this._xscale && this._yscale)>=100) {
			this._alpha = 100;
			this._xscale = this._yscale=100;
			trigger = 1;
		}
	}
	if (trigger == 1) {
		this._alpha -= 5;
		this._xscale = this._yscale -= 5;
		if (this._alpha<=0 && (this._xscale && this._yscale)<=0) {
			this._alpha = 0;
			this._xscale = this._yscale=0;
			trigger = 0;
		}
	}
}

```

---

<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:** [December 21, 2002, 7:56am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/17 "2002-12-21T07:56:12Z")

</div>

wow thas a cool effect  
thanks again:)

now make it rotae and sing the national anthem:crazy:

---

<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:** [December 21, 2002, 8:00am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/18 "2002-12-21T08:00:44Z")

</div>

Wait, I updated the code…

```auto
onClipEvent (load) {
	trigger = 0;
	assets = this._xscale=this._alpha=this._yscale=0;
}
onClipEvent (enterFrame) {
	if (trigger == 0) {
		this._xscale = this._alpha=this._yscale += 5;
		if ((this._alpha>=100 && this._xscale && this._yscale)>=100) {
			assets = 100;
			trigger = 1;
		}
	}
	if (trigger == 1) {
		this._xscale = this._alpha=this._yscale -= 5;
		if ((this._alpha && this._xscale && this._yscale)<=0) {
			assets = 0;
			trigger = 0;
		}
	}
}

```

As for rotating, I can do that. Singing the national anthem I cannot do. Unless you have a .mp3 of it…lol.

---

<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:** [December 21, 2002, 8:05am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/19 "2002-12-21T08:05:17Z")

</div>

Here it is with rotation…lol.

```auto
onClipEvent (load) {
	trigger = 0;
	assets = this._xscale=this._alpha=this._yscale=0;
}
onClipEvent (enterFrame) {
	this._rotation += 10;
	if (trigger == 0) {
		this._xscale = this._alpha=this._yscale += 5;
		if ((this._alpha>=100 && this._xscale && this._yscale)>=100) {
			assets = 100;
			trigger = 1;
		}
	}
	if (trigger == 1) {
		this._xscale = this._alpha=this._yscale -= 5;
		if ((this._alpha && this._xscale && this._yscale)<=0) {
			assets = 0;
			trigger = 0;
		}
	}
}

```

WHY AM I SO BORED!?!?!?!

It is 3:00am…lol. I am not even tired.

---

<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:** [December 21, 2002, 8:09am UTC](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899/20 "2002-12-21T08:09:58Z")

</div>

aww man i got my hopes all up to man  
oh well

j/p man very nice job

how can i make the background change color

[Next page](https://forum.kirupa.com/t/hide-mc-using-action-scripting/9899.md?page=2)
