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:

?View Code ACTIONSCRIPT
                       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.

?View Code ACTIONSCRIPT3
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>
Vote or add to Uitleg over het gebruik van deze icons : Add/Vote on eKudos Add/Vote on NUjij Add/Vote on MSN Reporter Add/Vote on Digg Stumble it! Add this article to Del.icio.us Add to Furl Add to you favourites on Technorati Add to your Google bookmarks Subscribe for the RSS-feed of this site Send this page as e-mail through Feedburner Maak een notitie op deze pagina met Fleck

Related posts:



About this entry