Creating Controls

Controls are Guide extensions that perform specific actions. In general, a control performs only a single action. However, that action can be as simple or as complex as you require for your specific solution.

There are two types of controls: Guide layout controls and field controls.

Overview of Guide controls

The different types of controls can be grouped according to their intended purpose:

Guide layout controls:
A Guide layout references Guide layout controls, and they never appear in Workbench. Examples of Guide layout controls include the navigation panel, Next and Previous buttons, the data entry panel, and the Guide Help panel.

The Guide Design perspective in Workbench provides a tremendous amount of functionality. However, some situations require you to create specific functionality based on your solution requirements. For example, you can create Guide layout controls that allow your users to quickly move to the first or last panel. These controls are useful in a large Guide. The Next and Previous buttons that appear on a Guide are Guide layout controls that let users move forwards and backwards through a Guide.

Field controls:
Field controls are the items that you add to a Guide panel in Workbench, such as fields, buttons, and lists. In some situations, using a different Flex object makes the user experience more engaging. For example, if the original Numeric Field object is used to store a percentage value, you can map the Numeric Field to an HSlider control. Mapping to a control creates a more intuitive data entry experience for a user.

To take full advantage of custom controls in a Guide, familiarize yourself with the Guide ActionScript packages. (See ActionScript Language Reference .)

Field controls in Workbench

In Workbench, field controls are items that you add to a Guide panel, such as fields, buttons, and lists.

In the Guide Properties view, all the field controls for a Guide are included in the Control Type > Display As list. When you select an item from that list, additional properties appear in the Guide Properties view. Each control type has different corresponding properties. For example, if you select HSlider or VSlider, the Minimum and Maximum properties appear.

When you extend an existing field control, the corresponding additional properties appear in the Guide Properties view.

Control type in the Guide Properties view

Class to extend

Button

mx.controls.Button

Checkbox

mx.controls.CheckBox

Checkbox List

ga.controls.CheckBoxList

Date field

mx.controls.DateField

Drop-down list

mx.controls.ComboBox

Horizontal slider

mx.controls.HSlider

HRule

ga.controls.HRule

Image field

ga.uiComponents.ImageField

List box

mx.controls.List

Nested panel

ga.uiComponents.PanelComponent

Numeric stepper

mx.controls.NumericStepper

Radio button

mx.controls.RadioButton

Radio button list

ga.controls.RadioButtonList

Static list

ga.uiComponents.StaticList

Static text

ga.uiComponents.StaticText

Static text multiline

ga.uiComponents.StaticTextMultiline

Submit Guide button

ga.uiComponents.SubmitGuideButton

Text area

mx.controls.TextArea

Text input

ga.uiComponents.TextInputPicture

Text input comb

ga.uiComponents.TextInputComb

Text input mask

ga.uiComponents.TextInputMask

Text input symbol

ga.uiComponents.TextInputSymbol

Vertical slider

mx.controls.VSlider

Creating a control

You can create new controls in either MXML or ActionScript. Save field controls in the controls folder and save Guide layout controls in a different folder.

Important: Try not to edit the field control files that are included with LiveCycle ES2.5. Instead, make uniquely named copies of the content to help you get started creating field control extensions.

Create a field control extension in MXML

  1. Start Flash Builder.

  2. Select File > New > MXML Component .

  3. Type a unique filename.

  4. In the Based On list, select a component that is most similar in behavior to the component you want to create. This method lets you take advantage of existing behaviors through inheritance.

  5. (Optional) Set values for Width and Height .

  6. Click Finish .

Create a field control extension in ActionScript

  1. Start Flash Builder.

  2. Select File > New > ActionScript Class .

  3. Type a unique class name.

  4. In the Superclass field, specify the ActionScript class that is most similar in behavior to the component you want to create. This method lets you take advantage of existing behaviors through inheritance.

  5. Click Finish .

    After you create the shell of the new control, you add the desired functionality using the Source view in Flash Builder. For more information about the Guides ActionScript API that you can take advantage of while adding functionality, see ActionScript Language Reference .

    Note: When you are developing controls for use on a Guide, some situations require you to import ActionScript objects. These ActionScript objects are generated automatically from the data model associated with the Guide. The data model contains ActionScript related to the behavior of the objects stored in the data model. This ActionScript can help you develop your custom control. You can access the ActionScript generated for data model objects in the C:\Documents and Settings\<username>\Application Data\Adobe\LiveCycle\ES2\Guides\generated\<LiveCycle Application>\<version>\Data Models folder. Import any required ActionScript files into your Flex library project.

What’s next?

Learn to create custom controls by studying several examples:

Example: FirstPanelButton

Example: LastPanelButton

Example: CustomHSlider

Creating Guide layout controls

Guide layout controls are extensions that affect how a user navigates through the sections and panels of a Guide. The Next and Previous buttons, controlled by the NextPanelButton and PreviousPanelButton ActionScript classes respectively, are examples of Guide layout controls.

