If you want to book a package (dining/tickets) and get the AAA room discount, you will have to book with a AAA office (you can only book an AAA room only discount through WDW).
All discounts are subject to availability and only a certain number of rooms are put aside for any discount.
If a code comes out that is better than your AAA discount package, your AAA agent will be able to switch to that code (assuming there is availability at the resort). Our agent did not have to cancel our existing reservation. She checked availability FIRST with the code and then switched our package over. Our confirmation number never changed.