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

[color=darkred][b]将代码写在组件的preInitialize事件监听器里面[/b][/color]
简化案例如下:





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/BlazeDS)