注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

有你做翅膀,孤单都是坚强

生命中总要经历曲折,或许是我们不愿意,突然到最后走不通,想重新来过,记录每件小事

 
 
 

日志

 
 
关于我
K24

曾经的生涩,曾经的懵懂,曾经的自恋,都随风去吧。。。

网易考拉推荐
 
 

flex 类苹果 switch button  

2012-11-03 11:17:41|  分类: @flex |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
flex 类苹果 switch button - 李印贞 - 有你做翅膀,孤单都是坚强
贴出代码, 只需要下面一个文件
1, switch_button.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:local="*"
width="700" height="460" creationComplete="init()" fontFamily="simsun" fontSize="12"
viewSourceURL="srcview/index.html">
<fx:Script>
<![CDATA[
import mx.events.ColorPickerEvent;

import spark.events.TextOperationEvent;
protected function init():void
{
sbw.value = sb.width;
sbh.value = sb.height;
salpha.value = sb.slideAlpha;
sduration.value = sb.slideDuration;
sfs.value = sb.getStyle("fontSize");
onColor.selectedColor = sb.getStyle("slotOnColor");
offColor.selectedColor = sb.getStyle("slotOffColor");
srx.value = sb.slideBlockRadiusX;

}

protected function sbw_changeHandler(event:Event):void
{
sb.width = sbw.value;
sb.state = SlideBlock.STS_OFF;
}

protected function sbh_changeHandler(event:Event):void
{
sb.height = sbh.value;
}

protected function salpha_changeHandler(event:Event):void
{
sb.slideAlpha = salpha.value;

}

protected function button1_clickHandler(event:MouseEvent):void
{
sb.switchHandler();
}

protected function checkbox1_changeHandler(event:Event):void
{
sb.dragMode = event.target.selected ;
}


protected function sduration_changeHandler(event:Event):void
{
sb.slideDuration = sduration.value;
}

protected function sfs_changeHandler(event:Event):void
{
sb.setStyle("fontSize",sfs.value);
}

protected function onColor_changeHandler(event:ColorPickerEvent):void
{
sb.setStyle("slotOnColor",onColor.selectedColor)

}

protected function offColor_changeHandler(event:ColorPickerEvent):void
{
sb.setStyle("slotOffColor",offColor.selectedColor)
}

protected function numericstepper1_changeHandler(event:Event):void
{
sb.slideBlockRadiusX = event.target.value;
sb.state = SlideBlock.STS_OFF;
}

]]>
</fx:Script>

<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->

</fx:Declarations>
<s:VGroup height="100%" width="100%">
<s:BorderContainer height="30%" width="100%">
<s:layout>
<s:HorizontalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<local:SlideBlock id="sb" slotResponse="false" slideBlockRadiusX="15" slideBlockRadiusY="15"/>
</s:BorderContainer>
<s:BorderContainer height="70%" width="100%">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:Form height="100%" width="33%">
<s:FormItem label="拖拽模式">
<s:CheckBox selected="true" change="checkbox1_changeHandler(event)"/>
</s:FormItem>
<s:FormItem label="滑槽响应">
<s:CheckBox selected="@{sb.slotResponse}"/>
</s:FormItem>
<s:FormItem label="开显示文字">
<s:TextInput id="slon" text="@{sb.onLabel}"/>
</s:FormItem>
<s:FormItem label="关显示文字">
<s:TextInput id="sloff" text="@{sb.offLabel}"/>
</s:FormItem>
<s:FormItem label="圆角x半径" >
<s:NumericStepper id="srx"
maximum="{50}" minimum="{0}" snapInterval="1" stepSize="1" allowValueWrap="false" change="numericstepper1_changeHandler(event)" />
</s:FormItem>
<s:FormItem label="圆角y半径" >
<s:NumericStepper maximum="{50}" minimum="{0}" snapInterval="1" stepSize="1" allowValueWrap="false" value="@{sb.slideBlockRadiusY}" />
</s:FormItem>
</s:Form>
<s:Form height="100%" width="34%">
<s:FormItem label="当前状态">
<s:Label text="{sb.state}"/>
</s:FormItem>
<s:FormItem label="滑槽字号" >
<s:NumericStepper id="sfs" maximum="{32}" minimum="{9}" snapInterval="1" stepSize="1" allowValueWrap="false"
change="sfs_changeHandler(event)" />
</s:FormItem>
<s:FormItem label="宽度">
<s:NumericStepper id="sbw" maximum="{600}" minimum="{60}" snapInterval="1" stepSize="10" allowValueWrap="false"
change="sbw_changeHandler(event)" />
</s:FormItem>
<s:FormItem label="高度" >
<s:NumericStepper id="sbh" maximum="{100}" minimum="{20}" snapInterval="1" stepSize="10" allowValueWrap="false"
change="sbh_changeHandler(event)" />
</s:FormItem>
<s:FormItem label="滑块透明度" >
<s:NumericStepper id="salpha" maximum="{1}" minimum="{0}" snapInterval="0.01" stepSize="0.1" allowValueWrap="false"
change="salpha_changeHandler(event)" />
</s:FormItem>
<s:FormItem label="滑动时间" >
<s:NumericStepper id="sduration" maximum="{1000}" minimum="{0}" snapInterval="1" stepSize="100" allowValueWrap="false"
change="sduration_changeHandler(event)" />
</s:FormItem>
</s:Form>
<s:Form height="100%" width="33%">
<s:FormItem label="切换状态">
<s:Button label="按我切换" click="button1_clickHandler(event)"/>
</s:FormItem>
<s:FormItem label="开文字颜色" >
<mx:ColorPicker id="onColor" change="onColor_changeHandler(event)"/>
</s:FormItem>
<s:FormItem label="关文字颜色">
<mx:ColorPicker id="offColor" change="offColor_changeHandler(event)"/>
</s:FormItem>
<s:FormItem label="开背景颜色" >
<mx:ColorPicker id="onBgColor" selectedColor="@{sb.slotOnBackgroundColor}"/>
</s:FormItem>
<s:FormItem label="关背景颜色">
<mx:ColorPicker id="offBgColor" selectedColor="@{sb.slotOffBackgroundColor}"/>
</s:FormItem>
<s:FormItem label="滑块颜色">
<mx:ColorPicker id="slideBgColor" selectedColor="@{sb.slideBackgroundColor}"/>
</s:FormItem>
</s:Form>
</s:BorderContainer>
</s:VGroup>
</s:Application>


  评论这张
 
阅读(40)| 评论(0)
推荐

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017