Hide MC using action scripting?

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

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


on (release){
	myMC._alpha = 0
}

Button 2


on (release){
	myMC._alpha = 100
}

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.

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

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.

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

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

thank you

No problem :wink:

one problem
it doesnt work

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

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

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

■■■■ now i feel stupid for missing that
thank you again

No problem.

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

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…

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

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

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

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…

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

wow thas a cool effect
thanks again:)

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

Wait, I updated the code…

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.

Here it is with rotation…lol.

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.

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