You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/08/18 18:04:42 UTC

[royale-asjs] 01/05: fix SourceTab. In general, components should not 'do work' in the property setters, even in Flex. This is even more important in Royale as Royale has less just-in-case change detection code. Properties should be set on the component before adding to the display list and those setters should not 'do work'. They should set values in the model and do the work latter, on being added to the display list or on some event like initComplete or creationComplete. I guess we'll see how often use [...]

This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch feature/MXRoyale
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit da2f493077f625a00da168dab19f57bed155ce6e
Author: Alex Harui <ah...@apache.org>
AuthorDate: Sat Aug 18 10:59:35 2018 -0700

    fix SourceTab.  In general, components should not 'do work' in the property setters, even in Flex.  This is even more important in Royale as Royale has less just-in-case change detection code.  Properties should be set on the component before adding to the display list and those setters should not 'do work'.  They should set values in the model and do the work latter, on being added to the display list or on some event like initComplete or creationComplete.  I guess we'll see how ofte [...]
---
 examples/mxroyale/tourdeflexmodules/src/SourceTab.mxml  | 11 +++++++++--
 examples/mxroyale/tourdeflexmodules/src/viewsource.mxml |  4 ++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/examples/mxroyale/tourdeflexmodules/src/SourceTab.mxml b/examples/mxroyale/tourdeflexmodules/src/SourceTab.mxml
index 829632c..bb75b9f 100755
--- a/examples/mxroyale/tourdeflexmodules/src/SourceTab.mxml
+++ b/examples/mxroyale/tourdeflexmodules/src/SourceTab.mxml
@@ -19,7 +19,8 @@
 
 <mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009"
 		 xmlns:mx="library://ns.apache.org/royale/mx"
-		 width="100%" height="100%">
+		 width="100%" height="100%"
+         creationComplete="getSource()">
 
     <fx:Script>
         <![CDATA[
@@ -30,11 +31,17 @@
         import mx.controls.Alert;
 
 		public var app:String;
+        public var src:String;
 			
         public function set source(file:String):void
         {
             label = file.substring(file.lastIndexOf("/")+1);
-            srv.url = file;
+            src = file;
+        }
+
+        private function getSource():void
+        {
+            srv.url = src;
             srv.send();
 			ta.verticalScrollPosition = 19; // at end of header
         }
diff --git a/examples/mxroyale/tourdeflexmodules/src/viewsource.mxml b/examples/mxroyale/tourdeflexmodules/src/viewsource.mxml
index 0c4a831..312fa0d 100755
--- a/examples/mxroyale/tourdeflexmodules/src/viewsource.mxml
+++ b/examples/mxroyale/tourdeflexmodules/src/viewsource.mxml
@@ -49,9 +49,9 @@
 	        		for (var i:int = 0; i < files.length ; i++)
     	    		{
 						tabs[i] = new SourceTab();
+                        tabs[i].source = files[i];
+                        tabs[i].app = appUrl;
 						tn.addChild(tabs[i]);
-						tabs[i].source = files[i];
-						tabs[i].app = appUrl;
     	    		}
 				}
 			}