74
Chapter 3: Creating Advanced Components in Flash MX 2004
// in this example).
super.init();
}
/*** f) Implement createChildren(). ***/
// Declare two children member variables.
var text_mc:TextInput;
var mode_mc:SimpleButton;
// Declare default skin names for the button states.
// This is optional if you do not want to allow skinning.
var modeUpSkinName:String = "ModalUpSkin";
var modeOverSkinName:String = "ModalOverSkin";
var modeDownSkinName:String = "ModalDownSkin";
// Note that we test for the existence of the children before creating them.
// This is optional, but we do this so a subclass can create a different
// child instead.
function createChildren():Void
{
if (text_mc == undefined)
createClassObject(TextInput, "text_mc", 0, { preferredWidth: 80,
editable:false });
text_mc.addEventListener("change", this);
text_mc.addEventListener("focusOut", this);
if (mode_mc == undefined)
createClassObject(SimpleButton, "mode_mc", 1,
{ falseUpSkin: modeUpSkinName,
falseOverSkin: modeOverSkinName,
falseDownSkin: modeDownSkinName });
mode_mc.addEventListener("click", this);
}
/*** g) implement measure ***/
// The default width is the size of the text plus the button.
// The height is dictated by the button.
function measure():Void
{
_measuredPreferredWidth = text_mc.preferre
mode_mc.preferredWidth;
_measuredPreferredHeight = mode_mc.preferredHeight;
}
/*** h) implement layoutChildren ***/
// Place the button depending on labelPlacement and fit the text in the
// remaining area.
function layoutChildren():Void
{
text_mc.setSize(width - mode_mc.width, height);
if (labelPlacement == "left")
{
mode_mc.move(width - mode_mc.width, 0);
Содержание FLEX - DEVELOPING COMPONENTS AND THEMES
Страница 1: ...Developing Flex Components and Themes in Flash Authoring ...
Страница 4: ...4 Contents ...
Страница 44: ...44 Chapter 2 Creating Basic Components in Flash MX 2004 ...
Страница 82: ...82 Index ...