You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@royale.apache.org by GitBox <gi...@apache.org> on 2019/10/21 22:45:04 UTC

[GitHub] [royale-asjs] aharui commented on issue #507: Issue in dbzutil

aharui commented on issue #507: Issue in dbzutil 
URL: https://github.com/apache/royale-asjs/issues/507#issuecomment-544739371
 
 
   The important part of your code is here
   
   ```
   		//Get Selected Row index of AdvancedDataGrid
   		public static function getSelRowIndex(dg:AdvancedDataGrid, aFieldName:String, aSelKey:String):uint {
   			var rowIndex:uint = 0;
   			if(aSelKey != null) {
   				var breakMainLoop:Boolean = false;
   				var dgDP:Object = dg.dataProvider;
   				var arrDGSelKey:Array = aFieldName.split("~");
   				var arrVOSelKey:Array = aSelKey.split("~");
   				var strDGSelKey:String = "";
   				var strVOSelKey:String = "";
   				for (var i:int = 0; i < arrVOSelKey.length; i++) {
   					strVOSelKey += arrVOSelKey[i] + "~";
   				}
   				strVOSelKey = strVOSelKey.indexOf('~') > -1 ? strVOSelKey.substring(0, (strVOSelKey.length)-1) : 
   					strVOSelKey;
   				if(dgDP != null) { 
   					for (var j:int = 0; j < dgDP.length; j++) {
   						for (var k:int = 0; k < arrDGSelKey.length; k++) {
   							strDGSelKey += dgDP[j][arrDGSelKey[k]] + "~";
   						}
   ```
   
   Because dgDP is declared as an Object,
   
   `var dgDP:Object = dg.dataProvider;`
   
   the compiler does not know it is an ArrayCollection requiring Proxy access.  In Flash it didn't matter, the Flash runtime would detect that the code is reading from a Proxy like ArrayCollection, but in the browser (without Flash) it does matter.  The JavaScript runtime does not know what a Royale Proxy is (at least, not now).
   
   So, if you get errors working with a Proxy like ArrayCollection, make sure the compiler knows you are working with an ArrayCollection.  Otherwise array access like `dgDP[j]`;
   
   IMO, the code to use should look more like:
   
   `var dgDP:ArrayCollection = dg.dataProvider as ArrayCollection;`
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services