You are proceeding correctly. Your next step would be to note that the coefficients of powers of x must be equivalent on each side of the equation, as A and B are numbers, not functions of x, and cannot introduce an x term.
That is, you are now to solve the two simultaneous equations:
8 = A + B
12 = 4A + B