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.
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.
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.