Do not save Guide layout controls in the controls folder.

The following examples illustrate how to create Guide layout controls to help users browse Guides that contain many sections and panels.

Example: FirstPanelButton

Description

This example creates a button object that, when clicked by a user at runtime, displays the first panel in the Guide. Adding this control to a Guide layout creates the following experience:

  • When the Guide renders, a button labeled First is dimmed. The user cannot interact with the button immediately.

  • The user navigates to another panel in the Guide using the Next button or through the navigation supplied by the Guide layout. After this navigation, the First button is displayed normally and is available to the user. Clicking the button returns the user to the first panel in the Guide.

Source

package com.adobe.guides.controls 
{ 
    import mx.controls.Button; 
    import flash.events.Event; 
    import flash.events.MouseEvent; 
    import ga.model.GAEvent; 
    import ga.model.PanelManager; 
 
    public class FirstPanelButton extends Button 
    { 
 
        // The PanelManager class controls the organization and behavior 
        // of panel instances at runtime. The class contains 
        // convenience properties and methods that are useful for  
        // manipulating panels within a Guide. 
        private var _pm:PanelManager; 
         
        protected override function createChildren():void   
        { 
            super.createChildren(); 
            this.label = "First"; 
            _pm = PanelManager.instance; 
 
            // Adds event listeners for the three events that can cause a 
            // change in the state of this button, and reevaluates if the button 
            // should display as enabled. 
            _pm.addEventListener(GAEvent.PAGE_SELECTION_CHANGE, pageChange); 
            _pm.addEventListener(GAEvent.PAGE_REMOVE, pageChange); 
            _pm.addEventListener(GAEvent.PAGE_ADD, pageChange); 
 
            // Sets the default behavior when the Guide renders. In this 
            // case, on the initial panel, the button should be dimmed. 
            super.enabled = false; 
        } 
 
        // When the button is clicked by a user, the current panel displayed 
        // is set to be the first panel in the Guide. 
        override protected function clickHandler(event:MouseEvent):void  
        {  
            if (super.enabled)  
            {  
                _pm.currentPage = _pm.firstPage; 
            }  
        } 
 
        // Conditionally sets the button's enabled property dependent on 
        // whether the current panel is the first panel in the Guide. 
        private function pageChange(event:Event):void  
        {  
            super.enabled = _pm.previousPage!=null; 
        } 
    } 
}

For information about adding this control to a Guide layout, see Adding custom Guide layout controls to panel layouts and Guide layouts .

When creating custom navigation controls, be aware of the methods and properties of the PanelManager class. (See ActionScript Language Reference .)

Example: LastPanelButton

Description

This example creates a button object that, when clicked by a user at runtime, displays the last panel in the Guide. Adding this control to a Guide layout creates the following experience:

  • When the Guide renders, a button labeled Last is displayed. Clicking the button sends the user to the last panel in the Guide.

  • If the user is on the last panel of the Guide, this button is dimmed and not available to the user.

Source

package com.adobe.guides.controls 
{ 
    import mx.controls.Button; 
    import flash.events.Event; 
    import flash.events.MouseEvent; 
    import ga.model.GAEvent; 
    import ga.model.PanelManager; 
 
    public class LastPanelButton extends Button 
    { 
        // The PanelManager class controls the organization and behavior 
        // of panel instances at runtime. The class contains 
        // convenience properties and methods that are useful for  
        // manipulating panels within a Guide. 
        private var _pm:PanelManager; 
         
        protected override function createChildren():void   
        { 
            super.createChildren(); 
            this.label = "Last"; 
            _pm = PanelManager.instance; 
 
            // Adds event listeners for the three events that can cause a 
            // change in the state of this button, and reevaluates whether 
            // the button should display as enabled. 
            _pm.addEventListener(GAEvent.PAGE_SELECTION_CHANGE, pageChange); 
            _pm.addEventListener(GAEvent.PAGE_REMOVE, pageChange); 
            _pm.addEventListener(GAEvent.PAGE_ADD, pageChange); 
 
            // Sets the default behavior when the Guide renders. In this 
            // case, on the initial panel, the button should be disabled. 
            super.enabled = true; 
        } 
 
        // When the button is clicked by a user, the current panel displayed 
        // is set to be the last panel in the Guide. 
        override protected function clickHandler(event:MouseEvent):void  
        {  
            if (super.enabled)  
            {  
                _pm.currentPage = _pm.lastPage; 
            }  
        } 
 
        // Conditionally sets the button's enabled property dependent on 
        // whether the current panel is the last panel in the Guide. 
        private function pageChange(event:Event):void  
        {  
            super.enabled = _pm.nextPage!=null; 
        } 
    } 
}

For information about adding this control to a Guide layout, see Adding custom Guide layout controls to panel layouts and Guide layouts .

