actionscript 3 - Adobe Air - Save window size and position -


i'm trying write xml file save position , size of app window in it. i'm running error:

typeerror: error #1010: term undefined , has no properties. maintimeline/setupwindow()

as:

import flash.display.nativewindowinitoptions; import flash.display.nativewindowsystemchrome; import flash.display.nativewindowtype; import flash.display.nativewindow;   function setupwindow(e:event = null):void {     gotolastposition();     this.nativewindow.addeventlistener( event.closing, saveappposition ); }  function saveappposition(e:event = null):void {     var xml:xml = new xml('<position x="' + this.nativewindow.x + '" y="' + this.nativewindow.y + '" width="' + this.width + '" height="' + this.height + '"/>');      var f:file = file.applicationstoragedirectory.resolvepath("appposition.xml");     var s:filestream = new filestream();     try     {         s.open(f,flash.filesystem.filemode.write);         s.writeutfbytes(xml.toxmlstring());     }     catch (e:error)     {         //trace(error( e ));     }         {         s.close();     } }  function gotolastposition():void {     var f:file = file.applicationstoragedirectory.resolvepath("appposition.xml");     if (f.exists)     {         var s:filestream = new filestream();         try         {             s.open(f,flash.filesystem.filemode.read);             var xml:xml = xml(s.readutfbytes(s.bytesavailable));              this.nativewindow.x = xml. @ x;             this.nativewindow.y = xml. @ y;             this.width = xml. @ width;             this.height = xml. @ height;         }                 {             s.close();         }     } }   setupwindow() 

what wrong code?

it call setupwindow() causing error, not saveappposition method. executed file processed , nativewindow not yet ready.

move setupwindow() call method (flexevent.creation_complete handler instance) , try again.

hope helps.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -