PDA

View Full Version : Aw man....help with removing a lot of mc's


SCook
04-11-2005, 02:26 AM
Yo,
I've added a bunch of MC's dynamically, and I need to remove them on the next keyframe. Uhm...proceedure? This is one of those simple things I know I should know, but I'm stuck on it, so I figured somebody in forum land would see my problem quickly. Thanks gang.

Flash Gordon
04-11-2005, 02:31 AM
can you use the same loop you used to create this but instead of duplicateMovie use the delete command???

SCook
04-11-2005, 02:45 AM
Apparently not. And I used attachMovie, not duplicateMovie. I don't think that makes a difference, tho.

Flash Gordon
04-11-2005, 02:51 AM
I'll shut up after this as i really don't know about the attachMovie command, but how about looping the unloadMovie or the equivalent "unattachMovie" command?

JLM
04-11-2005, 03:02 AM
//remove every mc in the place movieclip
//untested
for(all in place){
place[all].swapDepths(10000);//large no. maybe not too large
place[all].removeMovieClip();
}

SCook
04-11-2005, 11:34 AM
This is unbelievable....nothing is working! There is a cheap way to do this, meaning manually by just attachming another instance of a mc to the main timeline, but I really would rather remove the clips.

CyanBlue
04-11-2005, 11:40 AM
Yeah... That's unbelievable for sure... I cannot understand why those suggestions won't work...
Can you make a simple sample and upload it??? I'd love to see why it is not working... ;)

Stu
04-11-2005, 11:43 AM
Not working?

JLM's example above should work fine, just change "place" to the name of the holder clip you used attachMovie to add the clips to.

SCook
04-11-2005, 11:58 AM
Okay, here's the code I've got. It doesn't have any remove stuff now. I tried it in the onPress for the button, and also on frame 2, where the fullsized image should appear, which it does, but the thumbs don't get removed.

stop();
locator = "http://www.cookwebdesign.com/broadband/getport.php";
vars = new LoadVars();
vars.cat = "small";
vars.sendAndLoad(locator, vars, "post");
vars.onLoad = function() {
vars.nameArray = vars.names.split("|");
vars.descArray = vars.descs.split("|");
vars.featArray = vars.features.split("|");
vars.fileArray = vars.files.split("|");
vars.urlArray = vars.names.split("|");

createThumbs();
}

function createThumbs() {
var xPos = -300;
var yPos = -128;
var counter = 1;
for (i = 0; i < vars.nameArray.length - 1; i++) {
this.attachMovie("box", "b" + i, 10 + i);
this["b"+i]._x = xPos;
this["b"+i]._y = yPos;
this["b"+i].loadMovie("images/t" + vars.fileArray[i]);
createButtons(xPos + 50, yPos + 37.5, i);
if (counter < 5) {
counter++;
xPos += 125;
} else {
counter = 1;
xPos = -300;
yPos += 100;
}
}
}

function createButtons(xPos, yPos, ind) {
this.attachMovie("box2", "b" + i + "a", 50 + i);
this["b" + i + "a"]._x = xPos;
this["b" + i + "a"]._y = yPos;
this["b" + i + "a"]._width = 140;
this["b" + i + "a"]._height = 115;
this["b" + i + "a"]._alpha = 0;
this["b" + i + "a"].int = ind;
this["b" + i + "a"].onRollOver = function() {
this._alpha = 100;
}
this["b" + i + "a"].onRollOut = function() {
this._alpha = 0;
}
this["b" + i + "a"].onPress = function() {
_root.thumbInd = ind;
gotoAndStop(2);
}
}

Now, I did not use a holder MC to attach to. I attached them to the clip holding the code itself. This may be a solutions, however, I still think I should be able to step through them and remove the clips. I can't belieeve this...

SCook
04-11-2005, 12:02 PM
All right, I've got it now, it's working :-) A relatively simle task, beneath my skill level and yet....took like ten post to get it :-) I hate it when that happens. Thanks guys.

daveirish1
04-11-2005, 12:27 PM
hey scook, how'd you get it in the end? i'm tryin to do kinda the same thing, ie, every time a button is clicked it creates a movieclip, but first removes the ones created by other buttons before it.

CyanBlue
04-11-2005, 02:01 PM
Uh, what was the problem??? ;)

SCook
04-11-2005, 02:59 PM
On keyframe 2, I put this code in:

for(all in this) {
this[all].swapDepths(10000);//large no. maybe not too large
this[all].removeMovieClip();
}
this.attachMovie("box", "pic", 10);
pic._x = -310;
pic._y = -128;
pic.loadMovie("images/" + vars.fileArray[_root.thumbInd]);
pic._xscale = 90;
pic._yscale = 90;
this.attachMovie("box", "pic2", 11);
pic2._x = -130;
pic2._y = 10;
pic2._xscale = 360;
pic2._yscale = 355;
pic2._alpha = 0;
pic2.onRollOver = function() {
this._alpha = 25;
}
pic2.onRollOut = function() {
this._alpha = 0;
}
pic2.onPress = function() {
getURL(vars.urlArray[_root.thumbInd], "_blank");
}

site = new TextFormat();
site.align = "justified";
site.size = 14;
site.font = "Arial";
site.color = 0xffffff;

this.createTextField("siteText", 15, 60, -128, 240, 250);
siteText.multiline = "true";
siteText.wordWrap = "true";
siteText.html = "true";
theText = "<b>" + vars.nameArray[_root.thumbInd] + "</b><br><br>";
theText += vars.descArray[_root.thumbInd] + "<br><br>";
theText += "<i>" + vars.featArray[_root.thumbInd] + "</i><br><br>";
theText += vars.urlArray[_root.thumbInd] + "<br><br>";
theText += "<u>Dlick the image to visit the site</u>";
siteText.variable = "theText";
siteText.setTextFormat(site);

The important part is the top three lines. The rest is pretty specific to my stuff.