Actionscript 3 :: Remove Array-objects From DisplayList?
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
Similar Posts:
Apr 15, 2009
i have two classes:
videoPlayer(Document class) and videoControls(which is added to the stage by videoPlayer).
videoControls put an object on the stage at some point:
dp = new displayEnd();
dp.name="dpe";
addChild(dp);[code].....
View 1 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
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
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
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
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
Apr 27, 2010
I have an array of temporary objects created in a for loop. The objects are of type class "Tile", a class I created. However, it appears that whenever I create a lot of tiles in the for loop, the program slows down indefinitely.
While the array is whiped at a later trigger point, I am thinking that perhaps these Tile objects are not being erased from memory. They are being created on the fly in a for loop, and the array is being reset to "array = []".
Are the objects still in memory or are they cleaned up when the array is set to []?
View 3 Replies
Jun 10, 2011
I have a service which returns an Array of ObjectProxy objects. I would like to cast this to a custom object (a value object) and create an ArrayCollection. How can I do this?ited:I am using Django and PyAMF for the backend. I had to write a custom SQL query and I am wrapping the resulting records in ObjectProxy and sending the whole result as an ArrayCollection.Here is my client side code:
[ArrayElementType("SessionVO")]
[Bindable]
private var _list:ArrayCollection;
[code]....
View 2 Replies
Oct 8, 2009
I'm using the .unshift method therefore the newest values go into [0] and the rest are pushed down.
What is a good method to remove a value from an array once it has passed a certain length? For example i only want my array to hold 5 values.
Also, is there a method for clearing the entire array, ie removing all values? Or will i have to manually change all the values with a loop?
View 2 Replies
Dec 18, 2011
Is this the correct, most efficient way to recycle objects when creating an array of objects?
package com {
public class CreateList extends MovieClip {
//this is the object I will be recycling
private var newProperty:PropertyRow;
//this is the array I will use to reference the objects
[Code]...
View 2 Replies
Oct 17, 2011
iSo let's say I have three different arrays of objects, and I want to combine them into one sorted array. I want the order to be such that the items from each array are evenly distributed throughout the sorted array.
If there were 3 xItems, 3 yItems, and 3 zItems, the sorted array would have this order: x, y, z, x, y, z, x, y, z
HOWEVER, even if the arrays are differing lengths, I still need to make them alternate as much as possible. If there were 6 xItems, 4 yItems, and 2 zItems, the sorted array should have this order: x, y, x, y, x, z, x, y, x, y, x, z
View 1 Replies
Jul 13, 2010
I'm passing a Javascript Array() to Flash via FlashVars but Flash complains. Can you guys point me what am I doing wrong here?
javascript code
// array with the user defined cities
var usercities = new Array(
[code]......
View 3 Replies
May 26, 2011
I'm trying to use a SWFLoader to load an Application and add the loaded Application to my Displaylist.
public function onComplete(e:Event):void {
someContainer.addChild((e.target.content));
}
[code]......
View 3 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
Feb 4, 2010
i have two arrays of DesplayObjects and i want to add all the objects in the second array to the end of the first array, i knew that i just can just do a loop and puch em into the array, but i wondered if there was a simple function for doing this?
View 3 Replies
Sep 2, 2010
I have a Array of objects which is something like this :
SomeObject (Array)
[0] (object)
id = 1
[code].....
View 4 Replies
May 28, 2009
I am having some trouble understanding the display list. This might sound silly but how long does it take until a sprite is added to the display list?
My understanding is that the root variable is only accessible once the object is added to the display list.In the following code I add the TLSEntry_Text to the display list and then on the next line I try to trace its root variable without luck. The root variable appears only in the enter frame event... I guess a little bit later.
What am I missing here? Is there a way for the display list to "force refresh" itself?
[Code]...
View 5 Replies
Feb 7, 2011
Is there any event dispatched in ANY place of the display list if the order of display list items change?Or is there any other way to track that without manually keeping track of all display list order or needing to override all "setChildIndex" and "swapChildren" functions?
View 2 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 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
Mar 25, 2011
I'm working on a drag-drop solution, and acting when a item is dropped on the current target (let's say an "intelligent chess-board") is a breeze, as the board fires DragEvents when items are hovering over on dropped on the it.
What I'm looking for is a way to make the board act when an item is dragged OFF the itself. Of course - when the item is dropped somewhere else, I could fire an event there and tell the board that change has been done. But this is what I want to avoid.
I wonder if there is some way to monitor a change in the displaylist of the "board", so it fires an event when a child/element is removed from "outside"?
View 1 Replies
Jul 18, 2009
I am just trying to grasp a simple concept of utilizing loops, addChild, and eventListeners.My goal is to use a loop to create multiple instances of the same type of object from my library (called Ball), and when one is clicked, have it move "above" all other instances on the stage (and eventually drag, but that's easy enough to make happen later).My current code attempt is:
for(var i:uint = 0; i<=10;i++)
{
var my_ball:Ball = new Ball() //new instances of Ball from library export
[code].....
View 2 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
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