0)).length();
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("3rdparty.xml");
loader.addEventListener(Event.COMPLETE, load3rdParty);
loader.load(request);
}
protected function load3rdParty(event:Event):void
{
var loader:URLLoader = URLLoader(event.target);
var newNode:XML = new XML(loader.data);
if (newNode..node.length() > 0) {
explorerTree.appendChild(newNode.node);
compLibTree.dataProvider = explorerTree;
noExamples += (newNode..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, false);
openNode(application);
}
else {
loadApp("Welcome", null, false);
}
}
private function treeChanged(event:Event):void
{
var nodeApp:String = compLibTree.selectedItem.@app;
var link:String = compLibTree.selectedItem.hasOwnProperty("@link") ? compLibTree.selectedItem.@link : "";
var thirdParty:Boolean = compLibTree.selectedItem.hasOwnProperty("@thirdParty")
&& compLibTree.selectedItem.@thirdParty == "true";
if (nodeApp != null && nodeApp != "")
{
loadApp(nodeApp, compLibTree.selectedItem.@src, thirdParty, link);
}
else
{
compLibTree.expandItem(compLibTree.selectedItem, true, true);
}
}
private function loadApp(application:String, source:String, thirdParty:Boolean, link:String=""):void
{
if (application.indexOf(".swf") > 0) {
swfLoader.loadApp(application);
}
else if(application.indexOf(".jpg") > 0 || application.indexOf(".png") > 0)
{
swfLoader.loadApp(application,link);
}
else {
swfLoader.loadApp(application + ".swf");
}
if (thirdParty) {
vs.thirdPartyWarning();
}
else {
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);
}
]]>