【发布时间】:2010-02-25 15:37:49
【问题描述】:
好的,我正在努力做到这一点,以便当用户启动我的空中应用程序时,它会自行定位并调整自身大小,使其与上次打开时的大小一致。
这是我的代码:
private function init():void
{
gotoLastPosition();
this.nativeWindow.addEventListener( Event.CLOSING, saveAppPosition );
}
private 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());
s.close();
}
catch(e:Error){}
}
private function gotoLastPosition():void
{
var f:File = File.applicationStorageDirectory.resolvePath("appPosition.xml");
if(f.exists)
{
var s:FileStream = new FileStream();
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;
}
}
这确实有效,但是,我收到用户的抱怨,有时当他们启动应用程序时,找不到它的位置(屏幕外),他们可以右键单击任务栏项目并将其最大化以将其取回,但这不是必需的。
我只能假设这个问题是由我试图保存应用程序的位置引起的。我不知道可能出了什么问题,或者我该如何解决这个问题?
也许一种方法可以在定位后判断应用是否在屏幕外,如果是,则将其移动到屏幕上?不知道我该怎么做?
有什么想法吗?
谢谢!!!
【问题讨论】:
-
这种情况是否只发生在用户拥有多台显示器的情况下,或者当他们使用笔记本电脑插入不同分辨率的不同投影仪时,或者在同一用户的单显示器情况下?
-
我不确定,我不这么认为,1 位用户正在使用他的笔记本电脑并且正在度假,很确定它没有连接到投影仪。我现在想知道xml文件是否会以某种方式损坏。
标签: apache-flex air application-settings