You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2014/09/04 00:49:52 UTC

[11/50] [abbrv] git commit: [flex-utilities] [refs/heads/master] - Look for app parameter when loading application

Look for app parameter when loading application


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/02c5bdbb
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/02c5bdbb
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/02c5bdbb

Branch: refs/heads/master
Commit: 02c5bdbbc456e475a2950beaffb7c9052c4b66e8
Parents: 668810a
Author: Justin Mclean <jm...@apache.org>
Authored: Wed Aug 27 16:59:18 2014 +1000
Committer: Justin Mclean <jm...@apache.org>
Committed: Wed Aug 27 16:59:18 2014 +1000

----------------------------------------------------------------------
 TourDeFlex/TourDeFlex3/src/explorer.mxml | 66 +++++++++++++++++++++++----
 1 file changed, 57 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/02c5bdbb/TourDeFlex/TourDeFlex3/src/explorer.mxml
----------------------------------------------------------------------
diff --git a/TourDeFlex/TourDeFlex3/src/explorer.mxml b/TourDeFlex/TourDeFlex3/src/explorer.mxml
index 7a1443d..059f687 100755
--- a/TourDeFlex/TourDeFlex3/src/explorer.mxml
+++ b/TourDeFlex/TourDeFlex3/src/explorer.mxml
@@ -18,11 +18,12 @@
 
 <mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:explorer="*"
     width="100%" height="100%" pageTitle="{TITLE}"
-    initialize="init()" layout="vertical">
+    initialize="init()" creationComplete="checkParameters()" layout="vertical">
 
     <fx:Script>
         <![CDATA[
-			
+		import mx.core.FlexGlobals;
+
 		static protected const VERSION:String = "1.1";	
 		static protected const TITLE:String = "Tour De Flex Component Explorer";
 		static protected const FULL_TITLE:String = "Apache Flex™ Tour De Flex Component Explorer " + VERSION;
@@ -41,15 +42,27 @@
             compLibTree.dataProvider = explorerTree;
 			
 			noExamples = (explorerTree..node.(hasOwnProperty("@app") && @app.length() > 0)).length();
-		}			
+		}
+		
+		protected function checkParameters():void
+		{		
+			var parameters:Object = FlexGlobals.topLevelApplication.parameters;
+			
+			if (parameters.hasOwnProperty("app")) {
+				var application:String = parameters.app;
+				var source:String = explorerTree..node.(hasOwnProperty("@app") && @app == application).@src;
+				loadApp(application, source);
+				openNode(application);
+			}			
+		}
 
         private function treeChanged(event:Event):void
         {
             var nodeApp:String = compLibTree.selectedItem.@app;
+			
             if (nodeApp != null && nodeApp != "")
             {
-                swfLoader.loadApp(nodeApp + ".swf");
-                vs.loadSource(nodeApp, compLibTree.selectedItem.@src);
+				loadApp(nodeApp, compLibTree.selectedItem.@src);
             }
             else
             {
@@ -57,11 +70,46 @@
             }
         }
 			
-		private function gotoHome(event:Event):void {
+		private function loadApp(application:String, source:String):void
+		{
+			swfLoader.loadApp(application + ".swf");
+            vs.loadSource(application, source);
+		}
+			
+		private function gotoHome(event:Event):void
+		{
 			var urlRequest:URLRequest = new URLRequest("http://flex.apache.org/download-tourdeflex.html");
 			navigateToURL(urlRequest);
-		}		
-        ]]>
+		}	
+		
+		private function openNode(application:String):void
+		{
+			var node:XML = explorerTree..node.(hasOwnProperty("@app") && @app == application)[0];
+			var parent:XML;
+			var nodes:Array = [];
+			 
+			if (!node) {
+				return;
+			}
+			
+			parent = node.parent();
+			 
+			while (parent != null) {
+			    if (!compLibTree.isItemOpen(parent)) {
+			        nodes.push(parent);
+			    }
+			    parent = parent.parent();
+			}
+			 
+			for each (var expand:XML in nodes) {
+			    compLibTree.expandItem(expand, true);
+			}
+			 
+			compLibTree.selectedIndex = compLibTree.getItemIndex(node);
+			compLibTree.scrollToIndex(explorerTree.selectedIndex);
+		}
+	
+		]]>
     </fx:Script>
 
 	<fx:Declarations>
@@ -89,4 +137,4 @@
 	<mx:HBox width="100%">
 		<mx:Label fontSize="9" width="100%" text="Copyright © 2014 The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache Flex is trademark of The Apache Software Foundation." />
 	</mx:HBox>
-</mx:Application>
+</mx:Application>
\ No newline at end of file