2015-07-20 59 views
0

我有一个主容器内的两个容器。
一个容器宽度为20%,其他容器宽度为80%。
现在我想隐藏20%的按钮点击容器,所以我使用。调整大小的效果widthto百分比

<s:Resize id="resizeHide" widthTo="0" target="{fstContainer}"/> 

现在,在同一个按钮点击我想20%来调整该容器,然后会是怎样的解决方案。

我试过但没有为我工作。

<s:Resize id="resizeShow" widthTo="20" target="{fstContainer}"/> 

我无法设置固定宽度。并且调整大小效果只会占用像素宽度。

回答

1

要调整你的容器,以你的舞台宽度的20%,你可以简单地这样做:

Resize效果:

<s:Resize id="resizeShow" target="{fstContainer}"/> 

然后为按钮:

<s:Button id="btn_resize" label="Resize" click="resizeShow.widthTo = stage.stageWidth/5; resizeShow.play();"/> 

编辑:

位于2方式,是使用数据绑定,就像这样:

<s:Resize id="resizeShow" widthTo="{_20_percent}" target="{fstContainer}"/> 

声明绑定VAR:

[Bindable] protected var _20_percent:Number; 

然后,你可以将其值设置完成后您的应用程序的创建时,或者当它添加到舞台,...:

protected function on_addedToStage(event:Event):void 
{ 
    _20_percent = stage.stageWidth/5; 
} 

protected function on_creationComplete(event:FlexEvent):void 
{ 
    // here of course, as you know, the stage is not yet accessible 
    _20_percent = FlexGlobals.topLevelApplication.width/5; 
} 

和当然,在这里你只需要使用一个事件处理程序来设置值。

第3方式,是动态创建Resize效果,当用户按调整大小按钮:

protected function btn_resize_onClick(event:MouseEvent):void 
{ 
    var resizeShow1:Resize = new Resize(); 
     resizeShow1.target = fstContainer; 
     resizeShow1.widthTo = stage.stageWidth/5; 
     resizeShow1.play(); 
} 

而且它是由你来决定,你比较喜欢的方式;)

希望可以帮助。

+0

谢谢。但它不起作用。 – ketan

+0

对不起。我的错误,我写错了调整大小的ID。非常感谢它的工作。有没有其他解决方案或者这是最好的解决方案? – ketan

+1

@ketan编辑我的答案,看一看。 – akmozo

相关问题