constant morphisms from projective, integral schemes over k 
Let $X$ be a projective, irreducible, reduced scheme over $k$ and $Y$ be an affine $k$-scheme, where $k$ is algebraically closed. Prove that every morphism $f : X → Y$ is constant.

I know that for a general scheme $X$ which is irreducible as well as reduced (and $Y$ is just given to be a scheme i.e. no extra conditions imposed), combined with the fact that $f$ restricted to every affine open subset constant would imply that $f$ is constant . So if I can basically show that restriction of $f$ to every affine open subset is constant, we're done.
Now if in addition $Y$ is assumed to be an affine scheme, say $\operatorname{Spec}(R_1)$ then take any affine open subset say $\operatorname{Spec}(R_2) \subset X$ , then the homomorphism induced on the rings $R_2 \to R_1$ associated from the restriction of the morphism to the affine open subset, goes in the global section of the structure sheaf.
How to maybe combine these with the $k-scheme$ structure and also how to use the fact that our $X$ is also projective and a scheme over $k$.
Thanks for help.
 A: First, we note that $\mathcal{O}_X(X)$ is a field since $X$ is an integral projective scheme over a field. Next, for any locally ringed space $X$ and any affine scheme $Y$, there is a bijection between morphisms $X\to Y$ and ring homomorphisms $\mathcal{O}_Y(Y)\to \mathcal{O}_X(X)$ (see for instance Stacks 01I1, or EGA III Err 1 Prop 1.8.1 where it is attributed to Tate, or Hartshorne exercise II.2.4). The interesting portion of this bijection is that given a map on global sections $f$, we send a point $x\in X$ to the point $y\in Y$ corresponding to the preimage of $\mathfrak{m}_x\subset \mathcal{O}_{X,x}$ under the composite map $$\mathcal{O}_Y(Y)\stackrel{f}{\to}\mathcal{O}_X(X)\to\mathcal{O}_{X,x}.$$
So the morphisms $X\to Y$ are in bijection with maps from $\mathcal{O}_Y(Y)$ to a field. But such a map is given by a maximal ideal of $\mathcal{O}_Y(Y)$, and tracing through the bijection above, we see that this means that all points $x$ map to this maximal ideal.
A: To give an intuitive complement to the other answer, one can think of global sections of the structure sheaf of $(X,O_X)$ as maps to $X\rightarrow \mathbb{A}^1$, and affine schemes have heaps of such maps, while projective schemes have very few. One can then prove the result by noting that if the map $X\rightarrow Y$ wasn't constant, we could find a map from $Y$ to $\mathbb{A}^1$ that witnesses this ("functions on affine schemes seperate points"). Justifying this will boild down to unravelling the definitions of what it means to be a constant map, and using that the global sections of $O_X$ are just $k$, but I find it easier to do so with this geometric picture in mind.
