ActionScript 3.0 :: How To Remove Dynamic Objects
Nov 25, 2009
So far I have this squid-shaped MC floating and making bubble-shaped MCs which rise to the top of the stage. The bubbles get generated by following the squid's (x,y) cordinates. The whole thing looks convincing enough. The only problem is that as the memory gets full, the bubble animation degenerates, so I want to remove them once they reach the top. I figured I could use a removeChild() function tied to the same EventListner that makes them rise, but once removed it will look for the object again and throw an error. I know I'm missing something simple here, but I can't pin it down.!
Code:
var bubbleTimer:Timer=new Timer(1200);
var i:uint = 0;
[code]....
View 6 Replies
Similar Posts:
Jan 14, 2010
picture: [URL].. I am making a boardgame in flash Action Script 3 each position on the board is a buttons like this: button_1_1, button_1_2 etc. Whenever a character is selected you want to move it so the script has to add event listeners for positions around the selected unit
[Code]...
In the rest of the code I have:
function userClickedPosition(position_x:int, position_y:int) it selects or deselect a unit function selectUnit(position_x:int, position_y:int):it uses the listentoButton(1) function to add 8 listeners (the positions around the clicked unit)function deselectUnit(position_x:int, position_y:int): it uses the listentoButton(0) function to delete 8 listeners (the positions around the clicked unit)
My question: adding eventlisteners is no problem but removing them dont seem to work? What did I do wrong?
View 1 Replies
Aug 23, 2011
I have some objects on a form with the following instance names:
item_box1
item_box2
The following code will NOT remove all objects with "item" as the first part of their name. Why and how can I fix it?
ActionScript Code:
for(var i:int=0;i<main.numChildren;i++) {
if(main.getChildAt(i).name.substr(0,4) == "item")
[Code].....
View 6 Replies
Jan 31, 2010
I once saw an effect on a flash add I wanted to try make myself also - the cursor makes a vake that blur out and disapear, much like the vake of a plane, just faster. The problem is I need to remove the vake when it has faded out, or else it just stay in the background and fill up forever! I know there must be an easy way for this. Can some of you tell me the best way here? I have attached the fla-file and scripts. You see a comment where I try to put the code...
View 1 Replies
Jun 4, 2009
I am making a flash game. The game starts off running fast and smooth, however 15 minutes into the game it's noticibly slower. I worry that I am causing memory leaks by not removing objects from my game properly. I understand the whole garbage collection idea, but I still need confirmation.
[Code]...
View 6 Replies
Feb 10, 2010
I have a class "Ball" which display graphical circle ball in random x&y axis and Ifade out it with Event.ENTER_FRAME and specify removeEventListener if it reach alpha<=0 .Now I made multiple object from "Ball" class. Now, In my stage it works nice but when I see my Computer Memory status. my current flash.exe is increasing memory rapidly. Is how to remove my unusual object from my Memory. So that it would not get hang.
View 2 Replies
Nov 23, 2009
I'm trying to remove all objects from an array, and then emptying the array using splice. I'm restarting the game, removing all objects etc so that I can add them again. But what happens is that no object (enemies, blocks, bullets etc) is really removed. It's not visible anymore, but it's still on the stage wreaking havoc (hit detection still working, so enemies are avoiding enemies that were supposed to be removed, bullets hitting them and so on). And then when I restart the game a couple of times I have way too many objects and the game starts to lag. Code below: This is the code for the enemy, I have different loops for the other objects, but they all look the same:
Code:
for(var a=0; a<enemy1.length; a++) //loop through enemy1 {
if(enemy1[a].dead == true) //check if dead {
removeChild(enemy1[a]); //remove from stage
enemy1.splice(a,1); //remove element from array
}}
So to reiterate, I need to remove the objects from the stage, and clear/empty the array.
View 6 Replies
Jun 30, 2010
I have an array containing objects, where each object contains a boolean. I was wondering how I can remove only the objects where the boolean is set to true.I've tried doing it like this:
for(var k:int = 0; k < ballContainer.length; k++){
if(ballContainer[k].isCheck == true){
removeChild(ballContainer[k]);[code]....
But it doesn't seem to work that well. (Reason for it not working may very well be another reason, but I thought I'd check here anyway since I'm an AS3 novice)
View 5 Replies
Dec 5, 2010
I am using a carousel (from Lee Brimelowe's tutorial) as the main method of navigation from my site's homepage. There are six icons in the carousel, clicking any one brings the icon to the front and some dynamic text and a button to navigate to a different page appear on stage. Clicking the icon again brings the icon back to the carousel and the text and button disappear.The site is multi-lingual (English, German, Dutch, Polish) and all text changes to the relevant language by clicking a flag button, including the text that appears beside the 'expanded' carousel icon - all of the data is loaded from XML files.
The problem with changing the language is that the entire carousel needs to be destroyed and rebuilt each time, as all of the data needed for it is only loaded on runtime. I have this 'kinda' working, the problem I am having is:If you change the language via a flag button when an icon is 'expanded' the dynamic text and button (theText and urlBtn) get 'stuck' on the stage and you have to do some clicking on the new carousel icons remove them - not ideal!Can anybody out there please advise me on how I would include some AS to remove these items too when the language button is changed?
View 1 Replies
Jul 9, 2009
This doesn't work at all.[code]...
but adding "removeDuplicates(aPeople);" after "createfile(thename);" has no effect: in other words, when I push the savefile button, it keeps creating clones of the same objects. What can I do?
View 2 Replies
Sep 9, 2010
I'm trying to remove simple objects from memory, but when I call removeChildren memory usage rose :/ And I don't why ? And how can I remove objects ?
[Code]...
View 2 Replies
Nov 4, 2010
How to remove all flash objects from html with regex , code needed at c#.Regex will remove all html objects from html so there will be no flash based objects at results
View 1 Replies
Jan 4, 2011
I'm working on a game for the iPhone using flash, and since memory is crucial i want to clean up displayObjects not needed. All the objects i need to delete is MovieClips taken from some array to another using splice(). Here is the [code]...
View 2 Replies
Dec 2, 2009
I am creating a generic button that will remove items created dynamically in a movie clip container from memory (not just from the display list).
To track which item the user has selected for deletion, I have a click function that stores the name of the clicked object in a variable called objName. I then store a reference to the object itself in another variable called targetObj. I can then easily remove the object from the stage like this[code]...
View 3 Replies
Mar 31, 2011
On my flash application I am using the Google map API this creates a child object I have removed this on every other page with [code]...
View 8 Replies
Jun 28, 2011
How do I remove objects created only with code so that they don't ovelap when entering the frame again?[code]...
View 3 Replies
Jul 19, 2007
know how to remove objects like Plane from Papervision 3D scene? I have tried container.scene.removeChild(plane); but it gives me an error like this:"1119: Access of possibly undefined property scene through a reference with static type flash.display:Sprite." So what I'm understanding is that I can only use removeChild() with Sprite objects (and maybe MovieClips) but I cant remove objects that are part of Papervision scene?
View 11 Replies
May 22, 2009
Im new to AS3, and i have to use it for my current project. I have used the AS2 Transform tool extensively, but needless to say, the AS3 version works entirely differently.[code]...
View 1 Replies
Nov 27, 2002
How on earth do I use the onMouseDown event to remove objects generated by an array?
I'm still programming (if my bumbling can be called that ) the game I discussed in the 'Random Object Generation' thread and I'm using the basic framework of the array function that h88 gave me. Everything is working fabulously, but getting the things to disappear onMouseDown is a problem - it doesn't work.
Oh, and if I reference Target.prototype.onMouseDown and tell it it to this.unloadMovie, it unloads every single target on the screen instead of the one your mouse is actually over, making for a fairly... lame... game. I'm pretty sure it's because every single clip generated by the array is a Target prototype instance and so when the MouseDown occurrs, it unloads every Target movieClip. And I am using a hitTest in the Target.prototype.onMouseDown command, so that doesn't solve anything...
View 4 Replies
Aug 4, 2009
I'm creating a simulation in which a large number of objects are added to vectors and then taken away in random order (as more are being added). To remove the objects, I splice the object from the vector it's in, and notify all the other objects that an object ahead of them was removed so they can change their indices accordingly. As far as I know, the objects have no other references (I think), and within the object, I set everything to null. I read somewhere that you can't put "delete this" in the class, so I didn't bother with that. Will this be sufficient to get the object garbage collected, or should I do something else? What are the best ways to get something like this garbage collected?
View 2 Replies
Oct 2, 2011
I would like to remove objects from my array if they do not meet the condition. But I haven't been able to get the result i want.
[Code]...
View 5 Replies
Oct 1, 2010
Is there a way to generically remove an object from an array? (maybe not using array.filter or creating a new array)
Example:
var arr:Array= new Array();
//create dummy objs
for (var i:uint=0; i < 10; i++){
var someObject:SomeClassObject = new SomeClassObject();
[Code]....
View 3 Replies
Nov 28, 2011
I am adding a Timer object when my flv playback enters a Pause state and removing that Timer Object when playback starts again. I noticed that if I pause the movie and then drag the slider on the timeline the movie enters the Pause State again which adds another Timer Object....
How do I check to see if the Timer has already been added and if so remove it and add a new one.
See code below:
my_player.addEventListener(VideoEvent.PAUSED_STATE_ENTERED, pausePlay);
my_player.addEventListener(VideoEvent.PLAYING_STATE_ENTERED, startPlay);
function pausePlay(e:VideoEvent):void {
[Code].....
View 2 Replies
Sep 5, 2010
Im new to AS3 nd I just had a quick question. In the puzzle game below, How do I delete all of the puzzle pieces that have been generated?
[Code]...
View 1 Replies
Jul 4, 2009
Why and when? Because I addChild to the stage 1000 times but only removeChild 800 times, and even so, stage.numChildren returns to 0 after all my objects have exceeded the stage boundary. I have to mention that I am moving objects from left to right (it's a game) and the object's X and Y properties eventually exceed the stage boundaries. Does something happen automatically then??? Like... events removed or something like that? This is a continuation of this thread of mine, where I initially thought addChildren has issues: [URL].
View 5 Replies
Oct 11, 2011
I'd like to remove objects via removeChild after Tweenlite has finished tweening. But it doesn't really work because my objects are still in the DisplayList.
Code:
//TweenLite.to(sndText, .5, {alpha:0, onComplete:removeChild, onCompleteParams:[sndText]});//does not really work; still in DisplayList
TweenLite.to(sndText, .5, {alpha:0});
TweenLite.to(musicText, .5, {alpha:0});
TweenLite.to(sndSlider, .5, {alpha:0});
[code]....
View 3 Replies
Jun 16, 2011
ive come across this method 'as' and I dont get it.I am following a tut, and i have an array with my objects stored in it(for reference to control these sprites).They are instantiations of my sprite class 'Ball.as'
Code:
for(i=0;i<3;i++){
var myMCs:Ball = myMCs[i] as Ball;
}
when I remove it - flash doesnt seem to mind its absence.
View 5 Replies
Nov 9, 2009
I've created an XML thumbnail gallery, and would dearly love to add a simple looping preloader animation to each of the thumbnails whilst they are still loading. I'm struggling to remove the preloader movieclip, once the corresponding image has been loaded.
I'm currently creating the new movieclips within the loop, so I'm having problems referencing them in the following load complete function. I gave naming the "spin_loader" instances a go (i.e. spin_loader.name = "spin" + i), and then trying to remove it in the "thumbLoaded" function ( i.e. project_mc.removeChild(getChildByName("spin" + spinNum)), where spinNum is the equivalent number to "i"), but I just can't seem to crack it.
Code:
function createThumbs()
{
for (var i:Number = 0; i<my_total_project; i++)
[code]....
View 2 Replies
Sep 15, 2009
Is there a way to remove a movieclip that was not attached or created dynamically?
View 1 Replies
Aug 9, 2005
I have a for-loop that creates instances / duplicates of a movie clip that works like a charm:
[Code]...
Then I position each instance- and I fill an array with the number ("pg"), because: I also have the option to switch to a different view and at that point I want / need the MoveClips to disappear. So I have a function tied to the switching that goes through a loop for all instances of the movieclip copies (using the array with the IDs from the example above) and remove them.
[Code]...
View 1 Replies