UginL7
11.11.2009, 12:19
Тема может и избита, но ответа я так и не нашёл....
Вообщем суть вопроса:
Есть вот такой код из Файл1.as
var chSendData:connectToDB = new connectToDB(mcErr);
this.chLineAll = chSendData.chData(this.chLine.text+"\n");
Это отрабатывает при нажатии на кнопку и передаётся в РНР, тут проблем нет (и забегая на перёд - есть одновременно, в this.chLineAll ничего не приходит )
вот реализация connectToDB из Файл2.as
public function chData(chString:String):String
{
this.strChatLine = "";
this.urlRequestScript = new URLRequest("http://10.8.98.11/magic.ua/php/chat.php")
this.urlRequestScript.method = URLRequestMethod.POST;
this.urlLoaderData.addEventListener(Event.COMPLETE, sendChatString);
this.urlVarible.strChat = chString;
this.urlRequestScript.data = this.urlVarible;
this.urlLoaderData.dataFormat = URLLoaderDataFormat.TEXT;
try
{
this.urlLoaderData.load(this.urlRequestScript);
}
catch (err:Error)
{
var mcURLErr:errWindow = new errWindow("Ошибки при передаче данных в БД", this.mcErr);
}
return this.strChatLine; //Отрабатывает раньше, чем this.strChatLine принимает значение от РНР
}
internal function sendChatString(e:Event):void
{
this.strChatLine = e.target.data;
var mcURLErr:errWindow = new errWindow(this.strChatLine, this.mcErr);
this.urlLoaderData.removeEventListener(Event.COMPLETE, sendChatString);
}
Как я понимаю, что просто задача по получению данных уходит в другой поток и отрабатывает уже потом, после того как был отработан return.
Так вот сам вопрос как сделать задержку, что б this.strChatLine принимал значение и только потом отрабатывал return!?
пробовал сделать вот так
{
....
while(this.strChatLine == "")
{
}
return this.strChatLine;
}
но тогда флешка вылетает по таймауту, и к тому же это не есть хорошо.
Вообщем суть вопроса:
Есть вот такой код из Файл1.as
var chSendData:connectToDB = new connectToDB(mcErr);
this.chLineAll = chSendData.chData(this.chLine.text+"\n");
Это отрабатывает при нажатии на кнопку и передаётся в РНР, тут проблем нет (и забегая на перёд - есть одновременно, в this.chLineAll ничего не приходит )
вот реализация connectToDB из Файл2.as
public function chData(chString:String):String
{
this.strChatLine = "";
this.urlRequestScript = new URLRequest("http://10.8.98.11/magic.ua/php/chat.php")
this.urlRequestScript.method = URLRequestMethod.POST;
this.urlLoaderData.addEventListener(Event.COMPLETE, sendChatString);
this.urlVarible.strChat = chString;
this.urlRequestScript.data = this.urlVarible;
this.urlLoaderData.dataFormat = URLLoaderDataFormat.TEXT;
try
{
this.urlLoaderData.load(this.urlRequestScript);
}
catch (err:Error)
{
var mcURLErr:errWindow = new errWindow("Ошибки при передаче данных в БД", this.mcErr);
}
return this.strChatLine; //Отрабатывает раньше, чем this.strChatLine принимает значение от РНР
}
internal function sendChatString(e:Event):void
{
this.strChatLine = e.target.data;
var mcURLErr:errWindow = new errWindow(this.strChatLine, this.mcErr);
this.urlLoaderData.removeEventListener(Event.COMPLETE, sendChatString);
}
Как я понимаю, что просто задача по получению данных уходит в другой поток и отрабатывает уже потом, после того как был отработан return.
Так вот сам вопрос как сделать задержку, что б this.strChatLine принимал значение и только потом отрабатывал return!?
пробовал сделать вот так
{
....
while(this.strChatLine == "")
{
}
return this.strChatLine;
}
но тогда флешка вылетает по таймауту, и к тому же это не есть хорошо.