Allthough an old thread, yet never too late:
There is another possibility why the pop-up flash won't work:
Picture 2 square: Behind the metal hook (which locks the pop-up flash and releases it when the solenoid goes into action) there is a small black plastic rod.
This rod was just missing on the
K-x which I had repaired and used for a tutorial.
Luckily I had the top from a defunct *istD body which had the same rod, I'm pretty sure it is the same in all those Pentax DSLR's which need batteries inserted and camera switched on for the flash to pop up!
Picture 3 large square: Here one can see the metal spring which holds this rod in up position when the flash is up!. The rod moves down when one closes the flash.
Anyway, this pink K-x II repaired was working alright in all modes but one had to open the flash manually.
Luckily the owner did not need the flash so it wasn't a problem. But when I stumbled over your thread I thought "hey, this might be it".
So today this friend visited me, I opened the K-x again but found all what you described was o.k.
But then I noticed this tiny rod missing. After inserting it, all was fine, the K-x now works perfectly also with flash!
This is what this forum is also great for, one can find little treasures like yours which pave the way for faultfinding and faultsolving!