You can try this:
private var zoomToExtent:Extent;
private function doZoom(event:MouseEvent):void
{
if (graphicsLayer.numGraphics > 0)
{
var arr:Array = new Array();
for each (var g:Graphic in graphicsLayer.graphicProvider)
{
arr.push(g);
}
var ge:Extent = GraphicUtil.getGraphicsExtent(arr);
if (ge)
{
var dist:Number=1000;
var graphicsExtent:Extent = new Extent(ge.xmin-dist,ge.ymin-dist,ge.xmax+dist,ge.ymax+dist,map.spatialReference);
if (graphicsExtent)
{
zoomToExtent = graphicsExtent;
map.extent = graphicsExtent;
}
}else
{
var bdist:Number=1000;
var gr:Graphic = graphicsLayer.graphicProvider[0];
var pt:MapPoint = gr.geometry as MapPoint;
var ext:Extent = new Extent(pt.x -bdist,pt.y-bdist,pt.x+bdist,pt.y+bdist,map.spatialReference);
zoomToExtent=ext;
map.extent=ext;
}
checkEnvelope();
}
private function checkEnvelope():void
{
if (zoomToExtent.contains(map.extent))
{
map.zoomOut();
}
}
Basically creates an extent for the graphics layer and then sets the map.extent to the new extent. The check envelope is used for viewers that have cached base maps where the zooms are fixed. Let me know, it works well for me.