jeudi 1 janvier 2015

Change selected property of checkbox to true, but is still not checked (Flex/AS3)

I have a checkbox, which has a dataprovider (dp) in another class for the selected property. Initial I set the dp to false and the checkbox in the GUI is not checked. If I set dp initial to true, the box is checked. So far all how it should be. If I click on the checkbox, the changes are also okay. But I also need to check and uncheck the checkbox in code, so I change the dp value from false to true, but the checkbox doesn't update - no mark is in the box. The action which is related with the check is executed correctly. So I think its only a visibility thing.


Followed the important snippets:


Imagine an event starts the changeOption() function. dp1 becomes true and its the selected property of cbOpt1, but this box has still no mark. Thank you very much for your help.



package org.mypackage.modules.model {

public class Allog {
[Bindable] public var dataprovider1:Boolean = false;
[Bindable] public var dataprovider2:Boolean = false;

public function changeOption():void {
dataprovider1 = true;
}
}
}





<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://ift.tt/1aBfKeP"
xmlns:mate="http://ift.tt/1n6zkoX"
implements="org.mypackage.modules.views.IActivitylog"
creationComplete="init()">

<mx:Script>
<![CDATA[
import org.mypackage.modules.model.Allog;
[Bindable] private var allog:Allog = new Allog();
private function init():void{...}
]]>
</mx:Script>

<mx:HBox width="100%" height="100%">
<mx:VBox height="100%" width="50%" enabled="true">
<mx:Label id="lab" text="xxx" />
<mx:VBox id="oBox" height="100%" width="50%" >
<mx:Label text="yyy" />
<mx:HBox width="100%">
<mx:Label text="Filter:" />
<mx:CheckBox id="cbOpt1" selected="{allog.dataprovider1}" label="Option1" click="throwFilterEvent(1,cbOpt1.selected)" />
<mx:CheckBox id="cbOpt2" selected="{allog.dataprovider2}" label="Option2" click="throwFilterEvent(2,cbOpt2.selected)" />
</mx:HBox>
</mx:VBox>
</mx:VBox>
</mx:HBox>




Aucun commentaire:

Enregistrer un commentaire