Self-Affirmation theory posits, essentially, that if I do something “undesirable” (or bad), I will experience a threat to my self-image (which, the theorists assume, is probably based largely on me doing “desirable” things), and therefore I will try to compensate for my undesirable behavior and restore my self-image by affirming some other aspect of myself that is desirable. The theory seems a little cynical to me, but that’s just how the theory is.
In Spider-Man 3, Peter Parker/Spider-Man discovers the real man behind the death of his Uncle Ben. After confronting and apparently killing this villain, Spidey changes back into his civvies (civilian clothes, for all you non-comic book readers). While doing so, he feels angry and vengeful, and upon seeing his reflection in the mirror, decides to change his usually clean-cut hair-do into a more edgy, emo hair-do. Later on, after his guilt has hit home, he locks away the black costume, and changes his hair-do back to his usual clean-cut part. The fact that he changes his hair and realizes his guilt while looking in the mirror is meaningful, since it is a clear symbolism of self-reflection, or observing one’s self-image.
So, in the language of the theory, Spider-Man did something “undesirable” (almost killed Sandman), felt a threat to his self-image (and embraced it by “emo”-ifying his hair), then compensated for it (by locking away the black costume) and affirmed a more positive aspect of his self-image (by returning to the clean-cut hair-do).