【发布时间】:2011-08-03 15:02:32
【问题描述】:
我正在使用 Flex 3。
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.containers.HBox;
import mx.managers.PopUpManager;
[Bindable]private static var openRollOver:AssemblySearchResultContentsRollOver;
private var rollOverWindow:VBox;
private var created:Boolean = false;
private function createPopup():void
{
rollOverWindow = new VBox();
rollOverWindow.width = 300;
rollOverWindow.height = 50;
rollOverWindow.setStyle("backgroundColor", "#578BBB");
rollOverWindow.setStyle("paddingTop", "10");
rollOverWindow.setStyle("paddingBottom", "10");
rollOverWindow.setStyle("paddingLeft", "15");
rollOverWindow.setStyle("paddingRight", "15");
var hbox:HBox = new HBox();
hbox.width = 200;
hbox.height = 50;
hbox.setStyle("backgroundColor", "red");
// If I comment out this line then the VBox is 300*50, if I leave it in then
// the VBox is multiple times bigger (lots of scrolling vertical and horizontal)
rollOverWindow.addChild(hbox);
created = true;
}
public function showOptions():void
{
if (!created)
createPopup();
var pt:Point = new Point(0, 0);
pt = localToGlobal(pt);
rollOverWindow.x = pt.x + 80;
rollOverWindow.y = pt.y + 45;
PopUpManager.addPopUp(rollOverWindow, this);
openRollOver = this;
}
public function hideOptions():void
{
PopUpManager.removePopUp(rollOverWindow);
openRollOver = null;
}
private static function closeOpenOptions():void
{
if(openRollOver != null)
openRollOver.hideOptions();
}
]]>
</mx:Script>
蓝框是一个弹出窗口,当图像悬停在另一个视图上时,它使用方法控制:
private function imageOver(event:MouseEvent):void
{
event.stopPropagation();
rollOverWindow.showOptions();
}
private function imageOut(event:MouseEvent):void
{
event.stopPropagation();
rollOverWindow.hideOptions();
}
这是 VBox 内的 Hbox:
这是没有 Hbox 的:
有人知道为什么会这样吗?
【问题讨论】:
-
定义“大几倍”。垂直方向是否太大?横向?
-
@Jason Towne 两者,不知道它有多大,但它超过了 300 * 50 很多。
-
你有截图吗?
rollOverWindow在另一个容器中吗? -
@Jason Towne 添加了我的完整代码和截图
标签: actionscript-3 apache-flex flex3