Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Help Removing A Movie Clip Instance Using RemoveMovieClip() Please:)



hey please help someone. In a website i am trying to attach a movie clip to the stage to present some information. I use this code from a tutorial to do that.
code:
on (press) {
this.attachMovie("mypopmc", "window", 1);
window._x = 500;
window._y = 380;
}

this works fine and the MC comes up onto the stage. Then to remove the clip i use this code placed in a button inside the attached movie clip also from the tutorial.
code:
on (release) {
this.removeMovieclip("window");
}

This does not remove the movie clip from the screen. I have tried putting it outside the movie clip and on the stage but that doesnt work either.I am not using any components on my stage and the depth of my MC is 1. If anyone knows anyway in which this could work i would be really grateful. Thanks

Pete



FlashKit > Flash Help > Flash ActionScript
Posted on: 01-22-2006, 08:01 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

[FMX] RemoveMovieClip Not Removing Instance Mc
I am pretty new to AS2, but I am trying to make a shooting game. The player mc has all the scripting for movement and bullet firing. I've got the bullets detecting the enemies, but they won't call the removeMovieClip when the detection occurs. They will only play the enemy mc animation.

onClipEvent (enterFrame)
{
function fireBulletsNormal() // NORMAL SHOT
{
i++;
var newname = "star" + i;
_root.attachMovie("star", newname, i*100);
_root[newname]._y = _root.hero._y + 10;
_root[newname]._x = _root.hero._x + 10;
_root[newname].onEnterFrame = function()
{
var bullet_speed = 25;
this._x += bullet_speed;

if (this._x > 525)
{
this.removeMovieClip ();
}
var numEnemy = 6;
for (var h = 1; h <= numEnemy; h++)

if (this.hitTest(_root["enemy"+h]))
{
this.removeMovieClip();
_root["enemy"+h].play();
}
}
}

The final play() command should call a script embedded in the mc's last frame:

this.reset();
gotoAndStop(1);

I thought the reset command would remove the clip, but it doesn't seem to. I keep thinking this has to do with the fact that my enemies are instances.

Any help would be appreciated.

Help Removing MovieClip Instance With RemoveMovieClip() Please
hey please help someone. In a website i am trying to attach a movie clip to the stage to present some information. I use this code from a tutorial to do that.

on (press) {
this.attachMovie("mypopmc", "window", 1);
window._x = 500;
window._y = 380;
}

this works fine and the MC comes up onto the stage. Then to remove the clip i use this code placed in a button inside the attached movie clip also from the tutorial.

on (release) {
this.removeMovieclip("window");
}

This does not remove the movie clip from the screen. I have tried putting it outside the movie clip and on the stage but that doesnt work either.I am not using any components on my stage and the depth of my MC is 1. If anyone knows anyway in which this could work i would be really grateful. Thanks

Pete

RemoveMovieClip Removing The Wrong Movie?
Hi,

I was writing a small platform game when I stumbled into a problem, at a certain point the entire background would dissappear, and after a couple of hours of debugging found that was my removetiles function which was the cause.

removeTile = function(whichTile){
var tiletype = tilegrid[whichTile]
if(tiletype != undefined){
if(tiletype<foreground_tiles_start_at){
background["Tile"+whichTile].removeMovieClip();
}else{
foreground["Tile"+whichTile].removeMovieClip();
}
}
}

this function works perfectly, except when it called removeTile(726)

when that was called tiletype == 5, so it should have gone on to delete background.tile726 but instead it deleted background.

i place a small loop before background ["Tile"+whichTile].removeMovieClip() that output the name of all the clips in background and tile726 was in that.
i also placed a trace(background._target) before and after that line and which confirm that it was that line that is the problem, background._target was undefined after the removeMovieClip was called.

Is this a bug or have i just done something wrong?

RemoveMovieClip Not Removing Attached Movie
guys,

i am attaching a movieclip from the library to a movieClip specified in a variable. this all works fine using the following code.


Code:
eval(this.navHolder).attachMovie("emptyThread", "thread" + this.threads.length, this.depthCount, this.tempInitObj);
when it comes to the time i want to remove it again none of the following code combinations work.


Code:
eval(this.navHolder)["thread" + i].removeMovieClip();
eval(this.navHolder + ".thread" + i).removeMovieClip();
this[this.navHolder + + ".thread" + i].removeMovieClip();
this.navHolder["thread" + i].removeMovieClip();
i know that i am targeting the movieClip correctly, because i can track its _x propertly. it just stubbonly refuses to be removed. I've had a look through some of the other posts about "removeMovieClip" in this forum and have tried the various suggestions posted (such as mc.swapDepth(99999)) before trying to move it. all to no avail.

I;d appreciate any thoughts on what i might be doing wrong.

Many thanks!

T

Want Opening Movie Clip Instance To Close Underlying Movie Clip Instance
Just so you all know, I'm one of three people in our company that uses Flash and I'm considered "the expert". However, we don't do more than a few Flash projects a year, so my scripting knowledge is very, very green. Thanks in advance for your patience.

I have 22 buttons that play an assigned movie clip from the library. I suspect I'm building these things the wrong way (probably true), but here is how each button is constructed....

Each instance that I'm calling a button is actually identified as a movie clip intance with a button in it. It sits on its own layer. When I double-click an instance, several layers are displayed, the majority of which belong to the presentation of the movie clip. The clip lasts five frames.

The first frame consists of blank keyframes for each layer except for one layer that has stop() assigned to the frame and another layer with the actual button. The layer with stop() at frame 1 is then blank for the next three frames, and then another stop() on frame 5 (the last frame).

The button layer lasts all five frames. Here's the script for "display1980":

on (rollOver) {
_root.display1981.gotoandstop(1);
_root.display1982.gotoandstop(1);
_root.display1983.gotoandstop(1);
.
.
.
_root.display2003.gotoandstop(1);
_root.display2004.gotoandstop(1);
_root.display2005.gotoandstop(1);}

on (release) {
_root.Play();
play();
}

For each instance, there is no line of script that refers to itself. In this example for display1980, "_root.display1980.gotoandstop(1);" is not used.

As I mentioned earlier, each instance is on the main stage on its own layer. I've done this with only eight of my instances, so there are now eight layers. (There are--in fact--more than eight layers, but those are not part of this issue.)

The script I created does the job of getting rid of any previously displayed movie clip, but I created a new conumdrum: If I rollover any other button, the currently displayed clip closes. I've tried replacing "on (rollOver)" with "on (press)" but that doesn't work.

Like I said, I suspect I'm buildng this wrong. Is what I built a waste of time, or can it be salvaged? Or, is there a much better and efficient way (and I suppose there is) that can be described so that my green experience can absorb to good effect?

RemoveMovieClip Only Removing Some Of The Clips
hey, im having a little problem in my game on the first frame of the game i have this code

code:
for (i=2; i<=numEnemy; i++){
enemy1.duplicateMovieClip( "enemy"+i, i+100 );

}
for (a=1; a<=numEnemy1; a++){
enemy2.duplicateMovieClip( "enemy1"+a, a+100 );

}
for (b=2; b<=numEnemy; b++){
enemy3.duplicateMovieClip( "enemy3"+b, b+100 );

}
for (j=2; j<=numRock; j++){
rock1.duplicateMovieClip( "rock"+j, j+100 );
}


and using this code i get the following instance names on objects

enemy0
enemy1
enemy2
enemy10
enemy11
enemy12
enemy30
enemy31
enemy32
rock0
rock1
rock2

(dont ask me why theres no enemy2... cause im not sure)

now when i use that code i then want to remove all these MC's on frame 3 of my game (game over screen)

so i have this code

code:
removeMovieClip("enemy0");
removeMovieClip("enemy1");
removeMovieClip("enemy2");
removeMovieClip("enemy10");
removeMovieClip("enemy11");
removeMovieClip("enemy12");
removeMovieClip("enemy30");
removeMovieClip("enemy31");
removeMovieClip("enemy32");
removeMovieClip("rock0");
removeMovieClip("rock1");
removeMovieClip("rock2");


so i thought this would all work but then when it gets to frame 3 only
enemy0
enemy1
enemy2
enemy10
enemy11
enemy12

are removed and
enemy30
enemy31
enemy32
rock0
rock1
rock2

are still there, any ideas on how to fix?

Removing Sound With RemoveMovieClip();
I'm probably looking in al the wrong places, but I haven't been able to find documentation on how to *remove* sounds from Flash's cache. I'm doing this because I've got a multitrack player that I want to set up, and Flash only allows 8 tracks to be attached and played at the same time.

My instincts tell me that to remove a sound from memory is to do so by removing the movieclip, and if not, then the object. I've tried both methods, but without very much success. This is my code:

// start

_root.createEmptyMovieClip("clap_mc", 100);
clap = new Sound("clap_mc");
clap.attachSound("clap");
clap.setVolume(70);
clap.start(0, 99);

sq1.onRelease = function() {
trace("Before:");
trace(clap_mc);
trace(clap);

clap_mc.removeMovieClip();
delete clap

trace("After:");
trace(clap_mc);
trace(clap);
}

// end

These are the trace results:
Before:
_level0.clap_mc
[object Object]
After:
undefined
undefined

Even though both the object and the clip are removed upon release, the sound continues to play. The only way to make it stop is to use the .stop() command or stopAllSounds(), which is a useless method when I have to load more than 8 sounds. (8 Sounds being the Flash MX multi track limit)

Anyone else with more clues?

RemoveMovieClip Is Removing All My Attached Movies :-(
function away() {
for (i=0; i<numMenuItems; i++) {
_root["blob"+i].removeMovieClip();
}
}
this.attachMovie(_level0.ButTopic, "HEADSET", "AnimHolder");

Okay I have a movie that loads from the library with the attachMovie cmd. Now I have a number duplicated MCs on this page as well that are made to dissapear with the "away" function.

However for some reason

Code:

AEG.onRollOver = function() {
_root.away();
};



Makes the HEADSET (or Anim Holder) dissapear as well

What is going on? My remove Movieclip is targeting mcs with the suffix of "blob" so why is it affecting my attached HEADSET movie :-(

Any help would be much appreciated

RemoveMovieClip Is Removing All My Attached Movies :-(
Code:
function away() {
for (i=0; i<numMenuItems; i++) {
_root["blob"+i].removeMovieClip();
}
}
this.attachMovie(_level0.ButTopic, "HEADSET", "AnimHolder");
Okay I have a movie that loads from the library with the attachMovie cmd. Now I have a number duplicated MCs on this page that are made to dissapear with the "away" function.

However for some reason

Code:
AEG.onRollOver = function() {
_root.away();
};
Makes the HEADSET (or Anim Holder) dissapear as well

What is going on? My remove Movieclip is targeting mcs with the suffix of "blob" so why is it affecting my attached HEADSET movie :-(

It's late and I want to go home, not hating flash. Thanks in advance for any advice.

Removing A Movie Clip
Ok, I made one of those simple action scripting text effects, where each letter comes in one by one, very common, here's an example if you don't know what I'm talking about: http://www.flashkit.com/movies/Effec...43/index.shtml

So, I put this effect into a movie clip, and assigned an action to a button that tells the movie to play using tell targets. Now here's the problem: The text stays on the screen! I've tried using RemoveMovieClip, Set Property:Visibility=0, blank keyframes, but nothing works! The text just sits there. Any ideas on how to remove it??
Thanks for any help

Removing Movie Clip
Hi,

- Got totally no experience in actionscripting so could someone help me out with this(i suppose) simple qestion.

Got my first scene with several movieclips.
One of them exists into several other movieclips.
What i'm trying to do is stopping a movieclip from my mainscene from a movieclip in the movieclip.

scene (with movieclips)
........O
........O
........O----->O-
........O........|
..................|-O
........^........|-O
........|.........|-O-(use this movieclip to stop...)
........|.................|
.........<-----------|
............that movieclip

It aint working wth remove.clip neither with the unloadmovie.
Can anyone help me out ,thanks.

Namek

Removing A Movie Clip
Is it possible to remove a movie clip from the main timeline at a set point? Although the clip is present until frame 80 out of 125 it constantly plays when published and a new clip from frame 81 to 125 never appears. As a beginner I've spent a day trying to sort this but have all but given up.

Thanks
Mark

Removing A Movie Clip
one quick question. How would i go about writing code to remove a movieclip from the stage from the timeline of the movieclip itself? in other words, if i want every instance of a movie clip on the stage to remain on the stage for only 12 frames, i'd write an onEnterFrame function in the MC to decrement a counter that starts at 12, then check if the counter is 0. if it is, then what? Oh, and i doubt it matters, but i am using flash 8.

Removing A Movie Clip -
Code:
I have the following code:
for (var i = 0; i<amount; i++) {
thisFlake = this.attachMovie("snowflake1", "snowflake1"+i, i);
It places the movie snowflake1 on the stage in my Pre-Load Scene.

Then when I play the movie the snoflakes work right, but when the pre-loading is done there are falling snowflakes on my next scene, even though there is no code for the snowflakes in that scene.

I have tried numerous ways to remove the clip:
this.removeMovieclip("snowflake1")
delete "snowflake1"
this.removeAll

Please help as I am getting tired of flakes where they don't belong. Thanks.

Sincerely,
Greg

Removing A Movie Clip
When a movie clip reaches its end frame, how do I make it so that it is removed from the scene and thus actionscript that normally would affect it does not anymore. Like using a "remove movie clip" function. I know it does exist, just don't know how to use it. I would prefer the code to be placed in the movie clip's last frame. Thanks.

Removing A Movie Clip
Hi All,

I have a movie clip on stage that I want to remove completely when I press a button. I tried removeChild but it throws an error(im not using addChild). Any thougts? Thanks

Removing A Movie Clip
Hi all , new to flash. I am trying a very simple project of two balls on a screen , both converted to movie clips, one named ball1 the othe ball2. I just want to be able to click on ball1 and remove the movieclip of ball2 , but am having no luck. Any code suggestions please.

Removing A Movie Clip...
I am trying to get rid of movieclip that contains all my form fields when the form is submitted.
I have it set to do the following:

Code:
onClipEvent (data) {
this.removeMovieClip()
}
It seems that the removeMovieClip() command only really works with dynamicially created movie clips. is that correct?
Is there another way to get rid of a movie clip?

Removing A Movie Clip...
So i am by no means a flash guru... or even really proficient lol

What i need is the ability to remove a flash clip after it is done running, so the content that is under the flash video can be interacted with.

I have been doing some serious inter-web browsing and came up with 'MovieClip.removeMovieClip()' but i don't know how this function can be used.... is it actionscript?

further more can this even be done??!?

Removing A Movie Clip...
I am trying to get rid of movieclip that contains all my form fields when the form is submitted.
I have it set to do the following:

Code:
onClipEvent (data) {
this.removeMovieClip()
}
It seems that the removeMovieClip() command only really works with dynamicially created movie clips. is that correct?
Is there another way to get rid of a movie clip?

Removing A Movie Clip
Hey guys..

I have a Menu that you can't notice very well when u first come to the site so I have a movie clip that is a arrow flashing towards it..

When you first click on the menu I want to just delete and remove that arrow flasing movie clip for ever..

How is this done with AS because I looked up "removeMovieClip()" and it says it is only for movie clips created with "duplicateMovieClip()"

Thanks,

I was thinking like


ActionScript Code:
on (press) {
 
this.removeMovieClip(arrow_mc);
 
}

Removing Instance X Inside Instance X
In Flash CS3 in library I have a MovieClip symbol Help (exported for AS).
The function below opens an instance of the symbol when the button is clicked.


ActionScript Code:
function showHelp(e:MouseEvent):void {
    var helpwindow:Help = new Help();
    helpwindow.x = 50;
    helpwindow.y = 50;
    addChild(helpwindow);
}
This works and instance "helpwindow" shows on the screen.
Now inside the symbol Help i have another button which will run a function that would close that instance. How do I get rid of that instance? I was trying with removeChild but errors occurr.


ActionScript Code:
function removeHelp(e:MouseEvent):void {
    removeChild(MovieClip(parent).helpwindow);
}

Quote:




TypeError: Error #2007: Parameter child must be non-null.

Removing Duplicated Movie Clip
I have a code which duplicates a movie clip and positions it at random, then deletes the previous clip (taken from http://www.soundofdesign.com "worm" opensource)
It worked fine until I added a movie clip inside the duplicated clip (to randomly position a mask).
Now I cannot remove the first clip.
The code below is in one frame, the next frame loops back to it.

Code:

if (F<1) {
setProperty ("i0", _x, 130);
setProperty ("i0", _y, 130);
setProperty ("i0.pic", _x, -130);
setProperty ("i0.pic", _y, -130);
V = 0;
H = 0;
F = 1;
}
DIRECTION = random(4)+1;
if (DIRECTION == 1) {
if (H<1) {
duplicateMovieClip ("i0", "i"+F, F);
H++;
setProperty ("i"+F, _x, getProperty("i"+(F-1), _x)+130);
setProperty ("i"+F, _y, getProperty("i"+(F-1), _y));
setProperty ("i"+F+".pic", _x, getProperty("i"+(F-1)+".pic", _x)-130);
setProperty ("i"+F+".pic", _y, getProperty("i"+(F-1)+".pic", _y));
F++;
}
}
--[etc. for direction 2-4]--

removeMovieClip ("intruder"+(F-2));

>Thanks

[HELP]removing Duplicated Movie Clip
Basically, a random amount of movieclips have been attached to the stage using attachMovieClip().

how do i remove one of these movieclips from the stage?

I tried this["rock"+b].removeMovieClip()
but that didn't work

PLEASE HELP!

-Matt

Here's the Code (assume there are five movie clips in the library:rockone, rocktwo, rockthree, rockfour, rockfive):

Code:
gridheight = 15;
gridwidth = 15;
gridx=0;
gridy=30;
gridsize = 30;
b = 0;
for (a = 0; a != (gridheight*gridwidth); a++) {
randomnum = random(10);
if (randomnum == 1){
attachMovie("rockone", "rock"+b, b+100);
} else if (randomnum == 2){
attachMovie("rocktwo", "rock"+b, b+100);
} else if (randomnum == 3){
attachMovie("rockthree", "rock"+b, b+100);
} else if (randomnum == 4){
attachMovie("rockfour", "rock"+b, b+100);
} else if (randomnum == 5){
attachMovie("rockfive", "rock"+b, b+100);
}
if (randomnum>0 && randomnum<6){
this["rock"+b]._x = ((a % gridwidth)*gridsize)+gridx;
this["rock"+b]._y = ((Math.floor(a/gridwidth))*gridsize)+gridy;
b=b+1;
this["rock"+b].removeMovieClip();
}
}

Removing A Movie Clip From The Stage.
Now this sounds simple, and Im sure is simple, but i have the following problem:

On scene 1 i have a button that loads a movie clip, called movie1

On scene 1 I have a link that goes to anohter scene (scene2)

If I goto scene 2 when the movie clip is loaded onto the stage in scene1 it is still visible after i click to go to scene2

I have tried allsorts to try and remedy this but I have been unable to achieve this.

Can anyone help a frustrated noob???

thanks in advance
D

Removing Movie Clip Symbol
On frame one I have the main page with navigation.

frame two I have a symbol movie clip from the library loading

I placed a button on this movie clip to close it and go back to
frame one. It doesn't want to do this... the code I put in was

on release
goto scene 1 frame 1

But it doesnt do this.. what is the code?

Removing Contents Of A Movie Clip?
What code is used to remove all contents of a movie clip without deleting the movie clip from the stage?

the clip is created using createEmptyMovieClip.

thanks

Removing A Duplicated Movie Clip
Hi

im having trouble removing duplicated movie clips

Im using this code shot.duplicateMovieClip("shot"+fired, 1);

thiss makes a fired shot mark appear on the screen - now at the end of the animation in the MC I want it to remove itself but cant seem to do it

Ive tried from within the clip the following iterations

removeMovieClip("");
removeMovieClip(_this);
removeMovieClip(_root.shot);

but none seem to work - I guess its something to do with the fact that each puplicate gets a different name - but cant figure out how to call the name

thanks for your help as ever

Removing Movie Clip Prob
Hey guys, I just have a quick question. Why cant I remove a movieclip that is on the stage with the removeMovieClip function? Does it have to be imported from the library or something to be able to be taken out of the stage? If so can you please tell me how to do that.

Thanks!

Removing Pieces Of A Movie Clip
i want to be able to remove just a small piece of a movie clip, say a circle, by shooting at it, like in this game: http://www.newgrounds.com/portal/view/397568
i cant figure out the shooting, and i know how to remove a whole movie clip
but i was wondering if anyone knew how to just take a piece out

Help For Removing Movie Clip Dynamically
Hello Everyone,

I please need your help in removing Movie Clips Dynamically with the code, as I am making a simple brick breaker game I figured out the adding of the bricks dynamically but I cant make them to remove when the ball hits the bricks. The following way I have made the bricks


Code:
function makeLvl() {
var arrayLength:Number = lvlArray[currentLvl-1].length;
for (var i:Number = 0; i<arrayLength; i++) {
if (lvlArray[currentLvl-1][i] == 1) {
this.attachMovie("brick", "brick"+i, i, {_x:30+(i-brickRow*6)*80, _y:40+brickRow*20});
for (var c:Number = 1; c<=10; c++) {
if (i == c*6-1) {
brickRow++;
}
}
}
}
This way I am trying to remove it but no luck with it


Code:
if(ball1_mc.hitTest(brick1_mc)){
brick1_mc.removeMovieClip();
ballYSpeed*=-1;
}
Thanks alot for your help sorry if I made any mistakes in posting as I m a newbie to this site and to flash.

Removing Code From A Movie Clip
Is there a way to remove all of the on(rollOver){} on(Press){} ect from movie clips? basically just destroying any action script assoociated with that movie clip. I just want the movie clip to stop moving, and rollover effect etc

Any ideas anyone?

Removing A Movie Clip Via Actionscript
I was wondering if there was a way to remove a movieclip that you placed on the stage from the library using actionscript?

When I search all I get is when you bring them on stage using actionscript. If no one knows I will try to get the person I am helping to do it that way.

Thank you!

CS3 -AS2. Help Preloading Flv & Removing Movie Clip-
Hi everyone,
I'm almost finishing a website, but I have 2 problems,

Structure:
Main movie, loads:
1) biography swf
2) current work swf
3) recent work swf(2 problems)
4) contact swf

recent work loads 4 buttons, each one of them preloads an external swf which loads an external flv

Problem 1: Every time the preloader starts preloading the swf containing the flv, the video starts playing and the preloader is still visible on top of it. Is there a way to remove it? (I'm guessing it has something to do with progressive download, but if I don't use any preloader it's too long before it starts playing)

Problem 2: If you're watching a video (flv) and you click on one of the other buttons that take you either to bio, current or contact, the flv is still playing on the back. Is there a way to stop it?
The thing is I'm using 2 containers, changing their depth, fading in the top container while fading out the bottom container, that's why you can still hear the flv playing on the back, basically I need to remove the bottom container movie clip, but I have no clue where to put that code.

containerAS (thanks to senocular)

[code]
// this is the event handler for each container's
// onPreloaderComplete event - a custom event invoked
// in the preloadContents function
function preloadComplete(){

// swap the depths of the containers putting the
// one who just got new content at the top
container1_mc.swapDepths(container2_mc);

// check the depths of the 2 containers and assign
// bottomcontainer to the new lowest container
if (container1_mc.getDepth() < container2_mc.getDepth()){
bottomcontainer = container1_mc;
}else{
bottomcontainer = container2_mc;
}

// remove the preloader animation
preloader_mc.removeMovieClip();


// set the onEnterFrame event to fade in this container
this.onEnterFrame = fadeIn;
}

// this function fades in a container
// once its content has loaded
// it is to be used with onEnterFrame
function fadeIn(){

// if the alpha is less than 100, fade in
if (this._alpha < 100){

// increase using a rate of 5
this._alpha += 10;


}else{

delete this.onEnterFrame;
}
bottomcontainer.onEnterFrame = fadeOut;

function fadeOut(){

if (this._alpha > 1){

this._alpha -= 10;
}
}
}


// set onPreloaderComplete functions (event handlers)
// for each container to the preloadComplete function
// when a container is completely loaded, preloadContents
// will call onPreloaderComplete for the container which
// will run preloadComplete because of these definitions
container1_mc.onPreloaderComplete = preloadComplete;
container2_mc.onPreloaderComplete = preloadComplete;
[code]

If you want to take a look to the fla files, go to http://theantipode.com/cbfFiles
If you want to check out the problems go to http://theantipode.com/cbf

Thanks for any help you can provide
Caro

Removing A Non-duplicated Movie Clip
I have a game where there are pickUps and enemy's along the platform. I haven't used the duplicateMovieClip in order to place them on the platform I've just dragged the movie clips from the library onto the scene. I've used the hitTest in order to detect whether the player is hitting a pickUp or enemy. After they hit the pickUp/enemy I want to be able to remove the movie clip from the scene. I've tried using removeMovieClip but since I've not used a duplicated movie clip it doesn't work. Is there any other way to remove the movie clip on collision with the player?

thanks in advance,

rushin

Readd Movie Clip After Removing?
I removed a mc for a purpose, and now I want to put it back again on a button press, how do I do this? (loadmovie didnt seem to work)

I used
ActionScript Code:
_root.fish1.unloadMovie();
to remove it.

Help Needed Removing A Movie Clip
Hello

i have been staring at this for too long and need someone to hit me over the head with a fish and say... DUH...

please have a look for your own personal enjoyment

i have snow flakes
falling down all lovely and gently
and when they hit my green box, (or tree branch in final version) the snowflake turns to an icicle
the icicle then fades away
when the icicle has faded completely the movie clip it removed (i think i have this correct)
but
i cannot update my snowflake variable to let a new flake flutter down...
i have attached the flash file to look at because it is easier to see
it needs to stay in AS1 player 6

would appreicate some help
and yes, i know it is something really easy that i just cannot see....

many thanks

Removing Movie Clip Problem
I trying to load a movieclip into scene 1 and then with a close button attached to the loaded movie trying to remove the MC from scene 1. What am i doing wrong? The load works great...the unloading doesn't

attachMovie_btn.onRelease = function(){
this._parent.attachMovie("MCTrio", "trio_mc", 1);
trio_mc._x = 275;
trio_mc._y = 200;
};

and on a close button on the loaded MC i have

on (release) {
_parent.removeMovieClip("MCTrio");
}

Thanks Brian

Removing A Movie Clip And Getting It Back Again. Help Please.
Hi,
I have 2 MCs on the stage. I attach a movie to MC1 and do an _alpha tween on that by AS. After that, I use

ActionScript Code:
MC1.swapDepths(1000); //just to have a valueMC1.removeMovieClip();

After MC1 I do the same thing with MC2. It works removing the MC1.
If I want to do this as a loop, I remove MC2 as for the MC1.
Question: How can I get the MC1 back now?

Thanks,

Attaching And Removing Movie Clip
Advance Thanks for your valuable help

My Concept:

When i click an image i want to attach a animated movie clip with that image, i tried attach movie for that concept and its working fine, but i want to remove that animated movie clip when the same image is clicked again, how to check whether the animated movie clip is attached with the image, Please Help me out

Regards

Removing All Instances Of One Movie Clip Help
Hi all i'm new here and have been using these forums as a personal lifeline, as i have made substantial progresses through my creating of my simple game i have finally hit a snag of which i cannot find the answer for anywhere.

The problem is that I have a timer counting down which is currently set at 2.5 seconds for testing purposes, when the timer finishes out and reaches zero i want the entire stage to be cleared and the playhead to move to frame 5. So far i have this working but my problem is that my remaining children are on the stage and I do not know how to remove all of them since they all of the same name but it is stated that which one i want to remove is not defined. Frame 5 is the lose screen and Frame 4 is the Win screen, I also am having the problem of the timer continuing and creating an error if frame 4 is reached before the timer runs out. Here is my code and thanks in advance it's greatly appreciated and I will return the favor when i have learned more Actionscript


Code:
stop();


//Global Variables
var weap:MovieClip;
var timer:Timer;

init();




// ========================================//









function init()
{
timer = new Timer(20);
timer.addEventListener(TimerEvent.TIMER, runGame);
timer.start();
this.stage.addEventListener(MouseEvent.CLICK, changeColor);

//Creates the targets to be hit by weapon.
makeTargets(Math.round (Math.random() * 10), 1);
makeTargets(Math.round (Math.random() * 10), 2);

//Adds the weapon attached to mouse to the stage.
weap = new Weap();
weap.x = weap.y = 100;
weap.name = "weap";
addChild(weap);
}




function runGame(evt:TimerEvent)
{
//Calling the functions.
followMouse(evt);
rotateWeapon(evt);
checkCollision();
}



function makeTargets(numTargets, frame)
{
for(var i:int = 0; i < numTargets; i++)
{
var target:MovieClip = new Target();
target.x = Math.random() * stage.stageWidth;
target.y = Math.random() * stage.stageHeight;
addChild(target);
target.name = "target";
target.gotoAndStop(frame);
}
}


//This makes the weapon follow the mouse
function followMouse(evt:TimerEvent):void
{
weap.x += velFriction(weap.x, mouseX, 8);
weap.y += velFriction(weap.y, mouseY, 8);
}




function velFriction(orig:Number, dest:Number, coeff:Number):Number
{
return (dest-orig)/coeff;
}




//This rotates the object to point at the mouse.
function rotateWeapon(evt:Event):void
{
weap.rotation = getAngle(mouseX, mouseY, weap.x, weap.y);
}




function getAngle(x1:Number, y1:Number, x2:Number, y2:Number):Number
{
var radians:Number = Math.atan2(y1-y2, x1-x2);
return rad2deg(radians);
}




function rad2deg(rad:Number):Number
{
return rad * (180/Math.PI);
}


//This changes the object when clicking.
function changeColor(evt:MouseEvent):void
{
weap.play();
}




//This checks for collisions between objects
function checkCollision()
{

for(var i:uint = 0; i < this.numChildren; i++)
{
if(this.getChildAt(i).name != weap.name)
{
var targ = this.getChildAt(i);

if(weap.hitTestObject(targ))
{
if (weap.currentFrame == targ.currentFrame)
{
//Removes target when collision is correctly matched.
// trace("same")
removeChild(targ);
trace(numChildren);
if(this.numChildren == 1)
{
trace("gotoAndStop(4)")
removeChild(weap);
timer.removeEventListener(TimerEvent.TIMER, runGame)
this.gotoAndPlay(4);
}
}
else
{
// trace("different")
//Removes target when collision is incorrectly matched.
removeChild(targ);
//Repeat loop to add two of the following each time it is called.
for(var j:uint = 0; j < 2; j++)
{
//Adds new targets if incorrect collision is detected.
var target:MovieClip = new Target();
target.x = Math.random() * 500;
target.y = Math.random() * 300;
addChild(target);
target.name = "target";
target.gotoAndStop(targ.currentFrame);
trace(numChildren);
}
}
}
}
}
}

//timer length in seconds
var timerLength:Number = 5;

//new timer, 1000ms = 1 sec
var t:Timer = new Timer(500, timerLength);
t.addEventListener(TimerEvent.TIMER, checkTime);

//start timer
t.start();

function checkTime (e:TimerEvent):void
{
trace(--timerLength);
if(timerLength == 0)
{
trace("gotoAndStop(5)");
removeChild(weap);
timer.removeEventListener(TimerEvent.TIMER,runGame);
this.gotoAndPlay(5);
}
}

Removing Attached Movie Clip.
Hi,

I'm having a lot of trouble removing an attached movie clip. Basically I have set up a function to attach a movie clip name it 'mainNew'+1 then delete the previous clip i.e. mainNew. I have been stuck on this for hours, the code I have is the below, would really appreciate some help on this:


ActionScript Code:
#include "lmc_tween.as"
 
var lev = 0;
 
function removeCurrentClip()    {
//  trace('slideMain ' + slideMain.currentClip);
    removeMovieClip(slideMain.mainOld);
    removeMovieClip(this.slideMain.mainOld);
    this.slideMain.removeMovieClip(mainOld);
 
    trace('mainOld from remove = ' + slideMain.mainOld);
}
 
function mainClip (newClip) {
    lev++;
    slideMain.mainOld = mainNew;
    slideMain.mainNew = 'mainNew'+lev;
    trace('mainOld = ' + slideMain.mainOld);
    trace('mainNew = ' + slideMain.mainNew);
    slideMain.attachMovie([newClip] ,'mainNew'+lev,lev,{_alpha:0}).alphaTo(100,1.5,'linear',.2, removeCurrentClip);
 
}
 
slide1.onRelease = function()   {
    mainClip('one');   
}
 
slide2.onRelease = function()   {
    mainClip('two');
    trace('slideMain.currentClip = slideMain.newClip ' + slideMain.currentClip);
}
 
mainClip ('one');

Removing A Movie Clip Reference
Last edited by chance : 2003-01-27 at 06:31.
























For some reason, I can't seem to remove the reference to an unloaded movieclip that is contained in a movieclip that is contained in another movieclip that has been loaded using attachMovie(). I know the clip is being removed because listing the objects in the movie just shows the reference to the removed clip, not the objects within the removed
clip.



------------- Code ---------------
item = itemPath.attachMovie(itemClip, "item" + i, i);

var mp3 = item.mediaType_mc.mediaMp3_mc;
trace(mp3); // path to mp3
unloadMovie(mp3);
trace(delete mp3); // false

----------------------------------

I've tried:

mp3.unloadMovie()
unloadMovie(mp3)
mp3.removeMovieClip()
removeMovieClip(mp3)

Is there something I'm missing here? I don't have any code anywhere that references these clips so I can't for the life of me figure out why I can't delete their reference.

Any help is appreciated, or if you know a way in the debugger or somewhere else to show all references to a given object, that may help too. I may have set a variable somewhere that references these clips and forgotten about it.

Thanks.

Mark Chance
mchance@ideo.com
IDEO
http://www.ideo.com

Having Touble Removing Movie Clip
ok this is at the root


Code:

this.createEmptyMovieClip('fade_pan', 1);




this is in an onRelease for a button


Code:

_root.fade_pan.removeMovieClip();



The movie will not go away. What am I doing wrong?

External SWF Control & Removing Movie Clip..
Right...
I got two questions, and I'm wondering whetever some one can help me solve them!
Number 1: My Main SWF is at Level0 obviously, and I have a second SWF inside that running at Level1; is it possible now to create a button in the SWF in Level1 to open a SWF or Movieclip in the original SWF? Is this possible?

Basically I think this is like controlling an External SWF from another SWF.

Number 2: Is it possible to remove a movie clip with an alpha fade just by scripting? Without having to use a motion tween? Also can this be done also by using a button in the SWF in Level1, to remove the clip in the original SWF?

Thanks in advance

Removing Attached (linkage) Movie Clip
hi, need a help
i have attached my work file

actully i am trying to draw continues line one point to another by mouse click , and each points there will be a round shape(using linkage library method) with the mouse click .

the lines all are removed by this (_root.newgrid1.clear()) method.

the problem is that i was only able to remove one round shape from the stage using remove movie clip method,

how can i remove all the attached movie by the reset button from newgrid2?

-----------------------------------------------------------------------


This is the method i used to attach movie from library

var _loc3 = _root.newgrid2.attachMovie(color, "obj" + objCountx, objCountx);
--------------------------------------------------------------------------


################################################## ##
this is the method i used to remove the clip

_root.reset.onRelease = function () {

_root.newgrid1.clear();
_root.newgrid2.clear();

removeMovieClip(newgrid1);
removeMovieClip(newgrid2);

for (n in _root)
{

removeMovieClip (_root[n]);

}

}
################################################

[CS3] Removing Dynamically Loaded Movie Clip
Understanding that I'm about brain-dead at this point, I am trying to remove a movie clip that was created at runtime using 'createEmptyMovieClip'. I have placed a reset button on the stage (at authortime), and want it to remove the newly created clip.

Here's how I create the clip:


Code:
this.createEmptyMovieClip("shirtFrame", this.getNextHighestDepth());
And this is how I'm trying to remove it:


Code:
clearBtn_mc.onRelease = function () {
clearBtn_mc.prevFrame();
trace(shirtFrame);
removeMovieClip (_level0.shirtFrame);
}
Trace returns '_level0.shirtFrame

I'm missing something, but I don't know what.

Removing Attached (linkage) Movie Clip
hi, need a help

i am trying to draw continues line one point to another by mouse click , and each points there will be a round shape(using linkage library method) with the mouse click .

the lines all are removed by this (_root.newgrid1.clear()) method.

the problem is that i was only able to remove one round shape from the stage using remove movie clip method,

how can i remove all the attached movie by the reset button from newgrid2?

-----------------------------------------------------------------------


This is the method i used to attach movie from library

var _loc3 = _root.newgrid2.attachMovie(color, "obj" + objCountx, objCountx);
--------------------------------------------------------------------------


################################################## ##
this is the method i used to remove the clip

_root.reset.onRelease = function () {

_root.newgrid1.clear();
_root.newgrid2.clear();

removeMovieClip(newgrid1);
removeMovieClip(newgrid2);

for (n in _root)
{

removeMovieClip (_root[n]);

}

}
################################################

Copyright © 2005-08 www.BigResource.com, All rights reserved