views:

23

answers:

2

I have actionscript file with a binding {someBinding}...

The Main.mxml is where all the action happens. If I set {someBinding} in the "text" of a label component I will have a number.

I have another form.mxml file. Where I want that binding to be in, but it can't find such binding.

I need to have that {someBinding} in that other mxml, the same way as in the Main.mxml

Thanks, Yan

+1  A: 

You can't a value in one component (or File) to a value in another component (or file) in the way you seem to be asking. You'll have to expose those related values as properties and set the values.

This type of approach should work:

First add a property to component 2 and make it Bindable. Do this in a Script block, like this:

[Bindable] public var hBoxWidth : int;

Then bind it to something in your MXML of the same component, like this:

<mx:HBox width="{this.hBoxWidth}" />

Now some component will contain this one:

<mx:HBox>
  <myCustomComp:customHBox hBoxWidth={this.othervalue} />
</mx:Hbox>

So, when the othervalue changes it will change the hBoxWidth value on the customHBox component which will in turn change the width property on the HBox inside of customHBox.

Does that make sense?

www.Flextras.com
A: 

You can create the binding but you have to use ActionScript and you need a reference to the form.mxml file in the main.mxml (or visa versa).

This should give you an ideal of how it might work. Take a look at the syntax for the BindingUtils. bindProperty method. The use of BindingUtils code would be within main.mxml.

BindingUtils.bindProperty(otherForm.someOtherTextComponent, "text", this.someTextComponent, "text");
Mike