ActionScript 2.0 :: Surely RemoveMovieClip Also Removes Duplicates Of That MovieClip?
May 8, 2007
I'm getting rather disgruntled with Flash's contradictory statements. I just need someone to clarify one thing for me; is it true that if you apply removeMovieClip to a movieClip instance, it also removes all of its duplicate instances? When I try to apply this principle, for some bizarre reason, it only just deletes the original instance and NOT any of its duplicates:
I am making a drag and drop game using AS2 in Flash CS5 where mc items are duplicated and enlarged from a menu and can be placed anywhere on the stage to create a custom robot. Each part (arms, head, feet, etc.) is it's own mc with unique instance names. I have the drag and drop part all figured out, and I even have the duplicateMovieClip part working...
HOWEVER... Whenever I move from the current frame that an object was duplicated in, to another frame and then back, the clips dissapear one by one if you try to create a new one. Each list of menu items are in their own frames (heads, torsos, arms, etc.). As the duplicates are made, they remain on stage no matter what frame you go to and can still be dagged around, which is good, but as I said previously, they dissappear when you create a new duplicate. Not all disappear at once, only older created duplicates disappear as you bring in new duplicates.
My problem is as follows, I can create as many movie clips from on function as I wish, but as soon as I try and do two different functions - it messes up for some reason :S
Basically with my game, it is required for me to create these movieclips every so often. Because of this I created a re-usable function to do the creating:
ActionScript Code: function create_note1() { note1num++;
[Code].....
As you can see there are four different functions, and there are only 4 different movieclips that are added to the stage.
My problem is like this: I can call a single note (like create_note1();) as many times as I want without any problems, but If I try create_note1(); and create_note2(); It will remove note 1 and keep only note 2 on the screen. The problem really stumps me though, because if I called something like this: create_note1();, create_note2();, create_note4(); I may have notes 1 & 4 going down the screen and note 2 will have disappeared.
I am new to AS3 and only recently have been able to understand the display list.I am trying to run this code in my file.I made two movie clips in my library. Gave them class name as "One" and "Two"Now, this is the code that I run:
Code: var one:One = new One(); var two:Two = new Two();
I have used one of the tutorials that is available here found at [URL] because I really loved the effect. I have implemented this tutorial in my presentation and my problem right now is removing the movie clip because when I advance to my next scene in my presentation this movie clip displays.
So I duplicate a MovieClip that is on the Stage and created through the IDE like so: duplicateMovieClip(timeData, "nextTimeData", timeData._parent.getNextHighestDepth()); This works great, but when I go to delete the MovieClip like so:
[Code]...
It refuses to be deleted and trace(timeData) outputs _level0.timeData before and after removeMovieClip(timeData) Why would this be happening? EDIT: According to the answers and the flash documentation MovieClips created in the IDE have a negative depth and removeMovieClip() silently fails in removing MovieClips with a negative depth. So I am now attaching timeData from the library like so:
I have a movie clip which simply a logo. When user chooses an option, it should be gone. But it is still on the stage. The only way to make it disappear is turning _visible = false. But I want it free from the memory.
I want it to remove everyone that it hits, but it only removes the first one that hits. I am sure the answer is simple, but i am slow. Here is the code:
ActionScript Code: function removeSpawn(){ for(j=0;j<lvl1A;j++){
<local data member>.removeMovieClip(); trace(<local data member>);<----*** <local data member> = attachmovie
in the second iteration of this code after the <local data member> has been initialized to a movieclip, the trace prints out the value instead of saying undefined. Why is this happening?
I seem to be having a problem with removeMovieClip.In my little ol' game I've been working on, I have a big problem. The removeMovieClip command only works half of the time. When using the Desert Eagle, a slow-firing weapon, both bullet shells and bullets are duplicated and used properly, and remove themselves when their time has come as programmed. But when using an automatic weapon... it seems to be duplicated shells and bullets so fast that they don't remove themselves properly!
How it works: Let's take the bullet shells, for example. The bullet shells are created and run a bunch of scripts to fall realistically. Once they hit the ground they run an animation which makes a little sound, makes 'em bounce off the floor a bit then stay still for 5 seconds. After those 5 seconds, they're removed. It's that simple, yet it doesn't work.
I hate having to show everybody my stuff every time there's a bug but I trust you guys with my problems (this project is mostly for experience anyways). Try using the Pistol (1) and you'll see it working fine. Then try using the M4A1 (2) or the Steyr AUG (3) and press down on the mouse button for automatic mode. Those bullet shells won't dissapear. Warning: DO NOT aim at the box. I'm also having a problem removing those bullets, so it bugs when you aim at the box.
I have absolutely no idea why the following code isn't working. I've checked the documentation for removeMovieClip at least a dozen times. The only thing I've noticed is the following:Method; removes a movie clip instance created with duplicateMovieClip(), MovieClip.duplicateMovieClip(), or MovieClip.attachMovie().As you will notice, I'm using createEmptyMovieClip() - not one of the methods mentioned - but I swear I've used removeMovieClip to delete movieclips created this way before and it's worked fine. I can't find an alternative command, either.When I trace white in the onRollOut function, it returns the correct path, so it's not a targetting issue. I've also tried adjusting one of the movieclip white's properties (alpha) and it's worked fine.[code]
I'm new here, so let's introduce myself at first: My name is Bram, I live in Holland. I am 16 years old and currently working on a little project for school. In the project you can click on stuff, and that loads an external SWF. Here is how I did that:
[Code]...
Okay. That all works, but now I want to make a button that removes the external SWF (and brings you back to the original SWF). how to do that? If you need my FLA, tell me; i'll upload it. PS: I did use search, but couldn't find anything.
I'm working on a simple Flash game for school. In one level, multiple enemies spawn and the player is supposed to shoot them. I used removeChild() to get rid of the enemy that got shot, but when I click (hit) an enemy, everything on my stage gets removed; it goes completely blank.The function to populate my stage with enemies is the following:
private function Game2():void{ for (var i:uint=0; i<50; i++) { var man:MovieClip = new man_mc();
im using flash text engine to display text and i noticed it removes all whitespces at the end of a string.
e.g if i set a textblock text "a random line ", it is displayed as "a random line" but if i add a . at the end of the spaces it is displayed correctly "a random line ."
whats causing it...and how to display them correctly escape() and unescape wont change anything
I am working with components for the first time.... Now, currently, i am creating components with the attachMovie(), it works, but is it the right way to do it? The reason i ask is because i cant remove the components with removeMovieClip(), how do you remove them?
I'm doing a game (supposed to be done tomorrow).In this game I've got a hero who throws books at the enemies. When the book hits the enemy, I want the book to dissapear, but the thing is that it contiues to fly straight ahead and kill all the other enemies too. I've got a really huge source code for the game, but this part wouldn't be too hard to do, would it? So I've put this piece of code inside the book's movieclip.
PHP Code:
onClipEvent (enterFrame) { this._x += bokSpeed; for (i = 0; i < 3; i++) {
I have already foud out where I want to place my sprites in my game, and I don't want to have to go through th elengthy "duplicateMoveClip" procdure (or it seems to be lengthy to me anyways, it's probably like 2 lines of code, but still, I WANNA DO IT MY WAY!) ok, anyways, does delete only work on variables and not movie clips?here's what I have so farthis is in the bullet movie clip:
Code: onClipEvent ( enterFrame){ if (Key.isDown (Key.SPACE)){
I need to create a list of items align on vertical and the items need to have a expand animation and in the same time when the expand happens, i move the rest of the mcs up (or down).For exemple we have 5 mcs, _mc1, _mc2, _mc3, _mc4, _mc5, and we rollover _mc3, _mc1 & _mc2 move up (tween motion) with 20px; _mc3 expands with 10px up and 10px down; and _mc4,_mc5 moves down with 20 px to! This i already did (and it works perfect) but my problem appears if i add more then 11 mcs (on my computer) the flash start's to eat more CPU and the animation become slower and slower!So i thought to add only 3 mc down (so let we say that we see 3 mcs on stage i want to add more 3 out of stage down)...when you scroll down one mc goes up and will be removed and one will be added down, then when you scroll up, the last one will be removed and the first one will be add it again.
Exemple:We have 1,2,3,4,5, we scroll down, 1 goes up (and will be removed) and 6 will apear, we scroll more down, 2 will be removed and 7 will be added! We scroll up 7 will be removed and 2 will be add it! !!!!I need to remove a movieclip (in my exemple 1,2) only if they are out of stage(they are not visible anymore)
I'm fairly new to the use of loadMovie, unloadMovie, and removeMovieClip for external swfs, but anyways, let me summarize the problem as simply as I can. I have a shell.fla file that is currently loading in external swfs, one at a time, for a game. Here is an outline of how my shell works:
1. first part of game gets loaded in an empty movieclip (container_mc) 2. a listener is created that will listen to an event broadcaster that exists within the external swf. 3. when the listener receives the "done" message, I run container_mc.removeMovieClip() and then load part 2 of the game in a new empty clip called container2_mc.
At this point, I get really severe slowdown for some reason, and I don't know why!! Part 2 of the game is a tile based maze game which is not optimized 100%, but when I run that swf on its own (i.e. not inside the shell) it runs perfectly smooth. But when it is loaded after part 1, it goes really slow.
I'm just wondering it is that that .removeMovieClip() isn't working for me. I'm using the correct path to the object, and I've used this function many many times before. But it's not removing it now this time. I heard that there was some sort of bug in flash that you had to swap depths or something? Flash CS3
I was wondering if you remove a child with "removeChild" if it removes everything what was in the movieClip.I doesn't remove listeners automatically (right?). But does it remove bitmapData (from the memory) for example? Because I don't want to remove all bitmaps with the Dispose.Does it help if I initialize the garbage collector: "System.gc();".It does help with removing listeners automatically, but what about other things?On the adobe website about the GC.But it says:For the Flash Player debugger version and AIR applications only.But does this mean that if I play the SWF outside of Flash this GC doesn't do anything?
I've been working a flash drawing application with an undo button function so you can delete the last line you drew. Everything is working ok except when I use the clear_btn removeMovieClip(shapes[sc]); deletes all the lines so far but afterwards you are unable to draw again[code]....