Hi,
I’m having an ongoing problem trying to remove instances of child/children.
I have a function (btFnc) that creates a child (bT) and then the function is called several times to add instances to the stage - btFnc(264,3.6); btFnc(304,4.6); btFnc(344,5.6); btFnc(384,6.6); btFnc(424,7.6);
Yet i cannot for the life of me remove all of the children, only 1.
public class screen18 extends MovieClip {
private var scrnXMLLoader:XMLLoader;//XML Loading class
private var screenTxt:Array;
private var s1Txt:textF;
private var ph1:p1;
private var ph2:p2;
private var ph3:p3;
private var ph4:p4;
private var ph5:p5;
private var ph6:p6;
private var ph7:p7;
private var ph8:p8;
private var ph9:p9;
private var cBtn:skipBtn;
private var bT:blueTxt;
public function screen18():void {
scrnXMLLoader=new XMLLoader(["assets/XML/screen18.xml"]);
scrnXMLLoader.addEventListener(Event.COMPLETE,XMLLoaded);
}
private function XMLLoaded(e:Event):void {
screenTxt = new Array();
for (var i:Number = 0; i<scrnXMLLoader.getList[0].screen.text.length(); i++) {
screenTxt*= scrnXMLLoader.getList[0].screen.text*;
}
screen01();
}
private function screen01():void {
cBtn = new skipBtn();
ph1 = new p1();
addChild(ph1);
ph2 = new p2();
addChild(ph2);
ph1.x=730;
ph1.y=470;
ph1.alpha =0;
ph2.x=730;
ph2.y=470;
ph2.alpha =0;
s1Txt = new textF();
addChild(s1Txt);
s1Txt.textFnc(83,77,450,300,screenTxt[0],18,"name",0,0.4,"0x3C3B3B",true);
s1Txt.textFnc(83,141,450,300,screenTxt[1],18,"name",0,2.3,"0x3C3B3B",true);
s1Txt.textFnc(130,251,450,300,screenTxt[2],18,"name",0,4,"0x3C3B3B",true);
s1Txt.textFnc(130,291,450,300,screenTxt[3],18,"name",0,5,"0x3C3B3B",true);
s1Txt.textFnc(130,331,450,300,screenTxt[4],18,"name",0,6,"0x3C3B3B",true);
s1Txt.textFnc(130,371,450,300,screenTxt[5],18,"name",0,7,"0x3C3B3B",true);
s1Txt.textFnc(130,411,450,300,screenTxt[6],18,"name",0,8,"0x3C3B3B",true);
TweenLite.to(ph1,1.5,{alpha:1,y:166,rotation:2,delay:1,ease:Expo.easeOut});
TweenLite.to(ph2,1.5,{alpha:1,y:358,rotation:-3,delay:3,ease:Expo.easeOut,onComplete:nxt});
//btFnc(90,0);
//btFnc(154,2);
btFnc(264,3.6);
btFnc(304,4.6);
btFnc(344,5.6);
btFnc(384,6.6);
btFnc(424,7.6);
function btFnc(bY:Number,bDel:Number):void {
bT= new blueTxt();
addChild(bT);
setChildIndex(bT,0);
bT.x=454;
bT.y=bY;
bT.scaleX=.8;
bT.scaleY=.8;
bT.alpha=0;
TweenLite.to(bT,.5,{scaleX:1,scaleY:1,alpha:1,delay:bDel,ease:Cubic.easeOut,overwrite:0});
}
//
function nxt():void {
addChild(cBtn);
cBtn.alpha=0;
TweenLite.to(cBtn,.5,{alpha:1,ease:Expo.easeOut});
cBtn.x=878;
cBtn.y=588;
cBtn.buttonMode=true;
cBtn.mouseChildren=false;
cBtn.addEventListener(MouseEvent.MOUSE_OVER, sOver);
cBtn.addEventListener(MouseEvent.MOUSE_DOWN, s02Nxt);
}
function s02Nxt(e:MouseEvent):void {
cBtn.buttonMode=false;
cBtn.removeEventListener(MouseEvent.MOUSE_OVER, sOver);
cBtn.removeEventListener(MouseEvent.MOUSE_DOWN, s02Nxt);
TweenLite.to(cBtn,.5,{alpha:0,ease:Expo.easeOut});
TweenLite.to(s1Txt,.5,{alpha:0,ease:Expo.easeOut});
TweenLite.to(ph2,.5,{alpha:1,y:166,ease:Expo.easeOut,overwrite:0});
TweenLite.to(ph1,.5,{alpha:1,ease:Expo.easeOut,overwrite:0,onComplete:screen02});
removeChild(ph1);
removeChild(ph2);
}
}
This then repeats for screens 2, 3 & 4.
Any help would be greatly received as this has been driving me crazy for days now and I have tried many variations of the removeChild, At etc.
Thanks in advance
sta777