Brendan, Now you will not be able to use my whole code word for word as I do things with the Flexviewer2.0 that you will not have but here is my code and it works fine. Maybe you can see where you are going wrong.
<?xml version="1.0" encoding="utf-8"?>
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:viewer="com.esri.viewer.*"
xmlns:esri="http://www.esri.com/2008/ags"
xmlns:mxeffects="com.adobe.ac.mxeffects.*"
layout="absolute"
creationComplete="addStatList()">
<fx:Declarations>
<esri:GeometryService
id="geometryService"
concurrency="last"
fault="onFault(event)"
projectComplete="projectCompleteHandler(event)"
url="http://gis.calhouncounty.org/arcgis2/rest/services/Geometry/GeometryServer"/>
<esri:SimpleMarkerSymbol id="smsPoint" style="square" color="0xFFFF00" size="11" alpha="0.9">
<esri:SimpleLineSymbol color="0x000000"/>
</esri:SimpleMarkerSymbol>
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.SpatialReference;
import com.esri.ags.events.GeometryServiceEvent;
import com.esri.ags.events.MapMouseEvent;
import com.esri.ags.geometry.Geometry;
import com.esri.ags.geometry.MapPoint;
import com.esri.viewer.AppEvent;
import com.esri.viewer.ViewerContainer;
import mx.controls.Alert;
import mx.managers.CursorManager;
[Embed(source="assets/images/gsv_cursor.png")]
private var crosshairCursor:Class;
private var theStatus:String = "";
public function google():void{
setMapAction("","Show Google Street View",null);
map.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
map.panEnabled = false;
map.cursorManager.setCursor(crosshairCursor, 2, -8, -12);
}
private function mouseDownHandler (event:MouseEvent):void
{
if(theStatus == "Show Google Street View") {
map.cursorManager.setBusyCursor();
var mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
var outSR:SpatialReference = new SpatialReference(4326);
geometryService.project([mapPoint], outSR);
} else {
map.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
}
}
private function widgetClosedHandler(event:Event):void
{
map.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
map.panEnabled = true;
map.cursorManager.removeCursor(map.cursorManager.currentCursorID);
setMapNavigation(null, null);
}
private function widgetOpenedHandler(event:Event):void
{
google();
}
private function addStatList():void
{
ViewerContainer.addEventListener(AppEvent.SET_STATUS, statusSet);
theStatus = "Show Google Street View";
}
private function statusSet(event:AppEvent):void
{
if (event.data)
theStatus = event.data as String;
}
private function projectCompleteHandler(event:GeometryServiceEvent):void
{
var geom:Geometry = (event.result as Array)[0];
var mapPoint:MapPoint = geom as MapPoint;
var lng:String = mapPoint.x.toFixed(12);
var lat:String = mapPoint.y.toFixed(12);
// launch street view
var url:String = "http://gis.calhouncounty.org/FlexViewer2.0/StreetView.html?lat=" + lat + "&lng=" + lng;
var window:String = "StreetView";
var features:String = "toolbar=no,location=no,resizable=no,directories=no,status=no,scrollbars=no,copyhistory=no,width=610,height=700";
var WINDOW_OPEN_FUNCTION : String = "window.open";
ExternalInterface.call( WINDOW_OPEN_FUNCTION, url, window, features );
}
private function onFault(info:Object, token:Object = null):void
{
Alert.show(info.toString(),"Streetview Error");
}
protected function button1_clickHandler(event:MouseEvent):void
{
ViewerContainer.showError("This is a test error");
}
]]>
</fx:Script>
<viewer:WidgetTemplate id="wTemplate"
closed="widgetClosedHandler(event)"
open="widgetOpenedHandler(event)"
creationComplete="google()"
skinClass="com.esri.viewer.skins.WidgetTemplateSkin"
height="280"
width="370">
<mx:VBox width="100%" height="100%"
verticalGap="4"
horizontalAlign="center"
verticalAlign="middle" >
<mx:HBox width="100%"
horizontalGap="15"
horizontalAlign="center"
verticalAlign="middle">
<mx:Text id="selectPointLabelText"
text="Click location on the map to open Google® streetview panorama"
styleName="WidgetText" width="90%" textAlign="center"/>
</mx:HBox>
<mx:Button click="google()" label="Reactivate..."/>
</mx:VBox>
</viewer:WidgetTemplate>
</viewer:BaseWidget>