我需要通过 Hslider 缩放画布。问题是缩放画布后,我无法滚动到画布的最左侧和顶部,即左侧和顶部画布的某些部分不可见。我找不到原因。该示例的源代码如下所示。"
import mx.events.SliderEvent;
private function changeZoom(event:SliderEvent) : void
{
layout_cnv.scaleY = event.target.values[0]*2/100;
layout_cnv.scaleX = event.target.values[0]*2/100;
}
private function adjustDefaultZoom() : void
{
layout_cnv.scaleX = slider.values[0]/100*2;
layout_cnv.scaleY = slider.values[0]/100*2;
}
private function myDataTipFunc(val:String):String {
return String(val)+ "%";
}
]]>
</mx:Script>
<mx:Panel title="Zoom Demo" width="100%" height="100%">
<mx:Canvas id="canvas" width="100%" height="100%" horizontalScrollPosition="500">
<!--<mx:Image id="img" x="{canvas.width/2 - img.width/2}"
y="{canvas.height/2 - img.height/2}"
source="@Embed('../assets/products/Nokia_6630.png')"
creationComplete="adjustDefaultZoom()"
/>-->
<mx:Canvas visible="true" id="layout_cnv" creationComplete="adjustDefaultZoom()" borderStyle="solid" height="300"
width="500" verticalCenter="0" horizontalCenter="0"
verticalScrollPolicy="off" horizontalScrollPolicy="off" backgroundColor="#FFFFFF">
<mx:TextArea id="company_name_ta" visible="true" selectable="true" editable="true" height="20" backgroundAlpha="0.0" borderColor="#000000" width="200" fontSize="14"
borderStyle="solid" x="10" y="10" />
<mx:TextArea id="job_ta" height="20" selectable="true" borderColor="#000000" width="200" x="289" y="10" backgroundAlpha="0.0" textAlign="right"/>
<mx:TextArea id="fullname_ta" height="20" selectable="true" backgroundAlpha="0.0" borderColor="#000000" width="200" x="10" y="38" editable="true" enabled="true"/>
<mx:TextArea id="adress_line3_ta" height="20" selectable="true" backgroundAlpha="0.0" borderColor="#000000" width="200" x="10" y="268"/>
<mx:TextArea id="adress_line2_ta" height="20" selectable="true" backgroundAlpha="0.0" borderColor="#000000" width="200" x="10" y="240"/>
<mx:TextArea id="adress_line1_ta" height="20" selectable="true" backgroundAlpha="0.0" borderColor="#000000" width="200" y="212" x="10"/>
<mx:TextArea id="mobile_ta" height="20" selectable="true" backgroundAlpha="0.0" borderColor="#000000" width="200" x="289" y="40" textAlign="right"/>
<mx:TextArea id="fax_ta" height="20" selectable="true" backgroundAlpha="0.0" borderColor="#000000" width="200" y="68" x="289" textAlign="right"/>
<mx:TextArea id="email_ta" height="20" selectable="true" backgroundAlpha="0.0" borderColor="#000000" width="200" x="289" y="268" textAlign="right"/>
</mx:Canvas>
</mx:Canvas>
<mx:ControlBar horizontalAlign="center">
<mx:HSlider id="slider"
width="400"
minimum="1"
maximum="100"
labels="['0%','100%']"
values="[50]"
tickInterval="10"
snapInterval="1"
liveDragging="true"
change="changeZoom(event)"
dataTipFormatFunction="myDataTipFunc" />
</mx:ControlBar>
</mx:Panel>
"
请帮忙 。提前致谢。