3 Replies Latest reply on Sep 1, 2010 1:24 PM by Paul The Lad

    How to embed the published source's URL with SWF?

    Paul The Lad Level 1
      Hello,

      I followed the instructions provided here, in order to make
      sure that when users right-click on a SWF file, they would
      see the "View Source" option.

      The SWF itself is embedded in a blog but is being hosted elsewhere:
      <embed src="https://some.website.com/hosting/main.swf"
             quality="high"
             bgcolor="#869ca7"
             width="650" height="100"
             name="Main"
             align="middle"
             play="true"
             loop="false"
             quality="high"
             allowScriptAccess="sameDomain"
             type="application/x-shockwave-flash"
             pluginspage="http://www.adobe.com/go/getflashplayer">
      </embed>

      So right-clicking and selecting "view source" results in a URL
      which is broken because it is generated as relative to the blog
      (http://www.blog.com/article/srcview/index.html) ... instead of
      the hosting webspace url.

      I tried specifying
      srcUrl="https://some.website.com/hosting/srcview/index.html"
      but that didn't work.

      Can anyone tell me how to parametrize the source url such that
      I can explicitly specify where the source resides in the embed
      tag?
        • 1. Re: How to embed the published source's URL with SWF?
          Paul The Lad Level 1

          I suppose one workaround is to use the <iframe/> tag instead of <embed/> tag because that way the url generated to "view source" will be relative to the hosting website and not the embedding website. But still isn't there a way to be explicit about the location of the source code by using the embed tag?

          • 2. Re: How to embed the published source's URL with SWF?
            Subeesh Arakkan Level 4

            You can set the viewSourceURL in the application tag.

            1 person found this helpful
            • 3. Re: How to embed the published source's URL with SWF?
              Paul The Lad Level 1

              Thnak You!

               

              After you pointed it out, I realized that when I asked FlashBuilder to publish my code it added that property to my main applicaiton file.

               

              There are still a few caveats before it simply works, here they are:

               

              1) If the viewSourceURL is not set as an attribute/property of the application tag, setting it later in an event handler, such as the one for applicationComplete, does not add it to the context-menu so one must still have the original attribute/propety in the application tag. Setting the viewSourceURL again in a handler, will then update it correctly.

               

              2) How to get build the host URL?

              Well I found the answer to that here: http://www.taterboy.com/blog/2009/01/swf-based-relative-urls-in-flash-or-flex/ and throwing that into the applicationCompleteHandler works great.

               

              <s:Application
                             ...

                             viewSourceURL="srcview/index.html"
                             applicationComplete="applicationCompleteHandler(event)"
                             >
                  <fx:Script>
                      <![CDATA[

                          protected function applicationCompleteHandler(event:FlexEvent):void
                          {
                              var swfURL:String = FlexGlobals.topLevelApplication.loaderInfo.url;
                              swfURL = swfURL.substr(0, swfURL.lastIndexOf("/") + 1)
                              var tempDom:Array = swfURL.split("/");
                              var domURL:String = tempDom.slice(0,3).join("/") + "/";
                              viewSourceURL = domURL+ "srcview/index.html";
                          }

                      ]]>
                  </fx:Script>
                  ...
              </s:Application>