You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mark goldin <ma...@gmail.com> on 2016/06/01 08:38:40 UTC

ADG initilizes private vars for unknown reason

I have an ADG where I am using a local connection to refresh gird's data
and select previously selected item.
The pseudo code might loook like this:

private var _selectedIndex:int = 0;
private var _navigateToPrevSelection:Boolean = false;

private function get SelectedIndex():int
{
return _selectedIndex;
}
private function set SelectedIndex(value:int):void
{
_selectedIndex = value;
}
private function get NavigateToPrevSelection():Boolean
{
return _navigateToPrevSelection;
}
private function set NavigateToPrevSelection(value:Boolean):void
{
_navigateToPrevSelection = value;
}
// This function is called when the server has returned a coomand that
grid's data must be refreshed.
public function localConnectionHandler():void
{
     SelectedIndex = grid.seledctedIndex;
     // an event "ABC" is fired to generate new data for the grid.
     // set dataProvider is called since grid's data is bound to the ABC's
execution result
    // At this point SelectedIndex has the correct value;
}
override public function set dataProvider(value:Object):void
{
// When dataProvider is set after ABC was executed the SelectedIndex is set
to _selectedIndex's initial value which is zero.
        if (value)
        ....
}

Can someone please explain why private variables get initialized?

Thanks

Re: ADG initilizes private vars for unknown reason

Posted by Alex Harui <ah...@adobe.com>.
Maybe changing the DataProvider resets the selectedIndex.

On 6/1/16, 1:38 AM, "mark goldin" <ma...@gmail.com> wrote:

>I have an ADG where I am using a local connection to refresh gird's data
>and select previously selected item.
>The pseudo code might loook like this:
>
>private var _selectedIndex:int = 0;
>private var _navigateToPrevSelection:Boolean = false;
>
>private function get SelectedIndex():int
>{
>return _selectedIndex;
>}
>private function set SelectedIndex(value:int):void
>{
>_selectedIndex = value;
>}
>private function get NavigateToPrevSelection():Boolean
>{
>return _navigateToPrevSelection;
>}
>private function set NavigateToPrevSelection(value:Boolean):void
>{
>_navigateToPrevSelection = value;
>}
>// This function is called when the server has returned a coomand that
>grid's data must be refreshed.
>public function localConnectionHandler():void
>{
>     SelectedIndex = grid.seledctedIndex;
>     // an event "ABC" is fired to generate new data for the grid.
>     // set dataProvider is called since grid's data is bound to the ABC's
>execution result
>    // At this point SelectedIndex has the correct value;
>}
>override public function set dataProvider(value:Object):void
>{
>// When dataProvider is set after ABC was executed the SelectedIndex is
>set
>to _selectedIndex's initial value which is zero.
>        if (value)
>        ....
>}
>
>Can someone please explain why private variables get initialized?
>
>Thanks