Java Reference
In-Depth Information
How it works...
The lengthy (yet abbreviated) code segment shows you how to implement a custom control
class. This is done by extending the Control class from which our control will inherit several
properties and behaviors. For our Deck control, let's explore how it works.
F Defining the control —the Deck class extends the Control class, which extends
CustomNode . As a matter of fact, creating a custom control works in the same way
as creating a custom node; you need override function create():Node to
return the control you want to create. In our code example, we return an instance of
Group as the container for our Deck class.
F Class properties —all public variables declared in the class definitions will be
treated as class properties. Our custom Deck control will expose the following
self-explanatory properties:
roundCornerSize:Integer;
borderSize:Integer = 2;
borderColor:Color;
slideOffset:Integer=20;
duration:Duration = 300ms;
enableReflection:Boolean
The class Deck will also inherit properties from the base class Control .
F The Deck.add() function —the Deck class exposes the Deck.add(node:Node)
function to add items to the stack (internally managed by an instance of Group
assigned to variable stack ). The function wraps the added node in a virtual card
for the deck by calling createCard() which basically returns a Group instance
containing the added node and a Rectangle instance as a background. The card
is then added to the content sequence of the deck's internal stack .
 
Search WWH ::




Custom Search