AS3 :: Flash - RemoveChild() Removes Everything From Stage?
Mar 25, 2011
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();
[code].....
View 2 Replies
Similar Posts:
Aug 26, 2011
I have a removeChild and null question. I know removeChild removes my object from the stage but stays in memory until I call null on it. My question is, if I set the object to null, do I have to removeChild it at all? For example, I have a movieclip where I addChild lots of objects to it. So If I want to completely remove all traces of said movieclip and all its children, can I just set movieClip = null, or do I have to removeChild all its children and the movieclip itself beforehand.
View 6 Replies
Mar 21, 2009
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?
View 2 Replies
Sep 3, 2009
I am loading in a swf into my file, via the loader class. When I remove this child .. does all the swf remain in the memory, or is it discarded? I want to remove it entirely ..
Code:
var myLoader:Loader = new Loader();
myLoader.load("thisMovie.swf");
addChild(myLoader);[code]....
View 5 Replies
Feb 20, 2011
I have a main class that calls and removes screens with addChild and removeChild, these screens are movie clips.My issue lies in these movie clips, each clip is linked to a class - e.g. confidence.as links to my confidence screen.I am trying to add buttons and pieces of text from this class file onto the confidence screen, so essentially adding more movieclips on top of a movieclip that has already been added. I keep getting this error:TypeError: Error #2007: Parameter child must be non-null.I could do with some help figuring out how to add objects to my screens, as I am trying to prevent having everything in one class.
View 6 Replies
Sep 3, 2010
When you make a simple game that maybe has a few different 'screens' like start, help, and high score, and a few levels, and you don't wish to load from external swf's. What is the best practice for making these games as far as the timeline?To just have ONE frame that add's and removes child movieclips from the stage?
View 3 Replies
Jul 9, 2009
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();
[code].....
View 2 Replies
Nov 21, 2011
I am using removeChild() to remove a MovieClip. And via tests, I can confirm that it's working fine ( stage.contains(mc) returns false ). But the MovieClip still does not seem to be removed, as if the stage is not updated correctly.
View 1 Replies
May 3, 2011
New to flash as3, cant seem to get past a 2025 error when remove child is used. My player hits of an object called present_mc2 and is removed but an error comes up on stage.
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at VinnieBaggeB00033245_fla::MainTimeline/detecthit()
Here's my code:
var present2_mc:MCpresent = new MCpresent();
stage.addChild(present2_mc);
present2_mc.x=87;
present2_mc.y=305;
stage.addEventListener(Event.ENTER_FRAME, detecthit);
function detecthit(event:Event):void {{
removeChild(present_mc);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, detecthit);
}}
View 2 Replies
Aug 11, 2011
If im usin function to add a mc to the stage like so:var myChild:MC= new MC();
function somefunc()
{
stage.addChild(myMC)
[code].....
View 4 Replies
Jul 28, 2010
I have 4 movies that need to be loaded in sequence. The first movie loads the second one, the second one loads the third, then the third one loads the fourth. What I can't figure out is how to make sure there's only one movie loaded at any time. I've tried removeChildAt(0) and other methods. What's the best way to load a movie to the stage and wipe out what was on the stage?
View 4 Replies
May 29, 2010
I have a website with a homepage in which I have a movieclip called "menutopmc" which, as the name says, is a menu on top of the stage and it is an MC as instance. Inside this mc I have 5other mcs and each of them works as button.On the stage I have an other mc called "website" in which I load the several pages of the website.Here is some code to understand better what I'm doing:code on the main stage where I automatically load an swf when the website loads:
ActionScript Code:
stop();
var websiteRequest:URLRequest = new URLRequest("azienda.swf");
[code]...
and here is the code I have inside the mc menutopmc in order to change the child previously loaded on the stage:
ActionScript Code:
function btn_content(eventObject:MouseEvent):void {
MovieClip(parent).website.removeChild(websiteLoader);
[code]...
Now, the new addChild in the function btn_content works and it loads the new child on stage but the removeChild doesn't work and this is the error I get:
1120: Access of undefined property websiteLoader.
View 9 Replies
Nov 2, 2008
If I add a movieclip to the stage like this:
Code:
var feedbackBox_mc:feedbackBox = new feedbackBox;
feedbackBox_mc.x = 807;
[code].....
View 7 Replies
Jul 25, 2011
I have several objects created at frame 2 of my fla file, like:
Code:
stop();
var rotatorek:Rotator = new Rotator();
addChild(rotatorek);
var rpm:engine = new engine();
addChild(rpm);
etc...
After endGame is changed to true within one of my .as files, I got this error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:isplayObjectContainer/removeChild()
at Rotator_fla::MainTimeline/ruszMaszyna()[Rotator_fla.MainTimeline::frame2:94]
Frame 94 is first removeChild(rotatorek).
Why I can't remove all those children? I need to go to frame 1 without any instanced objects and cleared listeners.
View 3 Replies
Apr 15, 2010
I have a parent swf that loads in 6 little swfs. However, I have a button which should remove the loaders from the stage, no matter which one it is from the 6. At the moment I can only remove one of them because of the way I have coded the application. So, when I click on the button which is supposed to remove whatever loader is currently sitting on top of my parent movie, it only removes one of the loaders - the one which is named first under my resetAssets function.
I can not have:
removeChild(ldr);
removeChild(ldr2);
removeChild(ldr3);
etc.
Because only one of them is being displayed at the time and flash goes like "hey dude! where are the others you want me to remove then!?" I suppose the whole code has been built up poorly and I should loop the swfs through one loader instead of having a loader for each swf.. Then I could just remove the loader no matter what sits in there..?
Code:
//imports
import flash.filters.*;
import flash.events.*;
import flash.display.Loader;
import flash.display.Sprite;
var ldr:Loader = new Loader();
var req:URLRequest = new URLRequest("load_XML.swf");
[Code] .....
View 1 Replies
Nov 17, 2008
So, I have a file where I've added 27 movie clips to the stage using a for loop to cycle through items in an XML document. Here's the pertinent part of the code I'm using, it's AS3:
So, I end up with 27 instances of mini_mc, each named 0, 1, 2, 3, etc.
I'm trying to write code to remove them at a certain point in the movie but having problems. Here's what I'm using[code]...
View 5 Replies
Aug 12, 2009
I'm having a problem removing a child from the stage that is added dynamically. Shouldn't this work...
[Code]....
View 3 Replies
Mar 15, 2009
I'm working on a project which uses timline animation. The animated objects are involved in a collision detection script.
When they collide with other objects, their timelines are told to stop() and they're removed using removeChild. At this point they have a value of null (I've tested this.)
Strangely however, they invisibly re-instantiat themselves when the timeline animation loops back to frame 1. There's no code telling them to play anywhere in the program. They still have null values, but their collsion code still affects other objects.
View 6 Replies
Jul 21, 2011
I got some problems with removing a child from stage. The timer is still active I try to get rid of it with a killMe function. Called by REMOVED_FROM_STAGE event. But it doesn't work.
View 4 Replies
Apr 4, 2010
If I removeChild an object from the stage can it still be detected by a hittest? I have objects that are tweening off the stage and if they hit other objects they stop their tween i use removeChild to remove objects that I don't want a hittest to occur on which is the nature of my question.
View 1 Replies
Nov 7, 2009
I'm new to AS3 and have been making a Snake game. I've come up with a problem with the code (Yes, I have magically created problems trying to program Snake...It's going to be a long day). My problem is, with removeChild...I'm getting strange errors being throw at me. Not only that, but my Movieclip (myFood) is not being removed entirely, only the visuals of it are.
That being said, here is, what I believe to be, the most important chunk of code for this problem, along with the error it gives me.
Code:
/*
* Code for the Snake and whatnot extras.
* Also, Snake and Food are classes.
*/
var myFood:Food = new Food();
stage.addChild(myFood);
function snakeEatFood() {
[Code] .....
View 2 Replies
Jul 27, 2011
I'm currently working on a script which depending on various factors will add different movie clips to the stage. When the factors change so do the movie clips. I know that I can use removeChild(myMC); 100 times and wipe the stage, so I was thinking it would be possible to add all the movie clips to an array and use removeChild(myArray); to get rid of them but I'm coming up with the compiler error: Code: 1067: Implicit coercion of a value of type Array to an unrelated type flash.display:DisplayObject. so obviously I'm missing something. Is this even possible? is there a more effective way to remove Movie Clips from the stage?
View 6 Replies
Mar 29, 2010
I'm trying to build a conditional statement that will addChild and removeChild at different Timer Delays. Before I go any further, I thought, I should mention that I'm usinig TweenMax to ease the alpha of ease Child from 1 to 0 and back during the process to imitate a fade-in/out.
I'm getting issue with only one line - inside a conditional statement.It's running "OK". The movie runs as I want it, but the remove/addChild transitions are not at the speed I want it at. I am getting an error message in the output, but other than that, the movie runs fine.
stop();
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
[code]....
View 2 Replies
Apr 13, 2010
I'm wondering if there is a better way to approach this than my current solution...
I have a list of items, I then retrieve another list of items. I need to compare the two lists and come up with a list of items that are existing (for update), a list that are not existing in the new list (for removal) and a list of items that are not existing in the old list (for adding).
Here is what I'm doing now - basically creating a lookup object for testing if an item exists.
[Code]...
View 2 Replies
Nov 24, 2010
I have an application that was written with Flash Professional 8/AS2 and it parses XML for rendering dynamic media content. The XML pulls text with HTML markup out of CDATA sections and places them into an html enabled text field. Everything has worked wonderfully until Flash Player 10.
Now, if we use html escape characters for greater than or less than symbols, they are being decoded by the xml parser.
Here's my example CDATA section:
Here <u>we</u> go: This <node> <works>
when I grab its value using nodeValue or toString, the results are different from Flash Player 9 to 10. Here's what I'm getting:
[Code]....
In Flash 10, if I escape the ampersand, it will work, but this doesn't work in 9. for example, the following works in 10:
<![CDATA[Here <u>we</u> go: This <node> <works>]]>
This all happens before I assign it to a text field. How do I keep the parser from destroying my escaped characters in Flash 10? Do I just need to drop support for Flash Player 9 and go for what works in 10, or is there a solution for both?
View 2 Replies
Mar 30, 2011
I have added a new flash moovie to my website, the problem i have is that in Mozilla, Google Chrome and possibly more the side scrollbars disapear, however in IE they show perfectly. i can not show a url as i have to leave the old page up until i can find out what is causing the problem.
View 3 Replies
Oct 5, 2011
i've installed the Perforce Eclipse plugin successfully in Flash Builder 4.5.however, the only problem i've run into is that whenever i open a ActionScript file (either one that is or isn't checked out) there is no syntax coloring - it's simply a white background with black text.
i've changed themes so that i have a dark background with different colored syntax but Perforce also removes that coloring, although this time it's the dark background with all white text.
View 2 Replies
Nov 1, 2009
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++){
[code]......
View 1 Replies
Feb 21, 2009
I cant do 2 removeChild(); 's beneath eachotherSo their always will remain 1 child how can i delete that one?
addChild
removehild does work
removeChild
[code]......
View 2 Replies
May 29, 2009
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.
View 1 Replies