This content has been marked as final. Show 9 replies
I don't know PHP, so take that into account.
The onResultLogin will be called every time you successfully call the php service, regardless of the content of the result. So you will always switch to "Desktop" when you do a send. Only if there is a hard fault, will the result handler not be called.
The data returned by the call is located in the result object:
Exactly what it is depends on the resultFormat of the data service call. What Dataservice are you using(HTTPService, Webservice, RemoteObject)?
What is that PHP function returning? I advise you use XML to pass data around. It is the most easy to debug.
I'm using RemotObject. How can I see what is getting returned in the event.result object? I tried trace(event.result); but it never displays anything.
Preferably, I'd like to do a check in Flex as to whether "true" is returned. If it is, change to the Desktop state, if not, got to a different state. I just can't figure out the syntax to do this.
Your approach is correct. All you need to do is to be able to access the data in the result object.
RemoteObject is almost certainly defaulting to mx:Object. Unfortunately, Object is a bit difficult to debug compared to xml.
Are you using Flex Builder, where you can examine the contents of result in real time?
If not then it is trial and error to figure out the actual structure of the result object. Or you might find a "dumper" that will read out the contents of an object.
It looks like the PHP is returning a boolean? Maybe you can change the result format="string" (?text? You'll need to check the docs)
If it was me, I would change the php to return an xml string:
then set resultFormat="e4x",
then in the result handler do:
var sStatus:String = XML(event.result).text().toString(); //will be "true" or "false"
I am using Flex Builder, but really just started with it last week, so am not up on all it's features.
I'm not quite sure what it is this line does and where you are suggesting it should be.
then set resultFormat="e4x",
resultFormat is a property of all of the data sevice classes. It determines how the result data from the call will be stored in Flex. The default is Object, but e4x is the latest and greatest XML object(node).
You should use this if at all possible.
If you want to try, post back and I'll help.
If you want you can debug the data call in Flex Builder, and look at the result object directly in the watch panel..
The Console Panel only returns this, whether I use a username and password or not:
ReferenceError: Error #1056: Cannot create property isError on mx.messaging.AcknowledgeMessage.
Missed one line. It also returns "null".
Your php looks like it is returning a boolean. I don't think this is a good idea, especially if you are having trouble. Flex handles strings, xml, objects. Try a string.