flex 下拉滑块控制图片大小

vslider.mxml

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"  fontSize="14">
<mx:Script>
 <![CDATA[
  //定义图片的原始大小
  public var w:Number = 180;
  public var h:Number = 158;
  private function changeSize():void{
  //获得滑块指定的值
  var n:Number = slider1.value;
  //根据滑块指定的值获得图片新的宽和高,达到缩放图片
  image1.width=w*(4-n);
  image1.height=h*(4-n);
  }
 ]]>
</mx:Script>
    <mx:Panel title="滑块控件例子" width="611" height="564" layout="horizontal">
     <mx:VBox width="541" height="503" horizontalAlign="center"> 
     <mx:Label text="拖动滑块改变图片大小"/>
             <mx:Image width="180" height="158" id="image1" source="1.png" />
     </mx:VBox>
     <mx:HBox width="41" height="504">
                <!-- 创建滑块 -->
                 <!-- <mx:VSlider id="slider1"
                               labels="[3,1]"
                               tickInterval="0.5"
                               minimum="1"
                               maximum="3"
                               allowTrackClick="true"
                               liveDragging="true"
                            snapInterval="0.5"
                            enabled="true"
                               change="changeSize()"
                               value="3"
                               height="500"/>
                 -->

 <!-- 创建滑块 -->
                 <!-- <mx:VSlider id="slider1"
                               labels="[3,1]"
                               tickInterval="0.5"
                               minimum="1"
                               maximum="3"
                               allowTrackClick="true"
                               liveDragging="true"
                            snapInterval="0.5"
                            enabled="true"
                               change="changeSize()"
                               value="3"
                               height="500"/>
                 -->
<!-- labels="[1,3]" tickInterval="0.01" 让数值与刻度出现-->
<!--<mx:VSlider x="69" y="57" id="slider1" height="500" value="3" allowTrackClick="true" minimum="1" maximum="3" snapInterval="0.01" enabled="true" change="changeSize()"/> --> 

<mx:VSlider x="69" y="57" labels="[1,3]" id="slider1" height="500" value="3" tickInterval="0.5" allowTrackClick="true" minimum="1" maximum="3" snapInterval="0.5" enabled="true" change="changeSize()"/> 

     </mx:HBox>
        </mx:Panel>
</mx:Application>

 

 

    A+
发布日期:2009年05月13日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: