我遇到的问题是,在Flex的mx:HTML控件的可视区域外显示PDF。应用程序启动时 - mx:HTML设置为特定大小,但如果应用程序最大化,则可以放大。以下是复制它的条件:
以下是重现此问题的一些代码。组内的组看起来有些混乱,但我们的应用程序中还有其他东西,我已经删除了只是为了重现这个问题的小测试应用程序:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="1004" height="510" backgroundColor="#000000" >
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function press_clickHandler():void
{
htmlContent.location = "vt1_04_using_flash_builder.pdf";
}
]]>
</fx:Script>
<fx:DesignLayer>
<mx:HDividedBox id="myDividedBox" left="10" right="5" top="39" bottom="61" liveDragging="false">
<mx:Panel id="pnlTreeCtrl" width="250" height="100%" headerHeight="0">
<s:Button id="press" buttonMode="true" click="press_clickHandler()"
right="84" top="8" label="Press"/>
</mx:Panel>
<s:Group id="groupCourseMain" height="100%" >
<s:Group id="groupCourseHTML" right="0" top="30" bottom="0" width="100%">
<mx:HTML id="htmlContent" top="0" bottom="0" width="100%" />
</s:Group>
</s:Group>
</mx:HDividedBox>
</fx:DesignLayer>
</s:WindowedApplication>
编辑:红色箭头显示Reader X中浮动灰色条显示在可视区域外的位置:
答案 0 :(得分:2)
这似乎是一个已知的bug,没有修复。
解决方法是在加载文档后重新调整浏览器宽度,并在每次调整其父组时调整其大小。诀窍是重新调整一个像素的大小以强制重绘。以下代码似乎有效。这是我能做的最好的,可能有更好的解决方案。
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="1004" height="510" backgroundColor="#000000" >
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.events.ResizeEvent;
protected function press_clickHandler():void
{
htmlContent.location = "test.pdf";
}
protected function htmlContent_completeHandler(event:Event):void
{
this.htmlContent.width = this.groupCourseHTML.width - 1;
}
protected function groupCourseHTML_resizeHandler(event:ResizeEvent):void
{
this.htmlContent.percentWidth = 100;
}
]]>
</fx:Script>
<fx:DesignLayer>
<mx:HDividedBox id="myDividedBox" left="10" right="5" top="39" bottom="61" liveDragging="false">
<mx:Panel id="pnlTreeCtrl" width="250" height="100%" headerHeight="0">
<s:Button id="press" buttonMode="true" click="press_clickHandler()"
right="84" top="8" label="Press"/>
</mx:Panel>
<s:Group id="groupCourseMain" height="100%" >
<s:Group id="groupCourseHTML" right="0" top="30" bottom="0" width="100%" resize="groupCourseHTML_resizeHandler(event)">
<mx:HTML id="htmlContent" top="0" bottom="0" width="100%" complete="htmlContent_completeHandler(event)"/>
</s:Group>
</s:Group>
</mx:HDividedBox>
</fx:DesignLayer>
</s:WindowedApplication>