I agreed with Constant, that given the amount of money A in the box, the probability of winning the gamble may not be 0.5 anymore, that is where the orginal logic breaks.
For illustration purpose, assume everyone knows that A can not be larger than 10, then the player should esitmate his expectation as:
P(A=1)*P1+P(A=2)*P2+.... P(A=10)*P10, where Pi is the probability of win when A = i.
Obviously 1=P(A=1)>P(A=10)=0www.ddhw.com
If we do not assume there is any limit in the amount of money, then we have to assume there is a distribution on all the positive integers (or more accurately on all pairs of positive intergers), it can not be uniform, as LuanTan pointed out, and a direct proof using the above method can be tricky, because we may end up with infinite expectations. Sean9991's proof is a better approach, he acctually showed that given the amount of money in both boxes x,y (A = x, B=y or A = y, B=x), the expectation is the same, gamble or not.