我有一个按其包含的内容调整大小的组,但要使用 Tweener 执行转换,我必须设置宽度和高度属性。动画完成后,我将如何清除显式宽度和高度属性,以便 Group 根据其内容返回大小调整?
前:
<s:Group ><content.../></s:Group>
代码:
width = 250;
height = 250;
Tweener.addTween(this, {width:500, height:500, time:0.25, onComplete:openAnimationComplete});
在补间之后,组被有效地设置为 500x500,就好像它是这样的:
<s:Group width="500" height="500" ><content /></s:Group>
我希望它回到这个:
<s:Group ><content /></s:Group>
使用 Flextras 的解决方案更新测试代码:
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
var w:Object = myGroup.width;
var h:Object = myGroup.height;
if (myGroup.width!=300) {
myGroup.width = 300;
myGroup.height = 300;
}
else {
myGroup.width = NaN;
myGroup.height = NaN;
w = myGroup.width; // NaN
h = myGroup.height; // NaN
//myGroup.validateNow()
if (myGroup.parent is IInvalidating) {
IInvalidating(myGroup.parent).validateNow();
}
w = myGroup.width; // 600
h = myGroup.height; // 100
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Group id="myGroup" minHeight="0" minWidth="0" clipAndEnableScrolling="true">
<s:Button width="600" height="100" label="here is a button" click="button1_clickHandler(event)"/>
</s:Group>