Closing Pans after opening them in Flash (Followup)

Using Pano2VR/Object2VR SWF files with your own Flash projects
Post Reply
Posts: 5
Joined: Wed Feb 24, 2010 11:48 pm

Closing Pans after opening them in Flash (Followup)

Post by MikeyLPT » Tue Mar 02, 2010 4:52 pm

This is a followup on "noob question."

Hey guys. I really appreciated the help in directing me to the wiki which gave me the AS code to open an .swf panorama in a flash project. The one pan I used as a test pulls up and looks great. I quickly found out that was only half the battle though. When opening the object as external object, it just stays up. I can still navigate around my flash project with the buttons, but the panorama just sits on top. I don't know how to close it. I need to have something like 7 or 8 panoramas in this particular project, and the ability to close them with a simple button that looks like an "X". The button is already there, and has it's direction to go back to frame 1, I just need to know how to close each pan, so that upon clicking the "X," the pan closes at the same time they go back to frame 1. So my question is:

How do I close an .swf panorama in a flash project that has been loaded as an external object via the wiki as linked HERE? Can I do it with the same simple button that directs the project back to frame 1, or does it have to be in the same placeholder that opens the .swf?

Many thanks!


erik leeman
Posts: 470
Joined: Sat Sep 09, 2006 10:51 am

Re: Closing Pans after opening them in Flash (Followup)

Post by erik leeman » Tue Mar 02, 2010 8:00 pm

The interactive Pano2VR Flash panorama you loaded into your Flash application is 'just' an interactive object like any other you might create yourself before adding it to the Stage.
It has the same properties, like visibility, so it should also be possible to remove it from the Display List and memory when you've seen enough of it.

So you could do a vr.visible=false; or to get completely rid of it even do a removeChild (vr); followed by a vr = null; and be done with it.
Or should it be vr.pano.visible = false; ? and removeChild(vr.pano); plus a vr.pano = null; ?
Or should it be removeChild(loader); plus a loader = null; ?

Alas it's not quite that simple, in the Wiki Thomas tells us this:
If you like to remove the panorama use the following code:


You need to call the cleanup method to avoid errors like "Cannot access a property or method of a null object reference" because ActionScript doesn't provide a destructor for objects.
Several people (me included) have found this does not appear to free the memory the panorama occupied.
However, a lot of that memory can be retrieved by brutally erasing all six cube faces one by one like described here: ... =18&t=4198
But if anyone has a better idea or method I'd sure like to hear about it!

If you want more info about "Unloading SWFs with 'stage' References in AS3" you could have a look here: ... ading.html ... lipAS3.htm ... -7ffc.html


Posts: 5
Joined: Wed Feb 24, 2010 11:48 pm

Re: Closing Pans after opening them in Flash (Followup)

Post by MikeyLPT » Tue Mar 02, 2010 9:54 pm

As before, you've been very helpful Erik! I'll take an in-depth look into all this when I get home tonight. Thanks!

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest