Free AS3 Checkbox Component:
Writing new stylesheet or editing the V2 is headache for me. So I have created my own checkbox component. Hope will help you in your projects.
Difficulty of Use:
Intermediate to advanced users.
Sample component1:
Code for Sample1:
import com.Designscripting.Components.ICheck;
var _icheck:CheckButton = new CheckButton();
_icheck.index = 1;
_icheck.x = _icheck.y = 60;
_icheck._txt.text = "SampleData 1";
_icheck._btn.addEventListener(MouseEvent.CLICK, buttonClicked);
addChild(_icheck);
function buttonClicked(e:MouseEvent):void
{
//Code to open URL in _blank window.
navigateToURL( new URLRequest("http://www.designscripting.com/"), "_blank");
ICheck.setItem(e.target.parent);
}
Here we are importing the custom classes and creating an instance for CheckButton and adding it to display list.
Later on selecting the checkbox we are launching the URL:designscripting.com
Some Useful Functions of the Component:
- setItem()
- getSelectedIndices()
- getSelectedData()
- isItemSelected()
setItem: Static method to set the checkbox item selected.
getSelectedIndices: Static method to return selected index of checkbox, return type Array.
getSelectedData: Static method to return selected data of checkbox, return type Array.
isItemSelected: Static method to return checkbox is selected or not. return type Boolean.
Sample Component 2:
Code for Sample2:
import com.Designscripting.Components.ICheck;
var verticalSpacing:Number = 50;
for(var count:int =0; count<3; count++)
{
var _icheck:CheckButton = new CheckButton();
_icheck.x = 40
_icheck.y = 70+count*verticalSpacing;
_icheck.index = count;
_icheck._txt.text = "SampleData "+count;
_icheck._btn.addEventListener(MouseEvent.CLICK, buttonClicked);
addChild(_icheck);
}
function buttonClicked(e:MouseEvent):void
{
ICheck.setItem(e.target.parent);
}
resultMc.buttonMode = clearMc.buttonMode = true;
resultMc.addEventListener(MouseEvent.CLICK, function(e:MouseEvent){
_resultTxt.text = String("Selected Item\n"+ICheck.getSelectedIndices())
trace(ICheck.getSelectedData())
})
clearMc.addEventListener(MouseEvent.CLICK, function(e:MouseEvent){ICheck.reset();_resultTxt.text = ""})
Find the source files attached.












































Leave your response!