jump to navigation

Publishing source code with your Flex projects July 10, 2010

Posted by Tournas Dimitrios in Flex.

When your applications are ready to be released, Flex Builder lets you choose whether users can view source code and assets in the application. As with HTML, users can access and view the source in a web browser by selecting View Source from the context menu. The source viewer formats and colors the code so that it is easy to read. It is also a convenient way to share code with other Flex and ActionScript 3.0 developers.

Enable the view source option

Follow these steps:

  1. With the completed application project open in the editor, select Project > Export Release Build.
  2. Select Enable View Source or Include Source for ActionScript projects. 
  3. Click Choose Source Files.
  4. In the Publish Application Source dialog box, select the application file or files to include in the View Source menu. By default, the main application file is selected.
  5. (Optional) Change the source output folder. By default, a source view folder is added to the project output folder.
  6. Click OK. 

When users run your application, they can access the source code by selecting View Source from the context menu. The source code appears in the default web browser as a source tree that reflects the structure of the resources (packages, folders, and files) contained in your application (the ones that you decided to publish). Selecting a source element displays the code in the browser. Users can also download the entire set of source files by selecting the Download.zip file link.

Note: Because of Internet Explorer security restrictions, you may not be able to view the source on your local development computer. If this is the case, you will need to deploy the application to a web server to view the source.

Adding the view source menu to ActionScript projects

In Flex projects you add the View Source menu option to your application with the Export Release Build wizard. In ActionScript applications, you must add this option manually.The Flex framework contains the following function that you can use in an ActionScript application’s constructor to enable the view source menu:

com.adobe.viewsource.ViewSource.addMenuItem(obj:InteractiveObject, url:String, hideBuiltins:Boolean = true)

You can use this in your ActionScript applications as shown here:

package {
    import flash.display.MovieClip;
    import com.adobe.viewsource.ViewSource;

    public class MyASApp extends MovieClip
        public function MyASApp()
            ViewSource.addMenuItem(this, "srcview/index.html");

            // ... additional application code here


This example demonstrates adding the view source menu using the default location of the source folder (srcview). If you change the location of the source folder, your code should use the correct location.

Source: Adobe livedocs



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s