PDA

View Full Version : as3 custom class for fpp - possible?


martynrlee
04-22-2008, 08:22 PM
Hi Guys,

Just wondered if anyone has had any experiences in creating an external as3 class to setup the panorama movieclip / loader as a global variable?

I am currently developing an interactive cd-rom and can't seem to figure out how to adapt the code used in the example to an external as3 sheet.

all help most appreciated....

martynrlee
04-23-2008, 01:28 PM
I am currently trying to use the following method to create the external class:


package {
import flash.display.Loader ;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;

public class FlashPanoramaSprite extends Sprite
{
public var panorama:MovieClip;
public var border:MovieClip;
public var loader:Loader = new Loader();

public function FlashPanoramaSprite()
{
loader.load(new URLRequest("pano.swf"));
addChild(loader);
addChild(border);
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);
}

public function loadComplete (e:Event) : void
{
swapChildren(loader, border);
panorama = loader.content as MovieClip;
panorama.setArea(100,50,400,300);
panorama.loadPanorama("panoName=snow");

}
}
}


then using the following code to load the class:

var example:FlashPanoramaSprite = new FlashPanoramaSprite();

I am receiving the following error message:

TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChild()
at FlashPanoramaSprite$iinit()
at demoVersion11_fla::warwickVirtual_39/demoVersion11_fla::frame1()
CubePanorama v2.2 loaded.

ANY IDEAS FOLKS? I am really struggling with this and running out of ideas/time...

cheathamlane
04-23-2008, 10:04 PM
Hey there:

Try removing addChild(border); and swapChildren(loader, border);. Those look like leftovers from the embedPano FLA, and you haven't instantiated "border" in your ActionScript.

cheathamlane
04-30-2008, 02:25 AM
martyn:

Just curious if that was the issue, or if you got this resolved otherwise...

Cheers,

martynrlee
05-07-2008, 08:29 AM
Hi Cheethamlane, thanks for your feedback...apologies for my delayed response.

I used the method that you mentioned in your response initially then added the code relating to the 'border' in another attempt to get the panorama to load (in case this was the issue - it wasn't).

Unfortunately, I haven't had any luck so far in my tests in trying to set up the panorama loader scripts in an external class. It seems to load the CubePanorama environment then crashes with the following errors:

CubePanorama v2.2 loaded.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at CubePanorama/::create()
at CubePanorama$iinit()
at PanoController/::initPanorama()
at PanoController/loadPanorama()
at FlashPanoramaSprite/::loadComplete()

Any further ideas on how to resolve this issue are greatly appreciated...

Thanks again, Martyn.

testure
06-08-2009, 10:13 AM
Did you get it to work ?

martynrlee
06-16-2009, 09:22 AM
No I ran out time looking into this, im afraid.

Anyone else had any success with setting this up as an external class?

Clocked In
06-19-2009, 12:12 PM
Just encountered the same problem trying to create a wrapper/management class for PanoController, and after some minor hair loss I've solved it.

It seems at some point in the load process the PanoController needs to access its stage properties, and if it's not added to the stage then it'll throw that mysterious null object reference error.

Make sure the PanoController instance is on the stage before you call loadPanorama().

In most cases this means the PanoController needs to be added to the Loader display stack and the Loader needs to be added to the stage.

Clocked In
06-19-2009, 02:19 PM
Just realised that this will only work with pano.swf version 2.2.1.

I've tried it with 2.3 and 2.3.1 and I'm getting the same problem again. Why the hell is this?!