Показать сообщение отдельно
Старый 16.07.2015, 21:44
ArtS вне форума Посмотреть профиль Отправить личное сообщение для ArtS Найти все сообщения от ArtS
  № 8  
Ответить с цитированием
ArtS

Регистрация: Mar 2013
Сообщений: 19
Цитата:
Сообщение от callme Посмотреть сообщение
Ошибка выдается потому что переменная now_weight_loa существует только в теле функции now_weight_pol.



Объясните подробнее что вы хотите сделать.
У меня получается такой код:
Код AS3:
function first_weight_pol(): void {
	viewer_id = flashVars['viewer_id'];
	var first_weight_loa: URLLoader = new URLLoader();
	var request: URLRequest = new URLRequest('/first_weight.php'); // адрес вашего скрипта
	request.method = URLRequestMethod.POST;
	var vars: URLVariables = new URLVariables();
	vars['viewer_id'] = viewer_id;
	request.data = vars;
	first_weight_loa.addEventListener(Event.COMPLETE, onComplete);
	first_weight_loa.load(request);
	first_weight_loa.addEventListener(IOErrorEvent.IO_ERROR, qonCom1lete2112);
	function qonCom1lete2112(event: Event): void {
		first_weight_pol();
	}
	function onComplete(event: Event): void {
		first_weight.text = first_weight_loa.data;
	}
}
first_weight_pol();
 
function now_weight_pol(): void {
	viewer_id = flashVars['viewer_id'];
	var now_weight_loa: URLLoader = new URLLoader();
	var request: URLRequest = new URLRequest('/now_weight.php'); // адрес вашего скрипта
	request.method = URLRequestMethod.POST;
	var vars1: URLVariables = new URLVariables();
	vars1['viewer_id'] = viewer_id;
	request.data = vars1;
	now_weight_loa.addEventListener(Event.COMPLETE, onComplete1);
	now_weight_loa.load(request);
	now_weight_loa.addEventListener(IOErrorEvent.IO_ERROR, qonCom1lete21121);
	function qonCom1lete21121(event: Event): void {
		now_weight_pol();
	}
	function onComplete1(event: Event): void {
		now_weight.text = now_weight_loa.data;
	}
}
now_weight_pol();
 
///Вычисление
var mySum1: Number = Number(now_weight_loa.data) - Number(first_weight_loa.data);
итог.text = mySum1.toString();
Но выдает ошибку

Добавлено через 1 час 24 минуты
Решено, спасибо.


Последний раз редактировалось udaaff; 16.07.2015 в 22:15.