Generally speaking, no you cannot earn DL miles for flying AA, even if it's an AS code share. The code-share relationships only work 2 ways, not three. For instance, you can get DL miles on an AS flight, or AA miles on an AS flight, because AS is partners with AA and DL. But you can't get AA miles on a DL flight or DL miles on an AA flight because these two airlines have no relationship - the only common link is that they both partner with AS.
Hope this helps. Keep in mind that even if you buy an AA flight with an AS flight #, you will not be able to get delta miles unless the flight has a DL or AS flight number.