apache-flex - 如何创建具有动态高度的 Flex 应用程序?

标签 apache-flex actionscript-3

有没有办法让 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/

相关文章:

actionscript-3 - AS3 AIR/FlashBuilder 如何在退出时释放套接字?

actionscript-3 - 定制线帽?

java - Apache Pivot 1.4 与 JavaFX、Flex、Silverlight、Swing

apache-flex - 弹性 : What's the difference between an MXML "Component" and an MXML "Module"?

apache-flex - 土坯空气 : scroller throws error when changes focus between different applications

apache-flex - Flex 3 全局异常处理

actionscript-3 - 与常规 ActionScript 相比,构建字节码有什么优势吗?

actionscript-3 - 有没有办法清除 AS3/AIR 中的嵌入式位图 Assets

ios - 在iOS上占用GPS资源(使用地理位置类,Adobe AIR)

actionscript-3 - StageWebView在具有target = “_blank”的URL上缺少