ActionScript 3.0 :: Weak References Can Be Used For Memory Optimization?
Mar 5, 2010
i heard that weak references can be used for memory optimization, but i really don't understand what it is. does anyone around here know a good tutorial, blog or something that covers this issue?
View 2 Replies
Similar Posts:
Dec 12, 2009
The default value for weakReference in the call to addEventListener() is false. Many memory issues can be resolved by using weakReferences; in fact, some industry experts "strongly recommend always using weak references with listeners".If this is the case, can someone provide me with a good reason why weakReference defaults to true? (Note that I'm not asking why someone would ever want a listener that is not a weakReference, but rather why weakReference=false is the default)
View 2 Replies
Jan 12, 2010
I was having a weird problem on my Mac when creating a loader.
PHP Code:
var myUrlRequestURLRequest URLRequest(imageurl);myImageLoader Loader();myImageLoader.contentLoaderInfo.addEventListener(Event.INIT, imageInitHandler, false,
[code].....
View 0 Replies
Dec 11, 2009
The default value for weakReference in the call to addEventListener() is false. Many memory issues can be resolved by using weakReferences; in fact, some industry experts "strongly recommend always using weak references with listeners".If this is the case, can someone provide me with a good reason why weakReference defaults to true? (Note that I'm not asking why someone would ever want a listener that is not a weakReference, but rather why weakReference=false is the default)
View 4 Replies
Apr 19, 2010
As I currently understand, if an event listener is added to an object with useWeakReference set to true, then it is eligible for garbage collection and will be removed if and when the garbage collection does a sweep.
public function myCustomSpriteClass() //constructor {
this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener, false, 0, true);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener, false, 0, true);
}
In this case, is it not appropriate to initialize an object with weak references event listeners, incase the garbage collector does activate a sweep removing the objects event listeners since they were added during initialization of the object? In this case, would it only be appropriate to create a type of deallocate() method which removes the event listeners before the object is nullified?
View 1 Replies
Aug 29, 2011
I understand how weak references work, but I am bit confused regarding it's use in actionscript event listeners. Consider the example below:
public class Rectangle extends MovieClip {
public function Rectangle() {
var screen:Shape=new Shape();
[code]...
If the Rectangle object has no other references, then it is a candidate for garbage collection, but since there is an event listener within the object, the event dispatcher holds a reference to the object, even though there are no other references to the object(other than the one held by the event listener). Hence it is prevented from being garbage collected. Is this the reason why weak event listeners are prescribed? Is the flash player so naive that, it cannot figure out that the event listener is defined within the same object?
View 1 Replies
Aug 5, 2009
I've been teaching myself actionscript 3 over the past month or so and recently ran into an issue where an object kept doing things after I thought it had been removed. I figured out that the problem was caused by an event listener using the default of useWeakReference = false and I'm wondering why that's the default. what is the advantage to not using a weak reference? and why is that the default? it seems to me that in general you'd want to use weak references, so I must be missing something.
View 4 Replies
Apr 15, 2011
I have a simple air app that is deployed on a server. All it does is that it makes a httpService request to a webpage every 5 mins. For some reason, it starts out at out at 25MB memory utilization (Task manager), and every day, it adds about 1MB on top of that. I can't figure out why its sucking up memory. I have an eventlistener for the timer in the initialize of the app.I have read a few articles about memory optimization and best practices for air app development. They say you should remove the event listeners after they have fired. But if I do that, the timer will not fire any functions after it fires once.[code]
View 2 Replies
Jan 12, 2011
I am working on a touch screen project right now. There is a chance that the touchscreen will never be turned off, so I have to be very aware of the memory issue with the pc. I don't want the memory to keep building up and eventually it just freezes up the pc. Basically, I have separated each section into a separate swf. The idea is to load only the swf that is needed in order to optimize memory usage. I tested the app on a pc, when looking at the "processes" in the window task manager, it seems the memory used will just keep increasing as I navigate through the application, it seems to me it just keeps piling up external swfs in the application, but sometimes the memory will just suddenly decrease. And when the touchscreen application is idle, the memory will drop too.
The following code is what I used to load and unload the external swf. Did I do it right? Is there anything that may have left unnoticed that is still staying in the memory? Is there any other way to optimize the memory usage too?
ActionScript Code:
var prevLevel:* = this.parent;
var currentPage:MovieClip;
var oldPage:MovieClip;
var bgID:String;
[Code] .....
View 0 Replies
Jun 8, 2010
As I understand it if I set the weak reference param to true in my event listeners I don't need to worry about removing the listeners. I'm not really clear what would cause the listener to be set for garbage collection. I would hate to have a situation where the listener was removed before I wanted it to.
View 2 Replies
Feb 4, 2010
I just started using Swiz, and, it seems like Swiz forces you to create classes with weak encapsulation. Swiz requires all event handlers to be public in order to mediate events.
Assume that component 'A' dispatches a few events, which I want to listen to in component 'B'. Traditionally, I'll just add event listeners on 'A' in 'B' and all the event handlers in 'B' can be kept private. However, if, I am using Swiz, I need to make all the handlers, mediating events, public.
View 4 Replies
Dec 18, 2009
So there I was, creating a small app that allowed user to upload custom images. Everything went smooth, until......<insert horror music here> So you want to validate that its an image, and not something else. Well you restrict it with the File filter...but there are ways around that. So as a double check, you check the file type after a file is selected. <drum roll>
Awesome, the type method returns null if the image doesnt have the proper headers....what the hell....So most images are compressed for smaller file size, thus the headers are stripped out. So...Type method appears to be useless....There was a simple way around this using the name method..but what the hell...type method is weak!!
View 4 Replies
Aug 29, 2011
My problem is basically as follows. There is an instance of a class extending EventDispatcher. Everything goes well when I add event listener to the object like this:
[Code]...
Now someFunction is not called even though the line containing dispatchEvent('eventName') is being executed just like before (and there is an external reference to myObject as well). The application I'm developing is quite complex so, unfortunately, I can't post the exact code.
View 2 Replies
Jan 31, 2012
I have a bit trouble with LoaderMax memory occupy, i have a queue, and i am keep loading images depend on user's action. if they click load more and it keep load, but i would like to clean the memory which been occupied by the previous queue (i have remove all the children been added by the loading previously). is there a way i can do it? the behavior like this.
[Code]...
View 1 Replies
Sep 26, 2010
I have an FPS monitor running and notice that I am getting choppiness here and there, bringing my game from 40 to 27 fps and back and forth at certain stages. I have an idea of where it is happening, but do not know for sure. I looked up quite a few memory monitors but haven't found anything decent yet. Is there a memory monitor that allows you to see the memory leaked and find its location? If not, how about just he memory leaked?
View 4 Replies
Aug 2, 2007
I'm making an isometric game and I need to know which takes less memory for scrolling, making everything invisible that you can't see? Like if(!this.base.hitTest(worldHitter))this._visible = false; Or would it be better to remove the movieclips unseen and then reattach them when i should see them?
View 2 Replies
Jul 28, 2009
making a flash game that has a lot of rather complex illustrator graphics. In the game you walk down a street, so all the graphics has to be moved every frame. In some levels where there are a lot of objects in the street the game starts to lag. after importing it to flash and making a mc of it, break it apart to save flash from drawing all the shapes that aren visible anyway?
View 2 Replies
Nov 12, 2010
just uploaded my first flash website..and I'm having difficulty working out how to get google to 'see' it.
I've registered the site with google and have a very specific phrase in the <title> tag of the html code but the more I investigate, the more complicated it seems..Can anyone point me towards a step by step tutorial or something to get my site in the top 10 results?
View 5 Replies
Aug 23, 2010
Is there any program or setting for "pointing" flash programs at my graphics card rather than leaving it to the processor and RAM alone? I am running a specific frontend software that is a flash executable- unfortunately it lags heavily on execution despite the fact that I have a very nice video card installed.
View 3 Replies
Feb 18, 2011
I have read all the documentation and more on optimizations. My question is that if you have to resize sfws for different mobiles is it best to have a res thats the biggest mobile and the rest we can use fullscreen. Or is it best to make a smaller swf and have it size up to full screen. Obviously we are not going to create an swf in 20 sizes. By the way, is it MORE processor hogging for a mobile to size down a 800 by 600 standard swf than to downsize an swf thats only a little larger than the mobile screen.
View 4 Replies
Nov 8, 2011
I'm itching to find the most effective way of importing my illustrator vectors into flash but keeping the file size as small as possible. At the moment i'm literally copying my vectors in illustrator and pasting them in Flash, it clearly works but the file sizes seem really high and its hindering the performance of my fla. Is there a more effective way of exporting? or optimizing the imported vectors once they're inside flash?
View 1 Replies
Oct 20, 2003
I have a script as follows attached to an MC that is pretty processor intensive (well, that is when the MC is duplicated 30 times). I'm looking for some input from people on how to possibly optimize this to cut back on how badly it lags the rest of the movie. My computer is quite powerful but it still shows performance issues with this script:
[AS]
onClipEvent(load) {
//size of purpleCloud's active area
[code].....
View 3 Replies
Jun 28, 2005
I have a client that I built a wonderful flashed site for (html page embedd). It isn't getting any attention on google compared to other completely html based sites. How can I tweak this situation for more google searchability?
View 14 Replies
Feb 11, 2010
today i started some particle generator class that will move particles over the stage via drawing in a Bitmap. Everything works well with low amount of particles, lets say 1000, but for my surprise when i added 10 000 particles the frame rate dropped drastically. And i am saying that since i made the same particle generator using MovieClips instead of drawing in Bitmap, the performance test i run on both classes showed that the Bitmap class with 10K particles on my PC works in around 10-12 FPS, and the MovieClip variation in around 20-21 FPS with the same amount of particles. The particles are identical and both classes are using linked list system to move the particles. So the only logical conclusion is that something is not right with the drawing function.
Code:
private function drawParticles(e:Event):void{
// clearing the _pZone Bitmap of the previous data
_pZone.bitmapData.fillRect(_pZone.bitmapData.rect,0);
_pZone.bitmapData.draw(_blankMc);
[code]...
View 1 Replies
Aug 24, 2010
I wrote an application in flash AS3, and when I trace from flash the total memory usage of the total application is only about 9MB, But at the same time Task Manager Shows the memory usage as 110MB. Around 100MB difference.Flash Trace Method System.totalMemory difference of the Trace from the Beginning of the application to end of the application.
View 2 Replies
May 6, 2010
package uk.co.bigroom.utils
{
import flash.utils.Dictionary;
/**
* Class to create a weak reference to an object. A weak reference
[code]....
In this Class, how they denote one as Weak Reference and one as Strong reference.
View 1 Replies
Aug 25, 2010
I have live streaming but problem is that it is stopping and continues every 2-3 second, I do not know which issues causes it.
View 3 Replies
Jan 28, 2011
I am trying to improve the frame rate of a game that draws many floor tiles. Currently, the floor tiles are vector graphics and stored as different frames in a movie clip. I wanted to experiment with rasterizing a floor tile and seeing if that would provide any frame rate boosts. I did this by converting one of my tiles (one of the frames in my movie clip) to a png and replacing the vector version of this tile with this raster version. I then tested two worlds--one filled with tile A (vector) and another filled with tile B (png).
In all my tests, world with tile A (the original vector version) outperformed the world with tile B. I am guessing that the reason I am not getting the expected performance gains is because I am still rendering the tiles in the old style and not using any strict bitmap drawing calls?why it is that this method fails to boost rendering speed? Would I have to switch my rendering code to strict bitmap draw calls?
View 7 Replies
Jun 16, 2009
What are people using to increase their natural listing or rankings in search engines, etc for their flash websites.
What methods or ways are people using to search Engine optimize their Flash websites. Are people building their Flash website a certain way for SEO?
View 2 Replies
Dec 11, 2009
It is possible to enabled hardware optimization (wmode) from haxe?
View 1 Replies