2011-12-28 27 views
1

是否有任何(直接的)方式來解決Flex中多點觸控縮放事件的動態註冊問題?我無法圍繞這個包裹我的頭。Flex多點觸摸路徑比例尺動態註冊問題

我得到的是(在一些行和標籤中)組中的一條路徑,它本身被包裹在一個滾動條中;

<s:Scroller id="scroller"> 
    <s:Group id="scrollerContent"> 

    <s:Path id="path"> 
     <s:stroke> 
      <s:SolidColorStroke color="#ffffff" weight="2"/> 
     </s:stroke> 
     </s:Path> 
    </s:Group> 
</s:Scroller> 

我希望做的是在放大和縮小的路徑(和scrollerContent組中的其他東西),所以在我的creationComplete()方法,我添加了一個事件監聽到scrollerContent組:

scrollerContent.addEventListener(TransformGestureEvent.GESTURE_ZOOM, zoomEvent); 

這裏是克里斯托夫Coenraets提供用於他的圖表例的代碼(它實際上縮放路徑,基於x = 0雖然;

private function zoomEvent(e:TransformGestureEvent):void 
{ 
    zoom(e.scaleX, e.scaleY); 
} 
protected function zoom(scaleX:Number):void 
{ 
    var w:Number = path.width * scaleX; 
    if (scaleX>1) 
     path.width = w > width*5 ? width*5 : w; 
    else 
    { 
      path.width = w < width ? width : w; 
      if (path.x + path.width < width) path.x = width - path.width; 
     } 
} 

我知道的DynamicRegistration類,但不能正常工作,它仍然基於x = 0點縮放路徑。

DynamicRegistration.scale(scrollerContent, new Point(e.localX, e.localY), scrollerContent.scaleX*= e.scaleX, scrollerContent.scaleY=1); 

任何有關這方面的幫助將不勝感激!

+0

難道沒有一個人面對這問題?或者是否有更簡單的方法來縮放任何給定點的圖表?我知道GestureWorks爲此提供了一個可用的API,但如果可能的話,我想避免購買許可證,因爲我認爲對於有經驗的Flex/AS3開發人員來說,這種註冊並不是什麼大問題。 – AlBirdie 2011-12-30 13:42:38

回答

1

我用DynamicRegistration類,並得到了它的工作就是這樣,如果你還有興趣:

protected function onZoom(e:TransformGestureEvent, img:Image):void 
{ 
    DynamicRegistration.scale(img, new Point(e.localX, e.localY), img.scaleX*e.scaleX, img.scaleY*e.scaleY); 
} 

或者與本地彎曲法:

protected function onZoom(e:TransformGestureEvent, img:Image):void 
    { 
    img.transformAround(new Vector3D(e.localX, e.localY, 0), new Vector3D(img.scaleX*e.scaleX, img.scaleY*e.scaleY, 0)); 
    }