Pass data between flex components

前端 未结 2 1353
情深已故
情深已故 2021-02-11 01:31

I\'m new to flex , so forgive me if this is a dumb question.

Right now I\'m using custom events to pass data from one component to another. My problem is that events on

2条回答
  •  我寻月下人不归
    2021-02-11 02:12

    Easiest way is just to access the other component.

    
    
    private function onClickHandler(event:MouseEvent):void
    {
        component1.property1 = "Random data";
        component1.sendData("Random Data");
    }
    

    When you set a bindable public property in component1, it will raise a PropertyChangedEvent, which you can handle as well.

    You have a lot of options here, see which one is best in the context of what you are trying to do.

    EDIT: Reading further about what I think you're trying to do, you're trying to access component3 from component2, but component3 is not readiily visible to component1? It should still accessible through component2 though, (Components tend to be public members).

    private function component1OnClickHandler(event:MouseEvent):void
    {
         component2.component3.property1 = "Random data";
    }
    

    Hope this helps!

提交回复
热议问题