0
這應該很簡單。我錯過了什麼? 創建一個雪碧(容器),把它放在顯示列表上,添加一個新的雪碧(矩形)容器。 改變孩子的身高(rect)。 雖然正確渲染,但父級(容器)和子級(rect)的高度值未正確報告。 感謝您的協助。AS3顯示物體高度未正確報告
var container:Sprite = new Sprite();
addChild(container);
[Embed(source = "../lib/rectangle.swf")] // height is 100
var Rect:Class;
var rect:Sprite = new Rect();
trace(rect.height); // 100 is correct before placement in container
container.addChild(rect);
trace(rect.height); // 100 is correct after placement in container
trace(container.height); // 0 is not correct; should be 100
rect.height = rect.height + 100; // renders correctly at new height
trace(rect.height); // 100 is not correct; should be 200
trace(container.height); // 0 is not correct; should be 200
你說精靈(容器)內的精靈(矩形),但你的例子顯示精靈內的SWF。 SWF中的內容是什麼?它是壓倒大小的屬性? – Aaron
SWF是填充矩形的矢量圖。它的高度是100px,寬度是4px。我不知道嵌入的SWF對sprite屬性有什麼影響。如果精靈的屬性在AS3中更改,精靈將正常呈現。 – Gus
嵌入式swf嵌入爲二進制文件,因此其行爲有所不同。如果你創建了一個克隆,那麼這個克隆就會正常工作。 – BotMaster