Exactly the same way...
Parallex is when a closer object appears to be moving compared to more distant objects...
It's like when your in a car, and you look out the window and you see in the very far distance huge hills covered in trees (this would be your distant star background) and then, about half way between you and the hills are a few houses or possibly some more trees or something (this would be the closer stars) and these trees/houses appear to be moving sideways infront of the hills don't they? It looks like the hils are stationary but the houses are moving. But, when the car stops, it looks like the houses have stoped moving (the stars appear to stop moving) Whcih means that the Parrelex effect was only due to you, the person in the car, moving.
Of course, you know that the houses weren't moving, but in space it is ALOT harder to tell what is moving and what isn't therefore you set up a parallex like that, which has closer stars moving across the screen as your player moves and distant stars staying stationary.
Hope That Helped...
PS sorry i didn't post it in code, because i personally don't know how to do it, but i know the principles behind it all...

Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy