Both while and as can be used to talk about a longer background action that was in progress when something else happened.
- We discussed his plans while we were having lunch.
- As I was driving down the road, I saw a strange sight.
Note that while and as are conjunctions. They have a similar meaning to the preposition during, but they are used in different structures. While and as are followed by a subject and a verb. During, on the other hand, is followed by a noun or a noun phrase.
- I was in hospital during the summer. (Here the preposition during is followed by the noun the summer.)
- While I was in hospital, I would spend my days in reading. (Here the conjunction while is followed by the clause I was in hospital.)
As and while can also be used to talk about two longer actions or situations that go on at the same time.
- While you were playing I was working.
- John tidied the lounge while Susie cooked dinner.
As is mostly used to talk about two situations that change together. With this meaning it is used with simple tenses.
As can also be used to talk about two short actions that happen at the same time.
- She always arrives just as I leave for work.