FullScreen without any button, Yes We Can!...but

Using Pano2VR/Object2VR SWF files with your own Flash projects
Post Reply
erik leeman
Posts: 470
Joined: Sat Sep 09, 2006 10:51 am
Contact:

I've made a testpage with thumbnails that when clicked on open a Flash panorama directly in fullscreen mode.
Here's a link:
http://tinyurl.com/Direct-to-FullscreenPano

As such it is no problem to make this happen with a small Flash application as a helper, but like always there's some snakes in the grass.

Problem 1:
Letting that helper open a pano 'the normal way' takes forever, the (default) progress indicator in the skin seems to never end counting, and sometimes the pano doesn't load completely at all.
In short: this method of loading panos is to be avoided like the plague!
However, if I suppress visibility of the loading Pano and let my own progress bar in the helper do the counting, that very same pano loads like lightning!
Explanation? I have no idea!

Problem 2:
Pano2VR skin elements have a strange (= bad) effect on processor load.
A pano with one or two buttons doing absolutely nothing generates significant CPU usage, whereas the CPU shows no activity with a version of the same pano without any buttons.
Explanation? I have no idea!

Problem 3:
After closing the pano the memory it used isn't released.
Looking at the Forum history this is a well known problem, but the cure was supposed to be to remove the skin, and I did remove the skin!

vr.cleanup();
removeChild(loader);
vr.pano = null;
loader.unloadAndStop();

Seem to work, but my traces tell me this:

loader.content = null
vr.pano = null
vr = [object PanoPlayer]
loader = [object Loader]

And memory is NOT released!

These are serious obstacles for using (a series of) Pano2VR panoramas inside bigger Flash applications, and it would be VERY nice if they could be removed!

Cheers!

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

YESSSS!!!! I've found a solution for the memory problem!
Or at least for most of it anyway : D
In short, I've done this:

Code: Select all

	if (vr.pano) {
		vr.pano.bmpTile[0].dispose();
		vr.pano.bmpTile[0] = null;
		vr.pano.bmpTile[1].dispose();
		vr.pano.bmpTile[1] = null;
		vr.pano.bmpTile[2].dispose();
		vr.pano.bmpTile[2] = null;
		vr.pano.bmpTile[3].dispose();
		vr.pano.bmpTile[3] = null;
		vr.pano.bmpTile[4].dispose();
		vr.pano.bmpTile[4] = null;
		vr.pano.bmpTile[5].dispose();
		vr.pano.bmpTile[5] = null;				
		loader.mouseChildren = false;
		vr.pano.cleanup();
		removeChild(loader);
		vr.pano = null;
		loader.unloadAndStop();
	}
And as far as I can tell this method releases MOST of the occupied memory.
Most but not all, because I still get these traces:

loader.content = null
vr.pano = null
vr = [object PanoPlayer]
loader = [object Loader]

and I can see the pano object is still active after closing it, which is a p.i.t.a.
Anyway, my pagefile doesn't grow and grow and grow after opening a series of panos anymore.
Which is nice : )

Cheers!

Erik
mrt
Posts: 56
Joined: Mon May 19, 2008 1:22 pm

HI Erik,

This is GREAT!!!

You've no idea how much I've been trying to sort this out...

Cheers,

MrT
mrt
Posts: 56
Joined: Mon May 19, 2008 1:22 pm

Hello again,

Problem still isn't resolved...

When running the swf using flash everything works fine and the memory problem is sorted. However, once it's uploaded onto my site and I run it in a brower (firefox) I get the following message:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at PanoCube/cleanup()
at mp36_loader_fla::MainTimeline/close_pano_and_ful
l()

I'm loading the pan into a 4 frame swf.

Frame 1 code (to load the vr) is:

Code: Select all

import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
var loader:Loader;
loader = new Loader();
var url:String="mp3.swf";
var urlReq:URLRequest = new URLRequest(url);
var vr:MovieClip; // panorama movieclip

// This is done after the swf is loaded.
function finished_loading (e:Event) {
}

