Note that there are some explanatory texts on larger screens.

plurals
  1. PODispatching custom event from repeater component and listen event in other repeater components
    primarykey
    data
    text
    <p>I have a repeater component with custom event. My repeater components fires custom event holding data. My need is to dispatch event so other repeater components can access data from dispatching component. Any help is needed?</p> <p>Edit: Added whole stuff here.</p> <pre><code> &lt;!-- AttributeMapping.mxml --&gt; &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="40" creationComplete="creationCompleteHandler(event)"&gt; &lt;fx:Metadata&gt; [Event(name="mappingChanged", type="MappingChangeEvent")] &lt;/fx:Metadata&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.collections.ArrayCollection; import mx.collections.ArrayList; import mx.events.FlexEvent; import mx.events.ValidationResultEvent; import mx.validators.ValidationResult; import spark.events.IndexChangeEvent; private var mappedAttribute:String; [Bindable] private var _sourceAttribute:String; [Bindable] private var targetAttributeCollection:ArrayCollection = new ArrayCollection(); private var _targetAttributes:Array; private var _targetAttribute:String; public function get targetAttribute():String { return _targetAttribute; } public function get targetAttributes():Array { return _targetAttributes; } public function set targetAttributes(value:Array):void { _targetAttributes = value; targetAttributeCollection.source = _targetAttributes; } public function get sourceAttribute():String { return _sourceAttribute; } public function set sourceAttribute(value:String):void { _sourceAttribute = value; } protected function creationCompleteHandler(event:FlexEvent):void { this.addEventListener(MappingChangeEvent.MAPPING_CHANGED, mappingsChanged); } protected function mappingsChanged(event:MappingChangeEvent):void { lblFuck.text = event.MappedAttribute(); } protected function cmbTargetAttribute_changeHandler(event:IndexChangeEvent):void { this._targetAttribute = cmbTargetAttribute.selectedItem as String; dispatchEvent(new MappingChangeEvent(MappingChangeEvent.MAPPING_CHANGED, true, _targetAttribute)); } ]]&gt; &lt;/fx:Script&gt; &lt;s:Label text="{_sourceAttribute}" x="10" verticalCenter="0" id="lblSourceAttribute"/&gt; &lt;!-- &lt;s:DropDownList y="9" right="10" id="ddlTargetAttribute" dataProvider="{targetAttributeCollection}" width="217" prompt="Select target attribute..."/&gt; --&gt; &lt;s:ComboBox id="cmbTargetAttribute" change="cmbTargetAttribute_changeHandler(event)" dataProvider="{targetAttributeCollection}" right="10" verticalCenter="0"/&gt; </code></pre> <p></p> <pre><code>&lt;!-- Main.mxml --&gt; &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:controls="*"&gt; &lt;fx:Declarations&gt; &lt;!-- Place non-visual elements (e.g., services, value objects) here --&gt; &lt;/fx:Declarations&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.collections.ArrayCollection; import mx.events.ValidationResultEvent; import mx.validators.ValidationResult; [Bindable] private var targetAttributes:Array = new Array("Product Name", "Price", "Weight", "Lot Size", "Currency", "VAT", "Maximum Order Quantity"); [Bindable] private var sourceAttributes:Array = new Array("Name", "Price", "Product Weight", "Size", "Currency", "VAT", "Max Order Quantity"); ]]&gt; &lt;/fx:Script&gt; &lt;mx:VBox width="492" top="10" bottom="10" left="28"&gt; &lt;mx:Repeater id="attributeMap" dataProvider="{sourceAttributes}"&gt; &lt;controls:AttributeMapping targetAttributes="{targetAttributes}" sourceAttribute="{attributeMap.currentItem}"/&gt; &lt;/mx:Repeater&gt; &lt;/mx:VBox&gt; </code></pre> <p></p> <pre><code>&lt;!-- MappingChangeEvent.as --&gt; package { import flash.events.Event; public class MappingChangeEvent extends Event { public static const MAPPING_CHANGED:String = "mappingChanged"; private var attribute:String; public function MappingChangeEvent(type:String, bubbles:Boolean, attribute:String) { super(type, bubbles); this.attribute = attribute; } override public function clone():Event { return new MappingChangeEvent(type, bubbles, attribute); } public function MappedAttribute():String { return this.attribute; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload