Need help with delete attach MC

HI…

okay how to remove previous attach mc?..OKay here’s the big picture…I have 3 btn…and when u click each btn will load dt from dtbase based on different value…eg; btn0–>total record = 4,btn1–> total record = 5…and so on…ok forget about dtbase stuff…let’s get back to AS stuff…
ok as u can see the my AS below …it will receive the total amount value from dtbase each time different btn being press…
meaning that different value…so in my case…the
“this.items” hold the different value…so far it works okay …load and get bounce…my problem is how to delete previous attach mc?..I mean when i press btn1 it will attach 4 MC and then when I press btn2 suppose to it 's only attach 3 mc …but what happen now…it still load the 4 mc…meaning that it not delete the previous attach MC…so I really need help with it…is there anything I miss view…?

ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]**var**[/COLOR] col:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]4[/COLOR];

[COLOR=#000000]var[/COLOR] curBox:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]0[/COLOR];
[COLOR=#000000]var[/COLOR] spacing:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]10[/COLOR];
[COLOR=#000000]var[/COLOR] makeBoxesSpeed:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]100[/COLOR];
[COLOR=#000000]var[/COLOR] elasticSpeed:[COLOR=#0000FF]Number[/COLOR] = .[COLOR=#000080]7[/COLOR];
[COLOR=#000000]var[/COLOR] container:[COLOR=#0000FF]MovieClip[/COLOR];
container = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]_parent[/COLOR].[COLOR=#0000FF]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“container”[/COLOR], [COLOR=#000080]99[/COLOR][COLOR=#000000])[/COLOR];
container.[COLOR=#0000FF]_x[/COLOR] = [COLOR=#000080]200[/COLOR];
container.[COLOR=#0000FF]_y[/COLOR] = [COLOR=#000080]30[/COLOR];

[COLOR=#000000]function[/COLOR] loadthumbCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
curBox = [COLOR=#000080]0[/COLOR];
id = [COLOR=#0000FF]setInterval[/COLOR][COLOR=#000000]([/COLOR] test, makeBoxesSpeed,[COLOR=#0000FF]this[/COLOR].[COLOR=#000080]items[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR][COLOR=#0000FF]else[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]trace[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]function[/COLOR] testCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]curBox < boxes[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#000000]var[/COLOR] mythumb = container.[COLOR=#0000FF]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“box”[/COLOR], [COLOR=#FF0000]“box”[/COLOR] + curBox, curBox[COLOR=#000000])[/COLOR];
mythumb.[COLOR=#0000FF]_x[/COLOR] = [COLOR=#000000]([/COLOR]curBox % col[COLOR=#000000])[/COLOR] * [COLOR=#000000]([/COLOR]mythumb.[COLOR=#0000FF]_width[/COLOR] + spacing[COLOR=#000000])[/COLOR];
mythumb.[COLOR=#0000FF]_y[/COLOR] = [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]floor[/COLOR][COLOR=#000000]([/COLOR]curBox / col[COLOR=#000000])[/COLOR] * [COLOR=#000000]([/COLOR]mythumb.[COLOR=#0000FF]_height[/COLOR] + spacing[COLOR=#000000])[/COLOR];
mythumb.[COLOR=#0000FF]_xscale[/COLOR] = [COLOR=#000080]0[/COLOR];
mythumb.[COLOR=#0000FF]_yscale[/COLOR] = [COLOR=#000080]0[/COLOR];
mythumb.[COLOR=#000080]bounceMe[/COLOR]COLOR=#000000[/COLOR];
curBox++;
[COLOR=#000000]}[/COLOR] [COLOR=#0000FF]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]clearInterval[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]

[COLOR=#0000FF]MovieClip[/COLOR].[COLOR=#0000FF]prototype[/COLOR].[COLOR=#000080]bounceMe[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]this[/COLOR].[COLOR=#000080]scaleTo[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000080]100[/COLOR], elasticSpeed, [COLOR=#FF0000]“easeOutElastic”[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR];
[/LEFT]
[/FONT]

thanks in advanced

Maybe you could just create the container each time you call the test function?

Or you could just store references to the newly created clips in an array and loop through the array to remove-something like this

myarray =[]
function remove(){
	for(var obj in myarray){
		myarray[obj].removeMovieClip()
	}
}
function test(boxes){
	remove()
	myarray=[]
if (curBox < boxes) {
var mythumb = container.attachMovie("box", "box" + curBox, curBox);
mythumb._x = (curBox % col) * (mythumb._width + spacing);
mythumb._y = Math.floor(curBox / col) * (mythumb._height + spacing);
myarray.push(mythumb)
mythumb._xscale = 0;
mythumb._yscale = 0;
mythumb.bounceMe();
curBox++;
} else {
clearInterval(id);
}

}

Hi Stringy…

thnaks for ur reply…okay I just alter my code then done as ur per suggest but it seem’s it will remove the thumbs as soon as the thumb was attach…meaning that the result will be nothing was display…???..okay for the big picture herein I paste my full code…


     [FONT=Courier New][LEFT][COLOR=#808080]*#include "lmc_tween.as"*[/COLOR]

[COLOR=#000000]**var**[/COLOR] categoryArr:[COLOR=#0000ff]Array[/COLOR] = [COLOR=#000000][[/COLOR][COLOR=#ff0000]"shape"[/COLOR],[COLOR=#ff0000]"animals"[/COLOR],[COLOR=#ff0000]"object"[/COLOR][COLOR=#000000]][/COLOR];

[COLOR=#0000ff]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]**var**[/COLOR] j=[COLOR=#000080]0[/COLOR];j<[COLOR=#000080]3[/COLOR];j++[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
    [COLOR=#0000ff]this[/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]"btn"[/COLOR]+j[COLOR=#000000]][/COLOR].[COLOR=#000080]jvar[/COLOR] = j;
    [COLOR=#0000ff]this[/COLOR][COLOR=#000000][[/COLOR][COLOR=#ff0000]"btn"[/COLOR]+j[COLOR=#000000]][/COLOR].[COLOR=#0000ff]onPress[/COLOR] = [COLOR=#000000]**function**[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
        searchdt[COLOR=#000000]([/COLOR]categoryArr[COLOR=#000000][[/COLOR][COLOR=#0000ff]this[/COLOR].[COLOR=#000080]jvar[/COLOR][COLOR=#000000]][/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]


[COLOR=#000000]**var**[/COLOR] cat:[COLOR=#0000ff]LoadVars[/COLOR] = [COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]LoadVars[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]**var**[/COLOR] getdt:[COLOR=#0000ff]LoadVars[/COLOR] = [COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]LoadVars[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
getdt.[COLOR=#0000ff]onLoad[/COLOR] = loadthumb;
    
[COLOR=#000000]**function**[/COLOR] searchdt[COLOR=#000000]([/COLOR]category[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
    cat.[COLOR=#000080]dataType[/COLOR] = category;
    cat.[COLOR=#0000ff]sendAndLoad[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"http://localhost/multiupload/getimage.php?ck="[/COLOR]+[COLOR=#000000]**new**[/COLOR] [COLOR=#0000ff]Date[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR].[COLOR=#0000ff]getTime[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR],getdt,[COLOR=#ff0000]"POST"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]

[COLOR=#808080]*//var i:Number = 0;*[/COLOR]
[COLOR=#000000]**var**[/COLOR] col:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]4[/COLOR];
[COLOR=#000000]**var**[/COLOR] curBox:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]0[/COLOR];
[COLOR=#000000]**var**[/COLOR] spacing:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]10[/COLOR];
[COLOR=#000000]**var**[/COLOR] makeBoxesSpeed:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#000080]100[/COLOR];
[COLOR=#000000]**var**[/COLOR] elasticSpeed:[COLOR=#0000ff]Number[/COLOR] = .[COLOR=#000080]7[/COLOR];
[COLOR=#000000]**var**[/COLOR] container:[COLOR=#0000ff]MovieClip[/COLOR];
container = [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"container"[/COLOR], [COLOR=#000080]99[/COLOR][COLOR=#000000])[/COLOR];
container.[COLOR=#0000ff]_x[/COLOR] = [COLOR=#000080]30[/COLOR];
container.[COLOR=#0000ff]_y[/COLOR] = [COLOR=#000080]30[/COLOR];

[COLOR=#000000]**function**[/COLOR] loadthumb[COLOR=#000000]([/COLOR]success:[COLOR=#0000ff]Boolean[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
    [COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]success[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
      curBox = [COLOR=#000080]0[/COLOR];
     **okay [COLOR=#0000ff]this[/COLOR] portion I pass the total record value [COLOR=#0000ff]get[/COLOR] from dtbase to [COLOR=#000000]**function**[/COLOR] test..[COLOR=#000080]which[/COLOR] mean [COLOR=#ff0000]"this.items"[/COLOR] will hold different value..[COLOR=#000080]sometimes[/COLOR] it can be [COLOR=#000080]2[/COLOR],[COLOR=#000080]3[/COLOR],[COLOR=#000080]5[/COLOR] [COLOR=#0000ff]and[/COLOR] so [COLOR=#0000ff]on[/COLOR].. **
      id = [COLOR=#0000ff]setInterval[/COLOR][COLOR=#000000]([/COLOR] test, makeBoxesSpeed,[COLOR=#0000ff]this[/COLOR].[COLOR=#000080]items[/COLOR][COLOR=#000000])[/COLOR];
      [COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]message[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR][COLOR=#0000ff]else[/COLOR][COLOR=#000000]{[/COLOR]
      [COLOR=#0000ff]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]message[/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

myarray = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];

[COLOR=#000000]**function**[/COLOR] remove[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
    [COLOR=#0000ff]for[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000]**var**[/COLOR] obj [COLOR=#0000ff]in[/COLOR] myarray[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
        myarray[COLOR=#000000][[/COLOR]obj[COLOR=#000000]][/COLOR].[COLOR=#0000ff]removeMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
       
[COLOR=#000000]**function**[/COLOR] test[COLOR=#000000]([/COLOR]boxes[COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
**if I comment [COLOR=#0000ff]this[/COLOR] it will run as usual but still [COLOR=#0000ff]not[/COLOR] [COLOR=#0000ff]delete[/COLOR] previous attach thumb [COLOR=#0000ff]and[/COLOR] [COLOR=#0000ff]if[/COLOR] I put [COLOR=#0000ff]this[/COLOR] remove [COLOR=#000000]**function**[/COLOR] zero thumb will be display**
    remove[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    myarray = [COLOR=#000000][[/COLOR][COLOR=#000000]][/COLOR];
    [COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR]curBox < boxes[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
        [COLOR=#000000]**var**[/COLOR] mythumb = container.[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"box"[/COLOR], [COLOR=#ff0000]"box"[/COLOR] + curBox,curBox[COLOR=#000000])[/COLOR];
          mythumb.[COLOR=#0000ff]_x[/COLOR] = [COLOR=#000000]([/COLOR]curBox % col[COLOR=#000000])[/COLOR] * [COLOR=#000000]([/COLOR]mythumb.[COLOR=#0000ff]_width[/COLOR] + spacing[COLOR=#000000])[/COLOR];
         mythumb.[COLOR=#0000ff]_y[/COLOR] = [COLOR=#0000ff]Math[/COLOR].[COLOR=#0000ff]floor[/COLOR][COLOR=#000000]([/COLOR]curBox / col[COLOR=#000000])[/COLOR] * [COLOR=#000000]([/COLOR]mythumb.[COLOR=#0000ff]_height[/COLOR] + spacing[COLOR=#000000])[/COLOR];
        myarray.[COLOR=#0000ff]push[/COLOR][COLOR=#000000]([/COLOR]mythumb[COLOR=#000000])[/COLOR];
         mythumb.[COLOR=#0000ff]_xscale[/COLOR] = [COLOR=#000080]0[/COLOR];
         mythumb.[COLOR=#0000ff]_yscale[/COLOR] = [COLOR=#000080]0[/COLOR];
          mythumb.[COLOR=#000080]bounceMe[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
          curBox++;
    [COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#000000]{[/COLOR]
        [COLOR=#0000ff]clearInterval[/COLOR][COLOR=#000000]([/COLOR]id[COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]

[COLOR=#000000]}[/COLOR]

[COLOR=#0000ff]MovieClip[/COLOR].[COLOR=#0000ff]prototype[/COLOR].[COLOR=#000080]bounceMe[/COLOR] = [COLOR=#000000]**function**[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    [COLOR=#0000ff]this[/COLOR].[COLOR=#000080]scaleTo[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000080]100[/COLOR], elasticSpeed, [COLOR=#ff0000]"easeOutElastic"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR];
[/LEFT]
  [/FONT]
 

and here are my getimage.php code



<?
  $dbhost = "localhost";
  $dbusername = "root";
  $dbpassword = "";
  $dbname = "ecard";
  
  $db = mysql_connect($dbhost, $dbusername, $dbpassword);
  mysql_select_db($dbname, $db) or die("ERROR: Cannot connect to the database");
  
 $typedt = $_POST['dataType'];
 
// escape quotes and apostrophes if magic_quotes_gpc off 
 if (!get_magic_quotes_gpc()) {
    foreach($_POST as $key=>$value) {
           $temp = addslashes($value);
           $_POST[$key] = $temp;
    }
 }
  
  $query = "SELECT filename,type FROM upimgtest WHERE type = '$typedt'";
  $result = mysql_query($query);
  $row = mysql_num_rows($result);

if (!$row == 0){
    echo "&items=$row";   
    for ($i=0; $i < $row; $i++) {
            $dt = mysql_fetch_array($result );
            echo "&type$i=". $dt['type']."";
            echo "&filename$i=". $dt['filename']."";
    }
    echo "&end";
    echo ("&message=yes you got it");
}else{
   echo ("&message=No elements has found");
} 

?>

Hope I’m not in the wrong thread since my php code are not having any problems only my AS part…so really need help with it…

tq in advanced