function initHandler(event:Event):void {
	trace("initHandler: " + event);
	vr = MovieClip(loader.content); // cast 'DisplayObject' to 'MovieClip'

}

function initPanorama(e:Event) {
// check if the panorama object is available and initialize it
	if ((vr!=null) && (vr.pano!=null)) {
		removeEventListener( Event.ENTER_FRAME , initPanorama);
		vr.pano.setWindowSize(900,412); // resize the window
		vr.pano.setWindowPos(0,63); // reposition
	}
}
// call initPanorama every frame
addEventListener( Event.ENTER_FRAME , initPanorama);

// Tell the loader to call 'finished_loading' after the swf is loaded.
loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
// Tell the loader to call 'initHandler' after the swf is initialized.
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.load(urlReq);
addChild(loader); // add your swf directly to the stage
Frame 2 code (to close the vr and open it in a new full screen window or just close the vr)

Code: Select all

stop();

close.addEventListener(MouseEvent.CLICK,close_pano);

function close_pano(e:Event):void {
         if (vr.pano) {
          vr.pano.bmpTile[0].dispose();
          vr.pano.bmpTile[0] = null;
          vr.pano.bmpTile[1].dispose();
          vr.pano.bmpTile[1] = null;
          vr.pano.bmpTile[2].dispose();
          vr.pano.bmpTile[2] = null;
          vr.pano.bmpTile[3].dispose();
          vr.pano.bmpTile[3] = null;
          vr.pano.bmpTile[4].dispose();
          vr.pano.bmpTile[4] = null;
          vr.pano.bmpTile[5].dispose();
          vr.pano.bmpTile[5] = null;            
          loader.mouseChildren = false;
          vr.pano.cleanup();
          removeChild(loader);
          vr.pano = null;
          loader.unloadAndStop();
       }

   gotoAndStop(3)

}


full.addEventListener(MouseEvent.CLICK,close_pano_and_full);

function close_pano_and_full(e:Event):void {
       if (vr.pano) {
          vr.pano.bmpTile[0].dispose();
          vr.pano.bmpTile[0] = null;
          vr.pano.bmpTile[1].dispose();
          vr.pano.bmpTile[1] = null;
          vr.pano.bmpTile[2].dispose();
          vr.pano.bmpTile[2] = null;
          vr.pano.bmpTile[3].dispose();
          vr.pano.bmpTile[3] = null;
          vr.pano.bmpTile[4].dispose();
          vr.pano.bmpTile[4] = null;
          vr.pano.bmpTile[5].dispose();
          vr.pano.bmpTile[5] = null;            
          loader.mouseChildren = false;
          vr.pano.cleanup();
          removeChild(loader);
          vr.pano = null;
          loader.unloadAndStop();
       }

gotoAndStop(4)
}
frame 3 code

Code: Select all

stop();
frame 4 code (to launch the full screen vr in a new window)

Code: Select all

import flash.net.URLVariables;
import flash.net.URLRequest;
stop();



var link:URLRequest = new URLRequest("http://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.html");
navigateToURL(link);
Does anyone have any idea how to solve this?

Thank in advance.

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

Hi MrT,

What I would do is to rewrite and place all those bits of code in one single layer of one single frame (if possible).
Try to avoid using the time line if you can do it all in ActionScript.

Cheers!

Erik
mrt
Posts: 56
Joined: Mon May 19, 2008 1:22 pm

Thanks for getting back to me Erik,

I could blag my way around AS2 but am new to AS3 and have no idea how to go about putting these functions into 1 frame. Do you know of a template anywhere that would have the desired effect? It seems like the sort of thing that would be of use to a lot of people... Otherwise, could you point me in the direction of a url / book that I could learn the necessary skills from? I need something very basic as I have no programing skills other than a handfull of AS2 commands. I've been trying to solve this problem for months and it's driving me mad 'cos I've got load of nice vrs but can't present them in the way that I want to.

Thanks very much for your help.

MrT
Post Reply