【发布时间】:2013-01-15 21:19:34
【问题描述】:
我有一个内置于 Flash cs5 中的 Adobe Air 桌面留言板应用程序,它在动态文本字段中加载一个外部“.txt”文件,并每 2 分钟检查一次新文件。仅当文件是新文件时,我才需要它以 (NotificationType.CRITICAL) 通知用户,而不仅仅是每次加载它时。有可能吗?
应用中的所有代码:
NativeApplication.nativeApplication.startAtLogin=true
stage.nativeWindow.alwaysInFront=true;
//external text file load and recheck every 2 minutes
var myInterval:uint = setInterval (loadUrl, 120000);
var loader:URLLoader = new URLLoader(new URLRequest("https://my_text_file.txt"));
loader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void {
var loadedText:URLLoader = URLLoader(event.target);
if(myText_txt.htmlText!=loadedText.data){
myText_txt.htmlText = loadedText.data;
stage.nativeWindow.notifyUser(NotificationType.CRITICAL)
}else {
//do nothing
}
}
function loadUrl():void {
loader = new URLLoader(new URLRequest("https:///my_text_file.txt"));
loader.addEventListener(Event.COMPLETE, completeHandler);
}
// button control
Minimize_BTN.addEventListener(MouseEvent.CLICK, minimize);
function minimize(e:MouseEvent){
stage.nativeWindow.minimize();
}
drag_BTN.addEventListener(MouseEvent.MOUSE_DOWN, drag);
function drag(e:MouseEvent){
stage.nativeWindow.startMove();
}
stop(); //Stop on the frame you want
【问题讨论】:
-
您仍然需要存储旧的 txt 值。
标签: actionscript-3 air flash-cs5