The distinguished open sets are affine subschemes
You don't just want to prove that $D(f)$ is isomorphic to $\mathrm{Spec}(A_f)$ as locally ringed spaces via some random isomorphism. The ring map $\psi:A\rightarrow A_f$ (localization map) induces a morphism of schemes $g=\mathrm{Spec}(\psi):X=\mathrm{Spec}(A_f)\rightarrow Y=\mathrm{Spec}(A)$. As you seem to already know, the underlying map of topological spaces is a homeomorphism onto $D(f)$, which is an open subset of $Y$.
In general, a morphism of locally ringed spaces $g:X\rightarrow Y$ is called an open immersion if $g$ induces (on the underlying topological spaces) a homeomorphism onto an open subset of the target and $g_x^\sharp:\mathscr{O}_{Y,g(x)}\rightarrow\mathscr{O}_{X,x}$ is an isomorphism for each $x\in X$. It is equivalent for there to exist an open subset $V$ of $Y$ and an isomorphism of locally ringed spaces $h:X\cong V$ such that $i\circ h=g$, where $i:V\hookrightarrow Y$ is the canonical inclusion morphism and $V$ is regarded as a locally ringed space in the standard way, by restricting the structure sheaf of $Y$. If $g$ is an open immersion in the first sense, then $V=g(X)$ is open in $Y$, and there is a unique isomorphism $h:X\cong V$ with $i\circ h=g$.
So you just need to prove that the map $g$ is an open immersion. You already have the topological part, so the sheaf part amounts to proving that for each prime ideal $\mathfrak{q}$ of $A_f$, the map of stalks $g_\mathfrak{q}^\sharp:A_{\psi^{-1}(\mathfrak{q})}\rightarrow (A_f)_{\mathfrak{q}}$, is an isomorphism. Note that this map is given, by definition, by $a/s\mapsto\psi(a)/\psi(s)$, using the standard description of localizations as equivalence classes of fractions. Basic properties of localization tell you that $\mathfrak{q}$ has the form $\mathfrak{p}A_f$ for a unique prime ideal $\mathfrak{p}$ of $A$ not containing $f$, i.e. $\mathfrak{p}\in D(f)$, and the inverse image $\psi^{-1}(\mathfrak{q})$ is $\mathfrak{p}$. So you are reduced to the following claim: if $\mathfrak{p}\in D(f)$, then the canonical map induced by $\psi$, $A_\mathfrak{p}\rightarrow(A_f)_{\mathfrak{p}A_f}$, is an isomorphism.
You can prove this by explicitly manipulating fractions, but that's kind of messy in my opinion. I think it is better to observe that the map in question is defined solely in terms of the universal property of localization. Namely, the composite of localization maps $A\rightarrow A_f\rightarrow (A_f)_{\mathfrak{p}A_f}$ visibly sends $A\setminus\mathfrak{p}$ into the units of the target ring, so there is a unique $A$-algebra map $A_\mathfrak{p}\rightarrow (A_f)_{\mathfrak{p}A_f}$. This is $g_{\mathfrak{p}A_f}^\#$. Using similar considerations, you can, via the universal property of localization, produce a ring map in the other direction, and then verify, now using the uniqueness in the universal property, that the composite of the two maps in both directions is the identity on the appropriate ring, i.e., the maps are inverses of one another.
So, your approach is more or less correct in spirit, but somewhat out of order. It is not enough to show that the local rings of two locally ringed spaces match up, i.e., this does not yield a morphism in general (it is true that two morphisms which have the same effect on topological spaces and induce the same maps of local rings are equal, but you cannot necessarily start with maps on local rings and produce a morphism). You have to start with the morphism (which you have, induced by $\psi$), and then prove that the canonical maps on stalks induced by $\psi$ are isomorphisms.