cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Input Array Binding Not Changing Dynamically

Former Member
0 Likes
158

I am developing a component where I need to fill the values after the data comes in excel spreadsheet......

For Example : Binding multiple values in a single column of excel like 10,15,25,26......

I am binding the values as InputBindings.Array and OutputBindings.Array.

But my Component does not changes when the value on spreadsheet changes. But it works fine for a single value like if I have set a Maximum for my Graph. If I change the value in Spreadsheet my Graph automatically changes. But the x and y values which I have taken as arrays does not.............

PropertySheetCode:


switch (propertyName)
				{	
					case "value":
						Alert.show("BindingID"+bindingID);
						if ((bindingID == null) || (bindingID == ""))
						{
							valueEditor.text = "";
							return;
						}
						valueEditor.enabled = false;
						valueEditor.text = proxy.getBindingDisplayName(bindingID);
					//	setValueID(bindingID);
						proxy.bind("value", null, bindingID, BindingDirection.BOTH, InputBindings.ARRAY, OutputBindings.ARRAY);
						break;

My Component Code:


[Bindable]
   			[Inspectable(defaultValue="undefined", type="Array")]
       		[ArrayElementType("Number")]
   			public function get value():Array
   			{
    			return this._value;
   			}
   			public function set value(val:Array):void
   			{
    			if(_value != val)
    			{
    				this._value = val;
    				this._valuesChanged = true;
    				Alert.show("ValueArray"+val);
    				invalidateProperties();
    			}
   			}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Likes

It could be to do with your setValue function.

if(_value != val)

Try taking your comparison out and see if that works.

public function set value(val:Array):void
{
    // You do not have to do this but I find it is better to work with an empty array instead of null.
    if (!val)    val = [];

    this._value = val;
    this._valuesChanged = true;
    Alert.show("ValueArray"+val);
    invalidateProperties();
}

If it does work it is probably because the way Arrays are stored in Flex, if you change an Array you are changing its contents not the Array object itself.

I just assume that the array has always changed in my Array setter functions (as in the above code).

If you want to check properly you would need to write a compare function to compare each item in the Array (and if an item in the Array is a child Array do the same for the child Array etc).

Regards,

Matt