The following UnrealScript would work to get the value of a checkbox, assuming your checkbox has an instance name in Flash of 'aCheckBox' and assuming you're using a CLIK widget for that checkbox:
Getting a Checkbox's Value
Code:
var GFxClikWidget MyCheckBox;
var bool MyOption;
event bool WidgetInitialized(name WidgetName, name WidgetPath, GFxObject Widget)
{
switch(WidgetName)
{
case ('aCheckBox'):
MyCheckBox = GFxClikWidget(Widget);
MyCheckBox.AddEventListener('CLIK_select', OnMyCheckBoxChange);
default:
break;
}
return true;
}
function OnMyCheckBoxChange(GFxClikWidget.EventData ev) {
MyOption = bool(MyCheckBox.GetString("_selected"));
`log(MyOption);
}
defaultproperties
{
WidgetBindings.Add((WidgetName="aCheckBox",WidgetClass=class'GFxClikWidget'))
}
This will return true or false, though it will return undefined at first unless you specify the checkbox's value in UnrealScript and/or ActionScript first as true or false.
NOTE: While you could use CLIK_press as the event to listen for, this would yield the previous state of the checkbox and not the current state. CLIK_select ensures you get the current state of the checkbox AFTER the user pressed the checkbox button.
Setting a Checkbox's Value
To set a checkbox from UnrealScript:
Code:
SetMyCheckBox(true); // or false
function SetMyCheckBox(bool b) {
ActionScriptVoid("SetMyCheckBox");
}
In ActionScript, you should have the following code:
Code:
function SetMyCheckBox(checked:Boolean) {
aCheckBox.selected = checked;
}
Bookmarks