se me olvidaba la función de limpieza XDXD
Código PHP:
import fl.controls.CheckBox
var xml:XML=
<contenido>
<url name="chec1">ico1.swf</url>
<url name="chec2">ico2.swf</url>
<url name="chec3">ico3.swf</url>
<url name="chec4">ico4.swf</url>
</contenido>
var containerCheckBox:Array=new Array()
var containerLoader:Array=new Array()
function createCheckBox(){
for (var i:int=0;i<xml.child('url').length();i++){
var checkBox:CheckBox=new CheckBox()
checkBox.label=xml.url[i].@name
checkBox.y=checkBox.height*i
addEvent(checkBox,i,xml.url[i])
containerCheckBox.push(checkBox)
addChild(checkBox)
}
}
function addEvent(checBox:CheckBox,id:int,url:String):void{
var loader:Loader=new Loader()
containerLoader.push(loader)
addChild(loader)
checBox.addEventListener(Event.CHANGE, upLoadDownLoad);
function upLoadDownLoad(event:Event):void{
if (checBox.selected) {
loader.load(new URLRequest(url))
}else{
loader.unload();
}
}
}
function limpiar(event:Event):void{
for(var i:int=0;i<containerCheckBox.length;i++){
containerCheckBox[i].selected=false
containerLoader[i].unload()
}
}
createCheckBox()
boton.addEventListener(MouseEvent.CLICK,limpiar)