What is the deal with application.parameters?
I send a userId to my application to display a linechart with the application.parameter object. I get the userId parameter inside my application and can trace or alert it and I see the userId on my screen. Ok everything is working fine for now. Then I want to use the userId to call php function. And there is where it breaks. Somehow the userId parameter is empty.
example:
private var userId:int = 1234; private function init():void{ this.userId = Application.application.parameters.userId; } |
for this example I set a default value of 1234 and on creationComplete the userId is set with the real userId value, lets say that the userId in parameters is 1. If I trace the userId inside the application after the init() it returns 1. That is normal. But if I now call the remoteObject:
<mx:RemoteObject endpoint="test/test.php" id="phpCall" source="myFunction" destination="amfphp" showBusyCursor="true"> <mx:method name="getUser" fault="onFaultResult(event)" result="onResult(event)"> <mx:arguments><userId>{this.userId}</userId> </mx:method> </mx:RemoteObject> |
With this call the php function receives a userId with 1234. Very strange because we already set that with an other number.
solution for me
I tried a lot of different ways to fix this problem and now I finally found a solution. I set the value of the userId parameter inside a invisible label. And use that label to send the userId back to php.
this.userIdLabel.text =(this.userId).toString(); |
and in the remoteObject:
<mx:RemoteObject endpoint="test/test.php" id="phpCall" source="myFunction" destination="amfphp" showBusyCursor="true"> <mx:method name="getUser" fault="onFaultResult(event)" result="onResult(event)"> <mx:arguments><userId>{int(this.userIdLabel.text)}</userId> </mx:method> </mx:RemoteObject> |
Related posts:
About this entry
You’re currently reading “What is the deal with application.parameters?,” an entry on Arno Manders
- Published:
- 08.11.09 / 11am
- Category:
- Flex, General, Programming, actionscript 3












8 Comments
Jump to comment form | comments rss [?] | trackback uri [?]