Reputation: 37
var sunflowers30:Array = [sunflowerpetal1,sunflowerpetal2,sunflowerpetal3,sunflowerpetal4,sunflowerpetal5,sunflowerpetal6];
sunflowers30.visible = false;
Why is the code up there not working?? what am i doing wrong?? ( trying to make the array invisible).
also should this code not work as well? (below)( trying to go to a different scene once array ( all instances) are hidden/invisible).
if(sunflowers30.visible == false)
{
gotoAndPlay(1, "theplace")
}
;
Sunflowerpetal 1-6
are instances that are on my stage currentlySunflowers30
is the array i made from the instances on stage."Theplace"
is the next sceneHelp and comments are much appreciated I'm kind of new to AS3 and code in general but i bet you code gurus could help me out, many thanks ahead of time!
Upvotes: 0
Views: 1175
Reputation: 6403
Array does not have a visible property.
What you need to do is loop through the array and set the property on each element of that array.
var sunflowers30:Array = [sunflowerpetal1,sunflowerpetal2,sunflowerpetal3,sunflowerpetal4,sunflowerpetal5,sunflowerpetal6];
for each( var obj:Object in sunflowers30 ){
obj.visible = false;
}
// or another way or doing it
for( var i:int = 0; i<sunflowers30.length; i++){
obj.visible = false;
}
And as your second question asks if it should work the answer is no.
You are again targeting the array and not the object you want to test if it is visible.
if(sunflowerpetal1.visible == false)
{
gotoAndPlay(1, "theplace")
}
;
Upvotes: 1