我正在尝试像 flex 中的地图一样缩放我的绘图,但我所做的一切都是通过 HSlider 进行缩放。你能解释一下如何像谷歌地图一样缩放我的绘图吗?
这是我的缩放代码: 我的缩放功能:
private function doZoom(component:UIComponent,val:Number):void
{
if(component is Container)
{
var children:Array = Container(component).getChildren();
for(var i:int = 0; i < children.length; i++)
{
zoomChildren(children[i], val);
}
}
}
private function zoomChildren(component:UIComponent,val:Number):void
{
component.scaleX = val;
component.scaleY = val;
if(component is Container)
{
var children:Array = Container(component).getChildren();
for(var i:int = 0; i < children.length; i++)
{
doZoom(children[i], val);
}
}
}
public function applyZoom():void
{
if(pnl == null)
{
return;
}
doZoom(pnl,zoomSlider.value);
}
和我的组件:
<s:VGroup>
<s:Button label="Загрузить SVG" click="PathsService.getPaths()"/>
<mx:Panel y="30" width="1300" height="600" id="pnl" title="Отрисовка SVG" borderColor="#008040" fontFamily="Arial" fontWeight="bold" fontSize="13">
<s:VGroup height="100%" width="100%" clipAndEnableScrolling="true">
<s:SpriteVisualElement width="100%" height="100%" id="spr" />
</s:VGroup>
</mx:Panel>
<s:HGroup height="100%" width="100%">
<s:Label text="Zoom" x="250"/>
<mx:HSlider id="zoomSlider" minimum=".1" value="1"
maximum="2" change="applyZoom()" width="180" x="300"/>
</s:HGroup>
</s:VGroup>