5 Replies Latest reply on Nov 3, 2009 2:05 PM by Flex harUI

    Embedding an swf file and passing initialization parameters within an mxml

    krishna81m

      I have the following piece of code that I can embed directly in my web page as:

      <script src="http://charts.wikinvest.com/wikinvest/wikichart/javascript/scripts.php" type="text/javascript"></script><div id="wikichartContainer_3A3CB52E-11ED-031F-75B2-B5E51AD87A34"><div style="width: 390px; text-align: center; vertical-align: center; margin-top: 22px;"><a href="http://get.adobe.com/flashplayer/"><img src="http://cdn.wikinvest.com/wikinvest/images/adobe_flash_logo.gif" alt="Flash" style="border-width: 0px;"/><br/>Flash Player 9 or higher is required to view the chart<br/><strong>Click here to download Flash Player now</strong></a></div></div><script type="text/javascript">if (typeof(embedWikichart) != "undefined") {embedWikichart("http://charts.wikinvest.com/WikiChartMini.swf","wikichartContainer_3A3CB52E-11ED-031F-75B2-B5E51AD87A34","390","245",{"startDate":"30-1 0-1999","endDate":"30-10-2009","showAnnotations":"true","ticker":"GOOG","liveQuote":"true" });}</script><div style="font-size:9px;text-align:right;width:390px;font-family:Verdana"><a href="http://www.wikinvest.com/chart/GOOG" style="text-decoration:underline; color:#0000ee;">View the full NASDAQ:GOOG chart</a> at <a href="http://www.wikinvest.com/">Wikinvest</a></div>

       

       

      I am trying to embed this directly in my mxml as an swf file and pass parameters and have tried the following unsuccessfully.

       

      private function onLoadedAppComplete(event:FlexEvent):void {
                          try {
                                  loadedApp = Application(event.target.application);
                                  if(!loadedApp) throw new Error();

       

                                  // startDate=02-05-2009&endDate=02-11-2009&showAnnotations=true&ticker=GOOG&liveQuote=true
                                  loadedApp.parameters["startDate"] = "02-05-2009";
                                  loadedApp.parameters["endDate"] = "02-11-2009";
                                  loadedApp.parameters["showAnnotations"] = "true";
                                  loadedApp.parameters["ticker"] = "GOOG";
                                  loadedApp.parameters["liveQuote"] = "true";
                                 
                          } catch (e:Error) {
                                  Alert.show("Failed to get application loaded.", "Error", Alert.OK);
                          }
                  }

       

       

      <mx:SWFLoader x="324" y="145" width="210" height="200" id="myLoader"
                source="swf/WikiChartMini.swf?ticker=GOOG"
                complete="onLoadComplete(event)"
              ioError="onLoadError()" securityError="onLoadError()"/>

       

       

      and as well as

       

       

      <mx:SWFLoader x="324" y="145" width="210" height="200" id="myLoader"
                source="swf/WikiChartMini.swf?startDate=02-05-2009&endDate=02-11-2009&showAnnotations=tru e&ticker=GOOG&liveQuote=true"
                complete="onLoadComplete(event)"
              ioError="onLoadError()" securityError="onLoadError()"/>

       

       

      but the flex builder complains even before running.