I have added:
sub1_btn
Within sub1_btn there is a movieclip called “arrow”.
Using this code I am able to access it and tween it:
TweenMax.to(sub2_btn.arrow, 1, {rotation: -0});
However, using this code within a FOR statement (as there are 2), I am not
for (var i:int = 1; i<3; i++){
TweenMax.to(["sub"+i+"_btn"].arrow, 1, {rotation: -0});
}
What is wrong with the above code? The error is:
Error: Cannot tween a null object.
at com.greensock::TweenLite()
at com.greensock::TweenMax()
at com.greensock::TweenMax$/to()
at src::main/pullSub()
Try this instead:
The problem is that
["sub"+i+"_btn"]creates a new array, and that array doesn’t contain an objectarrow. But when you usethis["sub"+i+"_btn"]you access the movie clipsub[i]_btnas you want.