0

Posting for a colleague. Please don't up-vote or down-vote.

This is all inside the same MXML file.

public function toggleMonitor(part:Object):void { 
    if(part.active == 0)
        part.active = 1;
    else
        part.active = 0;
}

public function monitorAll(monitor:int):void {
    for(var part:Object in blah) {
        part.active = monitor;
    }
}

<mx:DataGrid dataProvider="{blah}">
    <mx:columns>
        <mx:DataGridColumn>
            <mx:itemRenderer>
                <mx:Component>
                    <mx:Image source="{data.active == 0 ? img1 : img2}" click="outerDocument.toggleMonitor(data)"/>
                </mx:Component>
            </mx:itemRenderer>  
        </mx:DataGridColumn>
    </mx:columns>
</mx:DataGrid>

<mx:Button click="monitorAll(1)"/>

Clicking on the image correct toggles the image (i.e. the toggleMonitor function works). But clicking on the button doesn't (i.e. the monitorAll function does not work). Why isn't the button working?

4

1 に答える 1

0

彼はなんとかその問題を解決した。メソッドは次のようになります。

public function monitorAll(monitor:int):void {
    blah.refresh(); 
        for (var i:int = 0; i < blah.length; i++){
            (blah.getItemAt(i) as Object).active = monitor; 
        }
    blah.refresh(); 
}
于 2013-02-07T21:58:45.003 に答える