ActionScript 3.0 :: Loader Get Removed (garbage Collected) Whilst Its Still Loading?
Oct 23, 2009can a loader get removed (garbage collected) whilst its still loading? does it have to be added to the stage or to an array?
View 3 Repliescan a loader get removed (garbage collected) whilst its still loading? does it have to be added to the stage or to an array?
View 3 RepliesWill a DisplayObject be garbage collected if the only reference keeping it in memory is set to null, but it's not removed from the display list?
View 1 RepliesConsider the following segment of code:
[Code]...
Do not worry about the syntax of this code. Here is my concern - The loader object which is used to send the HTTP request and which has the onLoadComplete event registered to is not referenced from outside the loadSomeContent() function. Is there a possibility that the loader object will be garbage collected and loadCompleteHandler() will never be called?
I just noticed a strange behaviour while looking at my application in the Flash Profiler. When I click a button in my TitleWindow then the TitleWindow doesn't get garbage collected after it is removed. I have no idea why that is happening.[code]...
View 2 RepliesI have checked and rechecked, and I do not know why these "buckets" aren't being killed when I run the reset menu function, a fresh set of eyes could really help.
Code:
package com.Views {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
[Code]...
i'm sure there are a lot of problems, but the only one I care about is destroying those buckets. inside the buckets, I have a listener for "removed from stage", and that kills all the listeners, etc, inside the buckets.
there is a Class A, it has a timer which updates its x position periodically. So all the instance of Class A will update their own x position. There is another Class B which extends Class A and overrides the function which updates position to change y position and call the trace function.
Now what I do now is create two instance alpha1, alpha2 of Class A and other two instance beta1, beta2 of Class B.
- alpha1 is only instantiated, but not added to the stage.
- alpha2 is instantiated, and there after added to the stage.
- beta1 is only instantiated, but not added to the stage.
- beta2 is instantiated, and there after added to the stage.
- let say after few seconds, I remove alpha2 and beta2 from stage.
Now suppose the GC fires collection, who all would be collected ?
I have that function in the class:
private function fireItemCreated(data: ByteArray): void {
setTimeout(function(): void {
var event: ItemCreatedEvent = new ItemCreatedEvent(data);
dispatchEvent(event);
}, 1000);
}
This function called to dispatch item created event when image thumbnail created.But it delays event on some time to prevent user interface freezes. And I'm guessing what could be happen if garbage collector executes after fireItemCreated function call but before timer event. Does the closure will be removed or it stays until it will be executed?
I'm trying to set up a test that will tell me whether a variable exists in memory or not. I'm running into the problem of my nested function preserving the local variable it uses, called "shouldBeDead". Here's my best effort, which doesn't work for me because the "shouldBeDead" variable is still alive[code]...
View 4 RepliesI recently posted on here about tweening in alphas of thumbnails that I was adding to a movieclip. It seems that the tween is getting garbage collected because not all of the thumbs fade in all the way. I have the tween defined outside of the function, but it is tweening a loader that is created within the function. Could this cause the tween to get garbage collected? if so, how do I fix it?
Here is the pertinent code:
var thumbTween:Tween;
var my_thumb:Loader;
function thumbLoaded(e:Event):void{
[code]...
I have had a few complications with syncing the notes coming down, then I realized tweens would be the best way to go, so I chose them.The problem is; the notes come down the screen. If there is any lag in performance, any note that is on the screen freezes on the spot, and the new notes come down, and stay in sync.This is telling me it's something to do with the tweens. The timeOuts I have set work fine for spawning notes at the right time, but the tweens are freezing on occasion, Im guessing because the timer for the tween keeps going, but flash does not notice it.Here is the code for adding the notes:
Code:
var myTween:Tween;
var timeWindow = 1;
[code].....
I was told that if you load a new SWF into a loader that has an existing SWF that the second SWF will replace the object(the first SWF) in the loader and in the display list.Does this mean that the first SWF is removed from the stage once the second SWF is loaded? I am asking because I would like to know if my this.addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler1); in the first SWF will fire once the second SWF is loaded.
View 3 RepliesI was told that if you load a new SWF into a loader that has an existing SWF that the second SWF will replace the object(the first SWF) in the loader and in the display list.
Does this mean that the first SWF is removed from the stage once the second SWF is loaded? I am asking because I would like to know if my this.addEventListener(Event.REMOVED_FROM_STAGE, removedFromStageHandler1); in the first SWF will fire once the second SWF is loaded.
I was thinking about Flash GC the other day and came up with a question about how reference counting would work in the following 4 class scenario (assume GuiMain is the movie's document class):
[Code]...
i've list-based components. when i no longer require them, i just use removeChild() method. i've applied setStyle() method to them. i'm a bit consufed, do i really need to use clearStyle() method or without doing it, flash will take them in garbage collection?
View 2 RepliesI'm loading some images with Loaders, cloning the BitmapData to a new Bitmap, and adding the Bitmap as a child of a Sprite. So far, so good. I want the Loaders I'm using to be removed by garbage collection, which they seem to be. The problem, or so it seems, is that when the Loaders are cleaned up, the Bitmaps I'm creating lose their data.
Edit: All this is happening when a class is instanced, and many copies of this class are being used as actors in a game. As the Actors are being created the older ones are losing their BitmapData to garbage cleanup. When all of them are finally loaded, only the last few are visible. I've rewritten my posted code as a class. If I prevent the Loaders from being cleaned up by somehow keeping a reference to them, the Bitmaps don't lose the data, but I don't want these Loaders hanging around.
[Code]..
It's a simple slideshow of thumnails which load images on thumb press. It is working perfectly with images, but now I have to load aswf with a flv component. Again the swf with the flv loads, but if I play the video and then hit another thumb to load a new image, the video swf disapears, but I can still hear the sound playing in the back ground! How do I remove the sound?
I have tried unloading by
Code:
pictLdr.unload();
But its not right.
This is not all the code but where it needs to be looked at, the
Code:
closePressHandler
Is the point where I need the sound to stop playing.
[Code] .....
i have a big flash file that loads in but takes a noticeable amount of time to download. Its a header and i was just wondering if i could have an image instantly appear and then when the flash is downloaded seamlessly overlap it? Just wondering if there was an HTML to do this?
View 1 Repliesif i have a movie clip with an even listener attached to it, is the event listener being removed automatically when the movie clip is removed from the stage or should i always remove the event listeners manually?
View 4 RepliesI want to remove all children of the name (mc1) but be able to add new one when I call the add function again Heres what I have
// Draws the squares
Code:
function drawIt(e:Event=null):void{
mc1.graphics.lineStyle(1);
mc1.graphics.beginFill(ITsColor);
[code]....
Removing all the (mc1) movieclips works fine, but when i click on the butotn to call drawIt again, all previous mc1's are displayed again with the new ones
I am attempting to load multiple images in AS3 and I'm exploring different options on how this can be done.I would like to have to only use one Load() instance and handle the various image assignments in the onComplete handler...here is my first attempt:
var buttonLdr:Loader = new Loader();
buttonLdr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onLoadError);
buttonLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadCo
[code]....
Sorry for the complicated topic. I got a .swf that loads in other .swfs. Rather than figuring out how to make a loader for loading .swfs I thought I'd just use a simple loader in the .swf I'm loading.
However, it doesn't work. It starts fully loaded but doesn't finish. Heres the AS:[AS]_root.stop();
PercentLoaded = _root.getBytesLoaded()/_root.getBytesTotal()*100;
[code].....
I am creating an CS5 flash application that is based largely on a library for loading MP3 files located on a user's computer using file references.
The issue I am having is that each time a new song is loaded, most of the memory is garbage collected but a small amount remains. In most cases this would be fairly unimportant, but the purpose of the application involves the user selecting a large number of mp3 files.
I am a bit new to AS3 and OOP, but I have come to the conclusion that the memory leak is within the library classes. I have tested the library using the smallest amount of my own code I could, and the problem remains. I did make minor changes to one of the library files, but as far as I can tell it is not the cause.Here is a link to the library, the actual download link is the "MP3FileReferenceLoaderLib.zip" link part way down the page:[URL] Here is the code I have for the main .as file:
Code:
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.FileFilter;
[code]....
I'm building an image viewer that has violent content (video games), and so it requires users to enter their birthdays. Problem is that because of company policy, I can't expose any of the source images being viewed in the event that someone might use their resources/net tabs (or just sniff the request) and get the direct link to the image. (I know that they could screenshot it, but that's out of anyone's control and not something I'm worried about.)Is there anyway to inherently mask loaded resources (images)? I've been using sockets, which is great, but there's also the problem of actually loading the image binary (after HTTP request headers are removed) as a Bitmap in Flash.
View 4 RepliesI want to have an AS3 app load images from url supplied by the user. But I don't want a malicious user to be able to load an SWF file in place of the image, such as with an altered extension "maliciousSwf.png". Well, not sure how big a security threat that is above and beyond the ability of the hacker to decompile swf, but I think that ideally such behavior should not be allowed.
So, is there any way to prevent this? When people allow users to load images in their Flash apps, do they somehow guard against loading of SWF? Or is this really absolutely no big deal?
im working on an image viewer and im loading an image to a loader and then add the loader to the stage.I want the user to be able to drag and drop the image but since it's a loader i dont know how to do it.
I tried
imageLoader.startDrag = true;
imageLoader.content.startDrag = true;
but im getting an error on both.
This is the situation: I am trying to build an uploader that will take data collected earlier in the form before the upload occurs and then rename the uploaded file with it. I've gotten the upload itself to work, but thus far I have no luck getting any sort of renaming to work, not even by PHP. I tried Loadvars to transfer the variables over and rename it during upload, yet it says "NO" and rejects the post variables when the upload occurs. I even tried loading the variables into an external file and transfering them back to the uploader via cookie, all at the same time. Again it says "NO!", and the file is uploaded as __"filename".jpg. This is my code thus far:
[Code]...
I'd like to know for sure that my objects are deleted when I 'null' them and remove listeners etc..
I'm not sure if the debugger in CS4 has a way to display that kind of info. Is there some other way?
I am working in flex builder 3 with an XMLListCollection and have run into this (should be simple) parsing snag...The XMLListCollection Data:
<data>
<term name="NUMBERS">
<alt_form name="1"/>
[code]......
I am doing my first all out flash site without a template and tried several different ways to load a external swf file to the site vie ui loader... it works fine on my local computer but when i put it online the external swf doesn't show at all while the rest of the site does, and im not getting any error..
View 17 RepliesI've got a custom component (quite complex so I can't post any code here, although that shouldn't matter), that I can add to a view. When the component is deleted from the view or the view is switched I call my own dispose method which removes remaining eventListeners and kills some references so that the component can eventually be nulled and collected by the GC.
All that works perfectly fine until I add a Spark TextInput to the MXML part of the component (it took me hours to find out what is preventing the component to be collected!), so I recon that the TextInput somehow automatically adds some eventListeners.
My question is what are these listeners, or is there anything else I haven't thought of?