Показать сообщение отдельно
Старый 22.09.2008, 17:07
Alex Lexcuk вне форума Посмотреть профиль Отправить личное сообщение для Alex Lexcuk Посетить домашнюю страницу Alex Lexcuk Найти все сообщения от Alex Lexcuk
  № 9  
Ответить с цитированием
Alex Lexcuk

блогер
Регистрация: Mar 2008
Адрес: Донецк_city
Сообщений: 1,094
Записей в блоге: 5
Код:
var txt:TextField = new TextField();
txt.text = "hello";
txt.autoSize = TextFieldAutoSize.LEFT;
addChild(txt);//добавить на рабочее поле
txt.scaleX = txt.scaleY = 3;
var loc_data:Date = new Date();
var break_data:Date = new Date();
var cor:uint;

var myTimer:Timer;
myTimer = new Timer(1000);
myTimer.addEventListener("timer", timerHandler);

var url:String = "http://www.dnadillo.dn.ua/fla/dn-time.php?t="+loc_data.getTime();
//?t="+new Date().getTime(); - это чтоб рнр файл не кешировался
var request:URLRequest = new URLRequest(url);

var loader:URLLoader = new URLLoader();
configureListeners(loader);
try {
	loader.load(request);
} catch (error:Error) {
	trace("Unable to load requested document.");
}

function configureListeners(dispatcher:IEventDispatcher):void {
	dispatcher.addEventListener(Event.COMPLETE, completeHandler);
}
function completeHandler(event:Event):void {
	var loader2:URLLoader = URLLoader(event.target);
	var variables:URLVariables = new URLVariables(loader2.data);

	trace("Время Сайта "+variables.dn_time);
	trace("Время Компа "+loc_data.getTime());	
	cor = loc_data.getTime() - Number(variables.dn_time)*1000;
	
	trace(uint(break_data.hours)+":"+uint(break_data.minutes));
	myTimer.start();
}


function timerHandler(event:TimerEvent) {
break_data.setTime(loc_data.getTime() - cor);
txt.text='Время сайта \n http://www.dnadillo.dn.ua/\n'+break_data.hours+":"+break_data.minutes;
txt.text=txt.text+'\nВремя КОМПА '+loc_data.getHours()+":"+loc_data.getMinutes();
}

/*<?php
//определение времени
$result_time = time(); 
//типа 1222084214

echo 'dn_time='.$result_time; //вывод в браузер (флешка, можно и в Opera IE7 и т.д.)

?>
*/


Последний раз редактировалось Alex Lexcuk; 22.09.2008 в 17:20.