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

查看:101
本文介绍了如何创建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);
		}
	}
}

这个函数假定你有一个可以接受的高度(或任何你能想到的)参数的JavaScript函数命名setFlashHeight。一个例子是:

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的功能可以很容易地改变设定闪光物体的高度。当你实现这个解决方案,你会发现,滚动条不能正常工作闪光灯消耗事件。但是,这是另一个问题......

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天全站免登陆