【发布时间】:2012-02-22 13:10:17
【问题描述】:
我尝试了 android 手机的放大和缩小功能,通过使用 transformGestureEvent.GESTURE_ZOOM 但它不能正确缩放,因为它总是缩放中心点,只是在内容(特定区域)内的两个手指之间不精确。
我尝试了以下 3 个用于放大和缩小的函数示例
1. private function onZoom(e:TransformGestureEvent):void/* not working properly */
{
swfLoader.scaleX *= e.scaleX;
swfLoader.scaleY *= e.scaleY;
}
2. private function onZoom(e:TransformGestureEvent):void/* not working properly */
{
swfLoader.scaleX *= (e.scaleX+e.scaleY)/2;
swfLoader.scaleY *= (e.scaleX+e.scaleY)/2;
}3. private function onZoom(e:TransformGestureEvent):void
{
// scale the view
swfLoader.scaleX *= e.scaleX;
swfLoader.scaleY *= e.scaleY;
var bounds2:Rectangle = swfLoader.content.getBounds(swfLoader.stage);
var dx:Number = bounds2.x - bounds1.x;
var dy:Number = bounds2.y - bounds1.y;
var dw:Number = bounds2.width - bounds1.width;
var dh:Number = bounds2.height - bounds1.height;
// move the view to keep it centered while zooming
swfLoader.x -= dx + dw/2;
swfLoader.y -= dy + dh/2;
}<s:BorderContainer id="contentPanel" width="100%" height="100%" backgroundColor="#cccccc" >
<s:Scroller id="scroller" width="100%" height="100%" >
<s:VGroup id="swfloadergroup" width="100%" height="100%" horizontalAlign="center" verticalAlign="middle" >
<s:SWFLoader id="swfLoader" smoothBitmapContent="true" autoLoad="true" doubleClickEnabled="true"
maintainAspectRatio="true" gestureZoom="onZoom(event)" scaleContent="true" loadForCompatibility="true" />
<s:SWFLoader id="preLLoader" autoLoad="true" width="30%" height="30%"
source="@Embed('assets/loading.swf')"
maintainAspectRatio="true" scaleContent="true "/>
</s:VGroup>
</s:Scroller>
</s:BorderContainer>
那么我的代码出了什么问题。我如何在两根手指之间缩放精确的内容(特定区域)。如果有人知道,请告诉我。
【问题讨论】:
标签: android actionscript-3 apache-flex flex4.5