I would really recommend you to go trough
flytandem's TransX tutorials. This was pure gold for me to learn using TransX.
As you can see on this picture, you only not have your own velocity, you also get velocity from the gravitational pull of the planet you are flying past.
You can sort of imagine it as having a rope fastened to a helicopter. If it was standing still, you would only have the velocity relative to the ground that you got from pulling yourself up.
At a slingshot, it's like the helicopter is going upwards while you pull yourself up. The velocity relative to the ground will be that of the velocity you pull yourself up with PLUS the vertical velocity of the helicopter, which of course will be higher than the one you pull yourself up with.