1 Reply Latest reply on Dec 8, 2009 6:52 AM by Gregory Lafrance

    Creating events in <mx:component>

    rcanulla Level 1

      Hi there,

       

      I am wondering what the dela is with <mx:component>.... Can it see outside the scope of itself? I am trying to access a method in the main file <mx:Script> block, and am getting a "can't find that function..." error.

       

      Any thoughts are greatly appreciated!

        • 1. Re: Creating events in <mx:component>
          Gregory Lafrance Level 6

          You need to use "outerDocument", and ensure the function is public:

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script>
              <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.controls.Alert;
              
                [Bindable] private var ac:ArrayCollection = new ArrayCollection([1,2,3,4,5]);
                  public function clickHandler():void{
                  Alert.show("here");
                }
              ]]>
            </mx:Script>
              <mx:List dataProvider="{ac}">
                <mx:itemRenderer>
                  <mx:Component>
                    <mx:Button click="outerDocument.clickHandler()"/>
                  </mx:Component>
                </mx:itemRenderer>
              </mx:List>
          </mx:Application>
          


          If this post answers your question or helps, please mark it as such.


          Greg Lafrance
          www.ChikaraDev.com

          Flex Development and Support Services