Although you have already accepted an answer, I want to provide another perspective. This question can be easily analyzed from a geometric perspective even if (like me) you are not facile enough with algebra to come up with an example like Jason's.
In the language of algebraic geometry, your problem can be stated as follows: let $\phi \colon Y \to X$ be a flat map of schemes (in this case, affine) and let $Z \subset X$ be a closed subscheme (in this case, defined by a principal ideal $Af$) such that $\phi$ induces an isomorphism $\phi^{-1} Z \xrightarrow{\sim} Z$. Let $U = X \setminus Z$ be the open complement with immersion morphism $j \colon U \to X$, and let $\def\sh{\mathcal}\sh{F}$ be a quasicoherent sheaf on $U$.
If $\phi^* (j_* \sh{F}) = 0$ on $Y$, is $j_* \sh{F} = 0$ on $X$?
In order to answer this question it is natural to consider the complementary situations of "on $U$" and "on $Z$". If we can show that $j_* \sh{F}|_U = 0$, then $j_* \sh{F}$ is supported set-theoretically on $Z$, and "nothing changes" if we pass to $\phi^{-1}(Z)$ since it is isomorphic, and zero there by hypothesis, so $j_* \sh{F}|_Z = 0$ as well and we would end up with $j_* \sh{F} = 0$ because it has no support.
Unfortunately, the first, "open" part is already false. To see this, let $V = Y \setminus \phi^{-1} Z$ and $k \colon V \to Y$ be the open immersion; then if $\phi^* j_* \sh{F} = 0$, we also have $k^* \phi^* (j_* \sh{F}) = \phi|_U^* j^* (j_* \sh{F}) = \phi|_U^* \sh{F} = 0$, since $\phi \circ k = j \circ \phi|_U$. So you want to make the implication $\phi|_U ^* \sh{F} = 0 \implies \sh{F} = 0$. But this can only be expected if $\phi|_U$ is faithfully flat, i.e. flat and surjective, which you have not hypothesized. (Otherwise, $\phi|_U$ has "no opinion" about the points of $U$ that are not in its image.)
Jason's counterexample just exploits this. He found a disconnected scheme $X$ and took $Y$ (and $Z$) to be one of its components. Then clearly the restriction of $\sh{F}$ to that component has nothing to do with its restriction to the other one.
However, it is a basic property of faithful flatness that the implication in question does hold when $B$ is faithfully flat over $A$ (or $Y$ over $X$, correspondingly).