I'm using MC Tween on some navigation blocks. Three blocks on top of each
other, they start out equal in side, when you click on one, it opens up
and
the others close up.
This involves tweening the clip's height and y coord. It works great for
basic MCs(see the good link below), but when I change it so that the
height
change is applied to a nested MC it goes all screwy.
Does anyone know of a problem with using this library in relation to
nested
MCs.
There's no problem with the library in relation to nested MCs. The problem
with your code on nested MCs is that instead of applying the code to the
nested MCs all the time - like you did with the 'un-nested' version - you're
applying it sometimes to the MC itself, and sometimes to the nested MCs.
Like increasing the _height of the parent MC but then decreasing the height
of the parent MC.
Think about it this way: forget about mc tween for a while. Instead of
applying _y and _height tweens, directly apply values to the properties, as
in
navBlock3._y = 200;
Will it work? In your second case, the nested FLA, it won't, no matter what
extension you use, because there are reference problems. So before thinking
of fixing problems on the animation, see if your movieclip references are
correct. The tween() function works just like assigning values to the
properties - so if the references themselves are wrong, there's no way it's
gonna work.
Anyways, this is your 'nested' code:
navBlock1.onPress = function() {
if ( this.state == 1 || this.state == 2 ) {
this.tween("_height", STATE_HEIGHTS[3], TWEEN_TIME);
this.state = 3;
trace("closing " + 2 + " and " + 3);
navBlock2.navBlockBG.tween("_height", STATE_HEIGHTS[1], 2);
navBlock2.state = 1;
navBlock3.navBlockBG.tween("_height", STATE_HEIGHTS[1], 2);
navBlock3.state = 1;
navBlock2.tween("_y", 150, TWEEN_TIME);
navBlock3.tween("_y", 200, TWEEN_TIME);
}
};
Notice you're changing the _height of the movieclip being expanded itself,
but when resetting the other two movieclips, you're changing the height of
the inner movie. This won't work; you have to use the inner movie or the
outer movie for both.
So instead, it should be this:
navBlock1.onPress = function() {
if ( this.state == 1 || this.state == 2 ) {
this.navBlockBG.tween("_height", STATE_HEIGHTS[3], TWEEN_TIME);
this.state = 3;
trace("closing " + 2 + " and " + 3);
navBlock2.navBlockBG.tween("_height", STATE_HEIGHTS[1], 2);
navBlock2.state = 1;
navBlock3.navBlockBG.tween("_height", STATE_HEIGHTS[1], 2);
navBlock3.state = 1;
navBlock2.tween("_y", 150, TWEEN_TIME);
navBlock3.tween("_y", 200, TWEEN_TIME);
}
};
Also, the other functions (navBlock2.onPress and navBlock3.onPress) have old
references, from the un-nested file, so you should properly make it tween
the navBlockBG movies instead - properly tweening the _height of your nested
navBlockBG instead of just the parent movieclip. In the end, just around one
sixth of the code of your second FLA is made for tweening the nested MCs, so
it's not gonna work until you go all the way.
Again, you can't mix expect to change the _height of a movieclip and expect
to change it back by resizing its parent or its child - it won't work
properly. If you want to reset the movieclip back, it should reset its own
_height.
- Zeh
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com