The Schengen Area is a bloc of several dozen European countries in which travel and visa handling are handled at a supranational level. In short, that means that a Schengen visa applies to the bloc as a whole, and not to individual countries.
Once you have permission to enter the Schengen Area, you are free to travel within that area, and you will not encounter any border controls, although you may be asked to produce the necessary papers by officials during 'non-permanent checks', such as highway patrols.
To answer your question directly: you will be allowed to leave Amsterdam airport to see the city (taking a direct NS train is cheap and convenient) and come back for the second leg of your journey. Do note that though you will not have to pass border control and customs, you will have to pass through airport security again, which can take some time depending on the time of day and season.
Enjoy your trip!
// Edit: You will be entering the Schengen Area in Amsterdam, much like one enters the US in Newark of JFK, even though there may be another leg to another US city such as Houston. For visa purposes, the leg from Amsterdam to Barcelona is domestic, just as JFK to Houston would be.