Apache flex 如何根据阶段宽度定义布尔值?
我正在尝试为flex应用程序创建动态布局 我需要一个布尔值,它取决于设置状态的浏览器窗口的总宽度,类似于Apache flex 如何根据阶段宽度定义布尔值?,apache-flex,actionscript-3,layout,performance,boolean,Apache Flex,Actionscript 3,Layout,Performance,Boolean,我正在尝试为flex应用程序创建动态布局 我需要一个布尔值,它取决于设置状态的浏览器窗口的总宽度,类似于 if(this.parentApplication.width<950) { currentState = "wide" }else{ currentState = "narrow" } if(this.parentApplication.width您可以尝试使用事件处理程序
if(this.parentApplication.width<950)
{
currentState = "wide"
}else{
currentState = "narrow"
}
if(this.parentApplication.width您可以尝试使用事件处理程序
myListener = new Object();
myListener.onResize = function() {
currentState = (obj.parentApplication.width<950) ? 'wide' : 'narrow';
};
Stage.addListener(myListener);
myListener=newobject();
myListener.onResize=函数(){
currentState=(obj.parentApplication.width实际上,等待调整大小将更便宜、更优雅。
在as3中,Stage类不再存在,被Stage所取代。
语法可能也不起作用(as3不太喜欢匿名函数:))
您将需要舞台可用(例如),然后
比如说:
[...when stage is available...]
stage.addEventListener( Event.RESIZE, onResizeHandler );
onResizeHandler( null );//calling the method with an null event to force a first check
[...other instructions...]
然后
private function onResizeHandler( e:Event ):void
{
currentState = ( stage.stageWidth < 950 ) ? 'wide' : 'narrow';
//or testing a given object's width rather than the stage.
}
私有函数onResizeHandler(e:Event):void
{
currentState=(stage.stageWidth<950)?“宽”:“窄”;
//或者测试给定对象的宽度而不是舞台。
}