Creating ControlsControls 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 controlsThe different types of controls can be grouped according to their intended purpose:
Field controls in WorkbenchIn 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.
Creating a controlYou 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
Create a field control extension in ActionScript
Creating Guide layout controlsGuide 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: FirstPanelButtonDescriptionThis 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:
Sourcepackage 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: LastPanelButtonDescriptionThis 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:
Sourcepackage 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 layoutsYou 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 controlsField 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: CustomHSliderDescriptionThis 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:
Sourcepackage 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 WorkbenchAfter 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
Mapping Guide objects to custom controlsTo 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
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