ActionScript 3.0 :: Removing Children Produces Memory Leaking?

Apr 22, 2009

I am having memory problems when adding & removing children. Here is a brief overview of what I'm doing:I'm ading children to a VBox component:the structure of the children is:

Code:
<mx:Canvas>
<mx:Image/>
<mx:Text/>

[code]....

All remove the children, BUT I am getting memory leaking, especially using the second method! If I don't add the TextField child to the UIComponent I don't seem to experience any memory problems!

View 2 Replies


Similar Posts:


Actionscript 3 :: Removing Parent Memory Used By All The Children?

Sep 17, 2010

I'm making a rather large flash project and so I'm concerned about memory usage. At the end of each section of the application I remove the overarching parent element that holds the content. Although this remove the parent, does this also free up the memory for each of the children contained within this, or should I run an iteration to remove those prior to removing the parent?

I'll give a little more explanation in-case I'm not expressing what I want:

addChild(movie1);
movie1.addChild(movie2);
movie1.addChild(movie3);
By using this code:
removeChild(movie1);

Does it remove movie2 and movie3 from memory or are they still stored, just unlinked?

View 3 Replies

ActionScript 3.0 :: Removing Things From Memory?

Mar 27, 2008

I'll try to explain the general operation of my program, and that might shed some light on my issue. I have a menu with 50 different small postcards. When one is chosen, the program zooms it up in order to fill the screen, populates some data which is unique to each postcard, and "flips" it so you can see the writing on the back. The postcard is a movieclip which imports a front image, 3 back images, and some XML text. There are some buttons on the "back" of the postcard to choose to look at a few images and text.When you choose to close the postcard, it flies away. I use the same movieclip for all 50 postcards, and just change the images and text that I load.

Once the postcard flies away, I want to remove it from memory. It won't happen with removeChild() as that keeps it there in case I want to reference it again I guess, and I have tried setting the postcard variable name to "null" without much success.I add listeners to the buttons on the postcard when I instantiate its class, so I am not sure if I have to remove them in order to get the garbage collector to deal with it. But, I also don't know what I don't know about removing things from memory. In one section of the Flash docs (Working with display object containers) it says:

"The removeChild() and removeChildAt() methods do not delete a display object instance entirely. They simply remove it from the child list of the container. The instance can still be referenced by another variable.(Use the delete operator to completely remove an object.)"And, at another place in the docs (the script reference about removeChild()) it says:

"Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance. The parent property of the removed child is set to null , and the object is garbage collected if no other references to the child exist. The index positions of any display objects above the child in the DisplayObjectContainer are decreased by 1.

View 6 Replies

ActionScript 3.0 :: Removing SWF From Memory After Deleting From DOM

Sep 29, 2011

I'm having a problem where I load my SWF (Advertisement) into the dom after an event happens in a flash game.  After viewing the ad, the SWF is removed with JavaScript and users continues to play, this continues several times without ever reloading the page.
 
The problem I am running into is in IE 8 & 9 performance of the game drops and frame rate becomes choppy after several ads are shown.  Each advertisment has a timer built in and my thought is that the ad is not being fully removed from memory hence causing a slowdown. 
 
Is there a way to ensure a full removal of the ad or at least a way to detect within the ad that it is no longer on the page & kill the timer?

View 1 Replies

ActionScript 3.0 :: Removing A MovieClip From Memory

Jan 11, 2011

I have a function called changeMovie which is supposed to load a new movie/swf into a already established container.I can get the new movie to load (all these movies have sound embedded in them) but I can not figure out how to get the old movieclip out of memory.I can foresee an instance of memory overload in my application down the line.I am using Flash CS3 with AS3.[code]As it stands now, I can get the new movie to play and be shown but the old movie clip still continues to play "in the background - along with its sound".

View 9 Replies

ActionScript 3.0 :: Removing Object From Memory?

Aug 5, 2011

I have this line

