`

Flex4滚动条与focous out事件

 
阅读更多
1、 滚动条
flex4中内容超出容器组件的方案
我们在开发中一般会用到s前缀的容器,即spark容器组件,但里面的内容如超过这些容器的大小时并不会产生滚动条,如有下列代码
<s:NavigatorContent label="基本信息" width="100%" height="100%">
<s:HGroup width="100%" height="100%">
<s:layout>
<s:HorizontalLayout useVirtualLayout="true"/>
</s:layout>
<resourcemanagement:HostBasicInfo id="hostBasicInfo" width="98%" height="100%"
  dispatcher="{model.dispatcher}" host="{model.hostInfo}"
  hostUsage="{model.hostUsageInfo}"  hostBasicPhysicalInfo="{model.hostBasicPhysicalInfo}"/>
</s:HGroup>
</s:NavigatorContent>
这里NavigatorContent里面的内容过多,会出现内容直接超出NavigatorContent的现象

查阅flex4文档后发现可以采用下面的办法解决
        <s:NavigatorContent label="基本信息" width="100%" height="100%">
<s:Scroller left="0" right="0" top="0" bottom="0" horizontalScrollPolicy="off">
<s:Group width="100%" height="100%">
<s:layout>
<s:HorizontalLayout useVirtualLayout="true"/>
</s:layout>
<resourcemanagement:HostBasicInfo id="hostBasicInfo" width="98%" height="100%"
  dispatcher="{model.dispatcher}" host="{model.hostInfo}"
  hostUsage="{model.hostUsageInfo}" hostBasicPhysicalInfo="{model.hostBasicPhysicalInfo}"/>
</s:Group>
</s:Scroller>
        </s:NavigatorContent>
即在需要滚动条的容器里面放入s:Scroller组件,将原来的内容放入s:Scroller组件内部(注意需要设置s:Scroller组件的子组件useVirtualLayout属性)

2、在弹出窗体中使用foucus out事件时建议
if(number == null) {
					this.addEventListener(FlexEvent.CREATION_COMPLETE,function():void {
						number.addEventListener(FocusEvent.FOCUS_OUT,checkNumberExist);
						location.addEventListener(FocusEvent.FOCUS_OUT,getLatLngByLocation);
					});
				}else {
					number.addEventListener(FocusEvent.FOCUS_OUT,checkNumberExist);
					location.addEventListener(FocusEvent.FOCUS_OUT,getLatLngByLocation);
				}
注意:checkNumberExist函数中含FocusEvent参数
而非:
<mx:FormItem label="编码:" required="true" focusEnabled="true" width="100%">
			<s:TextInput id="number" width="100%" enabled.addView="true" enabled.editView="false" text="@{_datacenter.number}"/>
		</mx:FormItem>

至于原因吗自己试试便知
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics