Skip to Content
0
Former Member
Feb 08, 2010 at 10:44 AM

Custom component property value handling at run time

32 Views

I would like to develop simple custom component which has three properties PROP1, PROP2 & RESULT . These parameters are bound to excel sheet cells as follows..

cell A1 connected to PROP1

cell A2 connected to PROP2 and

cell A3 connected to RESULT.

In excel A1 cell has excel formula set as =IF(A2<5,10,0).

Custom component would be simple button display at runtime and on click of the same, I would like to perform following actions in sequence with N number of times.

1. First push any random number to PROP2. (which is simple task, I believe)

2. Pick new value of PROP1 which is changed due to existance of excel formula (+ using dispatchevent I could able to pass value to excel cell A2. But not able to read new value of PROP1+)

3. check new PROP1 value equal to 10. If it is 10 then count it otherwise again push new random value to PROP2.

4. Continue step 1 to 3 till N number of times. and finally

4. Push number of counts for PROP1 value 10 to RESULT parameter.

All the parameters are bindable (getter/setter with [Bindable]) in Flex component application and flex propertysheet application use binding ID to bind with cell address. with binding direction BOTH and SINGLETON

Here is flex function code which triggered at button click.

public function test002():void {

while ( N < 100)

{

this.PROP2 = Math.round(Math.random()*1000);

dispatchEvent(new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE, false, false, PropertyChangeEventKind.UPDATE, "PROP2", null, PROP2, this));

if (this.PROP1 == 10)

{

cnt++;

}

}

this.RESULT = cnt;

}

My observations are as follows.

- new push of value to PROP2 get reflected to excel A2 when button click event is over, not at the time of while loop process execution.

- Also I observed PROP1 value never changes and it is the value which is recorded just before button click event of component at run time and remain the same till button click event is over.

- Further to this I notice as click event is over, new value of PROP2 reflected in cell A2 and change value (if it passes IF formula of excel ) in A1 as well. Next button click action takes these new A1 and A2 values in consideration and process the function "test002".

I would like to understand possibility of custom component event execution process, which can able to pass as well as read value from component parameters to underlying excel with changes due to excel formula existance. If it is not limitations (If so) what is the set of commands which can be helpful to achieve this. I appreciate if anybody explain typical event execution required in such scenarios with some actionscript code directions.

Thanks

Sandesh

Edited by: Sandesh Darne on Feb 8, 2010 11:48 AM

Edited by: Sandesh Darne on Feb 10, 2010 5:23 AM