A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: AS3 Reposition and Resize with Zinc Application and JSON works fine.

  1. #1
    Junior Member
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    15

    Wink AS3 Reposition and Resize with Zinc Application and JSON works fine.

    Hey Sirs & Ladies,

    i have built json with Zinc 4.0.22

    Code:
    PHP Code:
    <?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"
                    applicationComplete="onApplicationCompleteHandler(event)"
                    creationComplete="onCreationCompleteHandler(event)"
                    layout="absolute">
        <fx:Script>
            <![CDATA[
                
                import mdm.*;
                
                import mx.events.FlexEvent;
                
                private var myForm:mdmForm = mdm.Forms.getFormByName("MainForm");
                private var myPrefFile:String = "pref.json";
                private var urlLoader:URLLoader;
                private var urlReq:URLRequest;
                
                protected function onCreationCompleteHandler(event:FlexEvent):void
                {
                    mdm.Application.init();
                    
                    var exists:Boolean = mdm.FileSystem.fileExists(myPrefFile);
                    
                    if(exists == false)
                    {
                        // false
                        myForm.visible = true;
                        
                    }else{
                        // true
                        
                        urlReq = new URLRequest(myPrefFile);
                        
                        urlLoader = new URLLoader();
                        urlLoader.addEventListener(flash.events.Event.COMPLETE, onCompleteLoader);
                        urlLoader.load(urlReq);
                    }
                }
                
                protected function onCompleteLoader(evt:flash.events.Event):void
                {
                    var jsonObj:Object = JSON.parse(urlLoader.data);
                    
                    myForm.x = jsonObj.posx;                
                    myForm.y = jsonObj.posy;
                    myForm.width = jsonObj.appwidth;
                    myForm.height = jsonObj.appheight;
                    textarea.text = jsonObj.message;
                    
                    myForm.visible = true;
                }
                
                
                protected function onApplicationCompleteHandler(event:FlexEvent):void
                {
                    mdm.Application.addEventListener("onAppExit", onAppExitHandler);
                    mdm.Application.enableExitHandler();
                }
                
                private function onAppExitHandler(evt:flash.events.Event):void
                {
                    
                    var objString:String = JSON.stringify({
                        posx:this.myForm.x,
                        posy:this.myForm.y,
                        appwidth:this.myForm.width,
                        appheight:this.myForm.height,
                        message:this.textarea.text
                    });
                    
                    mdm.FileSystem.saveFile(myPrefFile, objString);
                    
                    mdm.Application.exit();
                }
                
            ]]>
        </fx:Script>
        
        <fx:Declarations>
            <!-- Platzieren Sie nichtvisuelle Elemente (z.*B. Dienste, Wertobjekte) hier -->
        </fx:Declarations>
        <mx:TextArea id="textarea" left="10" right="10" top="10" bottom="10"/>
    </mx:Application>
    And use MDM Zinc 4.0.22 right Panel: Change to sizable Standard and visibale = false;
    Don't worry!

    Bottom Panel: Switch to Extension "mdm.FileSystem" marks "X"

    Than it compiles.

    If you write message like this "Hello I am here and i save it. Don't worry!" than you Close Zinc app and open again from compiled Directory like C:\Users\<Username>\Adobe Flash Builder 4.6\<Name of Project>\bin\My Flash Application.exe and you see what does it happen? It saved after loading data.

    If you want know. Zinc app saves "pref.json" and you can check Notepad++ or Editor
    Example saved Preference file:
    Code:
    {"message":"Hello Jens this is example message.\r\rYes it works fine :D","appheight":719,"appwidth":867,"posx":195,"posy":141}
    And i would like to know: How do i add / remove line into json file? Example plugin is Array:

    Plugin:
    1-plugin-name
    2-plugin-name
    ...

    Than i would like delete 1-plugin-name and it doesn't matter for saving and updating json file.

    Thanks for help and Suggestion.

    P.S: Thanks for welcome to our Forum
    Best regards, SourceSkyBoxer

  2. #2
    Junior Member
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    15
    Hey Sirs & Ladies, why do you not answer me?

    P.S. I have created 3 threads why do kidding admins not want to support me?
    Are you okay? Or I have written bad English? I m deaf from Germany.

    Thanks!

  3. #3
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Oh so you are basically forcing people into supporting and helping you? xD that's cute
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  4. #4
    Senior Member
    Join Date
    Aug 2012
    Posts
    124
    You help him angle, you have master of more skills now, you may earn large money from skills.

  5. #5
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Quote Originally Posted by Terrencing View Post
    You help him angle, you have master of more skills now, you may earn large money from skills.
    So my doctor HAS TO attend me for free, because he has master of more skills now...?

    Nice to see you again Terrencing, hope you are doing great
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  6. #6
    Senior Member
    Join Date
    Aug 2012
    Posts
    124
    mayb he pay you if help , you want money like doctor , show some code , he offer pay maybee.
    perhap you not know code of this

  7. #7
    Junior Member
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    15
    Hello my dear @angelhdz and @Terrencing are you okay?? I think you know code or not? Ia m sorry i am nervous :/ I must keep cool Thanks

    File System If folder doesn't exist than it creates and if file doesn't exist than it will create tempfile and write from embedded file to local file? Is it possible?

  8. #8
    Junior Member
    Join Date
    Apr 2015
    Location
    Germany
    Posts
    15
    Sorry moved to Thread - MDM Zinc is died now
    Attached Images Attached Images
    Last edited by SourceSKyBoxer; 08-30-2015 at 02:42 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center