1 Reply Latest reply on Jun 8, 2010 7:22 AM by SpaghettiCoder

    How do I make a components functions or eventhandlers externally visible

    someScreenName123

      Afternoon,

      I have created a custom component with some public functions called function1 function2 function3 (not real names) my question is I'm wanting to do the below

       

      <Custom:Com1 height="100%" width="100%" function1="{this.someFunction}" />

       

      problem is the function1 is not visible outside of Com1,

       

      my second question is how to I mark my functions as events so when you look at intellisense they are lightning bolts rather than methods I think the two are intertwined.

       

      some more points are my code for all of my components is separate from my mxml via setting an actionscript to be the parent class and that actionscript class extends hbox or application. hope this makes sense, I'm a vb developer not an actionscripter which is probably why I'm doing something obviously wrong...

       

      Thanks in advance for any help

      Cheers

      Tom.

        • 1. Re: How do I make a components functions or eventhandlers externally visible
          SpaghettiCoder Level 3

          //1. you need to tell everyone this component has events

           

          <fx:Metadata>

          [Event(name="showPreview",type="flash.events.Event")]

          </fx:Metadata>

           

          //2. dispatch the event when the time comes

           

           

          private function clickHandler(event:MouseEvent):void

          {

          var eventObject:Event = new Event("showPreview");

          dispatchEvent(eventObject);

          }

           

          //3. listen to the event from outside of the component

           

           

          customComponent:Component showPreview="showPreviewHandler(event)"/>

           

          //4.  Handle the event.

           

           

          private function showPreviewHandler(event:Event):void

          {

           

          }