Я реверсирую разработку старой флеш-игры, и при входе в систему на сервер отправляется запрос POST. ActionScript2:
req.username = inicial.login_mc.username_txt.text;
req.password = inicial.login_mc.password_txt.text;
xmlResponse = new LoadVars();
xmlResponse.onLoad = function() {
xml = new XML(xmlResponse.xml);
trace("login xml: " + xml);
user = xml.childNodes[0];
};
url_login = "api/auth/user";
req.sendAndLoad(url_login, xmlResponse, "POST");
Запрос:
Request URL: http://localhost:3000/api/auth/user
Request Method: POST
Status Code: 200 OK
Remote Address: [::1]:3000
Referrer Policy: no-referrer-when-downgrade
username: aaaa
password: aaaa
Мой ответ:
Connection: keep-alive
Content-Length: 58
Content-Type: application/xml; charset=utf-8
Date: Sun, 18 Mar 2018 20:19:50 GMT
ETag: W/"3a-G4M/BpWRvMgDdvlmOtNMapl/lLw"
X-Powered-By: Express
<response hello = "world"><hi>howdoing</hi></response>
Проблема: флеш-память не получает ответа, а xml всегда пуст. flashlog.txt:
Warning: getClassStyleDeclaration is not a function
login xml:
Content-Type: text / xml тоже не работают.
Что это могло быть?





Это может вам помочь
var my_xml = new XML();
var myLoginReply_xml = new XML();
myLoginReply_xml.ignoreWhite = true;
myLoginReply_xml.onLoad = function(success){
if (success) {
// xml response with success
} else {
// failure
}
};
my_xml.sendAndLoad("YOUR_URL", myLoginReply_xml);
Если вы My response (цитируется ниже):
My response:
Connection: keep-alive
Content-Length: 58
Content-Type: application/xml; charset=utf-8
Date: Sun, 18 Mar 2018 20:19:50 GMT
ETag: W/"3a-G4M/BpWRvMgDdvlmOtNMapl/lLw"
X-Powered-By: Express>
<response hello = "world"><hi>howdoing</hi></response>
... Это то, что вы получаете обратно в AS2 (в String), тогда вы можете извлечь XML из этой строки.
Похоже, эта часть - ваши XML-данные:
<response hello = "world"><hi>howdoing</hi></response>
В приведенном ниже коде есть один пример извлечения в виде XML (например, рассмотрите также метод ParseXML):
var txt_response :String = ""; //original response string
var txt_XML :String = ""; //(extracted) string to be converted into XML object
//# //////////////////////////////////////////////////////////
//# 01) Get the Response :
txt_response = "Connection: keep-alive\nContent-Length: 58\nContent-Type: application/xml; charset=utf-8\nDate: Sun, 18 Mar 2018 20:19:50 GMT\nETag: W/\"3a-G4M/BpWRvMgDdvlmOtNMapl/lLw\"\nX-Powered-By: Express\n<response hello=\"world\"><hi>howdoing</hi></response>";
trace("txt_response : \n" + txt_response);//check if expected Response text
//# //////////////////////////////////////////////////////////
//# 02) Extract XML data from Response :
//# using: substring (start_Pos:Number, END_Pos:Number);
var pos_Start :Number = 0;
var pos_End :Number = 0;
pos_Start = txt_response.indexOf("<response");
pos_End = txt_response.indexOf("/response>");
txt_XML = txt_response.substring( pos_Start, pos_End+10); //+10 to reach end of this word (include it)
trace("txt_XML : \n" + txt_XML); //check if correct extract before using as XML
//# //////////////////////////////////////////////////////////
//# 03) Convert extracted text to XML :
var my_xml:XML = new XML(txt_XML);
trace( "checking XML attribute ( hello ) : " + my_xml.firstChild.attributes.hello); //gives: world
Использование my_xml.firstChild.attributes.hello показывает world как запись. Это то, что тебе надо?
Как я могу изменить SWF-код? Несколько недель назад я пробовал некоторые инструменты, но никто не работал.