AS3 Display List
- Started
- Last post
- 8 Responses
- redant
If anyone could help I would appreciate. This all works except that I don;t know how to completely remove the objects. one clip plays then it is "removed" but it continues playing the sound etc. Is there an easy understandable way to do this? My code is prob not so good. Any help is appreciated thanks.
import flash.events.MouseEvent;
scanfaxinterface.menuback.mouseE... = false;
scanfaxinterface.menuback.mouseC... = false;
var loadhere:MovieClip = new LoadHere();
var scanner:MovieClip = new ScanMovie();
var intro:MovieClip = new Intro();
var closebutton:MovieClip = new CloseButton();
var backbtn:MovieClip = new BackButton();
var myLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("fax.swf");//---Intro---\\
intro.x = 310;
intro.y = 140;
addChildAt(intro,0);//---Scan---\\
scanfaxinterface.mainmenu.btn01... onBtn01Click);
function onBtn01Click(evt:MouseEvent):voi...
scanner.gotoAndPlay(2);
this.removeChild(intro);
addChildAt(scanner, 0);
addChild(backbtn);
}
scanfaxinterface.mainmenu.btn02... onBtn02Click);
function onBtn02Click(evt:MouseEvent):voi...
addChild(closebutton);
addChild(myLoader);
myLoader.load(url);
addChildAt (loadhere, 2);
}backbtn.addEventListener(MouseEv... onBtnBackClick);
function onBtnBackClick(evt:MouseEvent):v... {
this.addChildAt(intro,0);
this.intro.gotoAndPlay(1);
if( this.contains( scanner) ){ this.removeChild( scanner); }
removeChild(backbtn);
}closebutton.addEventListener(Mou... onCloseClick);
function onCloseClick(evt:MouseEvent):voi... {
this.addChildAt(intro,0);
this.intro.gotoAndPlay(1);
this.removeChild(myLoader);
this.removeChild(loadhere);
removeChild(closebutton);
}
- skelly_b0
to get rid of something you need to remove all references to it. The object still exists in memory when removed from the list. Try something like this:
removeChild(backBtn);
backBtn = null;
- redant0
i did try that didn't stop the sound from playing so I figure the clip is still playing do I need to remove the "eventListener" if so how? I am trying to find info too.
- skelly_b0
yeah, you need to stop and remove everything before killing that object.
- redant0
I dunno maybe ill jus stop the clip then play it. ok thanks.
- zaq0
- redant0
o thanks I'll read this
- maximillion_0
turn sounds on and off and change the visibility of items in the display list (visible property). you dont always need to remove them just hide them, turn them off etc
- redant0
yea i ended up doing that stopping and starting. I was jusreading all about removing angarbage collector and all that. Confusing but it works now.