1
我有一個組的大小,它包含的內容,但使用Tweener執行轉換我必須設置寬度和高度屬性。動畫完成後,我將如何清除明確的寬度和高度屬性,以便本集團根據其內容返回大小?如何清除組的明確的寬度和高度
前:
<s:Group ><content.../></s:Group>
代碼:
width = 250;
height = 250;
Tweener.addTween(this, {width:500, height:500, time:0.25, onComplete:openAnimationComplete});
補間後,集團有效地設置爲500×500,好像它是這樣的:
<s:Group width="500" height="500" ><content /></s:Group>
我想它返回對此:
<s:Group ><content /></s:Group>
UPDATE
測試代碼使用從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>
將高度和寬度設置爲NaN還是Null?然後invalidateSize()強制組重新計算? – JeffryHouser
我沒有試過NaN。這樣可行。 :)如果你想要點,請添加一個答案。 –