如何创建具有动态高度的 Flex 应用程序? [英] How can I create a Flex application with dynamic height?

查看:20
本文介绍了如何创建具有动态高度的 Flex 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法允许 flex 应用程序在嵌入 HTML 包装器时具有动态高度?

Is there a way to allow a flex application to have a dynamic height while embedded in an HTML wrapper?

我希望 Flex 应用程序以一种不会导致垂直滚动条的方式增加高度.

I want the Flex application to grow in height in a way that it will not cause vertical scroll bars.

推荐答案

最好的方法应该是覆盖应用程序的度量方法,例如:

The best way should be overriding the Application's measure method like:

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 函数,该函数可以接受高度(或您命名的任何名称)参数.一个例子是:

This function assumes that you have a javascript function named setFlashHeight which can accept a height (or whatever you name it) parameter. An example would be:

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 对象的高度.当您实施此解决方案时,您会注意到滚动条无法正常工作,因为 flash 消耗了该事件.但那是另一个主题...

I use swfobject to embed my flex applications. So the flash object resides inside a div. If yours not; the js function could easily be altered to set the flash object's height. When you implement this solution, you'll notice that scrollBars aren't working as flash consumes the event. But that's another subject...

这篇关于如何创建具有动态高度的 Flex 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