Adding custom Guide layout controls to panel layouts and Guide layouts

You can implement Guide layout controls that you want to display as part of a Guide layout or panel layout. To implement the controls, add them to the MXML definition associated with a Guide layout or panel layout.

The following MXML source illustrates how to modify the Guide layout created in the Creating a simple Guide layout section. It adds the First and Last buttons created in the Example: FirstPanelButton and Example: LastPanelButton sections to the layout.

<?xml version="1.0" encoding="utf-8"?> 
<gc:Wrapper width="100%" height="100%" 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    xmlns:gc="ga.controls.*"  
    xmlns:cc="com.adobe.guides.controls.*" > 
     
    <mx:VBox width="100%" height="100%"> 
        <gc:PanelContent width="100%" height="100%" /> 
        <mx:HBox> 
            <cc:FirstPanelButton /> 
            <gc:PreviousPanelButton label="Back" /> 
            <gc:NextPanelButton label="Forward" /> 
            <cc:LastPanelButton /> 
            <gc:SubmitButton label="Submit Data" /> 
        </mx:HBox> 
    </mx:VBox> 
</gc:Wrapper>

In this example, a new namespace com.adobe.guides.controls.* is added to simplify the references to the new controls. In addition, the bold text represents the references to the custom navigation controls.

Creating custom field controls

Field controls are custom components that replace standard Guide items to provide an enhanced user experience.

The following information illustrates how to create field controls that provide a more intuitive data entry experience for users.

Example: CustomHSlider

Description

This example creates an HSlider control that you can use for mapping Guide items. This custom field control assumes that the original Guide item is used to specify integer values from 0 through 100 that indicate a percentage. Mapping a Guide item to this control creates the following experience:

  • When the Guide renders, an HSlider control appears in place of the original Guide item. The HSlider has the same caption value as the original Guide item. The user can drag the slider to set a value from 0 through 100.

  • When switching to the PDF view of the form, the value the user sets using the slider appears in the corresponding field. If the user changes the value on the PDF and then returns to the Guide, the slider value reflects the updated value.

Source

package com.adobe.guides.controls 
{ 
    import mx.controls.HSlider; 
 
    public class CustomHSlider extends HSlider  
    { 
 
        protected override function createChildren():void   
        { 
            super.createChildren(); 
 
            // Sets the minimum, maximum, and initial values for the range. 
            this.minimum = 0; 
            this.maximum = 100; 
            this.value = 0; 
 
            // The increment range for the slider, and the increments for the 
            // increment label. 
            this.snapInterval = 1; 
            this.tickInterval = 10; 
 
            // The label for the range represented by the slider. 
            this.labels=['0%', '100%']; 
 
            // Sets interaction properties allowing the slider to update in 
            //real-time in response to user interaction. 
            this.allowTrackClick = true; 
            this.liveDragging = true;  
        } 
    } 
}

For information about adding this control to a Guide layout, see Adding custom Guide layout controls to panel layouts and Guide layouts .

Referencing your Flex library project in Workbench

After you build your Flex library project in Flash Builder, reference the compiled SWC file in the Guide Design perspective of Workbench. This reference makes your control extension available.

Reference your Flex library project in Workbench

  1. Start Workbench.

  2. Add your Flex library project to a LiveCycle ES2.5 application.

  3. Switch to the Guide Design perspective, and open a Guide into which you want to incorporate the custom Guide layout.

  4. In the Guide Tree view, select the root node.

  5. In the Guide Properties view, in the Guide extensions option, click .

  6. Go to the SWC file for your Flex library project, and then click OK .

    Your Guide extensions are now available in the Display as option in the Guide Properties view. Click Preview to render the Guide.

    Important: If you edit the Flex library project after you add the project to a LiveCycle ES2.5 application, remove the reference to the project. The reference is located in the Guide extensions option ( Guide Properties view). After you remove the reference, to make the changes available, add the reference again.

Mapping Guide objects to custom controls

To use your custom field control on a Guide, associate an object in the Guide tree with your custom field control. Perform this mapping for each Guide object you want to associate with the new custom field control. You do not need to add the custom field control to a Guide layout or panel layout.

Map form design objects to custom field controls

  1. Start Workbench and either open an existing Guide, or create a Guide.

  2. Select the Guide object that you want to map in the Guide Tree view.

  3. In the Guide Properties view, click Display as , and select the name of your custom control. For example, using the custom control created in the Example: CustomHSlider section, select Custom H Slider .

  4. Save the Guide.

    Preview your Guide to view the new custom control.

What’s next?

Create your own custom controls, beginning with any of the examples, or by starting from a new MXML component or ActionScript class. For more information about the Guides ActionScript API, see ActionScript Language Reference .

To start learning about creating custom panel layouts, see Creating Panel Layouts or, for custom Guide layouts, see Creating Guide Layouts .

// Ethnio survey code removed