Veltar
Veltar

Reputation: 741

how do I pass a variable from my custom component a different component

In my custom component (Login), I create and set a variable userName, it is bindable:

[Bindable] private var userName:String;
userName = txtUsername.text;

I need to pass that variable to a different custom component (Overview), here is the code of the viewstack:

<mx:ViewStack id="mainViewStack" x="76" y="90" width="800" height="400">
    <components:Login />
    <components:Overview />
</mx:ViewStack>

I've searched for a way, but I haven't found one that does the trick. Thank you.

Upvotes: 0

Views: 54

Answers (1)

Kodiak
Kodiak

Reputation: 5978

You have to set this variable to public:

[Bindable] public var userName:String;

and then you can pass it like that (supposing userName is a property of Login):

<components:Login id="login" />
<mx:Label text="{login.userName}" />

Upvotes: 1

Related Questions