有没有办法让 flex 应用程序在嵌入 HTML 包装器时具有动态高度?
我希望 Flex 应用程序以不会导致垂直滚动条的方式增加高度。
最佳答案
最好的方法应该是重写应用程序的测量方法,例如:
private var _lastMeasuredHeight:int;
override protected function measure():void
{
super.measure();
if (measuredHeight != _lastMeasuredHeight)
{
_lastMeasuredHeight = measuredHeight;
if (ExternalInterface.available)
{
ExternalInterface.call("setFlashHeight", measuredHeight);
}
}
}
此函数假定您有一个名为 setFlashHeight 的 javascript 函数,它可以接受一个高度(或任何您命名的)参数。一个例子是:
function setFlashHeight(newHeight){
//assuming flashDiv is the name of the div contains flex app.
var flashContentHolderDiv = document.getElementById('flashDiv');
flashContentHolderDiv.style.height = newHeight;
}
我使用 swfobject 来嵌入我的 flex 应用程序。所以 flash 对象位于一个 div 中。如果你没有;可以轻松更改 js 函数以设置 flash 对象的高度。当您实现此解决方案时,您会注意到 scrollBars 不工作,因为 flash 使用该事件。但那是另一个主题......
关于apache-flex - 如何创建具有动态高度的 Flex 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/318675/