Code:
this.parent.removeChild(this);

So basicaly the object is removing it self from the parent object,but I still think that it exisits in memory and doing its backend job.How can I remove it completely from memory?

View 8 Replies

IDE :: Removing Children From Stage

Apr 6, 2009

im making a game and it has enemies randomly spawning at the top of the screen going down to the bottom, so far it all works fine, except for when i try to remove the enemies I get this erro.[code]

View 1 Replies

ActionScript 3.0 :: Removing Only Certain Children From MC?

Dec 2, 2010

I have a movieclip in which I want to remove all of the children that are of type textfield, leaving anything else.

This is what I have so far but it throws an error.

Code:
if(String(this.mcContentOnStage.getChildAt(i).type) == "[object TextField]")
{
"This must be a textfield!"
//this.mcContentOnStage.getChildAt(i).text
}

View 3 Replies

ActionScript 3.0 :: Flash Infinite Number Of Children Wasting Memory?

Sep 2, 2010

At the moment, I came across this problem where I have to work with many swf files.The problem is I'm using addChild() & loader to navigate between each swf. It doesn't seem to be a problem at first, but after numerous times of clicking back and forth, the flash player starts running slow.So I've came to a conclusion that eventhough new swf are added every time I clicked, but the parent swf still remained at the back which is overlapped by the child.

View 1 Replies

ActionScript 3.0 :: Removing Items From Memory Using Loop?

Feb 18, 2009

The following for loop removes children from their parent if they're in the display list. It works correctly, but I also want to remove each child from memory with the same loop.

View 1 Replies

ActionScript 3.0 :: Removing Stage Items From Memory

Apr 14, 2010

I am adding few items dynamically from the library to the stage by creating instances. If I remove them using removeChildAt() then the item gets removed from the display but exists in the memory. How can I remove this from memory?

View 2 Replies

ActionScript 3.0 :: Remove Something From The Stage Without Removing It From The Memory?

Sep 29, 2009

its possible to remove something from the stage without removing it from the memory. Ie not using removieChild(); Reason being: I want to replace an image inside a movieclip rather than add another image on top or remove the image and movieclip entirely.

View 2 Replies

ActionScript 3.0 :: Removing Array Contents From Memory?

Dec 2, 2009

I'm performing the following operation many times (sniped of code below). I'm creating a two dimension array whose overall size depends on each iteration the process takes.

myArray = new Array(); // initialize the array
myArray[0] = new Array(); // add new array to first index
myArray[1] = new Array(); // add new array to second index

Question is: When I need to recreate this sequence again, do I just perform the same operation (repeat the same 3-lines)? Or is there a way of freeing up resource first.

View 3 Replies

ActionScript 3.0 :: Removing Images From Memory In A Loop

Aug 14, 2009

I've made a script which loads in, at intervals, images in a sequence (image1.jpg, image2.jpg ). However I've being doing my nut as to how to remove the preceeding image from memory as looking a the Windows Task Manager, each image gets added again and again, accumulating memory usage. I've tried removeChild, and null; stuff, but to no avail.I want it to go through the 10 images, and with each step to the next image, remove the last one from memory.[code]

View 2 Replies

ActionScript 3.0 :: Removing Unreferenced Objects From Memory

Oct 15, 2009

I'm trying to make a Starfield program as practice for ActionScript 3. I'm using a timer event in the document class to create Star objects which are defined by an object class connected to the movieclip Star in the Library. The object class has a timer as well, and at each tick it repositions itself a few points away and scales up, creating the image of a star shooting towards the sides of the stage. When the star has gone past the boundaries of the stage or when it has scaled to a certain size, it removes itself from the display list with the command: this.parent. removeChild(this);This removes the star from the display list just fine, however after that I can't get the star to set itself to null so that it will be removed from memory, and I'd like some suggestions on how to do this properly. An idea I had was to make a function in the document class that the child objects can call, something like this.parent.KillMe(this) which would give itself as a reference to the function, which could then use a local variable reference to set the child to null, removing it from memory. This all seems terribly complex, so I'm sure there's another way.

