Copy link to clipboard
Copied
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")
}
}
}
};
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")
}
}
};
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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")
}
}
};
Copy link to clipboard
Copied
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")
}
}
};
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks. That makes sense.
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now