![]() |
|
||||||||||
|
|||||
|
Регистрация: Mar 2013
Сообщений: 19
|
Делаю получение данных, и использование их для вычисления.
///получение числа 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(now_weight_loa.data); необходимый_вес.text=mySum1.toString(); Цитата:
![]() |
|
|||||
|
...
модератор форума
Регистрация: Sep 2006
Адрес: Minsk
Сообщений: 4,286
|
|
|
|||||
|
Регистрация: Mar 2013
Сообщений: 19
|
Спасибо, но так не подходит, так как второе число (Number(now_weight_loa.data)) необходимо взять с другой функции.
|
|
|||||
|
Регистрация: Dec 2014
Сообщений: 312
|
Ошибка выдается потому что переменная now_weight_loa существует только в теле функции now_weight_pol.
Цитата:
|
|
|||||
|
[+4 25.07.12]
Регистрация: Nov 2010
Сообщений: 13
|
У вас now_weight_loa декларируется в методе now_weight_pol и область видимости переменной ограничивается методом, а вы пытаетесь пробиться к нему из вне, отсюда и ошибка:
Обращение несуществующего свойства now_weight_loa. |
|
|||||
|
Регистрация: Mar 2013
Сообщений: 19
|
Цитата:
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. |
![]() |
![]() |
Часовой пояс GMT +4, время: 21:17. |
|
|
« Предыдущая тема | Следующая тема » |
|
|