Sunday, February 12, 2006

Did You Know: Flex 2 Beta ViewSource

As you may or may not know, Adobe has added some nifty new functionality to mx.core.Application in the form of viewSourceURL. This in combination with Publish Application Source allows you to easily share the source of your applications. You can see an example of this with my FlickrService test app.

What to do with AS projects tho? Use com.adobe.viewsource.ViewSource.

ViewSource.addMenuItem (obj:InteractiveObject, url:String, hideBuiltIns:Boolean=true);

It's a simple helper that modifies the context menu of the target. It's undocumented tho, so be weary that it may move or be removed in the future.

package {

import com.adobe.viewsource.ViewSource;

import flash.display.Sprite;

public class ViewSourceExample extends Sprite {
public function ViewSourceExample () {
ViewSource.addMenuItem (this, "srcview");
}
}

}