Avg. Rating 2.0

Problem

You want to publish your source code for your Flex application so that a user can right-click on the Flex application and select “View Source” from the context menu and see your code/assets.

Solution

In Flex 2, you could publish your application source by selecting Project > Publish Application Source from the main menu.

Detailed explanation

In Flex 3, you can publish your application source by doing one of the following:
• Selecting Project > Export Release Build from the main menu.
• Selecting File > Export > Release Build from the main menu.
• Right click the Flex Project in the Flex Navigator or Navigator view, and select Export from the context menu. In the Export dialog, select “Release Build” under the Flex Builder node.

If you are just getting started with Flex Builder 3 (or Flex in general), or are migrating from Flex Builder 2 or early Flex Builder 3 betas (pre beta 2), the steps to enable the “View Source” context menu in your Flex applications has changed somewhat.

Currently (as of Flex Builder 3 beta 2), if you want to enable view source, you can do so in the “Export Release Build” dialog box (found by selecting Project > Export Release Build from the main menu), and clicking the “Enable view source” check box in the View source section. If you want to specify which files are included/excluded, simply click on the Choose Source Files button and check or uncheck files at your leisure. For example, in some of my examples, I may not include fonts which I downloaded elsewhere from the Internet. So I would go into the Export Release Build dialog box, click on Choose Source Files and deselect the fonts and then publish my Flex application. Of course, I always include a note explaining where you can obtain the specific fonts I used, but it makes it so developers visit the site, check out the copyright information, and sends a bit of traffic to the font makers site. But I digress… Back in the Publish Application Source dialog box (which can be found by clicking the Choose Source Files button in the Export Release Version dialog box, whew!), you can also specify where the generated source files will be copied to. By default the files will be placed in a folder named /srcview/ within your /bin-release/ folder of the published project files.

There you have it. Publishing your application source files with Flex Builder 3. Most, if not all, of the SWFs on this site should have view source enabled. Simply right-click on a SWF file and select View Source from the context menu. This allows you to view a nicely formatted/colored version of the source code, as well as download the source files as a handy ZIP file, or click on a link to download the Flex 3 SDK.

For more information, see http://blog.flexexamples.com/2007/10/21/publishing-a-projects-source-code-in-flex-builder-3-beta-2/
Report abuse

Related recipes