Search code examples
apache-flexactionscriptwidgetarcgis

Communication between widgets


i'm new in flex, and im working on Webmapping application using flex 4.6, java, and sql server as database, i'm just trying to make a communication between wigdets, i would like to copy each selected item of my combobox in widget1, and show it in the textinput in widget2, i just followed this steps explaind by Robert here http://forums.arcgis.com/threads/138...+communication but no luck, the problem that i'm facing is that i can't call components of the first widget (textinput, button....) from the second widget, they are often underlined !!

at jump you found the change i made,

Widget 1

var layoutArr:ArrayCollection = new ArrayCollection();
            private function widgetCommunication1():void
            {
                addSharedData("Liste des chapitres", layoutArr); 
            }

Widget 2

<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:viewer="com.esri.viewer.*"
                   width="638" height="552" creationComplete="application1_applicationCompleteHandler(event)" 
                   initialize="basewidget1_initializeHandler(event)">

<fx:Script>
        <![CDATA[

                        import com.esri.viewer.AppEvent;
            import mx.events.FlexEvent;
    protected function basewidget1_initializeHandler(event:FlexEvent):void
            {
                ViewerContainer.addEventListener(AppEvent.DATA_PUBLISH, sharedDataUpdated);
            }

 private function sharedDataUpdated(event:AppEvent):void
            {
                var data:Object = event.data;               
                if (data.key == "Liste des chapitres")

                {
                    dplist.selectedIndex = ***IntChap***.text;
                } 
            }   

]]>
    </fx:Script>

<s:DropDownList id="dplist" x="10" y="10" width="282" height="26" labelField="IntituleChap" dataProvider="{RemoteRapportDao.Selection.lastResult}" change="dplist_changeHandler(event)" ></s:DropDownList>

IntChap which is bold & italic is the textinput in widget1 , i got it underlined in widget 2, even if i made this communication any one can tell me what i'm messing ?? any help or code will be appreciated !


Solution

  • http://web.zone.ee/bespiva/ there is an example on the link above, just follow all the steps, it works very well ;)