我嘗試使用 transformGestureEvent.GESTURE_ZOOM對Android手機進行放大和縮小功能,但它沒有正確縮放,因爲它始終只在內容中的兩個手指之間縮放中心點(特定區)。Flex GestureZoom無法正常工作特定區域
我試過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>
那麼,什麼做錯了我的代碼。我如何縮放兩個手指之間的確切內容(特定區域)。如果有人知道,請讓我知道。
仍然不能正常工作。當手勢階段結束時,我試着保持localx和oldlocaly。和當手勢開始設置這些VARS到當前localx/Y但工作任何想法...如果(event.phase == GesturePhase.END)\t { \t \t \t \t \t跟蹤( '結束' + oldlocalY); \t \t \t \t \t \t \t \t \t \t oldlocalX = event.localX; \t \t \t \t \t oldlocalY = event.localY; \t \t \t \t \t \t \t \t \t} – user1206485 2012-02-23 06:13:14
感謝瓦倫丁:) – user1206485 2012-02-23 10:27:37