lundi 25 mai 2015

Flash AS3, strangeness when setting position of child movieclip

I'm dynamically adding movieclip objects to a parent container and then setting each newly added clip's y position to the height of the container plus some number of vertical padding pixels. The desired effect is to append the new movieclip to the bottom of a vertical column of movieclips (a text message thread). What's strange is that no matter what value I specify for vertical padding, the new clip is always displayed abutted exactly against the bottom of the previously added clip, as though the padding were always 0.

var smsVPadding:Number = 10;

// Get current bounds of sms_history_mc
var bounds = sms_history_mc.getBounds( sms_history_mc.parent );
var yPos:Number = bounds.height + smsVPadding;

// Add the new SMS to sms_history_mc
sms_history_mc.addChild( newSMS );

newSMS.y = yPos;

If I set the value of newSMS.y explicitly to a number newSMS.y = 600 it works as expected. However, if I set yPos by explicitly adding the padding pixels bounds.height + 10 the result is strange again.

trace(newSMS.y) yields the expected value, but the movielip's position does not reflect this.

Any thoughts? Please tell me I'm missing something ridiculous. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire