首页 > 设计 > 详细

Flex中如何利用top, bottom, left, right, horizontalCenter和vertical

时间:2016-02-07 16:21:04      阅读:170      评论:0      收藏:0      [点我收藏+]
接下来的例子演示了Flex中如何利用top, bottom, left, right, horizontalCenter和verticalCenter样式,放置某固定项目。
复制代码
代码如下:
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"> <mx:Style> Form { paddingLeft: 0; paddingRight: 0; paddingTop: 0; paddingBottom: 0; } </mx:Style> <mx:Script> <![CDATA[ import mx.events.SliderEvent; private function sliderLeft_change(evt:SliderEvent):void { image.setStyle("left", sliderLeft.value); image.setStyle("right", NaN); sliderRight.value = 0; } private function sliderRight_change(evt:SliderEvent):void { image.setStyle("right", sliderRight.value); image.setStyle("left", NaN); sliderLeft.value = 0; } private function sliderTop_change(evt:SliderEvent):void { image.setStyle("top", sliderTop.value); image.setStyle("bottom", NaN); sliderBottom.value = 0; } private function sliderBottom_change(evt:SliderEvent):void { image.setStyle("bottom", sliderBottom.value); image.setStyle("top", NaN); sliderTop.value = 0; } ]]> </mx:Script> <mx:Number id="MAX_WIDTH">{canvas.width - image.width}</mx:Number> <mx:Number id="MAX_HEIGHT">{canvas.height - image.height}</mx:Number> <mx:ApplicationControlBar dock="true"> <mx:Form> <mx:FormItem label="left:" direction="horizontal"> <mx:HSlider id="sliderLeft" minimum="0" maximum="{MAX_WIDTH}" value="0" liveDragging="true" snapInterval="1" dataTipPrecision="0" showTrackHighlight="true" change="sliderLeft_change(event);" /> <mx:Label text="{sliderLeft.value}" /> </mx:FormItem> <mx:FormItem label="right:" direction="horizontal"> <mx:HSlider id="sliderRight" minimum="0" maximum="{MAX_WIDTH}" value="0" liveDragging="true" snapInterval="1" dataTipPrecision="0" showTrackHighlight="true" change="sliderRight_change(event);" /> <mx:Label text="{sliderRight.value}" /> </mx:FormItem> <mx:FormItem label="top:" direction="horizontal"> <mx:HSlider id="sliderTop" minimum="0" maximum="{MAX_HEIGHT}" liveDragging="true" snapInterval="1" dataTipPrecision="0" showTrackHighlight="true" change="sliderTop_change(event);" /> <mx:Label text="{sliderTop.value}" /> </mx:FormItem> <mx:FormItem label="bottom:" direction="horizontal"> <mx:HSlider id="sliderBottom" minimum="0" maximum="{MAX_HEIGHT}" liveDragging="true" snapInterval="1" dataTipPrecision="0" showTrackHighlight="true" change="sliderBottom_change(event);" /> <mx:Label text="{sliderBottom.value}" /> </mx:FormItem> </mx:Form> </mx:ApplicationControlBar> <mx:Canvas id="canvas" width="100%" height="100%"> <mx:Image id="image" source="assets/bug.png"/> </mx:Canvas> </mx:Application>

Flex中如何利用top, bottom, left, right, horizontalCenter和vertical

原文:http://www.jb51.net/media/89474.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!