PDA

View Full Version : A Button to Disappear a MovieClip



Shertok
January 17th, 2010, 07:59 PM
I would appreciate any help!!

I have a button and 2 MovieClips, I am trying by clicking on a button to make one of them to be alpha=0. The result I keep getting is disappearing of all.

These 2 MovieClips are on the same frame (different layers).

The code that I have:
second_btn. addEventListener(MouseEvent.CLICK, getSecondMovie);

function getSecondMovie(e:MouseEvent):void
{
gotoAndStop("seconMovie");
if (getSecondMovie, "firstMovie" alpha = 0);

}

I hope I made myself clear, thanks in advance.

Shaedo
January 17th, 2010, 11:00 PM
To do what you have described: In general what you need to do is give your movie clip and instance name (say 'myMovieClip')
Then, as you have done create a event listener for your button that will trigger a function

second_btn. addEventListener(MouseEvent.CLICK, changeAlphaValue);
and then create a function like below

function changeAlphaValue(e:MouseEvent):void
{
myMovieClip.alpha = 0;
}


does this make sense?


Looking at you code: Your 'if' statement is broken. What it is doing is:

first is checks if getSecondMovie exists:

if(getSecondMovie
If this is true then it moves onto the next part of the if statement

"firstMovie"alpha = 0) This is just wrong.
you are kind of assigngin "firstMovie" alpha to equal 0 but it wont even do that.
finally you end with a semicolon which will terminate the if statement.

What you might want is

if(getSecondMovie)
{
firstMovie.alpha = 0;
}

Luck,
S.

Shertok
January 18th, 2010, 01:05 AM
Thank you so much Shaedo, your answer helped me to solve this issue, but new problems raised...