I haven't noticed a memory leak or slowdown, however, so I'm curious if objects without references that are removed from the display list are automatically removed? That could be both good and bad, as the object might want to add itself to the display list again at a later time; not in this Starfield program, but perhaps in another I write.

View 11 Replies

ActionScript 3.0 :: Removing Children Using RemoveChild

Apr 25, 2010

I am using a loader to load an asset to the stage from a class, the image is called "1.jpg". Using a timer event, after a certain amount of time that image is to be replaced with image "2.jpg", then after some time it is replaced with "3.jpg". etc.The way I set it up is using a series of if statements inside the timer function. At timer count 10, I first remove the child from the stage and then load the new image.[code]
However the removeChild(my_loader) does not work, it gives an error saying that it cannot be null

View 1 Replies

ActionScript 3.0 :: Removing All Children Of A MovieClip?

Feb 2, 2009

I have a MovieClip that I dynamically add other MCs as children to. Now I'd like to have a function that removes ALL children at once. I tried a loop with (i < mc.numChildren) but somehow it will only remove even-numbered children, the odd ones stay on stage?

View 12 Replies

Actionscript 3 :: Removing Children From A DisplayObject?

Aug 14, 2011

What would be the most efficent way to remove the children from a sprite/movieclip in respect to memory and garbage collection?I have seen atleast three ways.Simple re-assigment

sprite = new Sprite();
null and then new
sprite = null

[code].....

View 2 Replies

ActionScript 3.0 :: Removing All Added Children?

Jan 27, 2011

I have a problem with removing children. First button is adding movieclip each time you click and second button has to remove all of added movieclips, but it just dont work.

Code:
//add 2 euros
buttonDvaEuro.addEventListener(MouseEvent.CLICK, pridatDvaEuro);
function pridatDvaEuro(event:MouseEvent):void{

[code]...

View 9 Replies

ActionScript 3.0 :: Removing A Movie Clip Properly From Memory?

Jan 21, 2011

I am having a bit trouble removing a movieclip properly from memory.In the onComplete event I use this to add the swf content to my clip

[code]....

The removeChild is double here just for savty But the trace command from the clip I loaded continues to put somthing in my output window. So it still keeps running and it isn't even stoping.

View 4 Replies

ActionScript 3.0 :: Memory Doesn't Release When Removing MovieClips

Jul 8, 2009

The app is basically an animated character that sits on screen and moves around doing stupid little animations. Each animation (Talking, Dancing, Jumping, etc) is an individual Movie Clip made up of around 50 or so PNGs in sequence. I'm using CS3 to create the clips, and exported them as SWCs for use in Flex. When I addChild() the MovieClip to stage, memory usage increases, which makes sense. However when I use removeChild() on the same clip, and then add another clip, memory increases, and this goes on with every new clip... essentially leaving 10 clips in memory even if they aren't being played.

Now, first thing you are going to think is I've got a reference to the clip somewhere and it's not garbage collecting. Well, I'm using weak listeners everywhere, and I'm pretty sure I've killed every reference by NULLing out the objects. I understand Garbage Collection doesn't happen right away... but it never seems to happen. As a test, I wrote a really bare-bones app to attach and remove a clip to see if the memory ever frees. I've left the app running for a half hour after removing the clip from stage, and memory usage stays the same:

[Code]...

View 2 Replies

ActionScript 3.0 :: Removing All Children/ End Level Function?

Jul 15, 2009

so i am trying to create a "endlevel" function for my game, in this level i will need to remove all event listeners,stop all timers, remove all children off the stage and empty all arrays. i understand how to remove all event listeners and to stop all timers:

PHP Code:
myTimer1.stop;
myTimer2.stop;

[code]....

View 1 Replies

ActionScript 3.0 :: Removing Multiple Children From Container Mc?

Oct 5, 2009

I am having trouble determining where to add my removeChild() statement to clear multiple movieClips from a container mc. I know I need to determine if the container movieclip contains anything. I don't know how or what I should put and where to put it. If I can determine if my container mc has movies in it, I am assuming I can just declare it again (i.e

PHP Code:
panel= new MovieClip();
)to clear it. Am I correct?

