0 Replies Latest reply on Jan 5, 2007 3:40 AM by deesri

    Flex Modular applns

    deesri Level 1
      This is in continuation to my previous msg as i couldnot put the entire code

      **************MODULE CODE ******************
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Module creationComplete="init()"
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      xmlns:vh="com.keane.rss.view.helper.*"
      layout="absolute" initialize="helper.loadXML('assets/books.xml')">
      <mx:Style source="/assets/Style.css" />
      <mx:Metadata>
      [Event(name="addToCart", type="BookEvent")]
      </mx:Metadata>

      <mx:Script>
      <![CDATA[
      import mx.core.Application;
      import mx.controls.Alert;
      import mx.collections.ArrayCollection;
      import mx.utils.ArrayUtil;

      public var articles:ArrayCollection=new ArrayCollection([
      "books","handicrafts","artifacts"
      ]);

      public function init():void {
      cartPanel.setStyle('backgroundColor','red');
      // Alert.show("panel color "+ cartPanel.getStyle('backgroundColor'));
      }
      //Dispatching data which has to be listened by main appln
      public function dispatchData(data:Object):void {

      var be:BookEvent = new BookEvent("addToCart", data);
      Alert.show("Dispatching event in Bookbank "+be.type);
      dispatchEvent(be);
      }

      public function getData():void {
      //ACCESSING APPLICATION DATA IN MODULE
      var expenseData:ArrayCollection =Application.application.expenses;

      for(var i=0;i<expenseData.length;i++) {
      // mx.controls.Alert.show("inside for loop");
      expenses.text += expenseData.getItemAt(i).Month+" "+
      expenseData.getItemAt(i).Profit+" "+
      expenseData.getItemAt(i).Expenses+"\n"
      }
      }

      ]]>
      </mx:Script>

      <vh:SampleCartHelper id="helper"/>
      <vh:PanelHelper id="panelhelper"/>
      <mx:Model id="myModel" source="assets/books.xml"/>

      <mx:VBox id="bookholder" x="50" y="50" width="50%" height="100%">
      <mx:Panel id="leftPanel" width="70%" title="Book Listing" verticalScrollPolicy="auto" height="200">
      <mx:Repeater id="titleRepeater" dataProvider="{helper.bookListArray}">

      <mx:LinkButton styleName="footerLink"
      click="helper.populateCart(event.currentTarget.getRepeaterItem());currentState='cartState '"
      label="{titleRepeater.currentItem.title}" />

      <!-- calling dispatch data to dispatch event -->
      <mx:Button label="Add" click="dispatchData(event.currentTarget.getRepeaterItem());helper.populateCart(event.curr entTarget.getRepeaterItem());currentState='cartState'"/>
      </mx:Repeater>
      </mx:Panel>
      </mx:VBox>
      <mx:Panel x="50" y="300" width="70%" backgroundColor="#d4c792" id="myPanel">
      <mx:Text text="Data from Application " width="70" />
      <mx:Text id="expenses" width="200" />
      <mx:Button label="Click" click="getData()" width="70"/>
      </mx:Panel>

      </mx:Module>

      ANYBODY, COULD YOU EXPLAIN WHY THE MAIN APPLICATION IS NOT LISTENING TO THE MODULE'S EVENTS.