PanoCube/init() Error
Posted: Mon Apr 13, 2009 7:31 pm
Every time I load a pano in my flex app I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference. at PanoCube/init()
Does anyone know how to fix this or at least catch it?
Thanks.
Here's my Actionscript code:
/**
* loadWithCuepoints(swf:SWFLoader, cuePoints:Array) Loads a
* swf file onto the screen and places it. This allows us to use
* the media cache and to prevent downloading the same media over
* and over.
*
* @param - swf : SWFLoader
* @param - cuePoints : The cuepoints/links to display
* @return - void
**/
public function loadMedia(swf:SWFLoader, media:Media):void
{
url = media.mediaUsePath + media.media1Path;
loader = new Loader();
urlReq = new URLRequest(url);
vr = new MovieClip();
addEventListener(ResizeEvent.RESIZE, resize);
// call initPanorama every frame
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, initPanorama);
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
try
{
loader.load(urlReq);
}
catch(e:Error)
{
;
}
for(var j:int = 0; j < swfCanvas.rawChildren.numChildren; j++)
{
swfCanvas.rawChildren.removeChildAt(j);
}
swfCanvas.rawChildren.addChild(loader); // add your swf directly to the stage
}//end loadWithCuepoints
/**
* initHandler(event:Event) Casts the loader's content as a
* movie clip
*
* @param - event : The event that triggered this
* @return - void
**/
private function initHandler(event:Event):void
{
vr = MovieClip(loader.content); // cast 'DisplayObject' to 'MovieClip'
vr.isFlash10=false; // Disable Flash 10 rendering if the container is Flash 9
loadingTxt.visible = false;
}
/**
* initPanorama(event:Event) Sets the width and height as well
* as the position of the QTVR
*
* @param - event : The event that triggered this
* @return - void
**/
private function initPanorama(event:Event):void
{
// check if the panorama object is available and initialize it
if ((vr!=null) && (vr.pano!=null))
{
vr.pano.setWindowSize(swfCanvas.width, swfCanvas.height); // resize the window
vr.pano.setWindowPos(swfCanvas.parent.x, swfCanvas.parent.y); // reposition
}
}
/**
* resize(event:ResizeEvent) Invalidates the display
* so that the component will resize itself
*
* @param - event : The event that triggered this
* @return - void
**/
private function resize(event:ResizeEvent):void
{
invalidateDisplayList();
}
private var i:int = 0;
/**
* updateDisplayList(unscaledWidth:Number, unscaledHeight:Number)
* Updates the QTVR's size and position.
*
* @param - event : The event that triggered this
* @return - void
**/
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if ((vr!=null) && (vr.pano!=null))
{
vr.pano.setWindowSize(swfCanvas.width, swfCanvas.height); // resize the window
vr.pano.setWindowPos(swfCanvas.parent.x, swfCanvas.parent.y); // reposition
}
}
TypeError: Error #1009: Cannot access a property or method of a null object reference. at PanoCube/init()
Does anyone know how to fix this or at least catch it?
Thanks.
Here's my Actionscript code:
/**
* loadWithCuepoints(swf:SWFLoader, cuePoints:Array) Loads a
* swf file onto the screen and places it. This allows us to use
* the media cache and to prevent downloading the same media over
* and over.
*
* @param - swf : SWFLoader
* @param - cuePoints : The cuepoints/links to display
* @return - void
**/
public function loadMedia(swf:SWFLoader, media:Media):void
{
url = media.mediaUsePath + media.media1Path;
loader = new Loader();
urlReq = new URLRequest(url);
vr = new MovieClip();
addEventListener(ResizeEvent.RESIZE, resize);
// call initPanorama every frame
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, initPanorama);
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
try
{
loader.load(urlReq);
}
catch(e:Error)
{
;
}
for(var j:int = 0; j < swfCanvas.rawChildren.numChildren; j++)
{
swfCanvas.rawChildren.removeChildAt(j);
}
swfCanvas.rawChildren.addChild(loader); // add your swf directly to the stage
}//end loadWithCuepoints
/**
* initHandler(event:Event) Casts the loader's content as a
* movie clip
*
* @param - event : The event that triggered this
* @return - void
**/
private function initHandler(event:Event):void
{
vr = MovieClip(loader.content); // cast 'DisplayObject' to 'MovieClip'
vr.isFlash10=false; // Disable Flash 10 rendering if the container is Flash 9
loadingTxt.visible = false;
}
/**
* initPanorama(event:Event) Sets the width and height as well
* as the position of the QTVR
*
* @param - event : The event that triggered this
* @return - void
**/
private function initPanorama(event:Event):void
{
// check if the panorama object is available and initialize it
if ((vr!=null) && (vr.pano!=null))
{
vr.pano.setWindowSize(swfCanvas.width, swfCanvas.height); // resize the window
vr.pano.setWindowPos(swfCanvas.parent.x, swfCanvas.parent.y); // reposition
}
}
/**
* resize(event:ResizeEvent) Invalidates the display
* so that the component will resize itself
*
* @param - event : The event that triggered this
* @return - void
**/
private function resize(event:ResizeEvent):void
{
invalidateDisplayList();
}
private var i:int = 0;
/**
* updateDisplayList(unscaledWidth:Number, unscaledHeight:Number)
* Updates the QTVR's size and position.
*
* @param - event : The event that triggered this
* @return - void
**/
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if ((vr!=null) && (vr.pano!=null))
{
vr.pano.setWindowSize(swfCanvas.width, swfCanvas.height); // resize the window
vr.pano.setWindowPos(swfCanvas.parent.x, swfCanvas.parent.y); // reposition
}
}