Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to disable movieclips in actionscript 3.0?

Guest
Dec 13, 2015 Dec 13, 2015

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!

TOPICS
ActionScript
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 13, 2015 Dec 13, 2015

But it is not functioning as button. Should i stil use mouseEnabled ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

Yes it'll work on the buttons, movie clips, text fields and the sprites also.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 13, 2015 Dec 13, 2015

I tried and I got this error

1120: Access of undefined property boxxcorrectq8aayat.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 13, 2015 Dec 13, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

Can you show the button code that you're trying to hide the mc through?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 13, 2015 Dec 13, 2015

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;

  }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 13, 2015 Dec 13, 2015

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

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

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

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 13, 2015 Dec 13, 2015

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

So what do you mean in if(homee == false)? do you mean if it's invisible?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 13, 2015 Dec 13, 2015

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 (?)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

What you're trying to do here (pausebtn1 = true;)?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 17, 2015 Dec 17, 2015
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

The "pausebtn1" is a movie clip and you cannot set its value to false or true as I explained above..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

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

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 13, 2015 Dec 13, 2015

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

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines