Copy link to clipboard
Copied
Hi. I am trying to disable movieclips in my project but the movieclips are not function as button. It just simple box that I converted as movieclips. I tried to disable by using this way
xxxMC.visible = false;
however it still appears in my project when I run. Anyone can tell me the solution? Thank you in advance!
Copy link to clipboard
Copied
Hi.. If you want to disable it use:
xMC.enabled = xMC.mouseEnabled = false; //true to enable
you'll maybe need to set the mouseChildren property to false also:
xMC.enabled = xMC.mouseEnabled = xMC.mouseChildren = false;
xxxMC.visible = false; // it must be invisible except if you set the visible property to true in somewhere else..
EDIT
Copy link to clipboard
Copied
But it is not functioning as button. Should i stil use mouseEnabled ?
Copy link to clipboard
Copied
Yes it'll work on the buttons, movie clips, text fields and the sprites also.
Copy link to clipboard
Copied
I tried and I got this error
1120: Access of undefined property boxxcorrectq8aayat. |
Copy link to clipboard
Copied
Do you want to hide the movie clip only? if yes then use xMC.visible = false; only, and make sure that you're not setting it to true again in some other line or some loop function.
Copy link to clipboard
Copied
That if you want to disable the object but if it's not functioning as a button then it's already disabled so you don't need to use enabled & mouseEnabled properties.
Copy link to clipboard
Copied
Okay my project was supposed to work like when user click any provided buttons, there will be 2 boxes appear to indicate the right and wrong answer. And I want to make all the other buttons disable once user click any one of the provided button.
I managed to disable the button but the movie clips are still visible. So just now I tried your solution, and it give me the errors
Copy link to clipboard
Copied
Can you show the button code that you're trying to hide the mc through?
Copy link to clipboard
Copied
Sure. Here is my code.
answerq8aayat.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_65);
function fl_MouseClickHandler_65(event:MouseEvent):void
{
answerq8aayat.visible = true; //BUTTON
answerq8bayat.visible = true; //BUTTON
answerq8cayat.visible = true; //BUTTON
answerq8dayat.visible = true; //BUTTON
correctq8ayat.visible = false;
wrongq8ayat.visible = true;
boxxcorrect8aayat.visible = false; //MC
boxxwrongq8aayat.visible = true; //MC
boxxcorrect8bayat.visible = false; //MC
boxxcorrect8cayat.visible = false; //MC
boxxcorrect8dayat.visible = true; //MC
boxxwrongq8cayat.visible = false; //MC
boxxwrongq8dayat.visible = false; //MC
boxxwrongq8bayat.visible = false //MC
{
if(answerq8aayat.enabled = true)
//boxxwrongq8aayat.visible = boxxcorrect8dayat.visible = answerq8aayat.enabled = true;
boxxcorrectq8aayat.enabled = boxxcorrectq8aayat.mouseEnabled = boxxcorrectq8aayat. mouseChildren = boxxcorrectq8bayat.enabled = boxxcorrectq8bayat.mouseEnabled = boxxcorrectq8bayat. mouseChildren = false;
boxxcorrectq8cayat.enabled = boxxcorrectq8cayat.mouseEnabled = boxxcorrectq8cayat. mouseChildren = boxxcorrectq8dayat.enabled = boxxcorrectq8dayat.mouseEnabled = boxxcorrectq8dayat. mouseChildren = false;
}
Copy link to clipboard
Copied
The problem in the if statement you have to correct it as following:
function fl_MouseClickHandler_65(event:MouseEvent):void
{
answerq8aayat.visible = true; //BUTTON
answerq8bayat.visible = true; //BUTTON
answerq8cayat.visible = true; //BUTTON
answerq8dayat.visible = true; //BUTTON
correctq8ayat.visible = false;
wrongq8ayat.visible = true;
boxxcorrect8aayat.visible = false; //MC
boxxwrongq8aayat.visible = true; //MC
boxxcorrect8bayat.visible = false; //MC
boxxcorrect8cayat.visible = false; //MC
boxxcorrect8dayat.visible = true; //MC
boxxwrongq8cayat.visible = false; //MC
boxxwrongq8dayat.visible = false; //MC
boxxwrongq8bayat.visible = false //MC
if(answerq8aayat.enabled == true)
{
// hide the objects here use:
boxxcorrectq8bayat.visible = false;
trace("invisible"); // only to check if the code works.
}
}
That code will work but I think not as you want it to work, anyway try and tell me what happened.
Copy link to clipboard
Copied
Hi.. Ive tried the code you give. It works I supposed since there is no error indicate to that code. BUT. I cant try because there is one error with this code
1067: Implicit coercion of a value of type Boolean to an unrelated type flash.display:MovieClip. |
homeqz1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_774);
function fl_ClickToGoToScene_774(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(322, "celik bm");
}
var homee:Boolean = false;
homeqz1.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{
if(homee == false)
{
countdownTimer1.stop();
pausebtn1 = true; // ERROR HERE
}
}
Copy link to clipboard
Copied
Hi, The error says that the "homee" object is a MovieClip not a Boolean object, means homee value cannot be "false" or "true" like the Boolean object, The movie clip value is "MovieClip" and it has some properties, so if you want to check some property value you have to add it in the if statement:
if(homee.visible == false) // check the visibility of the homee mc if it's false (hidden)
{
//Do something
}
or:
if(homee.x >= 100) check the x axis of the homee mc if it's greater than or equal to 100
{
// Do something
}
Copy link to clipboard
Copied
Actually I have tried the code in new file project and it didnt have any problem. When I implemented the code into my project, then it shows the error. I dont understand why it happened since I have done everything accordingly. Besides, i dont understand why do i have to check the property value?
Copy link to clipboard
Copied
So what do you mean in if(homee == false)? do you mean if it's invisible?
Copy link to clipboard
Copied
what im trying to do here is when user click the 'homeqz1' button, the countdowntimer will stop and redirect the user back to home. The 'homee' is actually a variable (?)
Copy link to clipboard
Copied
What you're trying to do here (pausebtn1 = true;)?
Copy link to clipboard
Copied
Use one event listener and one function for the "homeqz1" button:
var homee:Boolean = false;
homeqz1.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{
if(homee == false)
{
countdownTimer1.stop();
homee = true;
MovieClip(root).gotoAndPlay(322, "celik bm");
}
}
// Add this code in the main timeline to resume the countdownTimer1
if(xMC.homee == true) // xMC is the movie clip instance name which including the timer code and the "homeqz1" button.
{
xMC.countdownTimer1.start();
xMC.homee = false;
}
Copy link to clipboard
Copied
Just FYI but with a Boolean variable you can just do: if(homee) to test for true or: if(!homee) to test for false... using == false or true is redundant and unnecessary.
Copy link to clipboard
Copied
The "pausebtn1" is a movie clip and you cannot set its value to false or true as I explained above..
Copy link to clipboard
Copied
Sorry I was wrong..
var homee:Boolean = false;
homeqz1.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{
if(homee == false)
{
countdownTimer1.stop();
homee = true; // ERROR HERE
}
}
Copy link to clipboard
Copied
Sorry I was wrong..
var homee:Boolean = false;
homeqz1.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{
if(homee == false)
{
countdownTimer1.stop();
homee = true; // ERROR HERE
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now