1

我正在使用带有图像视图的 flash builder 开发 android 和 iPhone 应用程序,但是每当我通过捏合缩放在 Galaxy s3 或 iPhone 上测试我的应用程序时,我都无法保持纵横比(图像高度和宽度),而它工作正常在银河 s2 上。

我正在使用此代码..

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        xmlns:com="com.*">
    <fx:Script>
        <![CDATA[
            [Embed(source="assets/image.jpg")]
            [Bindable]
            public var desertImage:Class;  


        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:titleContent>
        <s:Label color="#FFFFFF" fontWeight="bold" fontSize="25" text="Districts"/>
    </s:titleContent>

    <s:Group id="parentContaner"  width="100%" height="100%"  >
        <com:GestureImage x="1" y="2" width="{this.width}" height="{this.height}" source="{desertImage}" smooth="true" scaleMode="letterbox"    />

    </s:Group>


</s:View>

手势图像。作为捏缩放功能..

    private function onGesturePinch(pinchEvent:TransformGestureEvent):void{
        setAsCurrentChild();  
        var pinchMatrix:Matrix = this.transform.matrix;  
        var pinchPoint:Point =  
            pinchMatrix.transformPoint(  
                new Point((this.width/2), (this.height/2)));  
        pinchMatrix.translate(-pinchPoint.x, -pinchPoint.y);  
        pinchMatrix.scale(pinchEvent.scaleX, pinchEvent.scaleY);  
        pinchMatrix.translate(pinchPoint.x, pinchPoint.y);  
        this.transform.matrix = pinchMatrix;  
    }
4

0 回答 0