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

[i]._visible

Participant ,
Sep 17, 2013 Sep 17, 2013

Below is my code. This dosen't seem to work even though capts are all fasle. Where's the fault?

var capts:Array = [purchaseH0, purchaseH1, purchaseH2, purchaseH3];

for(i=0; i<capts.length; i++){

          _root["purchaseH"+i]._visible=false;

          nextStep_btn.onRelease = function () {

                    if(capts._visible==false){

                              trace("invisible")

                    } else {

                              trace ("visible")

                    }

                    }

}

};

TOPICS
ActionScript
1.0K
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

correct answers 1 Correct answer

Community Expert , Sep 17, 2013 Sep 17, 2013

i still don't know what you're trying to do but the additional for-loop i mentioned above should be inside, the onRelease:

          nextStep_btn.onRelease = function () {

               for(i=0; i<capts.length; i++){

                    if(capts._visible==false){

                              trace("invisible")

                    } else {

                              trace ("visible")

                    }

              }

};

Translate
Community Expert ,
Sep 17, 2013 Sep 17, 2013

i=capts.length when that button is clicked.

what are you trying to do when that button is clicked.  if you want to loop through capts, you'll need another for-loop.

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
Participant ,
Sep 17, 2013 Sep 17, 2013

Thanks for the reply kglad.

I used another for loop. But still the output is "visible".

Also either it's  if(capts._visible==false){  or if(capts._visible==true){ the output is still 'visible'?

var capts:Array = [purchaseH0, purchaseH1, purchaseH2, purchaseH3];

for(i=0; i<capts.length; i++){

          _root["purchaseH"+i]._visible=false;

}

for(i=0; i<capts.length; i++){

          nextStep_btn.onRelease = function () {

                    if(capts._visible==false){

                              trace("invisible")

                    } else {

                              trace ("visible")

                    }

                    }

};

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
Community Expert ,
Sep 17, 2013 Sep 17, 2013

i still don't know what you're trying to do but the additional for-loop i mentioned above should be inside, the onRelease:

          nextStep_btn.onRelease = function () {

               for(i=0; i<capts.length; i++){

                    if(capts._visible==false){

                              trace("invisible")

                    } else {

                              trace ("visible")

                    }

              }

};

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
Participant ,
Sep 17, 2013 Sep 17, 2013

Thanks Kglad. That worked. But I don't quite understand why does it make a difference when the for-loop is inside or outside the onRelease??

p.s.I'm using this to check if all mcs in capts is visible=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
Community Expert ,
Sep 17, 2013 Sep 17, 2013

this code:

for(i=0; i<capts.length; i++){

          nextStep_btn.onRelease = function () {

                    if(capts._visible==false){

                              trace("invisible")

                    } else {

                              trace ("visible")

                    }

                    }

};

creates capts.length number of identical onRelease handlers.  in as2, only the last one is implemented.  it overrides the earlier ones, but you can't tell because all of them are identical.

anyway, when you release nextStep_btn, i is equal to capts.length and there is no capts object so that if-statement makes no sense to flash.  ie, that block of code makes no sense to flash.

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
Participant ,
Sep 17, 2013 Sep 17, 2013

Thanks. That makes sense.

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
Community Expert ,
Sep 18, 2013 Sep 18, 2013
LATEST

you're welcome.

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