Hello, I want to design a Flex Web Application that would load features (flex components) hosted in different SWF or SWC files at runtime. The prototype of that application can be viewed on the url below.
http://80.227.133.21/FlexTestInternal/ApplicationLayoutManager.html The actual application needs to call a webservice that will return an xml. A sample xml is attached herewith. The xml contains the layout description and the names of feature (flex components) to be loaded. The layout and features varies for different users. I am thinking about deploying features in separate SWF/SWC files so that only the required files will be download at runtime. Can you please let me know the following in this regard? 1. How can I package individual features in separate SWF/SWF file using Flex Builder2. 2. How can I load the those separate SWF/SWC files at runtime from the main SWF file? 3. In case of separate SWF/SWC files for features, will the Flex library be included in every SWF/SWC file? I am also attaching the code of the prototype application. Regards, Jehanzeb __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="OnApplicationInitialize()"> <mx:Script> <![CDATA[ import mx.containers.VBox; import mx.containers.TabNavigator; import mx.containers.Canvas; import mx.controls.Label; import mx.containers.HDividedBox; import mx.containers.Panel; import mx.containers.VDividedBox; import mx.core.IContainer; import mx.utils.StringUtil; import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; private function OnApplicationInitialize() : void { this.ajaxServiceInvokerProxy.addEventListener(FaultEvent.FAULT, this.OnError); this.ajaxServiceInvokerProxy.addEventListener(ResultEvent.RESULT, this.OnResultArrived); this.ajaxServiceInvokerProxy.GetApplicationLayout.send(); } private function OnError(event:FaultEvent) : void { var message:String; message = StringUtil.substitute('Error Type: [0]. Error Message: [1].', "A", "B"); mx.controls.Alert.show(message, "WebService Error"); } private function OnResultArrived(event:ResultEvent) : void { var applicationLayout:String = event.result.toString(); var applicationLayoutXml:XML = new XML(applicationLayout); this.LayoutPanels(applicationLayoutXml); } private function LayoutPanels(applicationLayoutXml:XML) : void { var panelList:Object = applicationLayoutXml.child("Pages");//.child("Pages").child("Page");//.Panels; //panelList = panelList.child("Pages"); panelList = panelList.child("Page").child("Panels"); //mx.controls.Alert.show(panelList.toXMLString(), "WebService Result"); //this.txtPanelList.text = panelList.toXMLString(); var panel:Panel = new Panel(); panel.percentWidth = 100; panel.percentHeight = 100; panel.title = "Main Panel"; this.addChild(panel); var panelXml:XML = null; for each(panelXml in panelList.children()) { if(panelXml.name() == "HorizontalSplit") { this.ProcessHorizontalPanel(panel, panelXml); } else if(panelXml.name() == "VerticalSplit") { this.ProcessVerticalPanel(panel, panelXml); } } } private function ProcessHorizontalPanel(parentPanel:DisplayObjectContainer, horizontalPanelXml:XML) : void { var horizontalPanel:VDividedBox = new VDividedBox(); horizontalPanel.percentWidth = 100; horizontalPanel.percentHeight = 100; parentPanel.addChild(horizontalPanel); var topPanel:XMLList = horizontalPanelXml.TopPanel; var bottomPanel:XMLList = horizontalPanelXml.BottomPanel; this.ProcessChildPanel(horizontalPanel, topPanel, true); this.ProcessChildPanel(horizontalPanel, bottomPanel, true); } private function ProcessVerticalPanel(parentPanel:DisplayObjectContainer, verticalPanelXml:XML) : void { var verticalPanel:HDividedBox = new HDividedBox(); verticalPanel.percentWidth = 100; verticalPanel.percentHeight = 100; parentPanel.addChild(verticalPanel); var leftPanel:XMLList = verticalPanelXml.LeftPanel; var rightPanel:XMLList = verticalPanelXml.RightPanel; this.ProcessChildPanel(verticalPanel, leftPanel, false); this.ProcessChildPanel(verticalPanel, rightPanel, false); } private function ProcessChildPanel(parentPanel:DisplayObjectContainer, panelXmlList:XMLList, isHorizontalPanel:Boolean) : void { //var childPanel:Panel = new Panel(); var sizePercent:int = int(panelXmlList.attribute("SizePercent").toString()); var childPanel:Panel = new HeaderLessPanel(); if(isHorizontalPanel) { childPanel.percentWidth = 100; childPanel.percentHeight = sizePercent; childPanel.setStyle("backgroundColor", 0x4CAB32); } else { childPanel.percentWidth = sizePercent; childPanel.percentHeight = 100; childPanel.setStyle("backgroundColor", 0xAE1414); } parentPanel.addChild(childPanel); var panelXml:XML = null; for each(panelXml in panelXmlList.children()) { if(panelXml.name() == "HorizontalSplit") { this.ProcessHorizontalPanel(childPanel, panelXml); } else if(panelXml.name() == "VerticalSplit") { this.ProcessVerticalPanel(childPanel, panelXml); } else if(panelXml.name() == "CompositeFeature") { this.LayoutCompositeFeature(childPanel, panelXml); } else { var label:Label = new Label(); label.text = panelXml.name(); childPanel.addChild(label); } } } private function LayoutCompositeFeature(parentPanel:DisplayObjectContainer, compositePanelXml:XML) : void { var featureList:XMLList = compositePanelXml.Features; var tabbedPanel:TabNavigator = new TabNavigator(); tabbedPanel.percentHeight = 100; tabbedPanel.percentWidth = 100; var featureXml:XML = null; for each(featureXml in featureList.children()) { var vbox:VBox = new VBox(); vbox.label = featureXml.name(); vbox.percentHeight = 100; vbox.percentWidth = 100; var label:Label = new Label(); label.text = featureXml.name(); vbox.percentHeight = 100; vbox.percentWidth = 100; vbox.addChild(label); tabbedPanel.addChild(vbox); } parentPanel.addChild(tabbedPanel); } ]]> </mx:Script> <mx:WebService id="ajaxServiceInvokerProxy" wsdl="http://192.168.0.101/AjaxServiceInvoker2/AjaxServiceInvoker.asmx?wsdl" useProxy="false"> <mx:operation name="GetApplicationLayout"> </mx:operation> </mx:WebService> <!--<mx:TextArea id="txtPanelList" width="100%" height="100%"/>--> </mx:Application>
<?xml version="1.0" encoding="UTF-8"?> <Workspace Name="Default"> <Pages> <Page Name="Page 1" ActivePage="True"> <Panels> <HorizontalSplit IsMoveable="False"> <TopPanel SizePercent="92"> <VerticalSplit IsMoveable="False"> <LeftPanel SizePercent="26"> <HorizontalSplit IsMoveable="False"> <TopPanel SizePercent="54"> <HorizontalSplit IsMoveable="False"> <TopPanel SizePercent="50"> <CompositeFeature Layout="TabbedLayout"> <Features> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.Notification.NotificationFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="0f48f736-b0e2-480b-a90b-f1d89dadfe49" Name="Notification"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.NewsReader.NewsReaderFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="be5589d0-83c3-4de3-a6a0-b10dcc4936d1" Name="News"> <State /> <Links /> </Feature> </Features> </CompositeFeature> </TopPanel> <BottomPanel SizePercent="50"> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.MarketIndex.MarketIndexFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="af218173-c515-4a45-82e6-18d4bfc1fd77" Name="Market Index Summary"> <State /> <Links> <Link SourceId="af218173-c515-4a45-82e6-18d4bfc1fd77" DestinationId="055996b5-ae76-40fe-9648-a129f32952ba" /> </Links> </Feature> </BottomPanel> </HorizontalSplit> </TopPanel> <BottomPanel SizePercent="46"> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.Quote.QuoteFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="41089048-3751-4471-a86d-c75070b237f6" Name="Quote"> <State /> <Links /> </Feature> </BottomPanel> </HorizontalSplit> </LeftPanel> <RightPanel SizePercent="74"> <HorizontalSplit IsMoveable="False"> <TopPanel SizePercent="22"> <CompositeFeature Layout="TabbedLayout"> <Features> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.MarketByOrder.MarketByOrderFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="703c9c4e-a0ef-4192-8948-9a150348faa5" Name="Market By Order"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.MarketByPrice.MarketByPriceFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="df9b14bd-941c-4147-bc62-379c481d327f" Name="Market By Price"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.TopGainer.TopGainerFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="bcc395a5-5708-4b6c-97d5-d40713d7af8d" Name="Top Gainers"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.TopLooser.TopLooserFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="7e883537-72c5-4de4-ba36-025ede60b503" Name="Top Loosers"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.TopMover.TopMoverFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="a77877cf-a2eb-4c40-9f5b-250978f996ca" Name="Most Active"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.IndexDetail.IndexDetailFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="055996b5-ae76-40fe-9648-a129f32952ba" Name="Index Detail"> <State /> <Links /> </Feature> </Features> </CompositeFeature> </TopPanel> <BottomPanel SizePercent="78"> <CompositeFeature Layout="TabbedLayout"> <Features> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.MarketView.MarketViewFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="1a5ac357-39fe-4097-b7da-d5b966685d7c" Name="Market View"> <State /> <Links> <Link SourceId="1a5ac357-39fe-4097-b7da-d5b966685d7c" DestinationId="41089048-3751-4471-a86d-c75070b237f6" /> </Links> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.WatchList.WatchListFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="680ad294-922b-46aa-8088-10f21e9d1d0e" Name="WatchList"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.Search.SearchFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="1d7b2b7c-b629-4973-980e-4a4e38051cd3" Name="Search Symbols"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.AlertSetup.AlertSetupFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="2cf0c325-1870-4c8a-8d78-91a622f066a3" Name="AlertSetup"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.Analysis.AnalysisFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="e06c57d4-2d5e-463b-99f8-bbc622534f82" Name="Analysis"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.TradeHistory.TradeHistoryFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="5c0b0ad7-fd26-48e7-a5d7-47a7b3ef7166" Name="Trade History"> <State /> <Links /> </Feature> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.LiveChart.LiveChartFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="a486b8b3-c363-47cf-8d07-728e6508aa2c" Name="Live Chart"> <State /> <Links /> </Feature> </Features> </CompositeFeature> </BottomPanel> </HorizontalSplit> </RightPanel> </VerticalSplit> </TopPanel> <BottomPanel SizePercent="8"> <Feature Type="Sharesoft.WhiteWolf.Client.Desktop.MarketInformationFeatures.Ticker.TickerFeature" Assembly="Sharesoft.WhiteWolf.Client.MarketInformationFeatures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Id="be3538c9-cd1d-4304-82b6-50af01436875" Name="Ticker"> <State /> <Links /> </Feature> </BottomPanel> </HorizontalSplit> </Panels> </Page> </Pages> </Workspace>