We have performed molecular dynamics simulations to explore the influence of confinement on the glass-transition temperature Tg for supported atactic-polystyrene (aPS) thin films of different thickness (1-10 nm) and different strengths of attraction to the substrate (0.1-3.0 kcal/mol). The aPS films have been equilibrated in a melt at 540 K and further cooled down with a constant cooling velocity of 0.01 K/ps below Tg to room temperature, 300 K. On the basis of the density measurements, we have defined three different (substrate, middle, and surface) layers for each film. We found that the monomers close to the surface and in the substrate layer are partially oriented, which leads to more effective monomer packing. For the whole film the average density-based Tg value remains almost constant for films down to 2 nm thickness, where the middle layer vanishes. For the middle layer itself Tg does not depend on the total film thickness, while an increase up to 70 K is measured for the substrate layer depending on the strength of attraction to the actual substrate. The surface layer remains liquidlike in the whole temperature range (300-540 K). We claim that the redistribution of mass in the three film layers may explain the change with film thickness of the average Tg, if the latter is determined from linear fits of the average glass and melt densities.