Game Development Reference
In-Depth Information
private function okButtonOverListener(e:MouseEvent):void {
okButton.changeBackGroundColor(SimpleBlitButton.OVER);
}
private function okButtonOffListener(e:MouseEvent):void {
okButton.changeBackGroundColor(SimpleBlitButton.OFF);
}
}
}
Class import and variable definition section for BasicScreen
The class import section imports the necessary core Flash classes we will see in action shortly.
The one custom class the BasicScreen class makes use of is the CustomEventButtonId class.
We will dissect this class in detail later in the chapter, but for now, know that we dispatch an
instance of it if the OK button is clicked on any of the instances of this BasicScreen .
The variable definition section of the BasicScreen class creates variables to hold data for the
three optional pieces of the BasicScreen :
The background color BackGroundBitmapData , which is associated BackGroundBimap
The text to display on the screen, displayText
The button that will fire off the CustomEventButtonId when clicked, which is an instance
of another framework custom class we will create called SimpleBlitButton
All three of these optional items are set with public functions inside the BasicScreen class. The
Main.as class we create for each unique game will customize the BasicScreen instances by
passing values to these public functions inside its init function override of the GameFrameWork 's
init function.
One of the most interesting things about this BasicScreen class is the way we are creating this
background for the OK button. We decided not to import or embed any external assets for this first
game, because it would necessitate explaining how to do it in both the Flash IDE and Flash
Develop (with the open source Flex SDK), and it's too early in this topic for that discussion.
Instead, we have created a very simple custom button class called SimpleBlitButton . The
instance name for this button is okButton . We will discuss this class in detail in the
SimpleBlitButton class deinition.
The final variable we need is the id integer. This is passed into the BasicScreen instance from Main .
It is used in the switch:case inside the GameFrameWork classes' okButtonClickListener function to
change state based on the screen whose OK button was clicked.
Class constructor function definition
The constructor for the BasicScreen class accepts in the basic information needed to set up a
screen for display. A screen needs an id value passed in as an integer, as well as the information
needed to create the background color for the screen. This is done by passing values needed to
customize the backGroundBitmapData variable that was created in the variable definition section.
A BitmapData instance needs these four pieces of data passed:
A width
A height
Search WWH ::




Custom Search