根据屏幕分辨率动态调整组件大小

将代码写在组件的preInitialize事件监听器里面
简化案例如下:
		<s:HGroup id="leftContianer" width="70%" preinitialize="leftContianer_preinitializeHandler(event)">
		</s:HGroup>
		<s:HGroup id="rightSpacerContainer" width="30%" preinitialize="rightSpacerContainer_preinitializeHandler(event)"/>

	protected function leftContianer_preinitializeHandler(e:FlexEvent):void
	{
		var hg:HGroup=(e.currentTarget) as HGroup;
		if(hg!=null){
			if(Capabilities.screenResolutionX<=1024){
				hg.percentWidth=80;
			}else{
				hg.percentWidth=70;
			}
		}
		
	}
	
	protected function rightSpacerContainer_preinitializeHandler(e:FlexEvent):void
	{
		var hg:HGroup=(e.currentTarget) as HGroup;
		if(hg!=null){
			if(Capabilities.screenResolutionX<=1024){
				hg.percentWidth=20;
			}else{
				hg.percentWidth=30;
			}
		}
		
	}

你可能感兴趣的:(组件,Flex,大小,分辨率,尺寸)