# Accessing Gum Screens in Code

### Introduction

Gum screens which are part of a FlatRedBall project generate a custom class. This custom class provides access to all contained objects within the screen. While it is possible to also interact with the elements in a general way (by name), using the typed properties in a screen is usually safer and more convenient.

### Initial Setup

To write code against a Gum screen, you must first have:

* A Glue project
* A Gum project inside the Glue project
* A Glue screen (we'll call it GameScreen)
* A Gum screen (we'll call it GameScreenGum)
* The Gum screen file referenced by the Glue screen

Note: Once you add a Gum project to your Glue project, Glue will automatically add new Gum screens for each Glue screen. This functionality can be controlled by selecting the .gumx file in Glue:

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-15cfce742304e91c00db01b8f7b46244f0cece9b%2F2020-02-img_5e43122d7e020.png?alt=media)

If you have already created Glue screens and Gum screens, but the two are not associated, you can right-click on the Files of any Screen to add an existing Gum screen: ![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-9ad63729efc8f152c52ebb2375d1d9d190418651%2F2020-02-img_5e431272d0637.png?alt=media) Regardless of which method is used, the result is a Gum screen that is using a specific, generated class, as can be seen in Glue:

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-507a51e3b88ae4ba8f97c85cfcffb3913daac762%2F2020-02-img_5e43145966d3f.png?alt=media)

### Accessing Objects in Code

The Gum screen object can be accessed in code just like any other object. All contained objects in a Gum screen are accessible through properties on the Gum screen. For example, consider the following Gum screen:

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-e91f69a59478a17213b51c9d409e8d637096c45e%2F2020-02-img_5e4313383de58.png?alt=media)

These can be accessed in code using the names of the objects from Gum:

![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-c835be1cb2f4949f8bbec6c7c0ae2d485761fe15%2F2020-02-img_5e4313fdc956a.png?alt=media)

###
