First off, events will always bubble UP. To pass an event into a
component just inject it.

Here is a simple application that should get you started:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="vertical"
     xmlns:Components="components.*"
creationComplete="onCreationComplete()">
     <mx:Script>
         <![CDATA[
             import components.MyLabelMXML;
             import components.MyLabelAS;
             import vos.BoringVO1;

             [Bindable] public var vo:BoringVO1;

             private var myLabelAS:MyLabelAS = new MyLabelAS();

             private function button1_clickHandler(event:MouseEvent):void
             {
                 vo = new BoringVO1;
                 myLabelAS.dispatchEvent(new
MouseEvent(MouseEvent.CLICK));
             }

             private function onCreationComplete():void
             {
                 myLabelAS.text = "My Label AS via AS";
                 addChild(myLabelAS);

                 var myLabelMXML:MyLabelMXML = new MyLabelMXML();
                 myLabelMXML.text = "My Label MXML via AS";
                 addChild(myLabelMXML);
             }
         ]]>
     </mx:Script>
     <mx:Label id="theLabel" text="{vo.wall}"/>
     <Components:MyLabelAS text="My Label AS via MXML"/>
     <Components:MyLabelMXML text="My Label MXML via MXML"/>
     <mx:Button label="Click Me!" click="button1_clickHandler(event)"/>
</mx:Application>

MyLabelAS.as
package components
{
     import flash.events.MouseEvent;
     import mx.controls.Alert;
     import mx.controls.Label;

     public class MyLabelAS extends Label
     {
         public function MyLabelAS()
         {
             super();
             addEventListener(MouseEvent.CLICK, onMouseClick);
         }

         private function onMouseClick(event:MouseEvent):void
         {
             Alert.show("Mouse Click Event Received");
         }
     }
}

MyLabelMXML.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml";>

</mx:Label>

If you peruse this, you should be able to see how to move something into
a component as well as inject an event into a component. If you need
anymore help, just ask.


HTH.



Steve



--- In [email protected], mikeashields <mikeashie...@...>
wrote:
>
>
> I have the following simplified mxml application but want to know how
to move
> the label to a new component and the Button to a different component
(both
> components then being in the application).  More specifically I cannot
> determine how to "address" the variable names and/or event listeners
between
> components (ie component A event bubbles up to application but then
does not
> "bubble" down to component B).  Thanks in advance.
>
> <?xml version="1.0" encoding="utf-8"?>
> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
>       xmlns:s="library://ns.adobe.com/flex/spark"
>       xmlns:mx="library://ns.adobe.com/flex/halo"
>       minWidth="1024" minHeight="768" xmlns:components="components.*">
>
>  <fx:Script>
>  <![CDATA[
>
>   import vos.BoringVO1;
>
>   [Bindable]
>   public var vo : BoringVO1;
>
>   public function button1_clickHandler(event:MouseEvent):void
>   {
>    vo = new BoringVO1;
>   }
>
>  ]]>
>  </fx:Script>
>
>  <mx:Label id="theLabel" text="{vo.wall}"/>
>  <s:Button click="button1_clickHandler(event)" x="82" y="3"/>
>
> </s:Application>
>
> ------------------------
>
> package vos
> {
>  public class BoringVO1
>  {
>   [Bindable]
>   public var wall : String = "Hello World";
>  }
> }
>
>
> --
> View this message in context:
http://www.nabble.com/Binding-between-components-tp24061284p24078417.htm\
l
> Sent from the FlexCoders mailing list archive at Nabble.com.
>

Reply via email to