A Preloader to load the SWF

Using Pano2VR/Object2VR SWF files with your own Flash projects
bernielove1
Posts: 12
Joined: Fri Feb 05, 2010 9:12 pm

I created a web page that contained my swf file. When the page is loading it takes about 15 seconds for the SWF file to start loading. I wanted to add a separate preloader to show the progress. It works but when it loades it only shows my navigation buttons and hotspots. The rest is white. Here is what it looks like (http://www.photosynergy.net/hannesbecke ... ltour1.htm). Can anyone help me with this?

Thanks for your time,

Bernie
smooth
Posts: 1493
Joined: Sat Sep 09, 2006 7:30 pm

Where is the white coming from? It is a layer within the panorama that you have added and you need to either remove it or add a command for it to be hidden once loaded like:
On Load>Hide Element>White White being whatever you have named it.

Regards, Smooth 8)
Image
bernielove1
Posts: 12
Joined: Fri Feb 05, 2010 9:12 pm

No there is no layer of white or anything like that. I used Flash to create the preloader and someone on the Flash forum said "you have a compiler error in one of you swfs. you're trying to reference an object that doesn't exist at the time you're trying to reference it." To fix the problem I would have to have the FLA file (I believe). So I was wondering if I could create a preloader within Pano2vr? Here is the web page with the problem (http://www.photosynergy.net/hannesbecke ... ltour2.htm) and here is the page without the preloader (http://www.photosynergy.net/hannesbecke ... ltour1.htm).

If anyone can help I would be much indebted to you,

Bernie
smooth
Posts: 1493
Joined: Sat Sep 09, 2006 7:30 pm

Are you only using Pano2VR or are you writing something else with Flash?
Where is this pre-loader coming from and how is it made?
Upload your skin project file (the .ggsk file) or files if you have more than one.

Regards, Smooth 8)
Image
bernielove1
Posts: 12
Joined: Fri Feb 05, 2010 9:12 pm

I used Pano2VR to create the panorama an then used Adobe Flash to create a preloader. Here is the code for the Flash preloader-

var myRequest:URLRequest = new URLRequest("livingroom.swf");
var myLoader:Loader = new Loader();
myLoader.load(myRequest);
myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress) ;
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showContent);
var myPreloader:Preloader = new Preloader();
function showPreloader(event:Event):void {
addChild(myPreloader);
myPreloader.x = stage.stageWidth/2;
myPreloader.y = stage.stageHeight/2;
}
function showProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
myPreloader.loading_txt.text = "Loading - " + Math.round(percentLoaded * 100) + "%";
myPreloader.bar_mc.width = 198 * percentLoaded;
}
function showContent(event:Event):void {
removeChild(myPreloader);
addChild(myLoader);
}

I have also included my skin that I am using. The preloader that I am using in the skin doesn't appear at the very beginning of the loading process but after the SWF is loaded and when the image starts to appear. That is when the skin preload starts. I need a preloader that starts when the SWF file starts to load in the HTML page. When people view it they see a blank white screen for about 15 seconds (depending on their connection speed) as the SWF loads. I need a preloader at that point. Not when the images of the panorama starts.
Reflections.ggsk
(117.77 KiB) Downloaded 507 times
bernielove1
Posts: 12
Joined: Fri Feb 05, 2010 9:12 pm

Does Pano2VR use Action Script 2 or 3 in it's coding?
bernielove1
Posts: 12
Joined: Fri Feb 05, 2010 9:12 pm

When I test the preloader in Flash I get this-

init panorama player...
Sound:_background
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at PanoCube/init()
sound loaded _background
uhh... init stage
*** Security Sandbox Violation ***......

Is there something I can do to fix this?
User avatar
360Texas
Moderator
Posts: 3684
Joined: Sat Sep 09, 2006 6:06 pm
Location: Fort Worth, Texas USA
Contact:

Does Pano2VR use Action Script 2 or 3 in it's coding?
In pano2vr, when you get ready create your flash pano the default is Flash viewer version 9/10 in which case you would use Action Script 3

OR you can manually change the default to Flash 8 where you would use AS 2... but you loose quality. It renders course, and rotation is choppy.
Dave
Pano2VR Forum Global Moderator
Image
Visit 360texas.com
User avatar
360Texas
Moderator
Posts: 3684
Joined: Sat Sep 09, 2006 6:06 pm
Location: Fort Worth, Texas USA
Contact:

*** Security Sandbox Violation ***......

Just guessing, you probably are using a panorama rendered with Flash 9/10 with AS 2 code

Flash authoring folks might know more
Dave
Pano2VR Forum Global Moderator
Image
Visit 360texas.com
erik leeman
Posts: 470
Joined: Sat Sep 09, 2006 10:51 am
Contact:

Did you have a look at the ActionScript code and instructions Thomas provided on this page by any chance?

http://gardengnomesoftware.com/wiki/Pano2VR_-_Flash_API

Erik
bernielove1
Posts: 12
Joined: Fri Feb 05, 2010 9:12 pm

I took a look at it but I am not that well versed in AS. Is this a good start to add a preloader? Can you explain it a bit for me?

Much appreciated
User avatar
360Texas
Moderator
Posts: 3684
Joined: Sat Sep 09, 2006 6:06 pm
Location: Fort Worth, Texas USA
Contact:

I personally do not have or use Adobe Flash CS4x
Dave
Pano2VR Forum Global Moderator
Image
Visit 360texas.com
erik leeman
Posts: 470
Joined: Sat Sep 09, 2006 10:51 am
Contact:

Only use ActionScript 3.
Copy this bit, and adapt it so your .swf filename, URL and dimensions replace the example name and dimensions Thomas used:

Code: Select all

import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
var loader:Loader;
loader = new Loader();
var url:String = "park.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'
	vr.isFlash10=false; // Disable Flash 10 rendering if the container is Flash 9
}

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(200,100); // resize the window
		vr.pano.setWindowPos(200,200); // 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

Last edited by erik leeman on Mon Feb 08, 2010 11:03 pm, edited 3 times in total.
erik leeman
Posts: 470
Joined: Sat Sep 09, 2006 10:51 am
Contact:

Then add your load indicator code, like this for instance:

Code: Select all

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);

function loop(e:ProgressEvent):void {
	var perc:Number = e.bytesLoaded / e.bytesTotal;
	percent.text = Math.ceil(perc*100).toString();
	LoadIndicator.width = perc * 400;   // my loadindicator is 400 pixels wide at 100%
}
Oh, and you don't add a preloader to all this, the code Thomas provided IS a preloader!
That last bit of code only adds a growing graphic to it, to give some feedback regarding loading status to the person waiting.

However, to do all this only for that loading indicator is silly, it is MUCH easier to make one using Pano2VR's own skin editor!
Have a look at this tutorial video to see how it's done:
http://gardengnomesoftware.com/tutorial.php?movid=06_3

Erik
bernielove1
Posts: 12
Joined: Fri Feb 05, 2010 9:12 pm

I think I don't have the code right. This is what I have-

import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
var loader:Loader;
loader = new Loader();
var url:String = "http://www.photosynergy.net/hannesbecker/livingroom.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'
vr.isFlash10=false; // Disable Flash 10 rendering if the container is Flash 9
}

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(800,480); // resize the window
vr.pano.setWindowPos(200,200); // 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
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);

function loop(e:ProgressEvent):void {
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
LoadIndicator.width = perc * 800; // my loadindicator is 400 pixels wide at 100%
}

All I get is a white screen
Post Reply