[code].....

View 6 Replies

ActionScript 3.0 :: Removing Children Based On Location?

Mar 11, 2010

Question 1Whats a good example of removing objects from stage that aren't within the stages boundries. I first tryed using a transparent box and hittesting. then i realized that you cannot hittest an object that isn't on stage, to check if needs added. so i came up with this.

Code:
for (nn=-1; nn<2;++nn){
if (this.hu1.room+nn>=0 && this.hu1.room+nn<this.walls.ar.length){
for each (n in this.walls.ar[hu1.room+nn].ar){[code]....

That way it only adds the object if its not currently on the display list or am i better off just giving all objects an onscreen:Boolean variable?

View 4 Replies

ActionScript 3.0 :: Removing Some Preloader Movieclips Children

Jul 1, 2009

I'm having trouble removing some preloader movieclips I have inserted via AS3. The message I get is:
 
[Code]..

View 5 Replies

ActionScript 3.0 :: Coding Hierarchy And Removing Children?

Jan 20, 2010

To give a brief background of what's going on here.I am building a personal site where I have a navigation, and I have other subnavs inside of certain pages.Such as if I go to "work" inside of work i have "motion", "web" & "print".Here is some example code of one button on the navigation:

nav_mc.personalbtn_mc.addEventListener(MouseEvent.CLICK, buttonClick2);
function buttonClick2(event:MouseEvent):void {
gotoAndStop("personal");[code]...

It seems to me that actionscript will not read all the way down to the bottom when looking for objects.For example: The first if statement where it's asking if workss_mc exists or not, that will work if it's at the top, but if I move it down to the bottom it will not work.

View 33 Replies

Actionscript 3 :: Adding And Removing Children - Variable

Mar 15, 2012

So basically I've got a MovieClip called Jug and when the egg is clicked and dragged to the Jug I want it to disappear and then re-add itself in the place it first started. Aswell as this I want a variable to be added by 1 in value. I have tried fiddling around with this for a while now and I can't figure it out since when I remove child it gets errors. Here's the code:

[Code]....

View 2 Replies

ActionScript 3.0 :: Removing Children Outside Original Function?

Dec 14, 2010

I am creating a number of text fields dynamically and then adding them to various movie clips within a function like this:

ActionScript Code:
this['services'+i+'_mc'].addChild(btnTxt);

...how can I later remove them from their movieclips outside of the original function? I have tried everything I can think of. For example if I run another function with a loop and try

ActionScript Code:
this['services'+i+'_mc'].removeChild(btnTxt);

View 7 Replies

ActionScript 3.0 :: Timer Adding And Removing Children

Aug 24, 2011

I am creating a game and want to reward the player at the end of a level by playing an animation. I have created a timer to add the animation to the stage but cannot figure out how to remove the animation once the timer has completed counting. I am sure you wise scripters out there know the secrete to this mystery.

[Code]....

View 2 Replies

ActionScript 3.0 :: Adding And Removing Videos From Two Children Away

Mar 3, 2012

I've spent hours, and for all my self taught newbie-ness, I can't crack this: I have a navigation panel with several buttons. Lets call it mainNav. The mainNav buttons each add to the stage their corresponding MCs. They also remove any MCs from previous buttons currently on the stage. This is done by creating the MCs as variables, pushing those variables into an Array, and, when the mainNav button is pressed, calling the following function to remove the old (provided with assistance of the nice folks here), and then addChild(correspondingChild)

[Code]....

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved