Attacks are resolved in the following order:
1) announce attack; 2) if necessary, choose target; 3) if necessary, perform attack requirements (coin flip, discard energy); 4) if necessary, apply special effects; 5) check for Confusion; 6) perform attack, doing damage first, then applying any other effects.
Figuring our the amount of damage works as follows:
1) base damage (number written next to attack); 2) effects on Attacking Pokemon; 3) Weakness effect; 4) Resistance effect; 5) effects of attached Trainer or Energy cards; 6) effects on Defending Pokemon (Powers, Bodies, or last attacks); 7) place 1 damage counter per 10 damage; 8) do any other effects of attack to Defending Pokemon (discarding Energy, switching to Bench).
ONLY NOW do you check to see if any Pokemon are Knocked Out, by having more damage counters than their HP.