Sorry to hear your sad tale, it seems only too common. The agents get paid from the deposit you paid, so they have no interest, and moany could not sell on a resale at an increased price even in the boom times as the developer paid so much more commission than for a resale! Nowadays its virtually impossible as the prices of offplans have dropped dramatically leaving most in negative equity before they have even completed.
Im unclear as to what part of Spanish purchase law has changed? I can only assume where the proeprty changes hands from you to the next purchaser. In the old days, people did what you have done, placed deposits and then sold on the units, pocketing the difference and usually in cash. The law was tightened up so that the origianl buyer (you) had to declare the full amount and pay a 7% transfer tax to the new buyer, thereby ensuring the governement made its money and you would also have paid capital gains tax on the profit.
Many developers used to allow the transfer to go through, but as it is an admin nightmare, many now dont allow it, but it really depends on what your contract states. If its in the contract, the the developer cannot refuse this, if it was an oral agreement then forget it.
Coming back to completion, you may have a case of pulling out as I know of several buyers who have had anything from 50% to all of their deposits returned on the basis they cannot gain a mortgage due to the finacial crisis.
Best person to get hold of is Maria de Castro, she is a lawyer on this forum and has helped many. Without the full story anjd just as importantly the paperwork you have, it would not be possible to see what grounds you have.
You can as last resort try to negotiate with the developer - I know someone trying to do that now where he is being forced to complete or forfeit the deposit, yet the develoepr prices themselves have dropped so much that he cannot get the valuation needed in order to secure the mortgage promised!!!
Good luck and dont give up - keep shouting at your lawyers, the agency and the developer - they may try to do something at some stage!