Page 1 of 1

AS3 Class?

Posted: Sat Dec 22, 2007 9:42 pm
by WBSKI
Hey, I am trying out your Pano2VR software and want to integrate some panoramas into an AS3 Flash file. The code works fine when it is not in a packaged class, but when I put it in the class, I get a whole bunch of errors. Here is my current code:

Code: Select all

package com.vs.pano{
	import flash.display.*;
	import flash.net.URLRequest;
	import flash.events.Event;
	var loader:Loader;
	var urlReq:URLRequest
	var vr:MovieClip;
	class pano  {
		
		loader = new Loader();
		var url:String = "data/1/pan/base.swf";
		urlReq = new URLRequest(url);
		
		// 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.pano.setWindowSize(200,100);
		}
		// Tell the loader to call 'finished_loading' after the swf is loaded.
		loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
		loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
		loader.load(urlReq);
		addChild(loader);// add your swf directly to the stage
		
	}
}
I have used your Pano2QTVR for many years and will likely buy this software if I can get this class working.

Got it

Posted: Sun Dec 23, 2007 12:05 am
by WBSKI
I figured it out. Here is a working AS3 basic panorama class:

Code: Select all

package com.vs.pano{
	import flash.display.*;
	import flash.net.URLRequest;
	import flash.events.Event;

	public class pano extends MovieClip {

		public function pano() {
			var loader:Loader;
			loader = new Loader();
			var url:String = "URL HERE";
			var urlReq:URLRequest = new URLRequest(url);
			var vr: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.pano.setWindowSize(200,100);
			}
			// Tell the loader to call 'finished_loading' after the swf is loaded.
			loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);
			loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
			loader.load(urlReq);
			addChild(loader);// add your swf directly to the stage
		}
	}
}
Just change the package location and the url.

Posted: Sun Dec 23, 2007 12:16 am
by 360Texas
Hello WBSIK. While I am forum moderator, I am not AS3 proficient...

I thank you for your effort.