This content has been marked as final. Show 4 replies
You could try changing the scope of the component being popped up. For example, if you are using a TitleWindow you could make the TitleWindow a property of your Application. That way there is only one TitleWindow instance and the PopUpManager is just adding it and removing it from the Display List (as well as doing the other PopUpManger stuff). In a lot of the popup examples I have seen, the TitleWindow is creates as a variable within a function and so a new instance is created each time the function is called. Not really an issue with most non-visual variables as they are destroyed when the function is complete but with some visual components if there are strong references to the component (event listeners, registered with StyleManager, etc), that component may never be completely destroyed. I haven't tested this theory but it may be worth trying.
Thanks dazweeja , that workaround works too. It limits the damage to one instance in memory.
I agree with your diagnosis.
Variables declared within a function that are explicitly set to null would ideally be 'fully' marked for the Garbage collector somehow once the function is out of scope. (By 'fully', I mean that all children of that object should also be destroyed). PopupDialogs don't do that.
Personally, using global variables is fine by me but it's not a very aesthetically appealing solution for some.
Do you have a code example for me please?
I am using the popup for a piece of code that takes some time to run.. and when its done running i remove the popup. But when i run the script again, my popup doesn't appear. :(
Here the code i use:
private var pop2:Canvaspopup;
public function imageSelected(event:Event):void // i cum here on the select event from a file dialog box.
pop2 = Canvaspopup(PopUpManager.createPopUp(Application.application as Sprite,Canvaspopup,true));
// here i do some image stuff like use a loader for the selected image
public function handleImageComplete(event:Event):void //when the loader is complete i cum here
// do some image resizing and saving
sorry for my question.
in the imagecomplete handler i set pop2 = null
in the image select handler my if is always false so it never makes another popUp