This content has been marked as final.
Show 5 replies
-
1. Re: Help! Remove Movie Clips
blemmo Jul 21, 2006 5:36 AM (in response to 02TransAm)Do a removeMovieClip() for the MCs not needed anymore, or maybe make them invisible by setting the _visible property to false when you want to reuse them later. This should be done when the frame is entered, so you could place this on the frame's script (assumes that the clips are called "thumb0","thumb1" etc. and placed in _root):
for (var i=0;i<mccount;i++){
_root["thumb"+i].removeMovieClip();
//_root["thumb"+i]._visible = false;
}
hth,
blemmo -
2. Re: Help! Remove Movie Clips
02TransAm Jul 21, 2006 5:47 AM (in response to 02TransAm)OK...here's the code...At thebottom of the document, I need to remove the clips created on the next button. This is the same code from the gallery sample file; I just added my own XML file.
stop();
import mx.transitions.*;
_global.thisX = 30;
_global.thisY = 70;
_global.stageWidth = 600;
_global.stageHeight = 400;
var gallery_xml:XML = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success:Boolean) {
try {
if (success) {
var images:Array = this.firstChild.childNodes;
var gallery_array:Array = new Array();
for (var i = 0; i<images.length; i++) {
gallery_array.push({src:images .firstChild.nodeValue});
}
displayGallery(gallery_array);
} else {
throw new Error("Unable to parse XML");
}
} catch (e_err:Error) {
trace(e_err.message);
} finally {
delete this;
}
};
gallery_xml.load("gallery_practices2.xml");
function displayGallery(gallery_array:Array) {
var galleryLength:Number = gallery_array.length;
for (var i = 0; i<galleryLength; i++) {
var thisMC:MovieClip = this.createEmptyMovieClip("image"+i+"_mc", i);
mcLoader_mcl.loadClip(gallery_array.src, thisMC);
preloaderMC = this.attachMovie("preloader_mc", "preloader"+i+"_mc", 5000+i);
preloaderMC.bar_mc._xscale = 0;
preloaderMC.progress_txt.text = "0%";
thisMC._x = _global.thisX;
thisMC._y = _global.thisY;
preloaderMC._x = _global.thisX;
preloaderMC._y = _global.thisY+20;
if ((i+1)%5 == 0) {
_global.thisX = 20;
_global.thisY += 80;
} else {
_global.thisX += 80+20;
}
}
}
var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function() {
};
mclListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
var pctLoaded:Number = Math.round(loadedBytes/totalBytes*100);
var preloaderMC = target_mc._parent["preloader"+target_mc.getDepth()+"_mc"];
preloaderMC.bar_mc._xscale = pctLoaded;
preloaderMC.progress_txt.text = pctLoaded+"%";
};
mclListener.onLoadInit = function(evt:MovieClip) {
evt._parent["preloader"+evt.getDepth()+"_mc"].removeMovieClip();
var thisWidth:Number = evt._width;
var thisHeight:Number = evt._height;
var borderWidth:Number = 2;
var marginWidth:Number = 8;
evt.scale = 8;
evt.lineStyle(borderWidth, 0x000000, 100);
evt.beginFill(0xFFFFFF, 100);
evt.moveTo(-borderWidth-marginWidth, -borderWidth-marginWidth);
evt.lineTo(thisWidth+borderWidth+marginWidth, -borderWidth-marginWidth);
evt.lineTo(thisWidth+borderWidth+marginWidth, thisHeight+borderWidth+marginWidth);
evt.lineTo(-borderWidth-marginWidth, thisHeight+borderWidth+marginWidth);
evt.lineTo(-borderWidth-marginWidth, -borderWidth-marginWidth);
evt.endFill();
evt._xscale = evt.scale;
evt._yscale = evt.scale;
evt._rotation = Math.round(Math.random()*-10)+5;
evt.onPress = function() {
this.startDrag();
this._xscale = 30;
this._yscale = 30;
this.origX = this._x;
this.origY = this._y;
this.origDepth = this.getDepth();
this.swapDepths(this._parent.getNextHighestDepth());
this._x = (_global.stageWidth-evt._width+30)/2;
this._y = (_global.stageHeight-evt._height+30)/2;
mx.transitions.TransitionManager.start(this, {type:mx.transitions.Photo, direction:0, duration:1, easing:mx.transitions.easing.Strong.easeOut, param1:empty, param2:empty});
};
evt.onRelease = function() {
this.stopDrag();
this._xscale = this.scale;
this._yscale = this.scale;
this._x = this.origX;
this._y = this.origY;
};
evt.onReleaseOutside = evt.onRelease;
};
mcLoader_mcl.addListener(mclListener);
next_btn.onRelease= function() {
gotoAndStop(2);
}
back_btn.onRelease= function() {
gotoAndStop(1);
} -
3. Re: Help! Remove Movie Clips
blemmo Jul 21, 2006 6:06 AM (in response to 02TransAm)You must save the number of items so you can use it in the next button. Add a var to the timeline, or maybe another global:
_global.mccount = 0;
In createGallery(), assign the number of thumbnails to this:
_global.mccount = gallery_array.length;
Then you can use this number in the next button:
next_btn.onRelease= function() {
for (var i=0; i<_global.mccount; i++){
_root["image"+i+"_mc"].removeMovieClip();
}
gotoAndStop(2);
}
cheers,
blemmo -
4. Re: Help! Remove Movie Clips
02TransAm Jul 21, 2006 6:10 AM (in response to 02TransAm)Thanks, I am going to try it!!!!!!! -
5. Re: Help! Remove Movie Clips
02TransAm Jul 21, 2006 6:24 AM (in response to 02TransAm)You are awesome!!!! Seriously you are an Action Script Genious!!!!! Thank you sooooo much!!!!!! I worked perfectly!!!! How'd you get so good? Any tips?

