To avoid having too many colors, I use beamer's colors to emphasize items of my text. It looks something like this:
\documentclass[xcolor=dvipsnames]{beamer}
\usetheme{Madrid}
\newcommand{\gn}[1]{\textcolor{block title example.bg}{{}#1{}}}
\begin{document}
\begin{frame}{Green text}
\gn{This isn't working.}
\begin{example}[boring example]
nothing to see here.
\end{example}
\gn{This is green.}
This is black.
\end{frame}
\end{document}
Now, if I try to use the color before beamer uses it for the first time (as in "This isn't working"), I get the error:
Package xcolor Error: Undefined color `block title example.bg'.
Is there a way to resolve this?