Hi all,

I'm new at Flex and need some help about event handling among
different Flex components. I have a custom TitleWindow with a Button.
I want another custom component (used as a cell renderer in this
TitleWindow) to listen to this button to be clicked and then do
something. 

Here is my TitleWindow WActes.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow  xmlns:mx="http://www.macromedia.com/2003/mxml"; 
        xmlns="*" xmlns:ns1="Components.*" creationComplete="doInit()"
        title="This is my popup" closeButton="true"   
        click="this.deletePopUp()">
    
    <mx:Metadata>
        [Event("myEvent")]
    </mx:Metadata>

    <mx:Script><![CDATA[
       function myButtonClick() {
          dispatchEvent({type:"myEvent"});
       }
    ]]></mx:Script>


    <mx:DataGrid id="dgAlu" dataProvider="{myArr}" width="100%"  
        height="100%" editable="true" 
        variableRowHeight="true" wordWrap="true"">
    <mx:columns>
    <mx:Array>
    <mx:DataGridColumn headerText="Nom" columnName="nom"
editable="false" width="80" wordWrap="true"></mx:DataGridColumn>
    <mx:DataGridColumn headerText="Qualificacio" editable="false"
cellRenderer="Components.HBoxQualificacio"></mx:DataGridColumn>
    </mx:Array>
    </mx:columns>
    </mx:DataGrid>

    <mx:ControlBar>
      <mx:Button label="Close" click="deletePopUp()"/> 
      <mx:Button id="myButton" label="Click here"  
          click="myButtonClick()"></mx:Button>
    </mx:ControlBar>
        

</mx:TitleWindow>



And here is my own cell renderer, HBoxQualificacio.mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.macromedia.com/2003/mxml";
initialize="inici()" hScrollPolicy="off">

  <mx:Script><![CDATA[

    function inici() {
      var listenerObject = new Object();
      listenerObject.myEvent = function(event) {
        trace("myEvent catched"); //This is never printed!!! :-(
      }
      parent.myButton.addEventListener("myEvent", listenerObject);
    }   
  ]]></mx:Script>

  <!-- Several Flex components go here -->

</mx:HBox>



Please I do need some help! Thanks!





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to