<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Canvas id="box" scaleX="{doResize(scale)}" x="10" y="10" width="225" height="227" color="#000000"> <mx:Image x="35.5" y="10" source="img/5.jpg" width="154" height="207"/> </mx:Canvas> <mx:HSlider x="25" y="245" id="slider" change="scale=slider.value" minimum="0" maximum="1"/> <mx:Zoom id="zoom" target="{box}"></mx:Zoom> <!-- 动画效果zoom --> <mx:Script> <![CDATA[ //使用[Bindable]后,下一行表达式定义的变量就可以被用在绑定中。 [Bindable] //为了使参数scale具备绑定功能,所以使用了[Bindable]标签,[Bindable]专门用来定义绑定中的数据源对象 private var scale:Number=1; internal function doResize(num:Number):Number{ zoom.zoomWidthTo=num; zoom.play(); return box.scaleX; //这里必须有返回值,供属性scaleX使用。 } ]]> </mx:Script></mx:Application>