-
Because the result is just an int, then to get the result you will say
loginResult = e.data;
It is nothing more complex than that.
The 'data' in e.data is refering to the result. That result is simply an int. In the weather case, it was returning an object that had properties. hence having to say e.data.Latitude. The 'data' is the base of the results.
-
When I use loginResult = e.data; it has the following error:
1118: Implicit coercion of a value with static type Object to a possibly unrelated type int.
But the result is just an int, why it throws such error?
-
I searched that I need to cast the object to int
loginResult = int(e.data);
Then, it works!
Also, your method to pass parameters across frames also work!
Thank you very much.
-
Glad to see anyone using web services. I love them.
-
Hi
I encountered a strange problem.
Yes, it did work when I run it by Ctrl + Enter on Flash CS3.
Then, I publish it with html.
When I open http://127.0.0.1/FlashWS, I can see the login screen of flash.
However, it does not has response after I input username and password and click login button.
When I just open the swf locally, it is able to login. Just not able to login if embed into a html.
Do you have any idea?
-
Hi
The strange problem has not solved yet.
I added some debug note insides the code:
Code:
butLogin.addEventListener(MouseEvent.CLICK, doLogin);
function doLogin(event:MouseEvent)
{
prompt.text = "doLogin";
UserName = txtUsername.text;
Password = txtPassword.text;
trace("username " + UserName + ", password " + Password);
var ws = new WebService("http://XXX.XXX.XXX.XXX/FlashWS/Service.asmx?wsdl"); //it is a public ip
var op:Operation = new Operation(ws);
prompt.text = "ws";
op.addEventListener(OperationEvent.COMPLETE, onResult);
op.addEventListener(OperationEvent.FAILED, onFault);
op.CheckOperatorLogin(txtUsername.text,txtPassword.text);
prompt.text = "call function";
trace("txtUsername: " + txtUsername.text + ", txtPassword " + txtPassword.text);
function onResult(e:OperationEvent):void {
prompt.text = "onResult";
for (var prop in e.data){
trace (e.data[prop]);
}
loginResult = int(e.data);
trace("Login Result: " + loginResult);
prompt.text = "Login Result";
if (loginResult > 0){
prompt.text = "gotoandplay";
gotoAndStop(2);
} else {
stop();
}
}
function onFault (e:OperationEvent):void {
trace (e.data);
}
}
When I run it in Flash CS3, it can login and goto next frame.
When I run it on webserver, it runs up to the line
prompt.text = "call function";
Why was that?