`
yoshiyan
  • 浏览: 46457 次
社区版块
存档分类
最新评论

flex布局

    博客分类:
  • Flex
阅读更多
使用自定义Layout时,s:DataGroup和s:List应该如何选择?
与s:List相比,s:DataGroup没有selectedIndex,而且默认没有BackGround。

Spark List不能响应Click事件吗?
是的,需要在ItemRenderer里响应,然后通过DispathEvent告诉Spark List。
参考链接:
http://stackoverflow.com/questions/2299659/how-do-i-handle-click-event-in-spark-list-control-in-flex-4
或者你也可以响应change事件,在每次在change响应函数里处理完后,把Spark List的selectedIndex置为-1就可以了。

如何设置Layout的间距?
s:TileLayout使用horizontalGap和verticalGap来设置。
s:HorizontalLayout和VerticalLayout使用gap来设置。

如何使组件基于其container居中?
将组件的horizontalCenter和verticalCenter属性都设置为0。

使用horizontalCenter和verticalCenter需要注意的地方
horizontalCenter和verticalCenter的优先级比x,y高。一旦设置horizontalCenter,则x会被忽略掉,设置了verticalCenter,则y会被忽略掉。再也无法通过修改x,y的值,改变组件的属性。

horizontalCenter对left和right属性的影响
<mx:Button left="10" right="0" height="100%" horizontalCenter="0"/>
则此Button的布局将会是左边距为5,右边距也为5?
从而可知flex先根据left和right计算出宽度,然后再结合horizontalCenter调整布局。

top=0,bottom=0,left=0,right=0 和 width=100% , height=100%有啥差别?
They both have the same effect in a BasicLayout. The only different might be in performance. In other layouts like VerticalLayout and HorizontalLayout I don't think the constraints (top, right, etc) have any effect, but the percentage values do.

参考链接:
http://stackoverflow.com/questions/4447274/whats-the-diff-between-setting-top-0-bottom-0-left-0-right-0-or-width-100-heig

如何给Spark Scroller加child?
必须先为Scroller加上Group。
示例代码:

For AS:
var grp:Group = new Group();
grp.percentWidth = 100;
grp.percentHeight = 100;
grp.addElement( myChart );

var scroll:Scroller = new Scroller();
scroll.percentWidth = 100;
scroll.viewport = grp;

参考文章:http://stackoverflow.com/questions/2287431/flex4-how-to-add-a-child-to-spark-scroller-in-as

For MXML:
<s:Scroller>
   <s:Group>
      <s:image source="c:/gameCover.png"/>
   </s:Group>
</s:Scroller>


在layout中的element上运用transform effects时,effect的applyChangesPostLayout的取值对layout有什么影响?
All transform effects define the applyChangesPostLayout property which, by default, is set to true for the 3D effects. This setting lets the 3D effect modify the target component, but the parent container ignores the changes and does not update its layout while the effect plays. Changes to other container children still cause a layout update.
参考链接:
http://help.adobe.com/en_US/flex/using/WSF0D55C84-17E0-456a-A977-04BFE1E23BA8.html

从3D layout切换到2D layout时,如何去掉已有的3D layout的位置属性?
var e:ILayoutElement = target.getElementAt( i );				
// remove any 3D positioning
e.setLayoutMatrix( new Matrix(), false );


rotation VS rotationX、rotationY, rotationZ
rotation用于2D,rotationX、rotationY, rotationZ用于3D。

PerspectiveProejection的参考资料
3维旋转与透视变换(PerspectiveProjection)
http://www.byywee.com/page/M0/S225/225570.html

3D父容器是啥?
研究RotationX时看到的这个概念。
rotationX、rotationY, rotationZ的API解释如下:
引用
rotationX : Number
指示 DisplayObject 实例相对于 3D 父容器距离其原始方向的 x 轴旋转(以度为单位)。
rotationY : Number
指示 DisplayObject 实例相对于 3D 父容器距离其原始方向的 y 轴旋转(以度为单位)。
rotationZ : Number
指示 DisplayObject 实例相对于 3D 父容器距离其原始方向的 z 轴旋转(以度为单位)。

经过研究发现BorderContainer、UIComponnent默认情况下并不能做3D父容器,只有为其transform.perspectiveProjection设置了以后,它们才成了3D父容器。应该还有其他方法。
PS:在航空术语中,有关 y 轴的旋转称为偏航。有关 x 轴的旋转称为俯仰。有关 z 轴的旋转称为翻滚。

UIComponent和BorderContainer中的is3D属性在什么情况下为true?
默认为false,它的API解释如下:
引用
当元素为 3D 时,则为 true。元素也可以是 3D 的,因为它具有 3D 转换属性或 3D 布局后转换偏移,或二者都有。

为z属性设值,或者为其transform.matrix3D属性设置有意义的值后(new Matrix3D()不行)
is3D就会变为true。

roation如何摆脱stage的影响。我的组件stageX坐标不同,旋转同样的角度,显示的样子不一样。怎样才能一样?


layout可以拿到其container的实例吗?
<s:List>
    <s:layout>
       <local:CoverLayout/>
    <s:layout/>
</s:List>
在CoverLayout的类里,能拿到s:List的实例吗?

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics