• Tutorials
  • Blog
  • About
  • Contact
  • Adding View Source to Adobe Air in Flash Builder 4.5 and 4.6

    2012 - 03.15

    Oh jeez. I remember Flex Builder 3 making it easy for people to just right click your application and view source. What’s happened here?

    Quick answer is:

    Listen for the applicationComplete event and add the menu item:

    ViewSource.addMenuItem(this, “www.LinkToYourSource.org/srcview”)

    The long answer is that I spent the better part of an afternoon looking for an easy way to have Flash Builder do what it used to do (generate and show my source code). I was seeing Flash Builder to crazy stuff like rip out the “viewSourceURL” tag from my WindowedApplication. I figure there’s some sort of setting in the project properties that is set to kill stuff like this when doing a production release but I couldn’t seem to find it. Is my hair falling out?

    Oh, and yes, I’m talking about Adobe Air here. I see everything seem to be in order when doing a Flex browser application.

    To generate the view source files I fired up an old version of Flex 3 and when I went to the export wizard it had that old familiar “Enable view source”. I pulled in a more modern compiler but Flex Builder didn’t seem to get the build right. But it did generate the viewable source code. So I took that code and posted it online. Then I switched back to Flex 4.6 and made the actionscript call to add that source menu:

    protected function applicationCompleteHandler(event:FlexEvent):void
    ViewSource.addMenuItem(this, “http://SAMPLE_WEBSITE.ORG/srcview/index.html”);

    So while this solution works, I’m sure there’s some really simple way to get my old familiar wizard back.

    What am I doing wrong here?

    2 Responses to “Adding View Source to Adobe Air in Flash Builder 4.5 and 4.6”

    1. AFAIK (and I may be wrong here), there’s no default context menu in AIR apps. Flash default contact menu was disabled to allow us to use and customize it. Same thing will happen soon in Flash Player with the RIGHT_CLICK enabled mouseEvent. Guess adding your own contextMenuItem ain’t that hard anyway :)
      Thanks for pointing that out !

    2. admin says:

      Sounds like a valid point but it was a nice feature and there was some work put forth to get that code to show cleanly in HTML. Seems like it’d be worth keeping as apposed to just scrapping it. I figured it might be part of the mobile push. Thanks for the comment.

    Your Reply