ActionScript 3 and Flex 4 Zoom Gesture on SWFLoader

I seem to have a problem with Zoom Gestures on SWFLoader. I have a swf file, which is a plan of the house, I want the user to be able to zoom in and out with two fingers, the following code below is what I tried and does not work. When I test the touch screen, it does not scale when I put two fingers inside the SWF and try to zoom in.

<s:SWFLoader id="floorplanImage" source="@Embed('assets/test2.swf')" width="100%" height="100%" smoothBitmapContent="true" horizontalAlign="center" />

here is my actionscript 3 code

import flash.ui.Multitouch;  
            import flash.ui.MultitouchInputMode;  

            Multitouch.inputMode = MultitouchInputMode.GESTURE;

            import flash.events.Event;

            public var selectedItem:Object;

            public function init(): void
            {
                floorplanImage.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
            }

            public function onZoom (e:TransformGestureEvent):void{
                floorplanImage.scaleX *= e.scaleX;
                floorplanImage.scaleY *= e.scaleY; 
            }

Please, help!

UPDATE

I am following the gestouch route, however with this code I CANNOT zoom in or out on SWF. This works with a regular image, but not with SWF if I have something missing. Here is my code:

<mx:Script>
                <![CDATA[

                    import org.gestouch.events.GestureEvent;
                    import org.gestouch.gestures.TransformGesture;

                    private var _zoom:TransformGesture;

                    [Embed(source="assets/test2.swf")]
                    private var myClass:Class;
                    private var myMovieClip:MovieClip;


                    private function initModel():void
                    {   

                        myMovieClip = MovieClip(new myClass());
                        swfcontainer.addChild(myMovieClip);

                        _zoom = new TransformGesture(swfcontainer);
                        _zoom.addEventListener(org.gestouch.events.GestureEvent.GESTURE_BEGAN, onGesture);
                        _zoom.addEventListener(org.gestouch.events.GestureEvent.GESTURE_CHANGED, onGesture);

                    }

                    private function onGesture(event:org.gestouch.events.GestureEvent):void
                    {
                        const gesture:TransformGesture = event.target as TransformGesture;
                        var matrix:Matrix = swfcontainer.transform.matrix;

                        // Panning
                        matrix.translate(gesture.offsetX, gesture.offsetY);
                        swfcontainer.transform.matrix = matrix;

                        if (gesture.scale != 1)
                        {
                            // Scale and rotation.
                            var transformPoint:Point = matrix.transformPoint(swfcontainer.globalToLocal(gesture.location));
                            matrix.translate(-transformPoint.x, -transformPoint.y);
                            matrix.scale(gesture.scale, gesture.scale);
                            matrix.translate(transformPoint.x, transformPoint.y);

                            swfcontainer.transform.matrix = matrix;
                        }
                    }

                ]]>
            </mx:Script>

<mx:Image id="swfcontainer" horizontalAlign="center" width="100%" height="100%" />

, - ... , , , . ?

, , Adobe Flex Actionscript, , , .

+4
1

, , . , , Window design, SWF ;

FYI: SWF .

   _mLoader = new Loader();
 var mRequest:URLRequest = new URLRequest("drawer.swf" + "?nf=" + getTimer());
_mLoader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, onCompleteHandler);
 _mLoader.load(mRequest);


     private function onCompleteHandler(loadEvent:flash.events.Event):void
    {
          _mLoader.contentLoaderInfo.removeEventListener(flash.events.Event.COMPLETE, 
           Starling.current.nativeOverlay.addChild(LoaderInfo(loadEvent.currentTarget).content);

    }

, -, , lib, Strong

lib , Starling

GESTURE lib, flash lib

     var _zoom:
    _zoom = new TransformGesture(this);
    _zoom.addEventListener(GestureEvent.GESTURE_BEGAN, onGesture);
    _zoom.addEventListener(GestureEvent.GESTURE_CHANGED, onGesture);

private function onGesture(event:org.gestouch.events.GestureEvent):void 
    {

        const gesture:TransformGesture = event.target as TransformGesture;

        var matrix:Matrix = container_movieclip.transform.matrix;



        if (container_movieclip.scaleX!=1 || container_movieclip.scaleY!=1) 
        {
            matrix.translate(gesture.offsetX, gesture.offsetY);
            container_movieclip.transform.matrix = matrix;
        }

        if (gesture.scale != 1)
        {
            var transformPoint:Point = matrix.transformPoint(container_movieclip.globalToLocal(gesture.location));
            matrix.translate(-transformPoint.x, -transformPoint.y);
            matrix.scale(gesture.scale, gesture.scale);
            matrix.translate(transformPoint.x, transformPoint.y);
            container_movieclip.transform.matrix = matrix;

        }

    }

,

+4

Source: https://habr.com/ru/post/1680027/


All Articles