I did something like this a while back in a dijit I built: http://swingley.appspot.com/maps/zoomtoHere's the relevant code:
// serialize the extent to JSON, create a new extent to later pass to the map
var featExt = new esri.geometry.Extent(ext.toJson());
// listen to onExtentChange and then show a
// graphic for the selected feature's extent
this.extHandle = dojo.connect(this.map, 'onExtentChange', this, function() {
var outline = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0, 173, 230, 1]), 3),
symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, outline, new dojo.Color([0, 0, 128, 0])),
extGraphic = new esri.Graphic(featExt, symbol);
this.map.graphics.add(extGraphic);
// fade out the graphic and remove it
var fo = dojo.fadeOut({
'node': extGraphic.getDojoShape().getNode(),
'duration': 1500,
});
// remove the graphic and clean up the event listeners
// after the animation plays
this.foHandle = dojo.connect(fo, 'onEnd', this, function() {
this.map.graphics.remove(extGraphic);
dojo.disconnect(this.extHandle);
dojo.disconnect(this.foHandle);
});
fo.play();
});
// set the new extent
this.map.setExtent(featExt, true);
Another option is to use dojox.gfx.fx to fade out the graphic. Here's an example: http://jsfiddle.net/swingley/3VsgL/