0 Replies Latest reply on Feb 28, 2015 3:39 AM by SourceSkyBoxer

    Adobe Air is very smiller than Zinc App - Reposition and Resize not working?

    SourceSkyBoxer Level 1

      Hello guys, i have found and readden nice solution like NativeWindow was saved positions and sizes If i close Adobe Air App and i open again like NativeWindow was moved and resized. It is very simple working. And it works fine. 100 % Good! But how does it work with Zinc App because it doesn't work for positions and sizes. How do i fix? I have upgraded code from FileSerializer.as With mdm.Script:

      package

      {

        import flash.events.Event;

        import flash.net.URLRequest;

        import flash.net.URLStream;

        import flash.utils.ByteArray;

       

        import mdm.Application;

        import mdm.FileSystem;

        import mdm.System;

       

       

        public class FileSerializer

        {

        public static function WriteObjectToFile(object:Object, filename:String):void

        {

       

        var fileExists:Boolean = mdm.FileSystem.fileExists(mdm.Application.path+filename);

       

        var outByte:ByteArray = new ByteArray();

        outByte.writeObject(object);

       

        if(fileExists == false)

        {

        mdm.FileSystem.saveFile(mdm.Application.path+filename, "");

        mdm.FileSystem.BinaryFile.setDataBA(outByte);

        mdm.FileSystem.BinaryFile.writeDataBA(mdm.Application.path+filename);

        }

        }

       

        private static var stream:URLStream;

        public static function ReadObjectfromFile(filename:String):Object

        {

       

        var fileExists:Boolean = mdm.FileSystem.fileExists(mdm.Application.path+filename);

       

        if(fileExists == false)

        {

        var obj:Object;

       

        stream = new URLStream();

        stream.addEventListener(Event.COMPLETE, function(evt:Event):void

        {

        obj = stream.readObject();

        stream.close();

        });

       

        stream.load(new URLRequest(filename));

       

        return obj;

        }

       

        return null;

        }

        }

      }

      That is improved to mdm.Script and it saves sometimes.

       

      And i have create UserPref.as

      package

      {

        public class UserPref

        {

        public var zincForm:String = "MainForm";

        public var zincType:String = "sizeablestandard";

        //public var zincSWF:String = "MainApp.swf";

        public var zincPosX:Number;

        public var zincPosY:Number;

        public var zincWidth:Number;

        public var zincHeight:Number;

        }

      }

       

      And i create MainApp.mxml

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

        xmlns:mx="library://ns.adobe.com/flex/mx"

        layout="absolute" applicationComplete="applicationCompleteHandler(event)" creatingComplete="creationCompleteHandler(event)">

        <fx:Script>

        <![CDATA[

        import mdm.Application;

        import mdm.Event;

        import mdm.Forms;

        import mdm.mdmForm;

       

        import mx.events.FlexEvent;

       

        private var up:UserPref;

        private var form:mdmForm;

       

        protected function applicationCompleteHandler(event:FlexEvent):void

        {

        mdm.Application.init();

       

        this.up.zincPosX = this.form.x;

        this.up.zincPosY = this.form.y;

        this.up.zincWidth = this.form.width;

        this.up.zincHeight = this.form.height;

        FileSerializer.WriteObjectToFile(this.up, "pref.zup");

       

        mdm.Application.onAppExit = function (appevt:flash.events.Event):void

        {

        mdm.Application.exit();

        };

        mdm.Application.enableExitHandler();

       

       

        }

       

        protected function creationCompleteHandler(event:flash.events.Event):void

        {

        this.up = FileSerializer.ReadObjectfromFile("pref.zup") as UserPref;

        if(up) {

        mdm.Application.onFormReposition = function(rpevt:mdm.Event):void

        {

        this.form.x = up.zincPosX;

        this.form.y = up.zincPosY;

        };

       

        mdm.Application.onFormResize = function(rsevt:mdm.Event):void

        {

        this.form.width = up.zincWidth;

        this.form.height = up.zincHeight;

        };

        }else

        {

        this.up = new UserPref();

        }

        }

       

        ]]>

        </fx:Script>

        <fx:Declarations>

        <!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->

        </fx:Declarations>

       

      </mx:Application>

       

      And i recompile with Zinc Studio 4.0.22 than i try reposition and resize with Zinc Window than i close since saved files and i open again. But why does it not reposition and resize?

       

      How do i fix? Can somebody help me?

       

      Thanks best regards Jens Eckervogt